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

Caution with unused variables in SimpleVarInfo #358

Closed
yebai opened this issue Dec 16, 2021 · 0 comments
Closed

Caution with unused variables in SimpleVarInfo #358

yebai opened this issue Dec 16, 2021 · 0 comments

Comments

@yebai
Copy link
Member

yebai commented Dec 16, 2021

The new VarInfo #309 introduced many nice new features and significant performance improvements. However, it needs to be used with caution at the moment. For example, we can easily introduce spurious variables into SimpleVarInfo which does not influence logdensity evaluation, but would subtly change HMC behaviour (for good or bad). It is because the spurious variables (i.e. x[3:4]) would introduce additional momentum variables. Since these variables do not have a prior on them, the sampling results would become slightly tricky to analyse.

julia> using DynamicPPL, StableRNGs, Distributions

julia> @model function demo()
           m ~ Normal()
           x = Vector{Float64}(undef, 2)
           for i in eachindex(x)
               x[i] ~ Normal()
           end
           return x
       end

julia> _, vi = DynamicPPL.evaluate!!(m, SimpleVarInfo((x = ones(2), )), ctx);

julia> _, vi = DynamicPPL.evaluate!!(m, SimpleVarInfo((x = ones(4), )), ctx); # Note the spurious x variables x[3:4]

julia> vi
SimpleVarInfo((x = [-1.6438528680920432, 0.7944393211208289, 1.0, 1.0], m = 1.2973461452176338), -5.265062153308225)
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