Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/inference/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ function AbstractMCMC.sample_init!(
if init_theta !== nothing
# Doesn't support dynamic models
link!(spl.state.vi, spl)
model(spl.state.vi, spl)
model(rng, spl.state.vi, spl)
theta = spl.state.vi[spl]
update_hamiltonian!(spl, model, length(theta))
# Refresh the internal cache phase point z's hamiltonian energy.
spl.state.z = AHMC.phasepoint(rng, theta, spl.state.h)
else
# Samples new values and sets trans to true, then computes the logp
model(empty!(spl.state.vi), SampleFromUniform())
model(rng, empty!(spl.state.vi), SampleFromUniform())
link!(spl.state.vi, spl)
theta = spl.state.vi[spl]
update_hamiltonian!(spl, model, length(theta))
# Refresh the internal cache phase point z's hamiltonian energy.
spl.state.z = AHMC.phasepoint(rng, theta, spl.state.h)
while !isfinite(spl.state.z.ℓπ.value) || !isfinite(spl.state.z.ℓπ.gradient)
model(empty!(spl.state.vi), SampleFromUniform())
model(rng, empty!(spl.state.vi), SampleFromUniform())
link!(spl.state.vi, spl)
theta = spl.state.vi[spl]
update_hamiltonian!(spl, model, length(theta))
Expand Down Expand Up @@ -171,10 +171,10 @@ function AbstractMCMC.sample_init!(
# non-Gibbs sampling.
if !islinked(spl.state.vi, spl) && spl.selector.tag == :default
link!(spl.state.vi, spl)
model(spl.state.vi, spl)
model(rng, spl.state.vi, spl)
elseif islinked(spl.state.vi, spl) && spl.selector.tag != :default
invlink!(spl.state.vi, spl)
model(spl.state.vi, spl)
model(rng, spl.state.vi, spl)
end
end

Expand Down Expand Up @@ -417,7 +417,7 @@ function AbstractMCMC.step!(
# Transform the space
Turing.DEBUG && @debug "X-> R..."
link!(spl.state.vi, spl)
model(spl.state.vi, spl)
model(rng, spl.state.vi, spl)
end
# Get position and log density before transition
θ_old, log_density_old = spl.state.vi[spl], getlogp(spl.state.vi)
Expand Down