Skip to content
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

Method error for Stacked #169

Open
baggepinnen opened this issue Feb 13, 2021 · 2 comments
Open

Method error for Stacked #169

baggepinnen opened this issue Feb 13, 2021 · 2 comments

Comments

@baggepinnen
Copy link

I'm getting a method error when trying to run

using Turing: Variational
m = clamp_sim(trq_m, q_m)
advi = ADVI(10, 1000)
q = vi(m, advi)

where clamp_sim is a fairly complicated model relying on a private package. The model samples okay with the MH sampler and is differentiable with ForwardDiff. I hope the following stack trace is useful. If more info is required, I can try to reduce the model a bit, but I'm afraid I don't know enough about Turing/Bijectors to have any idea of what has gone wrong.

julia> q = vi(m, advi)
ERROR: MethodError: no method matching Stacked(::Tuple{Inverse{Bijectors.TruncatedBijector{1, Float64, Float64}, 1}, Bijectors.Exp{1}, Bijectors.Exp{1}, Inverse{Bijectors.TruncatedBijector{1, SVector{6, Float64}, SVector{6, Float64}}, 1}, Identity{1}, Bijectors.Exp{1}, Bijectors.Exp{1}, Inverse{Bijectors.TruncatedBijector{2, Matrix{Float64}, Matrix{Float64}}, 2}}, ::NTuple{8, UnitRange{Int64}})
Closest candidates are:
  Stacked(::Any, ::AbstractArray) at /home/fredrikb/.julia/packages/Bijectors/L39Ij/src/bijectors/stacked.jl:44
  Stacked(::A, ::Tuple{Vararg{UnitRange{Int64}, N}}) where {N, A<:(AbstractArray{var"#s27", N} where {var"#s27"<:Bijector, N})} at /home/fredrikb/.julia/packages/Bijectors/L39Ij/src/bijectors/stacked.jl:35
  Stacked(::C, ::Tuple{Vararg{UnitRange{Int64}, N}}) where {N, C<:Tuple{Vararg{Union{Bijector{0}, Bijector{1}}, N}}} at /home/fredrikb/.julia/packages/Bijectors/L39Ij/src/bijectors/stacked.jl:28
  ...
Stacktrace:
 [1] Stacked(bs::Tuple{Inverse{Bijectors.TruncatedBijector{1, Float64, Float64}, 1}, Bijectors.Exp{1}, Bijectors.Exp{1}, Inverse{Bijectors.TruncatedBijector{1, SVector{6, Float64}, SVector{6, Float64}}, 1}, Identity{1}, Bijectors.Exp{1}, Bijectors.Exp{1}, Inverse{Bijectors.TruncatedBijector{2, Matrix{Float64}, Matrix{Float64}}, 2}}, ranges::Vector{UnitRange{Int64}})
   @ Bijectors ~/.julia/packages/Bijectors/L39Ij/src/bijectors/stacked.jl:44
 [2] meanfield(rng::Random._GLOBAL_RNG, model::DynamicPPL.Model{var"#15#17", (:trq_m, :q_m), (), (), Tuple{Matrix{Float64}, Matrix{Float64}}, Tuple{}})
   @ Turing.Variational ~/.julia/packages/Turing/uAz5c/src/variational/advi.jl:84
 [3] meanfield
   @ ~/.julia/packages/Turing/uAz5c/src/variational/advi.jl:53 [inlined]
 [4] vi(model::DynamicPPL.Model{var"#15#17", (:trq_m, :q_m), (), (), Tuple{Matrix{Float64}, Matrix{Float64}}, Tuple{}}, alg::ADVI{AdvancedVI.ForwardDiffAD{40}}; optimizer::AdvancedVI.TruncatedADAGrad)
   @ Turing.Variational ~/.julia/packages/Turing/uAz5c/src/variational/advi.jl:109
 [5] vi(model::DynamicPPL.Model{var"#15#17", (:trq_m, :q_m), (), (), Tuple{Matrix{Float64}, Matrix{Float64}}, Tuple{}}, alg::ADVI{AdvancedVI.ForwardDiffAD{40}})
   @ Turing.Variational ~/.julia/packages/Turing/uAz5c/src/variational/advi.jl:109
 [6] top-level scope
   @ REPL[8]:1
@torfjelde
Copy link
Member

Yeah this is an issue with how the transformation from real space to constrained space is constructed. Essentially, at the moment only 0- and 1-dimensional distributions are supported by that constructor. I got the fix though, just a sec!

@torfjelde
Copy link
Member

TuringLang/Turing.jl#1545

Hopefully we'll get the this merged ASAP, but it's a fairly simple change so in the meantime you could just copy-paste the def of Vec and the redefinitions of meanfield and bijector from the file:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants