If I have a model with lots of stochastic RVs, and I approximate the model using variational inference using approx = pm.fit()
, approx.mean.eval()
returns, I assume, the means of the approximate posterior distributions for all stochastic RVs. But this method doesn’t give the labels, so I’m not sure which value corresponds to which RV. Any suggestions on how to map them?
There is a mapping property, see:
approx = pm.fit()
# dict
means_dict = approx.bij.rmap(approx.params[0].eval())
# array
sample_array = approx.bij.map(approx.sample(1))
Fantastic. Thanks!