TuringLang / AdvancedHMC.jl

Robust, modular and efficient implementation of advanced Hamiltonian Monte Carlo algorithms
https://turinglang.org/AdvancedHMC.jl/
MIT License
228 stars 39 forks source link

RFC `find_good_eps` #27

Closed xukai92 closed 5 years ago

xukai92 commented 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

        θ′, 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.

xukai92 commented 5 years ago

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?

xukai92 commented 5 years ago

Closed by PR #79.