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

LKJCholesky model fails through LogDensityProblems when using SimpleVarInfo #652

Open
sunxd3 opened this issue Sep 5, 2024 · 0 comments

Comments

@sunxd3
Copy link
Member

sunxd3 commented Sep 5, 2024

julia> @model demo_lkj() = x ~ LKJCholesky(2, 1.0)
demo_lkj (generic function with 2 methods)

julia> model = demo_lkj()
Model{typeof(demo_lkj), (), (), (), Tuple{}, Tuple{}, DefaultContext}(demo_lkj, NamedTuple(), NamedTuple(), DefaultContext())

julia> logdensity = DynamicPPL.LogDensityFunction(model, DynamicPPL.VarInfo(model));

julia> logdensity_simple = DynamicPPL.LogDensityFunction(model, DynamicPPL.SimpleVarInfo(model));

julia> θ = rand(4);

julia> LogDensityProblems.logdensity(logdensity, θ) # this is fine
-Inf

julia> LogDensityProblems.logdensity(logdensity_simple, θ)
ERROR: MethodError: no method matching length(::LinearAlgebra.Cholesky{Float64, Matrix{Float64}})

Closest candidates are:
  length(::PrettyTables.RowTable)
   @ PrettyTables ~/.julia/packages/PrettyTables/f6dXb/src/tables.jl:109
  length(::Distributions.VonMisesFisherSampler)
   @ Distributions ~/.julia/packages/Distributions/nmUhn/src/samplers/vonmisesfisher.jl:20
  length(::LibGit2.GitBlob)
   @ LibGit2 ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LibGit2/src/blob.jl:3
  ...

Stacktrace:
 [1] map
   @ ./tuple.jl:291 [inlined]
 [2] unflatten(original::Tuple{LinearAlgebra.Cholesky{Float64, Matrix{Float64}}}, x::Vector{Float64})
   @ DynamicPPL ~/DynamicPPL.jl/src/utils.jl:628
 [3] unflatten(original::@NamedTuple{x::LinearAlgebra.Cholesky{Float64, Matrix{Float64}}}, x::Vector{Float64})
   @ DynamicPPL ~/DynamicPPL.jl/src/utils.jl:639
 [4] unflatten(svi::SimpleVarInfo{@NamedTuple{…}, Float64, DynamicPPL.NoTransformation}, x::Vector{Float64})
   @ DynamicPPL ~/DynamicPPL.jl/src/simple_varinfo.jl:264
 [5] unflatten(varinfo::SimpleVarInfo{…}, context::DefaultContext, θ::Vector{…})
   @ DynamicPPL ~/DynamicPPL.jl/src/abstract_varinfo.jl:737
 [6] logdensity(f::DynamicPPL.LogDensityFunction{SimpleVarInfo{…}, Model{…}, Nothing}, θ::Vector{Float64})
   @ DynamicPPL ~/DynamicPPL.jl/src/logdensityfunction.jl:139
 [7] top-level scope
   @ REPL[14]:1
Some type information was truncated. Use `show(err)` to see complete types.

versions
Julia 1.10.5
Bijectors: 1.13.17
DynamicPPL: 0.29.0

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

1 participant