-
-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Helper Function for evaluating log_likelihood #3373
Comments
I believe the above code computes the posterior predictive log density, which includes both prior and likelihood. In the past, when I've computed log-likelhood, I've manually masked out the prior sites. I'm unsure whether it's practical to automatically mask out prior sites in a way that is correct for reparametrization and other auxiliary variables. Maybe a first step could be adding a log-likelihood computation to a couple existing tutorials, then seeing if there's a general implementation (that is e.g. batchable)? |
@fritzo thanks for pointing out my mistake, much appreciated! Was just wondering how did you mask out your prior sites systematically (I'm very much new to Pyro)? You're right, it might be worth wrtiting up a couple of tutorials fot the log-likelihood computation, do you have any recommendations of where to start? |
I've enclosed the top of a hierarchical model in a boolean def example_model(data, include_prior: bool = True):
# Sample top level variables from the prior.
with poutine.mask(mask=include_prior):
loc = pyro.sample("loc", Normal(0, 1))
scale = pyro.sample("scale", LogNormal(0, 1))
# Observe data.
pyro.sample("data", Normal(loc, scale), obs=data)
Gosh there are over 50 tutorials on https://pyro.ai/examples . You might pick a domain you're interested in and add a section at the end. Then "likelihood" should still show up in search results. |
@fritzo Thanks for this. Great, I can add them in the tutorial, might be useful! |
Issue Description
Currently training some bayesian neural networks using HMC, would it be useful to include the calculation of log likelihood as a helper function? probably something like this using conditioning and trace?
The text was updated successfully, but these errors were encountered: