-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add a model
argument to getparams
and setparams!!
functions
#150
Conversation
I kept |
I left some comments above. In addition, we want to consider using |
Agree with this. This is what I've done in MCMCTempering.jl. |
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 second @yebai 's suggestions on the type of model passed; it should be AbstractMCMC.AbstractModel
, not logdensity_function
. A logdensity_function
is indicated by AbstracftMCMC.LogDensityModel
.
Moreover, IMO we should pass model
as the first argument, not the last, and then "drop it" by default, i.e.
setparams!!(model, state, params) = setparams!!(state, params)
That way, if one needs access to the model
you overload setparams(model, state, params)
directly for that specific model type; otherwise, you just overload setparams!!(state, params)
. This will make it less likely that we'll run into method ambiguities, since the setparams!!(model, state, params)
will be specific for a given model type.
Updated @yebai @torfjelde |
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 left some further comments. I am happy to discuss them.
EDIT: on second thought, I'd be happy if you want to pass model
and state
as two arguments instead of combining them into a tuple (model, state)
.
At the moment, I think pass them as two argument is more preferable for me -- just a less layer of indirections. |
Thanks Hong, for AbstractMCMC, let's try to have two approvals, so I'll wait a bit for @torfjelde's opinion |
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.
Looking good! But IMO we should not have additional implementations for a logdensity_function
arguments. Currently, we take the approach of passing a LogDensityModel
everywhere we want to indicate that we're working with a logdensity function; we should follow this convention in setparams!!
and getparams
too.
Co-authored-by: Tor Erlend Fjelde <[email protected]>
No objection removing them, I added them because this what |
Co-authored-by: Tor Erlend Fjelde <[email protected]>
Makes sense:) So |
very much agree 👍 |
logdensity_function
to getparams
and setparams!!
model
argument to getparams
and setparams!!
functions
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'll approve because it's in a good enough state now 👍
But is how to implement this documented somewhere? And if so, should we add a note to make it clear that if you don't need access to the model
you should implement setparams!!(state, params)
and not setparams!!(model, state, params)
?
I assume here |
No, it's a |
This makes a lot of sense
We definitely should, but I am not very clear on what directions to give now. I would vote for just merge this and enhance this part of the documentation later (also the interface might change again in near future). Do you think this is a bad idea? |
I'm happy with this given that right now my reviews are quite async (this will be better starting on Thu this coming week) since I'm in a different timezone. Regarding the directions, I stated above
That's the main thing IMO 🤷 |
Thanks @sunxd3, @torfjelde! |
Good stuff @sunxd3 ! :) |
ref: TuringLang/AdvancedHMC.jl#378 (comment)