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

allow more flexible proposals in atomic snpe-c #732

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

michaeldeistler
Copy link
Contributor

if one used, e.g., an MCMCPosterior, or simply a torch.distributions.MultivariateNormal, one would get an error that the propsals has no attribute posterior_estimator. This is fixed here.

Resolves #706

@michaeldeistler michaeldeistler requested a review from janfb August 23, 2022 16:41
@codecov-commenter
Copy link

Codecov Report

Merging #732 (341ac90) into main (b7f0e9e) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #732   +/-   ##
=======================================
  Coverage   74.25%   74.25%           
=======================================
  Files          79       79           
  Lines        6033     6033           
=======================================
  Hits         4480     4480           
  Misses       1553     1553           
Flag Coverage Δ
unittests 74.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
sbi/inference/snpe/snpe_c.py 75.36% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -161,7 +161,8 @@ def train(
# last proposal.
proposal = self._proposal_roundwise[-1]
self.use_non_atomic_loss = (
isinstance(proposal.posterior_estimator._distribution, mdn)
isinstance(proposal, DirectPosterior)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this check change the behaviour for MCMCPosterior or MultivariateNormal?

Copy link
Contributor Author

@michaeldeistler michaeldeistler Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, the first check was isinstance(proposal.posterior_estimator._distribution, mdn). This raised an error if, e.g., proposal was an MCMCPosterior.

Now, the first check is isinstance(proposal, DirectPosterior) which will be False if proposal is, e.g., an MCMCPosterior. Because everything below is an and case, these lines will never be executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Python behaviour is clear to me, I was wondering about the sbi semantic. But true, we want the line to be False for MCMCPosterior and other, instead of throwing an error. so all good!

@@ -161,7 +161,8 @@ def train(
# last proposal.
proposal = self._proposal_roundwise[-1]
self.use_non_atomic_loss = (
isinstance(proposal.posterior_estimator._distribution, mdn)
isinstance(proposal, DirectPosterior)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Python behaviour is clear to me, I was wondering about the sbi semantic. But true, we want the line to be False for MCMCPosterior and other, instead of throwing an error. so all good!

@michaeldeistler michaeldeistler merged commit ce42bad into main Aug 24, 2022
@michaeldeistler michaeldeistler deleted the flexible-proposals branch August 24, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does multi-round SNPE work with RejectionPosterior as proposal?
3 participants