-
Notifications
You must be signed in to change notification settings - Fork 155
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
Conversation
There was a problem hiding this 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)?
sbi/analysis/sbc.py
Outdated
@@ -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() |
There was a problem hiding this comment.
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)
?
There was a problem hiding this 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 Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
when creating the list of
reduce_fn
s for SBC, we need to index the columns oftheta
, not the rows.Addtionally, the local variable
i
will not bind to the correspondinglambda
functions.I worked around that with an
eval
for now, but there is certainly a more elegant solution out there.closes #794