-
Notifications
You must be signed in to change notification settings - Fork 219
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
Allow for a named tuple for initial_params
#2286
Comments
I would also love to see named tuple generally supported across the Turing ecosystem, but that would probably need some work. It's also somewhat dependent on this PR |
Definitively possible! I made a quick PoC concept here: TuringLang/DynamicPPL.jl#632 I'm somewhat limited in time these days, but maybe someone can complete it (shouldn't be much work).
Supporting |
@torfjelde We don't yet officially support passing |
No, but we don't need this to support |
Another potential feature for TuringLang/DynamicPPL.jl#632 would be to set all/some of these initial parameters as functions that are then applied the prior. For instance, |
Though I agree that seems convenient, it's just a bit too much hassle to maintain as it really only saves a single call from the user perspective: init_parmas=mean(rand(Vector, model))` (though this is somewhat "new" / not well-documented tbh) |
I agree with Tor |
This has now been solved by TuringLang/DynamicPPL.jl#632 I believe? @sunxd3 ?:) |
Cheers for the work! |
Small thing, but |
I am probably understanding wrongly, but for @model function f()
x ~ Normal(0, 1)
y ~ Normal(x, 1)
end mean of |
Ah sorry, yes that's very true. I wrote that a bit too quickly trying to convey that you can take the mean of smaoples from the model to get it. You can do: chain_prior = sample(model, Prior(), 1000) and then extract from this:) |
Well yes but my point was about some syntactic sugar to conveniently (and efficiently) set the initial parameters to the prior means, and sampling from the priors first appears as overkill given that the distributions usually have analytically defined means. Hence the Alternatively, is there a way to extract the prior distributions as a vector, for instance: priors = get_priors(model)
priors
One could then run:
|
My understanding is that currently
initial_params
must be a vector of the length of the parameters, but this can become a bit tricky for models with lots of parameters.Would it be possible to allow for passing, for instance, a named tuple (
initial_params=(μ=2.5, σ=1.0)
) to set initial values on desired parameters?The text was updated successfully, but these errors were encountered: