-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extensions for AdvancedHMC.jl and AdvancedMH.jl (#161)
* Added extensions for AdvancedHMC.jl and AdvancedMH.jl * Bump Julia compat entry to 1.9 + CI to 1.10 (which will be LTS soon) * Relaxed test a bit
- Loading branch information
Showing
6 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
strategy: | ||
matrix: | ||
version: | ||
- '1.7' | ||
- '1.10' | ||
- '1' | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module MCMCTemperingAdvancedHMCExt | ||
|
||
using MCMCTempering: MCMCTempering, Setfield | ||
using AdvancedHMC: AdvancedHMC | ||
|
||
MCMCTempering.getparams_and_logprob(t::AdvancedHMC.Transition) = t.z.θ, t.z.ℓπ.value | ||
MCMCTempering.getparams_and_logprob(state::AdvancedHMC.HMCState) = MCMCTempering.getparams_and_logprob(state.transition) | ||
|
||
# TODO: Implement `state_from` instead, to avoid re-computation of gradients if possible. | ||
function MCMCTempering.setparams_and_logprob!!(model, state::AdvancedHMC.HMCState, params, lp) | ||
# NOTE: Need to recompute the gradient because it might be used in the next integration step. | ||
hamiltonian = AdvancedHMC.Hamiltonian(state.metric, model) | ||
return Setfield.@set state.transition.z = AdvancedHMC.phasepoint( | ||
hamiltonian, params, state.transition.z.r; | ||
ℓκ=state.transition.z.ℓκ | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,3 @@ using Turing: Turing, DynamicPPL | |
|
||
include("utils.jl") | ||
include("test_utils.jl") | ||
include("compat.jl") |