Closed xukai92 closed 5 years ago
Copied from @yebai comment in https://github.com/TuringLang/AdvancedHMC.jl/pull/23#discussion_r268405153
r = rand_momentum(rng, h) H = hamiltonian_energy(h, θ, r)
out of find_good_eps and wraping
find_good_eps
θ′, r′, _is_valid = step(Leapfrog(ϵ′), h, θ′, r′) H_new = _is_valid ? hamiltonian_energy(h, θ′, r′) : Inf
into a function
function A(ϵ, h, θ, r) θ′, r′, _is_valid = step(Leapfrog(ϵ′), h, θ′, r′) return H_new = _is_valid ? hamiltonian_energy(h, θ′, r′) : Inf end
Then, we can drop the dependency on AdvancedHMC from this function: find_good_eps(h::Hamiltonian, θ::AbstractVector{T}, A::Function; max_n_iters::Int=100), and move it into adaption/stepsize.jl.
AdvancedHMC
find_good_eps(h::Hamiltonian, θ::AbstractVector{T}, A::Function; max_n_iters::Int=100)
adaption/stepsize.jl
I refactored it anyway (in 6cd458d) but I don't see any reason we have to drop the dependency any more. Plus it still depends on Hamiltonian any way?
Hamiltonian
Closed by PR #79.
Copied from @yebai comment in https://github.com/TuringLang/AdvancedHMC.jl/pull/23#discussion_r268405153
out of
find_good_eps
and wrapinginto a function
Then, we can drop the dependency on
AdvancedHMC
from this function:find_good_eps(h::Hamiltonian, θ::AbstractVector{T}, A::Function; max_n_iters::Int=100)
, and move it intoadaption/stepsize.jl
.