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

Initial AbstractMCMC.step should not sample #366

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions src/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ function AbstractMCMC.step(

# Compute next transition and state.
state = HMCState(0, t, metric, κ, adaptor)
# Take actual first step.
return AbstractMCMC.step(rng, model, spl, state; kwargs...)
# Return the initial transition and state.
return Transition(t.z, merge(stat(t), (is_adapt = false,))), state
end

function AbstractMCMC.step(
Expand Down Expand Up @@ -260,10 +260,13 @@ function (cb::HMCProgressCallback)(
κ = state.κ
tstat = t.stat
isadapted = tstat.is_adapt
if isadapted
cb.num_divergent_transitions_during_adaption[] += tstat.numerical_error
else
cb.num_divergent_transitions[] += tstat.numerical_error
# The initial transition will not much information beyond the `is_adapt` field.
if haskey(tstat, :numerical_error)
if isadapted
cb.num_divergent_transitions_during_adaption[] += tstat.numerical_error
else
cb.num_divergent_transitions[] += tstat.numerical_error
end
end

# Update progress meter
Expand Down
Loading