From 4963b00f7e5a5bd05ed422699f614279003fc00a Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Tue, 23 Apr 2024 11:05:34 +0100 Subject: [PATCH 1/5] initial step should just construct the initial transitio and step; it should not perform any sampling of the parameters. --- src/abstractmcmc.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abstractmcmc.jl b/src/abstractmcmc.jl index 905deaf7..7b91a07b 100644 --- a/src/abstractmcmc.jl +++ b/src/abstractmcmc.jl @@ -132,8 +132,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( From 181c8cb9143362e50ea09139841570a4b00a854d Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Tue, 23 Apr 2024 11:06:13 +0100 Subject: [PATCH 2/5] bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index efdaf2a4..2d471834 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "AdvancedHMC" uuid = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d" -version = "0.6.1" +version = "0.6.2" [deps] AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001" From 4bf86ec2a0778543775a4006f1684ac5c076b9d5 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Tue, 23 Apr 2024 11:14:25 +0100 Subject: [PATCH 3/5] Update src/abstractmcmc.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/abstractmcmc.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abstractmcmc.jl b/src/abstractmcmc.jl index 7b91a07b..6c64dccb 100644 --- a/src/abstractmcmc.jl +++ b/src/abstractmcmc.jl @@ -133,7 +133,7 @@ function AbstractMCMC.step( # Compute next transition and state. state = HMCState(0, t, metric, κ, adaptor) # Return the initial transition and state. - return Transition(t.z, merge(stat(t), (is_adapt=false,))), state + return Transition(t.z, merge(stat(t), (is_adapt = false,))), state end function AbstractMCMC.step( From 50b56abecf75d962683d3f52638cc2f987b7d9ba Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Thu, 25 Apr 2024 15:16:55 +0100 Subject: [PATCH 4/5] fixed issue in callback for first iteration --- src/abstractmcmc.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/abstractmcmc.jl b/src/abstractmcmc.jl index 6c64dccb..ec3c2107 100644 --- a/src/abstractmcmc.jl +++ b/src/abstractmcmc.jl @@ -210,7 +210,8 @@ function (cb::HMCProgressCallback)(rng, model, spl, t, state, i; nadapts = 0, kw κ = state.κ tstat = t.stat isadapted = tstat.is_adapt - if isadapted + # The initial transition will not much information beyond the `is_adapt` field. + if isadapted && haskey(tstat, :numerical_error) cb.num_divergent_transitions_during_adaption[] += tstat.numerical_error else cb.num_divergent_transitions[] += tstat.numerical_error From 151c662512193c1dca1247d9d480c3db203ecc1a Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Mon, 6 May 2024 13:38:01 +0100 Subject: [PATCH 5/5] attempt at fixing callback issues --- src/abstractmcmc.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/abstractmcmc.jl b/src/abstractmcmc.jl index ec3c2107..d36c765a 100644 --- a/src/abstractmcmc.jl +++ b/src/abstractmcmc.jl @@ -211,10 +211,12 @@ function (cb::HMCProgressCallback)(rng, model, spl, t, state, i; nadapts = 0, kw tstat = t.stat isadapted = tstat.is_adapt # The initial transition will not much information beyond the `is_adapt` field. - if isadapted && haskey(tstat, :numerical_error) - cb.num_divergent_transitions_during_adaption[] += tstat.numerical_error - else - cb.num_divergent_transitions[] += tstat.numerical_error + 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