Difference between Predictive() with posterior_sample and Predictive() with guide

Hello,
I’ve read the Pyro documentation for Predictive() function, and I have a question about the contents of the documentation.

The documentation states that Predictive() generates the samples from the predictive distribution conditioned on the parameter posterior_samples. Does that mean I have to specify the posterior_samples in order to properly draw the posterior samples from the predictive distribution? If I do not specify the posterior_samples, but only specify the guide, does the Predictive() function in this case still draw samples from the predictive distribution?

Thank you,

Hi @h56cho, the doc of guide said it is “optional guide to get posterior samples of sites not present in posterior_samples”. So if you don’t specify posterior_samples, the guide will generate all posterior samples for you. Then under the hood, Predictive will use those posterior samples to get predictions. Do you think we need to update the docs for clarification?

Hello,

Yes, I find the documentation’s explanation quite confusing…so for instance, if I just execute the code below, would I be obtaining the predictive samples from the forward function?

pred_obj=Predictive(model=my_model, guide=my_guide)
pred_obj.forward(my_input)

Thanks,

It does that job. Just for my understanding to update the docs accordingly, what makes you confused? Originally, we don’t have guide argument in Predictive. But we found that it is more convenient for users to skip the step: generate posterior samples from guide. So we include guide in a later commit.

Perhaps I was confused because I interpreted the term “predictive samples” and “posterior samples” to have the same meaning…now that I realized that the two terms have different meanings, the contents of the documentation are much more clear now…thank you for the clarification. :slight_smile:

1 Like

Glad that it helps. :slight_smile: