I’m new to Turing.jl (and quite new to Julia as well) and reading the Guide documentation ( Guide ), section “Querying Probabilities from Model or Chain”. The probability query examples are of the form
prob"x = 1.0, y = 1.0 | model = gdemo, s = 1.0, m = 1.0"
Am I correct to assume that this code should work verbatim, or should I change/transform them in some way?
The reason I ask is that the following program throws an error:
@model function gdemo(x, y)
s ~ InverseGamma(2, 3)
m ~ Normal(0, sqrt(s))
x ~ Normal(m, sqrt(s))
y ~ Normal(m, sqrt(s))
end
model = gdemo(2,4)
chains = sample(model, HMC(0.01, 5), 10000)
prob"x=1.0, y=1.0 | model=gdemo, s = 1.0, m = 1.0"
The error is:
“”"
ERROR: LoadError: AssertionError: model isa Model
Stacktrace:
[1] probtype(::NamedTuple{(:x, :y),Tuple{Float64,Float64}}, ::NamedTuple{(:model, :s, :m),Tuple{typeof(gdemo),Float64,Float64}}) at /home/hakank/.julia/packages/DynamicPPL/jOFDR/src/prob_macro.jl:63
[2] logprob(::NamedTuple{(:x, :y),Tuple{Float64,Float64}}, ::NamedTuple{(:model, :s, :m),Tuple{typeof(gdemo),Float64,Float64}}) at /home/hakank/.julia/packages/DynamicPPL/jOFDR/src/prob_macro.jl:25
[3] top-level scope at /home/hakank/julia/turing/turing_tutorial12.jl:35
[4] include(::String) at ./client.jl:457
[5] top-level scope at ./timing.jl:174 [inlined]
[6] top-level scope at ./none:0
in expression starting at /home/hakank/julia/turing/turing_tutorial12.jl:35
“”"
Here’s my versioninfo():
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core™ i9-7940X CPU @ 3.10GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake-avx512)
Environment:
JULIA_DEPOT_PATH = /home/hakank/.julia
JULIA_NUM_THREADS = 14
JULIA_PKG_SERVER = pkg.juliahub.com
JULIA_LOAD_PATH = @:@v#.#:@stdlib
I’m running via JuliaPro_v1.5.2-1 (via Atom) and Turing version v0.14.10. The same error is thrown using Julia version 1.5.3.
Best regards,
Hakan