Skip to content

predict on vector of varinfo is incorrect if the varinfo passed in is linked #983

Open
@penelopeysm

Description

@penelopeysm
julia> @model f() = x ~ Beta(2, 2)
f (generic function with 2 methods)

julia> m = f(); v = link!!(VarInfo(m), m)
VarInfo{@NamedTuple{x::DynamicPPL.Metadata{Dict{VarName{:x, typeof(identity)}, Int64}, Vector{Beta{Float64}}, Vector{VarName{:x, typeof(identity)}}, Vector{Float64}}}, Float64}((x = DynamicPPL.Metadata{Dict{VarName{:x, typeof(identity)}, Int64}, Vector{Beta{Float64}}, Vector{VarName{:x, typeof(identity)}}, Vector{Float64}}(Dict(x => 1), [x], UnitRange{Int64}[1:1], [1.3950616230805561], Beta{Float64}[Beta{Float64}=2.0, β=2.0)], [0], Dict{String, BitVector}("del" => [0], "trans" => [1])),), Base.RefValue{Float64}(-1.8839487262608983), Base.RefValue{Int64}(0))

julia> v[@varname(x)] # Should always be in (0, 1), even though it's been linked
0.8013990731398695

julia> pdns = predict(m, [v])
1-element Vector{VarInfo{@NamedTuple{x::DynamicPPL.Metadata{Dict{VarName{:x, typeof(identity)}, Int64}, Vector{Beta{Float64}}, Vector{VarName{:x, typeof(identity)}}, Vector{Float64}}}, Float64}}:
 VarInfo{@NamedTuple{x::DynamicPPL.Metadata{Dict{VarName{:x, typeof(identity)}, Int64}, Vector{Beta{Float64}}, Vector{VarName{:x, typeof(identity)}}, Vector{Float64}}}, Float64}((x = DynamicPPL.Metadata{Dict{VarName{:x, typeof(identity)}, Int64}, Vector{Beta{Float64}}, Vector{VarName{:x, typeof(identity)}}, Vector{Float64}}(Dict(x => 1), [x], UnitRange{Int64}[1:1], [1.3950616230805561], Beta{Float64}[Beta{Float64}=2.0, β=2.0)], [0], Dict{String, BitVector}("del" => [0], "trans" => [0])),), Base.RefValue{Float64}(-Inf), Base.RefValue{Int64}(0))

julia> pdns[1][@varname(x)]
1.3950616230805561

julia> getlogp(pdns[1])
-Inf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions