Hi,
I have a model of type bambi.models.Model
with Family name categorical
and link name softmax
. For this model, learned regression weights can be expressed as a matrix of size MxK, where M is the number of covariates and K is the number of categories that were observed in the training data. (With an identifiability constraint imposed, one column of this matrix is fixed to 0, so we could represent this as an Mx(K-1) matrix; however I will ignore this detail for the sake of this discussion.)
I have then used pymc3’s mean field ADVI to fit this model, giving me an object of type pymc3.variational.approximations.MeanField
. If I call that object model_fitted_by_ADVI
, then I can extract the posterior expected regression weights via model_fitted_by_ADVI.mean.eval()
, but those regression weights take the form of a flat vector, so it is unclear how to reconstruct the weight matrix from this vector. I do not know if the entries of the vector represent the matrix unfolded by row, by column, or by some other mechanism.
What is the recommended way to reconstruct the regression weight matrix from the flat vector (or to access it directly)?
Thank you kindly in advance for any guidance that you might be able to share.