Pyro obs term


#1

I am aware the obs is in the model rather than guide. and the ELBO has two term, one is likelihood p(y/z) and another is KL(q(z)//p(z)). I want to ask the model basically is the p(z) and there is no trainable parameters inside. how the obs in the model would back propagate to the guide to improve the likelihood. I saw the kernel on TensorFlow, the likelihood is calculated based on the loss between correct label and the output of q(y/z). so, the obs in pyro is p(y/z) or q(y/z)?

I say p is the prior, and q is the approximate distribution


#2

In your model, when you call pyro.sample, SVI will use the replay effect-handler to replace the value sampled at a particular sample site in your model with the one from the guide. When you run this forward you can get your p(x, z) term (with z sampled from the guide), and running the guide itself gives you the q(z) term. If you want to understand how this is achieved behind the scenes, you should take a look at the Minipyro example or the custom elbo objectives example.