You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>@modeldemo(x) = x .~Normal()
demo (generic function with 2 methods)
julia>demo(missing)()
ERROR: MethodError: no method matching dot_assume(::Random.TaskLocalRNG, ::SampleFromPrior, ::Normal{…}, ::VarName{…}, ::Missing, ::UntypedVarInfo{…})
[...]
julia>demo([missing])()
ERROR: MethodError: no method matching loglikelihood(::Normal{Float64}, ::Vector{Union{Missing, Float64}})
[...]
Even if you use condition, you still run into a similar issue when specifying components, i.e.
julia>@modelfunctiondemo()
x =Vector{Float64}(undef, 2)
x .~Normal()
end
demo (generic function with 4 methods)
julia> (demo() | (@varname(x[1]) =>1.0,))() # not conditioned2-element Vector{Float64}:1.68419369841405460.3645020534551503
The reason why we do this is because of performance: we want .~ to be faster than just iterating over the entire broadcast expression and calling tilde_assume!! and tilde_observe!! separately. However, this is very, very confusing for users, and I think it's very understandable.
Sooo the question is how to fix this. A few immediate thoughts:
Do we need .~? Does it just make things confusing?
Should we just convert it into a loop over the broadcasted expression and drop the perf benefits?
The text was updated successfully, but these errors were encountered:
How significant are the perf benefits? Could we benchmark this?
Either of the proposed two solutions would also simplify the tilde pipeline code a lot, improving maintainability. It's a source of a lot of corner cases and code complexity.
We could ask on Slack/Discourse whether our users are making heavy use of .~, to gauge how much effort we should put into keeping it around and performant.
Do we need .~? Does it just make things confusing?
Should we just convert it into a loop over the broadcasted expression and drop the perf benefits?
I lean towards option 2 or something similar if it simplifies the implementation. The tilde pipeline is becoming a bit too (deep and) complex to reason about.
Ref: TuringLang/Turing.jl#2390 (comment)
MWE:
Even if you use
condition
, you still run into a similar issue when specifying components, i.e.The reason why we do this is because of performance: we want
.~
to be faster than just iterating over the entire broadcast expression and callingtilde_assume!!
andtilde_observe!!
separately. However, this is very, very confusing for users, and I think it's very understandable.Sooo the question is how to fix this. A few immediate thoughts:
.~
? Does it just make things confusing?The text was updated successfully, but these errors were encountered: