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

README example fails #295

Closed jmsull closed 1 year ago

jmsull commented 1 year ago

Hi, I am trying out AHMC for the first time and noticed that the README example doesn't work.

The line

metric = DiagEuclideanMetric(D)

gives the error:

ERROR: MethodError: no method matching DiagEuclideanMetric(::Int64)
Closest candidates are:
  DiagEuclideanMetric(::Int64, ::V) where {T<:Real, V<:AbstractVector{T}} at ~/.julia/packages/AdvancedHMC/9AC0k/src/metric.jl:44
  DiagEuclideanMetric(::Int64, ::A, ::A, ::A) where {T<:Real, A<:AbstractVector{T}} at ~/.julia/packages/AdvancedHMC/9AC0k/src/metric.jl:19
  DiagEuclideanMetric(::A) where {T<:Real, A<:AbstractVector{T}} at ~/.julia/packages/AdvancedHMC/9AC0k/src/metric.jl:35

Looks like there was an accepted argument change since this example was written?

jmsull commented 1 year ago
initial_ϵ = find_good_stepsize(hamiltonian, initial_θ)

Also gives

ERROR: UndefVarError: find_good_stepsize not defined

yebai commented 1 year ago

@jmsull This might be because you are using a very old version of AdvancedHMC. Can you post which version of AHMC you are using? You can get this information by running ] st.

jmsull commented 1 year ago

@yebai

Thanks for the reply - sorry, I must have made some package mistake somewhere (though I restarted after updating AHMC as instructed), now those things above work after updating and restarting Julia a second time.

st AdvancedHMC
[0bf59076] AdvancedHMC v0.3.6

However now there is an issue with the NUTS line?

proposal = NUTS{MultinomialTS, GeneralisedNoUTurn}(integrator)
ERROR: UndefVarError: NUTS not defined

This works fine though

proposal = AdvancedHMC.NUTS{MultinomialTS, GeneralisedNoUTurn}(integrator)

and it looks like NUTS should be exported when runninng using AdvancedHMC?

Also a package order loading issue - closing.