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

fix sbc reduce funs, refactor plotting. #793

Merged
merged 2 commits into from
Dec 19, 2022
Merged

fix sbc reduce funs, refactor plotting. #793

merged 2 commits into from
Dec 19, 2022

Conversation

janfb
Copy link
Contributor

@janfb janfb commented Dec 17, 2022

when creating the list of reduce_fns for SBC, we need to index the columns of theta, not the rows.
Addtionally, the local variable i will not bind to the corresponding lambda functions.
I worked around that with an eval for now, but there is certainly a more elegant solution out there.

closes #794

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Oh wow, thanks a lot for fixing this, and sorry for the bug.

I'm wondering how this could slip through this test? Any ideas for better tests here (not necessarily in this PR)?

@@ -175,7 +177,9 @@ def sbc_on_batch(

# rank for each posterior dimension as in Talts et al. section 4.1.
for i, reduce_fn in enumerate(reduce_fns):
ranks[idx, i] = (reduce_fn(ths, xo) < reduce_fn(tho, xo)).sum().item()
ranks[idx, i] = (
(reduce_fn(ths, xo) < reduce_fn(tho.reshape(1, -1), xo)).sum().item()
Copy link
Contributor

Choose a reason for hiding this comment

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

I find .reshape(1, -1) hard to parse, maybe use .unsqueeze(0)?

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

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

Awesome, thanks a lot!

@codecov-commenter
Copy link

Codecov Report

Merging #793 (fc4b5a7) into main (214ee4e) will increase coverage by 0.19%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #793      +/-   ##
==========================================
+ Coverage   74.43%   74.62%   +0.19%     
==========================================
  Files          79       79              
  Lines        6144     6144              
==========================================
+ Hits         4573     4585      +12     
+ Misses       1571     1559      -12     
Flag Coverage Δ
unittests 74.62% <100.00%> (+0.19%) ⬆️

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

Impacted Files Coverage Δ
sbi/analysis/plot.py 56.43% <ø> (ø)
sbi/analysis/sbc.py 95.00% <100.00%> (+15.00%) ⬆️

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

@janfb janfb merged commit 6cdf678 into main Dec 19, 2022
@janfb janfb deleted the bugfix-sbc branch December 19, 2022 10:30
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.

SBC ranking returns incorrect ranks since 0.20.0
3 participants