diff --git a/README.md b/README.md index dc3d31b5..9c52315f 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ If you are interested in using AdvancedHMC.jl through a probabilistic programmin - We presented a poster for AdvancedHMC.jl at [StanCon 2019](https://mc-stan.org/events/stancon2019Cambridge/) in Cambridge, UK. ([pdf](https://github.com/TuringLang/AdvancedHMC.jl/files/3730367/StanCon-AHMC.pdf)) **API CHANGES** -- [v0.5.0] **Breaking!** Convinience constructors for common samplers changed to: - - `HMC(init_ϵ::Float64=init_ϵ, n_leapfrog::Int=n_leapfrog)` - - `NUTS(n_adapts::Int=n_adapts, δ::Float64=δ)` - - `HMCDA(n_adapts::Int=n_adapts, δ::Float64=δ, λ::Float64=λ)` +- [v0.5.0] **Breaking!** Convenience constructors for common samplers changed to: + - `HMC(init_ϵ, n_leapfrog)` + - `NUTS(n_adapts, target_acceptance)` + - `HMCDA(n_adapts, target_acceptance, integration_time)` - [v0.2.22] Three functions are renamed. - `Preconditioner(metric::AbstractMetric)` -> `MassMatrixAdaptor(metric)` and - `NesterovDualAveraging(δ, integrator::AbstractIntegrator)` -> `StepSizeAdaptor(δ, integrator)` @@ -77,15 +77,15 @@ n_samples, n_adapts = 2_000, 1_000 metric = DiagEuclideanMetric(D) hamiltonian = Hamiltonian(metric, ℓπ, ForwardDiff) -# Define a leapfrog solver, with initial step size chosen heuristically +# Define a leapfrog solver, with the initial step size chosen heuristically initial_ϵ = find_good_stepsize(hamiltonian, initial_θ) integrator = Leapfrog(initial_ϵ) -# Define an HMC sampler, with the following components +# Define an HMC sampler with the following components # - multinomial sampling scheme, # - generalised No-U-Turn criteria, and # - windowed adaption for step-size and diagonal mass matrix -proposal = NUTS{MultinomialTS, GeneralisedNoUTurn}(integrator) +proposal = HMCKernel(Trajectory{MultinomialTS}(integrator, GeneralisedNoUTurn())) adaptor = StanHMCAdaptor(MassMatrixAdaptor(metric), StepSizeAdaptor(0.8, integrator)) # Run the sampler to draw samples from the specified Gaussian, where diff --git a/src/abstractmcmc.jl b/src/abstractmcmc.jl index 31bdf999..8e0956c5 100644 --- a/src/abstractmcmc.jl +++ b/src/abstractmcmc.jl @@ -289,16 +289,15 @@ end make_integrator(spl::HMCSampler, ϵ::Real) = spl.κ.τ.integrator make_integrator(spl::AbstractHMCSampler, ϵ::Real) = make_integrator(spl.integrator, ϵ) make_integrator(i::AbstractIntegrator, ϵ::Real) = i -make_integrator(i::Type{<:AbstractIntegrator}, ϵ::Real) = i make_integrator(i::Symbol, ϵ::Real) = make_integrator(Val(i), ϵ) -make_integrator(i...) = error("Integrator $(typeof(i)) not supported.") +make_integrator(@nospecialize(i), ::Real) = error("Integrator $i not supported.") make_integrator(i::Val{:leapfrog}, ϵ::Real) = Leapfrog(ϵ) make_integrator(i::Val{:jitteredleapfrog}, ϵ::Real) = JitteredLeapfrog(ϵ) make_integrator(i::Val{:temperedleapfrog}, ϵ::Real) = TemperedLeapfrog(ϵ) ######### -make_metric(i...) = error("Metric $(typeof(i)) not supported.") +make_metric(@nospecialize(i), T::Type, d::Int) = error("Metric $(typeof(i)) not supported.") make_metric(i::Symbol, T::Type, d::Int) = make_metric(Val(i), T, d) make_metric(i::AbstractMetric, T::Type, d::Int) = i make_metric(i::Type{AbstractMetric}, T::Type, d::Int) = i