-
Notifications
You must be signed in to change notification settings - Fork 43
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
Deepcopy adaptor before starting sampling #382
base: master
Are you sure you want to change the base?
Conversation
I have this terrible fear that somebody out there might have a workflow which relies on the adaptor being mutated in a predictable manner (https://xkcd.com/1172/) .... Of course, it's in the tests 😄 AdvancedHMC.jl/test/adaptation.jl Lines 16 to 18 in 5d56902
|
39a4c24
to
9998e10
Compare
This avoids the unintuitive behaviour seen in #379
9998e10
to
9015dd4
Compare
Thanks @penelopeysm !
Despite opening #379 (comment) I'm actually I inspect the adaptor sometimes after sampling in order to see the mass matrix it adapts. |
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.
IMO we should probably just drop this sample impl in favour of AbstractMCMC.jl's sample
🤷
It's more of a relic from before we had that implementation, and so we might now be at a point where it's not worht keeping it around anymore.
Base.isnan(v::DualValue) = any(isnan, v.value) || any(isnan, v.gradient) | ||
Base.isnan(v::AbstractVecOrMat) = any(isnan, v) | ||
Base.isnan(z::PhasePoint) = isnan(z.ℓπ) || isnan(z.ℓκ) |
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.
Seems unrelated?
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.
Indeed, that's a hangover from #381 because I was a bit lazy to fix the commit history
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.
Realised this one has a double bump in Project.toml too. - let's decide on that PR first then I'll modify accordingly
The implementation of
sample()
in AdvancedHMC mutates the adaptor passed in, which is both unintuitive (it'ssample
notsample!
) and also undocumented (see #379).This PR:
sample()
tosample_mutating_adaptor()
(other suggestions for names welcome – I didn't want to usesample!
as that has another meaning)sample()
which performs a deepcopy of the adaptor before handing over tosample_mutating_adaptor()
Random.GLOBAL_RNG
toRandom.default_rng()
, which I think is the proper modern method of accessing the global PRNG state.Draft for now to check that CI passes + also to wait for #381 to be merged. (or rejected 😱 )