-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor inference for CRP DP GMM via SMC, PG, IS #10
Comments
You might want to do something like this instead. @model dp_gmm_crp_delayed(y) = begin
nobs = length(y)
alpha ~ Gamma(1, 0.1) # mean = a*b
rpm = DirichletProcess(alpha)
# Base measure.
H_mu = Normal(0, 3)
H_sigma = InverseGamma(2, 3)
# Latent assignment.
z = tzeros(Int, nobs)
n = tzeros(Int, nobs)
K = 0
mu = tzeros(Float64, nobs)
sigma = tzeros(Float64, nobs)
for i in 1:nobs
z[i] ~ ChineseRestaurantProcess(rpm, n)
n[z[i]] += 1
if z[i] > K
mu[z[i]] ~ H_mu
sigma[z[i]] ~ H_sigma
K += 1
end
y[i] ~ Normal(mu[z[i]], sqrt(sigma[z[i]]))
end
end This might contain a bug as I haven't tested it. In general, it is beneficial to delay sampling of RVs for SMC and PG, as in this code. I wasn't aware of this myself, Hong told me a while ago. |
I think Martin's version at least removes the possibility of mis-using
Can you remind me of the example Hong gave? I thought as for delay sampling of RVs, we should indeed put them in the same loop, which is what Arthur is doing ATM. My understanding is that the model can stop early if it observes data in an online-fashion. |
Also try running the inference in the https://github.com/mohamed82008/DynamicPPL_NeurIPS environment. I think I fixed some bugs there for dynamic programs. |
You are completely right Kai. Stupid me. I’ll update the code example. |
What is the output of I see that My limited understanding is that in SMC, you end up with particles and weights for those particles, which together represent approximate posterior samples. So does Sorry if this sounds like a mess... |
@mohamed82008 Do you mean use the libraries and versions listed in |
Yes activate the environment and run your code there. |
Yes, it should return particles and their weights. I’ll need to have a look as I’m not 100% sure. I should be able to do so by tomorrow evening. Sorry for the late reply. |
The model in the notebook (assuming it is the latest version) looks good to me. Also, it makes sense to set an upper bound on the total active clusters It is also a good idea to explore different sampler setups. Sampling everything using SMC (even with a large number of particles) would probably lead to poor inference results due to usual SMC dependency issues. Similar issues would also affect the PG sampler. It is generally a better idea to use PG + MH, PG + HMC, or PG + MH + HMC samplers, where PG is only used for discrete random variables (i.e. cluster assignments). A potentially good sampler I imagine: |
@yebai Thanks for the comment! Awesome, I'll double check that I'm using the latest versions. You answered my other question. I've searched around and read that, in Turing, |
That's correct -- PG is conditional SMC in Turing. |
I am currently on the master branch of Turing. The model is: @model dp_gmm_crp_delayed(y, Kmax) = begin
nobs = length(y)
alpha ~ Gamma(1, 1/10) # mean = a*b
rpm = DirichletProcess(alpha)
# Base measure.
H_mu = Normal(0, 3)
H_sigma = LogNormal(-1, 0.5)
# Latent assignment.
z = tzeros(Int, nobs)
n = tzeros(Int, nobs)
K = 0
mu = tzeros(Float64, Kmax)
sigma = tzeros(Float64, Kmax)
for i in 1:nobs
z[i] ~ ChineseRestaurantProcess(rpm, n)
n[z[i]] += 1
if z[i] > K
mu[z[i]] ~ H_mu
sigma[z[i]] ~ H_sigma
K += 1
end
y[i] ~ Normal(mu[z[i]], sigma[z[i]])
end
end; In this case, When I use a sampler like: Kmax = 30
sample(dp_gmm_crp_delayed(y, Kmax), Gibbs(MH(0.1, :alpha), PG(10, :z), HMC(0.01, 100, :mu, :sigma)), iterations) I get the following error (it seems like TypeError: in typeassert, expected Float64, got ForwardDiff.Dual{Nothing,Float64,2}
Stacktrace:
[1] setindex!(::Array{Float64,1}, ::ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2}, ::Int64) at ./array.jl:826
[2] setindex!(::TArray{Float64,1}, ::ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2}, ::Int64) at /home/ubuntu/.julia/packages/Libtask/Zo6uM/src/tarray.jl:65
[3] macro expansion at ./In[12]:26 [inlined]
[4] ##evaluator#311(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1},Array{Set{DynamicPPL.Selector},1}}}},ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2}}, ::DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}, ::DynamicPPL.DefaultContext) at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/compiler.jl:356
[5] evaluate_threadunsafe at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/model.jl:157 [inlined]
[6] (::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}})(::Random._GLOBAL_RNG, ::DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1},Array{Set{DynamicPPL.Selector},1}}}},ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2}}, ::DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}, ::DynamicPPL.DefaultContext) at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/model.jl:136
[7] Model at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/model.jl:135 [inlined]
[8] Model at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/model.jl:126 [inlined]
[9] f at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/core/ad.jl:104 [inlined]
[10] vector_mode_dual_eval(::Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}}, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2,Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1}}) at /home/ubuntu/.julia/packages/ForwardDiff/sdToQ/src/apiutils.jl:37
[11] vector_mode_gradient! at /home/ubuntu/.julia/packages/ForwardDiff/sdToQ/src/gradient.jl:103 [inlined]
[12] gradient!(::Array{Float64,1}, ::Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}}, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2,Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1}}, ::Val{true}) at /home/ubuntu/.julia/packages/ForwardDiff/sdToQ/src/gradient.jl:35
[13] gradient!(::Array{Float64,1}, ::Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}}, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2,Array{ForwardDiff.Dual{ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64},Float64,2},1}}) at /home/ubuntu/.julia/packages/ForwardDiff/sdToQ/src/gradient.jl:33
[14] gradient_logp(::Turing.Core.ForwardDiffAD{40}, ::Array{Float64,1}, ::DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}, ::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/core/ad.jl:114
[15] gradient_logp at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/core/ad.jl:78 [inlined]
[16] ∂logπ∂θ at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/hmc.jl:474 [inlined]
[17] ∂H∂θ at /home/ubuntu/.julia/packages/AdvancedHMC/P9wqk/src/hamiltonian.jl:31 [inlined]
[18] phasepoint(::AdvancedHMC.Hamiltonian{AdvancedHMC.UnitEuclideanMetric{Float64,Tuple{Int64}},Turing.Inference.var"#logπ#55"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}},Turing.Inference.var"#∂logπ∂θ#54"{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}}}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/ubuntu/.julia/packages/AdvancedHMC/P9wqk/src/hamiltonian.jl:69
[19] phasepoint at /home/ubuntu/.julia/packages/AdvancedHMC/P9wqk/src/hamiltonian.jl:139 [inlined]
[20] sample_init at /home/ubuntu/.julia/packages/AdvancedHMC/P9wqk/src/sampler.jl:42 [inlined]
[21] Turing.Inference.HMCState(::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}, ::Random._GLOBAL_RNG; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/hmc.jl:638
[22] Turing.Inference.HMCState(::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.Sampler{HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:alpha, :z, :mu, :sigma),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:alpha,Tuple{}},Int64},Array{Gamma{Float64},1},Array{DynamicPPL.VarName{:alpha,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},Int64},Array{ChineseRestaurantProcess{DirichletProcess{Float64},TArray{Int64,1}},1},Array{DynamicPPL.VarName{:z,Tuple{Tuple{Int64}}},1},Array{Int64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},Int64},Array{Normal{Float64},1},Array{DynamicPPL.VarName{:mu,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:sigma,Tuple{Tuple{Int64}}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}, ::Random._GLOBAL_RNG) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/hmc.jl:609
[23] DynamicPPL.Sampler(::HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}, ::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.Selector) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/hmc.jl:384
[24] (::Turing.Inference.var"#80#81"{Gibbs{(:alpha, :z, :mu, :sigma),Tuple{MH{(:alpha,),NamedTuple{(),Tuple{}}},PG{(:z,),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}}},DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}})(::HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/gibbs.jl:85
[25] map at ./tuple.jl:159 [inlined]
[26] DynamicPPL.Sampler(::Gibbs{(:alpha, :z, :mu, :sigma),Tuple{MH{(:alpha,),NamedTuple{(),Tuple{}}},PG{(:z,),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}}}, ::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::DynamicPPL.Selector) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/gibbs.jl:76
[27] Sampler at /home/ubuntu/.julia/packages/DynamicPPL/MRwtL/src/sampler.jl:55 [inlined]
[28] sample(::Random._GLOBAL_RNG, ::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::Gibbs{(:alpha, :z, :mu, :sigma),Tuple{MH{(:alpha,),NamedTuple{(),Tuple{}}},PG{(:z,),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}}}, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/Inference.jl:165
[29] sample at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/Inference.jl:165 [inlined]
[30] #sample#1 at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/Inference.jl:155 [inlined]
[31] sample(::DynamicPPL.Model{var"###evaluator#311",(:y, :Kmax),Tuple{Array{Float64,1},Int64},(),DynamicPPL.ModelGen{var"###generator#312",(:y, :Kmax),(),Tuple{}}}, ::Gibbs{(:alpha, :z, :mu, :sigma),Tuple{MH{(:alpha,),NamedTuple{(),Tuple{}}},PG{(:z,),Turing.Core.ResampleWithESSThreshold{typeof(Turing.Inference.resample_systematic),Float64}},HMC{Turing.Core.ForwardDiffAD{40},(:mu, :sigma),AdvancedHMC.UnitEuclideanMetric}}}, ::Int64) at /home/ubuntu/.julia/packages/Turing/NZ9IU/src/inference/Inference.jl:155
[32] macro expansion at ./In[95]:20 [inlined]
[33] macro expansion at ./util.jl:175 [inlined]
[34] top-level scope at ./In[95]:3 |
You need to slightly adjust the model definition so that it works with AD. |
@model function dp_gmm_crp_delayed(y, Kmax, ::Type{T}=Vector{Float64}) where {T}
nobs = length(y)
alpha ~ Gamma(1, 1/10) # mean = a*b
rpm = DirichletProcess(alpha)
# Base measure.
H_mu = Normal(0, 3)
H_sigma = LogNormal(-1, 0.5)
# Latent assignment.
z = tzeros(Int, nobs)
n = tzeros(Int, nobs)
K = 0
mu = T(undef, Kmax)
sigma = T(undef, Kmax)
for i in 1:nobs
z[i] ~ ChineseRestaurantProcess(rpm, n)
n[z[i]] += 1
if z[i] > K
mu[z[i]] ~ H_mu
sigma[z[i]] ~ H_sigma
K += 1
end
y[i] ~ Normal(mu[z[i]], sigma[z[i]])
end
end; That should work. |
Thanks, I'll try that. Also, what is the reason for |
See this library: https://github.com/TuringLang/Libtask.jl |
So if I were to use |
Yes. |
I simulated some data and fit the following model to the data. I get poor inference. i.e., the results don't really match up with the simulation truth. Particularly, I tend to learn 4 to 5 clusters when my data has 4 almost-equally-sized clusters, but there are usually only 1 or 2 big (dominating) clusters in the posterior inference.
So, my first question is am I abusing the API? In my DP gaussian mixtures of location and scale, I use a base measure (H) which is Normal x InverseGamma (two independent distributions) for the location (mu) and scale (sigma). Am I doing this correctly? (It runs, but I suspect I'm doing something outside the intended use.)
My second question is, if the model is implemented correctly, what might be the cause for poor inference? Admittedly, I'm not familiar with
SMC/PC
. But does increasing the number of particles generally lead to better inference?Here is the complete notebook.
The text was updated successfully, but these errors were encountered: