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
I tried to make posterior predictions by adapting the example from predict() for my model.
I made a mistake where I used the conditional model, m_lin_reg instead of linear_reg.
This made the code evaluate forever and therefore did not result in any useful error message.
This is of cause a user error, but it would have saved me a lot of frustration if an error was thrown.
# based on example from ?predictusing Turing
@modelfunctionlinear_reg(x, y, σ =0.1)
β ~Normal(0, 1)
μ = β .* x
for i ∈eachindex(y)
y[i] ~Normal(μ[i], σ)
endendf(x) =2* x +0.1*randn()
Δ =0.1
xs_train =0:Δ:10; ys_train =f.(xs_train);
xs_test = [10+ Δ, 10+2* Δ]; ys_test =f.(xs_test);
m_lin_reg =linear_reg(xs_train, ys_train);
chain_lin_reg =sample(m_lin_reg, NUTS(100, 0.65), 200);
# Mistake where I use conditional model `m_lin_reg` instead of the intended `linear_reg()`# This hangs forever.
m_lin_reg_test =m_lin_reg(xs_test, Vector{Union{Missing, Float64}}(undef, length(ys_test)));
predictions =predict(m_lin_reg_test, chain_lin_reg)
ys_pred = ys_pred =vec(mean(Array(group(predictions, :y)); dims =1));
The text was updated successfully, but these errors were encountered:
JohannesNE
changed the title
Simple user error makes code Evaluate forever - Calling DynamicPPL.Model as a function.
Simple user error makes code evaluate forever - Calling DynamicPPL.Model as a function.
Mar 12, 2024
Thanks for the issue report @JohannesNE, agreed that this is not good behavior on Turing's part. On Julia 1.10 this leads to a StackOverflow, which also isn't great.
I tried to make posterior predictions by adapting the example from
predict()
for my model.I made a mistake where I used the conditional model,
m_lin_reg
instead oflinear_reg
.This made the code evaluate forever and therefore did not result in any useful error message.
This is of cause a user error, but it would have saved me a lot of frustration if an error was thrown.
The text was updated successfully, but these errors were encountered: