Pyro: Trace_dist must be trace posterior distribution object when i ran code in tutorial.

Created on 8 Nov 2020  Β·  5Comments  Β·  Source: pyro-ppl/pyro

Description

I'm having problems with the code I'm running in tutorial:
https://bookdown.org/robertness/causalml/docs/tutorial-on-deep-probabilitic-modeling-with-pyro.html
codes:
image

error:
image

thanks for any help!

Environment

For any bugs, please provide the following:

  • OS and python version. windows 10, Python 3.8.3
  • PyTorch version 1.6.0
  • Pyro version: 1.5.0
question

Most helpful comment

Hi @lwgkzl, you don't need to use EmpiricalMarginal to plot histogram. You can plot samples in samples_posterior directly.

γ‚γ‚ŠγŒγ¨γ†γ”γ–γ„γΎγ—γŸ

All 5 comments

@lwgkzl The API of MCMC has changed since that tutorial is written. To get posterior samples, you can use

mcmc = MCMC(...)
mcmc.run(...)
posterior = mcmc.get_samples()

@lwgkzl The API of MCMC has changed since that tutorial is written. To get posterior samples, you can use

mcmc = MCMC(...)
mcmc.run(...)
posterior = mcmc.get_samples()

Many thanks : )

@lwgkzl The API of MCMC has changed since that tutorial is written. To get posterior samples, you can use

mcmc = MCMC(...)
mcmc.run(...)
posterior = mcmc.get_samples()

After this line of code is run:
samples_posterior = mcmc.get_samples()
The type of variable samples_posterior is still not TracePosterior, so when i run the code:
marginal = EmpiricalMarginal(samples_posterior , "weight")
The error still exists, did I not understand what you meant?

Hi @lwgkzl, you don't need to use EmpiricalMarginal to plot histogram. You can plot samples in samples_posterior directly.

Hi @lwgkzl, you don't need to use EmpiricalMarginal to plot histogram. You can plot samples in samples_posterior directly.

γ‚γ‚ŠγŒγ¨γ†γ”γ–γ„γΎγ—γŸ

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neerajprad picture neerajprad  Β·  4Comments

lundlab-kaltinel picture lundlab-kaltinel  Β·  3Comments

martinjankowiak picture martinjankowiak  Β·  3Comments

neerajprad picture neerajprad  Β·  4Comments

fritzo picture fritzo  Β·  4Comments