-
-
Notifications
You must be signed in to change notification settings - Fork 6
Make the HMC & NUTS kernels return scan updates
#56
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
Make the HMC & NUTS kernels return scan updates
#56
Conversation
|
Despite the seemingly minimal change, |
33addff to
e006a4e
Compare
e006a4e to
84c4ca2
Compare
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.
There doesn't appear to be anything wrong with the updates-related changes.
Despite the seemingly minimal change,
test_nuts_mcsedoes not pass anymore which is an indication that something is seriously wrong.
I can reproduce the CI error in test_nuts, but test_nuts_mcse passes locally. Changing the RNG seed in test_nuts affects the pass/fail results significantly, yet the values are all within at least a +-1 range of the "true" values.
It's not clear to me why those step size, mass matrix values, etc., should guarantee errors within the test ranges, so there's not much more I can say than that the tests look flaky.
Also, the function evaluation time seem rather long for these toy problems; are there any tests like these that check the trajectory statistics as well? If not, it looks like we need them.
|
I was thinking about getting rid of all non-mcse tests. As you said, they're flaky as a way to assess the correctness of samples and they take a long time to run. |
Codecov Report
@@ Coverage Diff @@
## main #56 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 461 461
Branches 24 24
=========================================
Hits 461 461
Continue to review full report at Codecov.
|
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.
Let's squash the updates-related commits together, and the same for the test change commits.
|
Also, we can keep the old tests, but mark them as |
e0c58ac to
43a052d
Compare
tests/test_hmc.py
Outdated
| return ess | ||
|
|
||
|
|
||
| def compute_mcse(samples, true_param): |
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.
Does this function name still apply; it doesn't appear to be returning a standard error?
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.
Nope, renamed it.
tests/test_hmc.py
Outdated
| def compute_mcse(samples, true_param): | ||
| """Compute the probability of getting an error more extreme | ||
| than the one we observe assuming the samples are really drawn | ||
| from the target distirbution. |
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.
Is this assuming a normal target distribution?
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.
Yes
| ], | ||
| non_sequences=0.5, | ||
| n_steps=2000, | ||
| non_sequences=1.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.
Does it not pass with a smaller step size?
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.
It does. Here I adapted the step size manually to get an average acceptance probability of 0.8 (target in the window adaptation warmup); it also runs slightly faster.
43a052d to
b0104d9
Compare
README.rst
Outdated
| next_step, _ = kernel(*initial_state, 1e-2) | ||
| print(next_step[0][1].eval({y_vv: 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.
Our examples should probably use aesara.function and the returned updates (e.g. to avoid potentially confusing users down the line).
b0104d9 to
56ee318
Compare
scan updates
Since #55 the inner scans do not use
default_updates but instead return the inner updates following scan's inner function semantics. In this PR we make kernel return inner updates as well.