-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Calling models on non-arguments #145
Comments
Should this be I think the most consistent thing to do for now would be to error and suggest a transformation that moves parameters to the args like The other option that's a little more afield is to do the transformations on-demand. In these cases though the user might need to distinguish between If that were possible, I might also expect that e.g. Should this all be done under the hood? It would be pretty interesting, but it's hard to know when to stop :P |
Good catch, yes that's what I meant.
There's a core idea I think we need to preserve here: a Soss model is a joint distribution over its parameters, conditional on its arguments. This lets us keep model transformations and forward sampling very fast and simple. When we need to sample from some parameter conditional on observing something downstream, there are lots of options, and things get much more complicated. So the guideline (at least for now) is that the core of Soss should be able to do things that are very mechanical, and where "the way to do it" is obvious and can be fast. Things with more choices (like inference) need to be outside the core. Your example |
Yeah, I like the KIS approach in general. We can go a little further with "obvious" extensions if they're unambiguous and consistent. Regarding calling models on non-arguments, here's another example to note, suggesting the idea of an argument might not be central: julia> m = @model begin
x ~ Normal(μ)
y ~ Normal(x)
end;
julia> rand(m(μ=4)) # this works as if μ is an arg
(x = 5.500516432453989, y = 4.208745378540177)
julia> m.args # but...
0-element Array{Symbol,1} Likewise if |
Just to note, the current behavior has caused some confusion, e.g. @baggepinnen 's comment here. |
Oh, and also... julia> using Soss
julia> μ = 10.0
10.0
julia> m = @model begin
x ~ Normal(μ)
y ~ Normal(x)
end;
julia> rand(m())
(x = 10.151203386020851, y = 10.506361236271212) I think this is the right behavior, since otherwise things like |
Say we have a model
Currently we can do
This works as expected, but a user might be surprised by
This happens because of the current rules for scoping.
y
is not an argument, so the model considers the firsty
to be outside the scope of the model.QUESTION: Is this the semantics we want?
Note: You can still easily pass
y
into the model, like this:So the concern isn't that this is hard to do (no pun intended). The point is more to check that the we have consistent reasonable semantics.
The text was updated successfully, but these errors were encountered: