-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Better parameter learning and inductive types #191
Merged
Merged
Conversation
This file contains 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
# for free
to join this conversation on GitHub.
Already have an account?
# 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.
TL;DR
We add support for learning arbitrary objectives in terms of probabilistic queries. To find the value of θ that maximizes
pr(flip(θ) & flip(θ) & !flip(θ))
:Macros make it easy to work with probabilistic inductive types:
To ensure we always have up-to-date documentation, tours of the core of Dice.jl and parameter learning have been added to tests. I recommend first looking at these to get a better sense of the interface.
Better parameter learning
We update autodiff to represent the log probabilities of
Dist{Bools}
s symbolically, to train arbitrary loss functions instead of just doing MLE. In fact, we support "arbitrary interleavings" - computation dependent on log probabilities can be used as flip parameters, to create more symbolic log probabilities, etc.The core construct we add to is the struct
LogPr(::Dist{Bool}) <: ADNode
.LogPr
, usecompute_mixed
rather thancompute
.Dist
containing a flip whose probability is dependent on aLogPr
, usepr_mixed
rather thanpr
.train!(::Valuation, loss::ADNode; epochs, learning_rate)
updates a valuation (dict fromVar
s to values) to minimize loss by GDExamples and tests are given in test/autodiff_pr.
Other improvements
We add the functions
sample_as_dist
andfrombits_as_dist
, which work the same as their non-_as_dist
counterparts, except they return deterministicDists
instead of Julia primitives (e.g.DistUInt32(3)
instead of3
), allowing us to feed the results back into programs (e.g. passing them toprob_equals
to check the probability of a particular sample/grounding).Future work
Ideally, parameter learning integrates with a dedicated AD library like Zygote.jl. However, it requires care to make sure it plays well with CUDD, and we already have our tiny autodiff framework, so this PR does not make things much more complex.