Skip to content
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

Feature request: add a parameter that allows Predictive to propagate gradients #3404

Open
pwsiegel opened this issue Oct 18, 2024 · 0 comments

Comments

@pwsiegel
Copy link

Issue Description

When generating samples using pyro.infer.predictive.Predictive, gradients are dropped. It looks like this is an intentional design choice from the code, but I'm not sure why - if there's a good reason then ignore me.

Code Snippet

Create a model and fit a guide such that model(x).requires_grad and guide(x)['some_site'].requires_grad both return True when x has gradients enabled. Then do:

predictive = Predictive(model, guide=guide, num_samples=100)
posterior_samples = predictive(x)

Then posterior_samples['some_site'].requires_grad is False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants