-
Notifications
You must be signed in to change notification settings - Fork 230
Preserve context in LogDensityFunction
#1943
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
Preserve context in LogDensityFunction
#1943
Conversation
Pull Request Test Coverage Report for Build 4740709796
💛 - Coveralls |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## master #1943 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 21 21
Lines 1422 1422
======================================
Misses 1422 1422
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
devmotion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I would just suggest adding a few additional tests to cover all changes. Feel free to merge afterwards.
| # Get the initial log pdf and gradient functions. | ||
| ∂logπ∂θ = gen_∂logπ∂θ(vi, spl, model) | ||
| logπ = Turing.LogDensityFunction(vi, model, spl, DynamicPPL.DefaultContext()) | ||
| logπ = Turing.LogDensityFunction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this is not tested (codecov complains)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests have been added 👍
| # Make a new transition. | ||
| densitymodel = AMH.DensityModel( | ||
| Base.Fix1(LogDensityProblems.logdensity, Turing.LogDensityFunction(vi, model, DynamicPPL.SamplingContext(rng, spl))) | ||
| Base.Fix1( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems MH sampler should be tested as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Though it seems to really struggle with here, even with the prior (despite sampling from the prior; am really confused about this..)
…gdensityfunction' into torfjelde/preserve-context-in-logdensityfunction
After TuringLang/DynamicPPL.jl#452 we can properly preserve the context related to the model.
For example, at the moment something like
won't work because
LogDensityFunctionis constructed withDefaultContext, which then replaces the leaf-context inmodelwhen we callevaluate!!.After this PR, stuff like the above works as intended.