Closed zenon closed 4 years ago
I thougt that using a upper case X might help,
truth = rand(m(X=randn(6)));
ERROR: ArgumentError: Sampler for this object is not defined
Complete error message:
ERROR: ArgumentError: Sampler for this object is not defined Stacktrace: [1] Random.Sampler(::Type{Random.MersenneTwister}, ::Random.SamplerTrivial{For{GeneralizedGenerated.Closure{(β, x;) -> let (Soss).Normal((Soss).:(x', β), 1) end,Tuple{Array{Float64,1}}},1,Base.Generator{Base.OneTo{Int64},getfield(Base, Symbol("##176#177")){Array{Float64,1}}}},Any}, ::Val{1}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\Random\src\Random.jl:143 [2] Random.Sampler(::Random.MersenneTwister, ::Random.SamplerTrivial{For{GeneralizedGenerated.Closure{(β, x;) -> let (Soss).Normal((Soss).:(x', β), 1) end,Tuple{Array{Float64,1}}},1,Base.Generator{Base.OneTo{Int64},getfield(Base, Symbol("##176#177")){Array{Float64,1}}}},Any}, ::Val{1}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\Random\src\Random.jl:140 [3] rand(::Random.MersenneTwister, ::Random.SamplerTrivial{For{GeneralizedGenerated.Closure{(β, x;) -> let (Soss).Normal((Soss).:(x', β), 1) end,Tuple{Array{Float64,1}}},1,Base.Generator{Base.OneTo{Int64},getfield(Base, Symbol("##176#177")){Array{Float64,1}}}},Any}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\Random\src\Random.jl:230 (repeats 2 times) [4] rand(::For{GeneralizedGenerated.Closure{(β, x;) -> let (Soss).Normal((Soss).:(x', β), 1) end,Tuple{Array{Float64,1}}},1,Base.Generator{Base.OneTo{Int64},getfield(Base, Symbol("##176#177")){Array{Float64,1}}}}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\Random\src\Random.jl:235 [5] _rand(::Model{NamedTuple{(:X,),T} where T<:Tuple,begin β ~ Normal() |> iid(size(X, 2)) y ~ For(eachrow(X)) do x Normal(x' β, 1) end end}, ::NamedTuple{(:X,),Tuple{Array{Float64,1}}}) at C:\Users\Zenon.julia\packages\GeneralizedGenerated\x3uMp\src\closure_conv.jl:102 [6] rand(::Soss.JointDistribution{NamedTuple{(:X,),Tuple{Array{Float64,1}}},NamedTuple{(:X,),T} where T<:Tuple,begin β ~ Normal() |> iid(size(X, 2)) y ~ For(eachrow(X)) do x Normal(x' β, 1) end end}) at C:\Users\Zenon.julia\packages\Soss\JSNdl\src\rand.jl:8
The rest of the example code depends on it, so I'm stuck.
Except
weightedSample(m(σ=1), (μ=0.0,))
and
weightedSample(m(σ=1), (x=[-1,0,1],))
which both give: ERROR: UndefVarError: X not defined
and
nuts(m(σ=1),(x=[-1,0,1],)) |> particles
It leads to: ERROR: UndefVarError: nuts not defined
What am I doing wrong??
Hi @zenon ,
Sorry for the delay, I had missed the notification for this. I seem to have introduced a bug in the definition of For
. I should have it fixed within a day or two. More details soon...
Cool, thank you! :-)
I made some code and README updates; it should work now in master. Thanks again for letting me know about this!
Hello Chad! Great, thank you!
I can repeat everything until
symlogpdf(m2) |> expandSums
There are still issues in
weightedSample(m(σ=1), (μ=0.0,))
weightedSample(m(σ=1), (x=[-1,0,1],))
The latter seems to just need an uppercasing of X. The first one wants an X too, and I don't know yet where.
I can repeat everything until
symlogpdf(m2) |> expandSums
Hmm, that's weird. Does it throw an error? If you just type expandSums
at the prompt, does it recognize it?
There are still issues in...
Oops, I still need to update that, it's referring to a different model. I think there's a way to have doctests, I need to get around to that
Ehm, with "until" I indended to mean "until and including" (this is not my native language)
A suggestion, helpful for readers that are unsure about what happens (like me), and used e.g. by Turing: Add a
Random.seed!(...)
near the start of the readme, so we can reproduce your results exactly.
Do doctests exist for Julia? I agree this should make things easier :-)
I had forgotten about Weave! https://github.com/JunoLab/Weave.jl
Updated! Now it's in README.jmd
, which produces README.md
. It's not yet automated, for now I'm just calling weave
on the command line
Cool.
I'm sorry, I feel like a gadfly, tbh. I updated Soss again, and in
symlogpdf(m2) |> expandSums |> foldConstants
foldConstants isn't found, and in the second benchmark line
@btime logpdf($m2(X=X), $truth, $codegen)
I get
ERROR: MethodError: no method matching
logpdf(::Soss.JointDistribution{NamedTuple{(:X,),Tuple{Array{Float64,2}}},NamedTuple{(:X,),T} where T<:Tuple,begin
k = size(X, 2)
β ~ Normal() |> iid(k)
yhat = X * β
N = size(X, 1)
y ~ For(N) do j
Normal(yhat[j], 1)
end
end}, ::NamedTuple{(:X, :β, :y),Tuple{Array{Float64,2},Array{Float64,1},Array{Float64,1}}},
::typeof(codegen))
Kind regards, and I really appreciate your patience. (I didn't try weave yet, I just tried the code by copy and paste. In case this makes a difference.)
No worries! I appreciate your help making sure it's all working properly.
Are you on master? The symbolic stuff is very recently updated
Master, update, and now everything works fine. Thank you!
If you got more documentation, I'll have a go at it too :-)
Hi,
in the Readme, it says
and then
This gives; ERROR: UndefVarError: X not defined