-
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
sample
equivalent but including states
#84
Comments
I'm in favor of adding the keyword argument and passing it to samples = save!!(samples, sample, i, model, sampler; kwargs...) we would call samples = save!!(samples, (sample, state), i, model, sampler; kwargs...) as you suggested. Then our default version of At the very least, we shouldn't add a whole other |
Hmm, this is actually a bit more annoying that I originally thought 😕 As you said, it'll introduce type-instabilities unless we make it a |
Maybe we should just provide a callback? I.e. struct StateHistoryCallback{A}
states::A
end
StateHistoryCallback() = StateHistoryCallback(Any[])
function (cb::StateHistoryCallback)(rng, model, sampler, sample, state, i; kwargs...)
push!(cb.states, state)
return nothing
end so users can do state_history = []
sample(..., callback=StateHistoryCallback(state_history))
state_history |
I dunno that seems super hacky to me. I think it's valuable to provide the states but I think it's worth investing having it's own code path (whatever that looks like). |
Sometimes I want both the samples and the states rather than just the states. Of course this can be achieved by just using the iterator interface explicitly, or a callback, but it's a bit inconvenient to have to write this every time.
Would it make sense to introduce a
sample_with_states
method or simply a keyword argument tosample
, e.g.include_states::Bool
, specifying whether or not to also include the states in the return-value (I'm more in favour of just callingsave!!
with tuple(sample, state)
rather than changing than returning having the kwarg making it so that we instead returnsamples, states
at the end).Thoughts?
The text was updated successfully, but these errors were encountered: