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

Support multinomial sampling for NUTS, and more #79

Merged
merged 41 commits into from
Jul 10, 2019
Merged

Conversation

xukai92
Copy link
Member

@xukai92 xukai92 commented Jul 6, 2019

This PR resolves / will resolve:

src/trajectory.jl Outdated Show resolved Hide resolved
@xukai92
Copy link
Member Author

xukai92 commented Jul 6, 2019

@yebai Please take a look over the changes. So far I didn't change the transition interface (which means I don't touch the previous AbstractTrajectory stuff) yet. The only main change I did is introducing a tree struct called FullBinaryTree that contains a sampler::AbstractTreeSampler. With the FullBinaryTree I refactored the build_tree function with two tree sampling methods (slic and multinomial dispatched by the sampler.

@xukai92 xukai92 requested a review from yebai July 6, 2019 22:14
@xukai92
Copy link
Member Author

xukai92 commented Jul 6, 2019

Just check the code is still type stable.

@yebai
Copy link
Member

yebai commented Jul 8, 2019

Please take a look over the changes. So far I didn't change the transition interface (which means I don't touch the previous AbstractTrajectory stuff) yet. The only main change I did is introducing a tree struct called FullBinaryTree that contains a sampler::AbstractTreeSampler. With the FullBinaryTree I refactored the build_tree function with two tree sampling methods (slic and multinomial dispatched by the sampler.

Thanks, Kai. Below are some issues I found so far.

The current PR contains 2 types for trajectory sampling method (slice/multinomial):

  • TreeSampling
  • TreeSampler

These 2 types have very similar functionality IMO. Maybe we can consider unify them to slightly reduce clutter and improve readability. Also, the following field names can be unified since they both indicate a trajectory sampling method (i.e., slice/multinomial)

  • NUTS.sampling # maybe change this to sampler
  • FullBinaryTree.sampler

@xukai92
Copy link
Member Author

xukai92 commented Jul 8, 2019

The reason I have NUTS.sampling is I don't want to initalize any sampler (which has some parameters based on the actual methods) when constructing NUTS.

One solution is to change NUTS.sampling to NUTS.samplerType::Type{T} where {T<:TreeSampler}. How do you think?

@yebai
Copy link
Member

yebai commented Jul 8, 2019

One solution is to change NUTS.sampling to NUTS.samplerType::Type{T} where {T<:TreeSampler}. How do you think?

Yeah, that could work.

@xukai92
Copy link
Member Author

xukai92 commented Jul 10, 2019

@yebai

Breaking changes

  • ∂ℓπ∂θ is now assumed to retunr a (value, graident) tuple
  • ∂H∂θ now returns (logprob, -∂ℓπ∂θ) tuple

Almost 2x speed-up by using the cache.

src/integrator.jl Outdated Show resolved Hide resolved
@yebai
Copy link
Member

yebai commented Jul 10, 2019

@yebai Also did you see my comments starting with REVIEW in the code? Those are thing that needs double check for the algorithm correctness.

I checked - it looks correct!

@yebai
Copy link
Member

yebai commented Jul 10, 2019

We need to update the example in README (and probably Turing at some point) since ∂ℓπ∂θ needs to return both value and gradient now.

@xukai92
Copy link
Member Author

xukai92 commented Jul 10, 2019

Sure. I will update it.

@xukai92 xukai92 merged commit 8cfe715 into master Jul 10, 2019
@yebai yebai changed the title [WIP] Support multinomial sampling for NUTS, and more Support multinomial sampling for NUTS, and more Jul 10, 2019
@xukai92
Copy link
Member Author

xukai92 commented Jul 10, 2019

Just merged it. Thanks for the help! @yebai

I will finish the rest issues for v0.2 in another PR in the next few days. Those are mostly interface changes and RFC so I hope it won't take as long as this one.

@yebai yebai deleted the kx/multinomial branch July 10, 2019 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants