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
ForwardDiff cannot determine ordering of Dual tags for Laplace distributions #1300
Comments
You can avoid the issue by defining your model as @model function mwe()
lvar ~ Uniform(5.0,15.0)
T = typeof(lvar)
u ~ filldist(truncated(Laplace(55.0, lvar), T(10.0), T(Inf)), 10)
return u
end (Note that there is no reason to specify the input argument |
I think the proper fix upstream is just adding Base.eltype(::Type{Laplace{T}}) where {T} = T Then https://github.com/JuliaStats/Distributions.jl/blob/feae3ba9ada360d2980c901e7c737ca02bda7a31/src/truncate.jl#L25 should guarantee that the lower and upper bound of the truncated distribution are also dual numbers (as in the manual fix mentioned above). I'll quickly check if my intuition is correct. |
I can confirm that defining |
Thanks for the replies! I could get around the problem by typecasting the limits to truncated as suggested. |
I asked about my problem here: https://discourse.julialang.org/t/forwarddiff-cannot-determine-ordering-of-dual-tags/40345 and was directed to open an issue at Turing.
Here’s my MWE
The error is:
Cannot determine ordering of Dual tags ForwardDiff.Tag{Turing.Core.var"#f#7"{DynamicPPL.VarInfo{NamedTuple{(:lvar, :u),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:lvar,Tuple{}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:lvar,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:u,Tuple{}},Int64},Array{Product{Continuous,Truncated{Laplace{Float64},Continuous,Float64},FillArrays.Fill{Truncated{Laplace{Float64},Continuous,Float64},1,Tuple{Base.OneTo{Int64}}}},1},Array{DynamicPPL.VarName{:u,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64},DynamicPPL.Model{var"###evaluator#333",(:T,),Tuple{Type{Array{Float64,1}}},(),DynamicPPL.ModelGen{var"###generator#334",(:T,),(:T,),Tuple{Type{Array{Float64,1}}}}},DynamicPPL.Sampler{NUTS{Turing.Core.ForwardDiffAD{40},(),AdvancedHMC.DiagEuclideanMetric},Turing.Inference.SamplerState{DynamicPPL.VarInfo{NamedTuple{(:lvar, :u),Tuple{DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:lvar,Tuple{}},Int64},Array{Uniform{Float64},1},Array{DynamicPPL.VarName{:lvar,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}},DynamicPPL.Metadata{Dict{DynamicPPL.VarName{:u,Tuple{}},Int64},Array{Product{Continuous,Truncated{Laplace{Float64},Continuous,Float64},FillArrays.Fill{Truncated{Laplace{Float64},Continuous,Float64},1,Tuple{Base.OneTo{Int64}}}},1},Array{DynamicPPL.VarName{:u,Tuple{}},1},Array{Float64,1},Array{Set{DynamicPPL.Selector},1}}}},Float64}}}},Float64} and Nothing ...
and goes on for more characters than allowed in the body here. Not able to figure this out! Why isn’t this working?
The text was updated successfully, but these errors were encountered: