Repository navigation
Add IID x support to PosteriorBasedPotential - #1810
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1810 +/- ##
==========================================
- Coverage 87.85% 87.80% -0.06%
==========================================
Files 140 140
Lines 12716 12724 +8
==========================================
Hits 11172 11172
- Misses 1544 1552 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Thanks for the contribution! This looks great already.
I think we can make this a bit more efficient by using log_prob_batched which would vectorize the N evaluations.
Other than that a few more test cases should be considered and this would in addition require updating some documentation files i.e. here. We should mention that this is now also possible with NPE (when using e.g. sample_with="mcmc").
manuelgloeckler
left a comment
There was a problem hiding this comment.
Great! Thanks for implementing this so quickly :)
Related Issues
Summary
This PR adds support for multiple Independent and Identically Distributed (IID) observations to
PosteriorBasedPotential. This unlocks the ability to use methods like MCMC, Variational Inference (VI), or importance sampling (sample_with="mcmc", etc.) for Neural Posterior Estimation (NPE) when dealing with IID datasets.Changes
set_x: Removed theNotImplementedErrorthat previously blocked IID data. The method now safely passes thex_is_iidflag down toBasePotential.__call__logic: Added an IID branch that evaluates the log-probability for each individual observation, sums them up, and subtracts the expanded prior.ValueErrorifprioris missing or lacks alog_probmethod, but only inside the IID branch.test_posterior_based_potential_iid_log_probtotests/posterior_nn_test.py. It parameterizes overiid_batch_size = [1, 2, 5]and compares our new potential calculation directly against an analytically exact Linear Gaussian ground truth to ensure the tensor math is okay.