-
Notifications
You must be signed in to change notification settings - Fork 32
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
ValuesAsInModelContext cleanup #767
Comments
Secondly, I think the current interface is slightly confusing: # Method 1
values_as_in_model(model::Model[, varinfo::AbstractVarInfo, context::AbstractContext])
# Method 2
values_as_in_model(rng::Random.AbstractRNG, model::Model[, varinfo::AbstractVarInfo, context::AbstractContext]) The current behaviour is like this
# Test for yourself
using DynamicPPL, Distributions, Random
@model f() = begin; x ~ Normal(); y ~ Normal(x); end
m = f()
vi = VarInfo(Xoshiro(468), m)
values_as(vi, Dict) # (x => 0.0720089, y => -0.00203489)
values_as_in_model(m)
values_as_in_model(m, vi)
values_as_in_model(Xoshiro(469), m)
values_as_in_model(Xoshiro(469), m, vi) Essentially:
|
For the top comment, I think it's okay to remove the type parameter and only support OrderedDict. If I understand correctly, OrderedDict is the only "reliable" type we can support in the sense that if user tell us to output For the second comment, although I didn't write the code, it makes sense to me that: if you (the user) give me a random number generator, you are explicitly telling me to sample, otherwise I am just going to give you the current values. Although I don't mind a more explicit name. (just edited my comment, realized I misread) |
Calling
values_as_in_model(...)
can only ever return an OrderedDict of values, due to the combination of:DynamicPPL.jl/src/values_as_in_model.jl
Lines 190 to 198 in 6657441
DynamicPPL.jl/src/values_as_in_model.jl
Lines 30 to 32 in 6657441
It's possible for
ValuesAsInModelContext
to be constructed with a different type, but there is no use case for this in DynamicPPL, andValuesAsInModelContext
is not exported. So there is some flexibility in the codebase which isn't actually being made use of.Imo we should either:
values_as_in_model
to take another parameter to specify the output type, so that it forms part of the public interface,The text was updated successfully, but these errors were encountered: