Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify Trajectory type for static, dynamic HMC samplers. #103

Closed
yebai opened this issue Sep 20, 2019 · 3 comments
Closed

Unify Trajectory type for static, dynamic HMC samplers. #103

yebai opened this issue Sep 20, 2019 · 3 comments

Comments

@yebai
Copy link
Member

yebai commented Sep 20, 2019

We have the following nice composable interface for NUTS at the moment

p = NUTS{Multinomial,GeneralisedNoUTurn}(int)

where NUTS is a subtype of DynamicTrajectory. Maybe we can also unify StaticTrajectory and DynamicTrajectory via introducing a Static type and a MetropolisTS trajectory sampler (with the final point as an MH proposal), i.e.

struct Static{T<:Integer} <: AbstractTerminationCriterion
    n_leapfrog::T
end

struct MetropolisTS <: AbstractTrajectorySampler end

# dynamic HMC with Multinomial sampling and generalised No-U-Turn. 
nuts = Trajectory{MultinomialTS,GeneralisedNoUTurn}(int)

# static HMC with a Multinomial sampling
hmc_Multinomial = Trajectory{MultinomialTS,Static}(int)

# standard HMC with an MH correction step
hmc= Trajectory{MetropolisTS,Static}(int)

We can also use integration time instead of a number of leapfrog steps in the Static type. This allows us to use Trajectory to construct all common HMC samplers including HMC, HMCDA and NUTS.

@yebai yebai pinned this issue Sep 20, 2019
@xukai92
Copy link
Member

xukai92 commented Oct 11, 2019

I will do #102 first and see how to unify them later.

@xukai92
Copy link
Member

xukai92 commented Nov 12, 2019

After working on the spiral idea for a bit I realise that what we really need to do is treat the transition kernel as a seperate type.

sturct Kernel{T<:AbstractTrajectory,S<:AbstractTrajectorySampler,F<:AbstractRefreshment}
t::T
s::S
f::F
end

The current NUTS{MultinomialTS,GeneralisedNoUTurn} should be Kernel(NUTS{GeneralisedNoUTurn}, MultinomialTS()) where f by default is set to be the completely refreshment.

By explicitly dispatch over transition() over Kernel, we can also the compelte control of a complete transition.

PS: We can also provide a composite kernel somehow. This is useful to combine a multinomial step + a MH step. Or maybe it's overcomplicated and we could introduce a specific type for this.

@xukai92 xukai92 modified the milestone: aabi2020 Dec 2, 2019
@xukai92 xukai92 unpinned this issue Feb 15, 2020
@xukai92 xukai92 added this to the Release v0.3 milestone Feb 15, 2020
@xukai92 xukai92 added this to To do in Abstraction refactoring via automation Feb 15, 2020
@xukai92 xukai92 moved this from To do to In progress in Abstraction refactoring Aug 2, 2020
This was referenced Aug 2, 2020
@yebai
Copy link
Member Author

yebai commented Feb 15, 2021

Closed by #245

@yebai yebai closed this as completed Feb 15, 2021
Abstraction refactoring automation moved this from In progress to Done Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants