Pyro.sample function

Dear Pyro Users

Can anyone tell what exactly pyro.sample(name, dist, obs=y) is doing? I note that when y is not None, this function cal simply returns this y. Then what is its impact? Does it produce any sample inside?


Hi @junbin.gao, you can find a detailed explanation in this tutorial. Just a short answer: an observed site is mainly used for computing likelihood or for conditional.

Thanks Du. Understood now.

Hi Du
In examples, sometimes we see pyro.sample, sometimes, pyro.nn.PyroSample, sometimes PyroSample(), what are the difference?

@junbin.gao pyro.sample is the main Pyro primitive. PyroSample is created later to make things easier for Bayesian Neural Networks. In my opinion, the former is more flexible and more friendly to ppl users, while the latter is probably more friendly to neural network users.