-
Notifications
You must be signed in to change notification settings - Fork 230
Early API functions and the interface guide. #920
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
Author
|
Alright, I've fixed the bugs on this one. We're ready for a review. |
…ster, switch to storing only NamedTuples without VarNames.
xukai92
reviewed
Oct 27, 2019
xukai92
reviewed
Oct 27, 2019
Member
Author
|
Looks like the tests are good. Does anyone have any further comments on this? |
yebai
approved these changes
Nov 22, 2019
Member
|
Ready to merge from my side after the merge conflict is fixed. |
Member
Author
|
I'm going to close this for now and split the guide into parts. I will add the guide on just the interface methods in another PR, #1007. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes
SamplerconstructorVarNameinstead of a string inTransitionstructs (for later access)observestatement for all samplers which just usesSampleFromPrior()assumestatement which just returns the current value and it's densityThere are some things in here I think we should discuss before merging, because I've made a couple design choices that I hope might enable more people to work with immutable
Transitionstructs instead of relying so heavily on mutable states. The guide is an attempt to showcase partial immutable sampling to mirror the non-Turing implementation, and the functions I added in to Turing's code base might make this a little easier.New functions
Here are the new tools I've added in for developers. I'd like some feedback on these specifically to see how we feel about them.
Transitionconstructor, which has the signatureTransition(model::Model, spl::Sampler, θ::T, nt::NamedTuple=NamedTuple()). You can pass in the model and the sampler, it'll run the model, grab the density, and bundle everything up for you into aTransition.parameters!is a function with the signatureparameters!(spl::Sampler, t::Transition), which accepts aTransitionand updates theVarInfoto contain the parameters in theTransition. It returns a vector of the parameters if you would prefer to work with vectors instead of aNamedTuple.parametersis a function which simply returns aNamedTupleof thevi.variables(spl::Sampler)is a function that returns a vector containing theVarNamesof a sampler, so you can retrieve or set information about them in aVarInfo. I would like this to be an iterator or something slightly quicker than what it is now, but I like the idea of giving developers quick access to some iterable ofVarName.Distributions.logpdf(model::Model, spl::T, θ::P)accepts a model, a sampler, and a vector, and returns the log density. It's a little clumsy but it should get us closer to models that people can just evaluate.There's some bugs in here I still have to fix, but this is the core of the PR.