Skip to content

1350 leakage correction breaks consistency of log prob vs log prob batched#1355

Merged
janfb merged 5 commits intomainfrom
1350-leakage-correction-breaks-consistency-of-log_prob-vs-log_prob_batched
Jan 10, 2025
Merged

1350 leakage correction breaks consistency of log prob vs log prob batched#1355
janfb merged 5 commits intomainfrom
1350-leakage-correction-breaks-consistency-of-log_prob-vs-log_prob_batched

Conversation

@manuelgloeckler
Copy link
Contributor

This should fix the issue #1350.

Changes

  • accept_reject_sample now returns a tensor of acceptance_rates.
  • Only change was needed for the restriction estimator. Which now reduces this tensor to a float.
  • Test added and extended to bounded priors to detect inconsistencies with leakage correction methods.

Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for fixing this! 🙏

But where was the bug then here? Was it because the min_acceptance_rate was returned, which was the min over the batch of xs in case of log_prob_batched?

@codecov
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.42%. Comparing base (d3f22b5) to head (f512659).
Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1355       +/-   ##
===========================================
- Coverage   89.40%   78.42%   -10.99%     
===========================================
  Files         118      118               
  Lines        8715     8749       +34     
===========================================
- Hits         7792     6861      -931     
- Misses        923     1888      +965     
Flag Coverage Δ
unittests 78.42% <100.00%> (-10.99%) ⬇️

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

Files with missing lines Coverage Δ
sbi/samplers/rejection/rejection.py 88.00% <100.00%> (ø)
sbi/utils/restriction_estimator.py 76.31% <100.00%> (-8.59%) ⬇️

... and 32 files with indirect coverage changes

@manuelgloeckler
Copy link
Contributor Author

But where was the bug then here? Was it because the min_acceptance_rate was returned, which was the min over the batch of xs in case of log_prob_batched?

The bug was that different xs in batched sampling lead to different posteriors. But the leakage correction scaled every "posterior" with the "min_acceptance_rate" i.e. the posterior which leaks most. But different posteriors, have different leakage.

@janfb janfb merged commit a6a220d into main Jan 10, 2025
6 checks passed
@janfb janfb deleted the 1350-leakage-correction-breaks-consistency-of-log_prob-vs-log_prob_batched branch January 10, 2025 12:41
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.

leakage correction breaks consistency of log_prob vs. log_prob_batched

2 participants