Comments (2)
As suggested by Kai on Slack tempering would need to be added to the 'step' function
Secondly, you need to add the tempering steps to (
)AdvancedHMC.jl/src/integrator.jl
Lines 37 to 65 in 637c2be
Making sure to that we "heat up" and "cool down" symmetrically as suggested by Neal, 2012. As pointed out by Kai due to nature of the leapfrog implementation taking full step for the momentum within the trajectory we need to take extra care.
An if elseif
scheme for tempering with the trajectory like this should probably work:
n_steps = 5
println("Step:0")
println("half*sqrt(α)")
for i in 1:n_steps
if i*2 == n_steps && i != n_steps
#θ, r = θ_new, r_new/α
println("half*sqrt(α) + half/sqrt(α) = full")
println("Step:",i,".5")
elseif 2*i < n_steps
#θ, r = θ_new, r_new*α
println("full*α")
println("Step:",i,".5")
elseif i*2 > n_steps && i != n_steps
#θ, r = θ_new, r_new/α
println("full/α")
println("Step:",i,".5")
else
#θ, r = θ_new, r_new/α_sqrt
println("full/sqrt(α)")
println("Step:",i)
end
end
Lastly, @xukai92 raised the issue of how to exactly implement the tempering code within the existing code structure as well as how much effect it will have on AHMC
sampling:
So it comes to a design issue, should I implement this conditions inside
step
and check iflf.α == 1
, or we’d better introduce anotherIntegrator
type which does this job and implementlf_momentum
andlf_position
separate for each type and rely on multiple dispatch to deal with this conditions. Not sure what’s the better way. But for your purpose add this conditions should work.
However, I’m not sure how does this actually interact with NUTS (for plain HMC it seems all good), as NUTS only callsteps
withn_steps=1
and the trajectory building relies on its on doubling tree algorithm.
from advancedhmc.jl.
An update from above code(fixing an error), the tempering could be conceptually done like this:
n_steps = 5
α = 1.02
α_sqrt = sqrt(α)
println("Step:0")
#θ, r = θ_new, r_new*α_sqrt
println("half*sqrt(α)")
for i in 1:n_steps
if i*2 == n_steps && i != n_steps
#θ, r = θ_new, r_new
println("half*sqrt(α) + half/sqrt(α) = full")
println("Step:",i,".5")
elseif 2*i < n_steps
#θ, r = θ_new, r_new*α
println("full*α")
println("Step:",i,".5")
elseif i*2 > n_steps && i != n_steps
#θ, r = θ_new, r_new/α
println("full/α")
println("Step:",i,".5")
else
#θ, r = θ_new, r_new/α_sqrt
println("full/sqrt(α)")
println("Step:",i)
end
end
from advancedhmc.jl.
Related Issues (20)
- Antithetic/Control Variates sampling
- Add low-rank metric adaptation HOT 4
- Support for RMHMC with explicit integrator HOT 1
- Sampler failure when num of samples = 1
- Add Pathfinder adaptation
- AMAGOLD support HOT 1
- Unify the Euclidean metric types
- Expose adapted mass matrix
- README example fails HOT 3
- Step size initialization uses GLOBAL RNG instead of reproducible RNG from caller
- Forecasting
- Feature request: HMC sampling from convex polytopes defined by linear programs
- Add nuts-rs's metric adaptation HOT 15
- More friendly default `sample` interface HOT 9
- Make `HMCState` stores `rng` in `AbstractMCMC` interface. HOT 5
- Weighted Log Likelihood #featurerequest
- Convinience Constructors HOT 16
- Objects of type LogTargetDensity are not callable HOT 2
- Removing support for AbstractMCMC.Sample piracy HOT 4
- Retest is broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from advancedhmc.jl.