Skip to content

Commit

Permalink
Fix scoping bug in HMC
Browse files Browse the repository at this point in the history
  • Loading branch information
xukai92 committed Mar 24, 2017
1 parent c41c920 commit dffcb77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/samplers/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function step(model, data, spl::Sampler{HMC}, varInfo::VarInfo, is_first::Bool)

dprintln(2, "sampling momentum...")
p = Dict(k => randn(length(varInfo[k])) for k in keys(varInfo))
if spl != nothing && ~isempty(spl.alg.space)
p = filter((k, p) -> getsym(varInfo, k) in spl.alg.space, p)
end

dprintln(2, "recording old H...")
oldH = find_H(p, model, data, varInfo, spl)
Expand Down
2 changes: 1 addition & 1 deletion test/gibbs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ x = [1.5 2.0]
s, m
end

gibbs = Gibbs(1000, PG(16, 8, :s), HMC(2, 0.1, 4, :m))
gibbs = Gibbs(1000, PG(20, 4, :s), HMC(2, 0.1, 4, :m))
chain = @sample(gibbstest(x), gibbs)

Turing.TURING[:modelex]
Expand Down

0 comments on commit dffcb77

Please sign in to comment.