Getting the named parameter values in numpyro?

I am trying to obtain the value of the parameters in numpyro. When I run MCMC I could do something like

mcmc.get_samples()[‘z’]

However, I am not sure what is the equivalent when I run the SVI.

After,
result = svi.run (model, …)

The following gives a list of values but I am unable to understand what they mean?
result.params

Or What does the following mean ?

‘auto_arn__0$params’

Any help is appreciated.

In SVI, you are training a guide to approximate the posterior distribution, basiclly you should feed the values of variables in the guide to your model to get the posterior value of interested variables in your model.
For example:

guide_trace=pyro.poutine.trace(guide).get_trace()
trained_model=pyro.poutine.replay(model,trace=guide_trace)
model_trace=pyro.poutine.trace(trained_model).get_trace()

you can get those values by watching model_trace.nodes

1 Like

Such arn parameters are parameters of auto guides. To get posterior samples you can use Predictive as in SVI docstring

1 Like