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
chain = sample(constrained_uniform(n), NUTS(), 1000; thinning=20, discard_initial=200, initial_params=initial_params): ArgumentError: Uniform: the condition a < b is not satisfied.
ERROR: KeyError: key X not found
Stacktrace:
[1] getindex(h::Dict{AbstractPPL.VarName{:X, Accessors.IndexLens{…}}, Int64}, key::AbstractPPL.VarName{:X, typeof(identity)})
@ Base ./dict.jl:498
I think in Turing v0.34.0 NamedTuple has to be used for initial_params however I had some difficulties to make it work. Could anyone pls help me on this issue? Thank you!
Julia version info
versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 128 × Intel(R) Xeon(R) Platinum 8362 CPU @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, icelake-server)
Threads: 1 default, 0 interactive, 1 GC (on 128 virtual cores)
Thank you for bringing up this issue. To clarify, initial_params should be an AbstractVector{<:Union{Real, Missing}}. For example, the following code should work as expected:
When initial_params is a NamedTuple, the initialization is somewhat limited. The error occurs because from model's perspective (as in the VarInfo), X doesn't exist, but rather X[1], x[2].... Currently, there is no direct way to initialize individual components like X[i] (although we can and should add ways to support this).
For this specific model, if the definition is as follows:
@modelfunctionconstrained_uniform(n)
Z ~Uniform(10, 20)
X ~filldist(Uniform(0, Z), n)
end
I hope this helps resolve the issue. Please let us know if this works on your end. Additionally, I’ve created TuringLang/DynamicPPL.jl#774 to track potential improvements.
Thanks so much @sunxd3! I also found using filldist is consistent with named tuple. I see the trick in providing initial_params. I am so grateful for the prompt help and detailed interpretation from all of you!! To this end, I'm closing this thread.
Minimal working example
Description
I want to sample
Z ~ Unif(10,20)
andX ~ Unif(0,Z)
for two iidXs
.When
initial_params
is not set, there's nothing wrong. However, ifinitial_params=initial_params
, then it produces errors.v0.33.0:
chain = sample(constrained_uniform(n), NUTS(), 1000; thinning=20, discard_initial=200, initial_params=[initial_z,initial_x])
:correct
chain = sample(constrained_uniform(n), NUTS(), 1000; thinning=20, discard_initial=200, initial_params=initial_params)
:ArgumentError: Uniform: the condition a < b is not satisfied.
v0.34.0:
chain = sample(constrained_uniform(n), NUTS(), 1000; thinning=20, discard_initial=200, initial_params=[initial_z,initial_x])
chain = sample(constrained_uniform(n), NUTS(), 1000; thinning=20, discard_initial=200, initial_params=initial_params)
I think in Turing v0.34.0 NamedTuple has to be used for initial_params however I had some difficulties to make it work. Could anyone pls help me on this issue? Thank you!
Julia version info
versioninfo()
Manifest
]st --manifest
The text was updated successfully, but these errors were encountered: