-
Notifications
You must be signed in to change notification settings - Fork 9
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
Improve (hopefully) how HybridGibbs uses samplers state and history #503
Conversation
…or Gibbs sampling
The MH sampler did not append to self._acc, and therefore self._acc stayed at the initial value 1, which meant that the tune method increased the step length to the maximum (i.e. 1). I have pushed a small change that fixes this. In line 220 of cuqi/experimental/mcmc/_gibbs, the skip_len of the tune method is hardcoded to 1, meaning that the tuning of the scale parameter is always based on only the latest self._acc, i.e. either 0 or 1. This is not sensible for tuning. I suggest either using skip_len = max(int(0.1 * Nb), 1) which is the default in the warmup method in cuqi/experimental/mcmc/_sampler. Or letting it be user defined, again similar to the implementation in the warmup method in cuqi/experimental/mcmc/_sampler. |
I fixed an issue concerning how I first implemented appendence to self._acc. Now implemented in HybridGibbs instead of MH so it is also compatible with regular sampling (non-Gibbs), which already has appendence to self._acc implemented. I have added the option of setting the tune_freq for HybridGibbs sampling, so it is no longer hard-coded. The implementation is equivalent to tune_freq in cuqi/experimental/mcmc/_sampler. I have no further comments or concerns related to storing and using the acceptance rate in HybridGibbs :) |
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 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.
Minor wording changes + simplificaiton of code Co-authored-by: amal-ghamdi <[email protected]> Co-authored-by: chaozg <[email protected]>
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.
LGTM. Regarding the issue of the example at the docstring of HybridGibbs
, which is of course out the scope of this PR, I took the liberty of creating an issue to track it: #511
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.
Thank you @nabriis, I just added one comment regarding printing a warning for NUTS.
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.
LGTM!
Closes #483.
This PR makes it such that HybridGibbs will extract each of its samplers state and history, then reinitialize the sampler with a new target, then set the sampler state and history from earlier.
This reason we have to do this is because changing .target will not always correctly set all internal variables of the samplers that depend on the target.
Also thanks to Silja, ensured that acc rate is stored correctly in HybridGibbs.
Suggestion for review if method works
Use CWMH and compare with HybridGibbs using MH. Are the results similar? Test both warmup and sampling.
Silja reviewed and tested. Result OK.