-
Notifications
You must be signed in to change notification settings - Fork 48
Consolidate RHMC Changes #481
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
base: qqy/NEW_RMHMC
Are you sure you want to change the base?
Conversation
This reverts commit 2020f2d.
|
AdvancedHMC.jl documentation for PR #481 is available at: |
… gradients, but not changing the schedule). (#473) * initial changes to get a working demo * fix tests, add new ones, and add documentation * fix type * fix some stray tests * delete tmp folder with demo * address review comments * reference interface refactor issue * refactor and fix test rng handling * improve docstring for NutpieVar * remove superfluous white space * fix JET tests * add entry to history, bump version * fix NutpieVar docstring * increase number of tests for mass matrix adaptation --------- Co-authored-by: Markus Hauru <markus@mhauru.org>
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | ||
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | ||
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | |
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | |
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. | |
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | |
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | |
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. |
|
|
||
| - Adapt the mass matrix `metric` of the Hamiltonian dynamics: `mma = MassMatrixAdaptor(metric)` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | ||
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | ||
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | |
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | |
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. | |
| currently to be initialized for a `metric` of type `DiagEuclideanMetric` | |
| via `mma = AdvancedHMC.NutpieVar(size(metric); var=copy(metric.M⁻¹))` | |
| until a new interface is introduced in an upcoming breaking release to specify the method of adaptation. |
|
|
||
| - Adapt the step size of the leapfrog integrator `integrator`: `ssa = StepSizeAdaptor(δ, integrator)` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| - The randomness is controlled by `rng`. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| z = PhasePoint( | ||
| θ, θ, DualValue(0., θ), DualValue(0., θ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| z = PhasePoint( | |
| θ, θ, DualValue(0., θ), DualValue(0., θ) | |
| ) | |
| z = PhasePoint(θ, θ, DualValue(0.0, θ), DualValue(0.0, θ)) |
| pc1 = MassMatrixAdaptor(UnitEuclideanMetric) # default dim = 2 | ||
| pc2 = MassMatrixAdaptor(DiagEuclideanMetric) | ||
| # Constructing like this until we've settled on a different interface | ||
| pc2_nutpie = NutpieVar{Float64}((2, )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| pc2_nutpie = NutpieVar{Float64}((2, )) | |
| pc2_nutpie = NutpieVar{Float64}((2,)) |
| ) | ||
| # Constructing like this until we've settled on a different interface | ||
| adaptor2_nutpie = StanHMCAdaptor( | ||
| NutpieVar{Float64}((2, )), NesterovDualAveraging(0.8, 0.5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| NutpieVar{Float64}((2, )), NesterovDualAveraging(0.8, 0.5) | |
| NutpieVar{Float64}((2,)), NesterovDualAveraging(0.8, 0.5) |
| # For this target, Nutpie (without regularization) will arrive at the true variances after two draws. | ||
| res_nutpie = runnuts_nutpie(ℓπ, DiagEuclideanMetric(D)) | ||
| @test res.adaptor.pc.var ≈ σ² rtol = 0.2 | ||
| @test preconditioned_cond(res_nutpie.adaptor.pc, Σ) < preconditioned_cond(res.adaptor.pc, Σ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| @test preconditioned_cond(res_nutpie.adaptor.pc, Σ) < preconditioned_cond(res.adaptor.pc, Σ) | |
| @test preconditioned_cond(res_nutpie.adaptor.pc, Σ) < | |
| preconditioned_cond(res.adaptor.pc, Σ) |
| # find the best preconditioner for the target. | ||
| # As these are statistical algorithms, superiority is not always guaranteed, hence this way of testing. | ||
| res_nutpie = runnuts_nutpie(ℓπ, DiagEuclideanMetric(D)) | ||
| n_nutpie_superior += preconditioned_cond(res_nutpie.adaptor.pc, Σ) < preconditioned_cond(res.adaptor.pc, Σ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| n_nutpie_superior += preconditioned_cond(res_nutpie.adaptor.pc, Σ) < preconditioned_cond(res.adaptor.pc, Σ) | |
| n_nutpie_superior += | |
| preconditioned_cond(res_nutpie.adaptor.pc, Σ) < | |
| preconditioned_cond(res.adaptor.pc, Σ) |
Changes include:
We should consolidate all the RHMC changes so that there is one PR to the main branch.