-
Notifications
You must be signed in to change notification settings - Fork 27
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
Pointpriors #663
base: master
Are you sure you want to change the base?
Pointpriors #663
Conversation
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.
Hey @bgctw !
Can you clarify why you want the .~
statements to be treated as a single log-prob in your case? You mention that your motivation is tempering; it's a but unclear to me why varwise_logpriors
are needed for this. And why is the Chain
needed in this case? When I think of tempering in our context, I'm imaging altering the likelihood / prior weightings during sampling, not as a post-inference step.
Maybe even write a short bit of psuedo-code outlining what you want to do with this could help!
From your initial motivation in #662, I feel like we can probably find alternative approaches that might be a bit simpler:)
src/context_implementations.jl
Outdated
r, lp, vi = dot_assume_vec(dist, var, vns, vi) | ||
return r, sum(lp), vi | ||
end | ||
function dot_assume_vec( |
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.
Is this actually needed for what you're trying to achieve here or was this "a step along the way"?
Arguably it seems like a nice improvement to the current code-base regardless:)
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.
Yes, this was only needed for the initial pointwise resolving the prior components. With the last commit, I reverted to a simpler coarser resolution. I will revert this.
My goal is to modify the log-density during sampling. I imagine putting something similar to Hence, I want to query the log-densities of the prior components as seen by a sampler that generated the samples in a The single number provided by The pointwise resolution, i.e. resolving also the components of the log-density components of |
Pull Request Test Coverage Report for Build 10918143575Details
💛 - Coveralls |
use loop for prior in example Unfortunately cannot make it a jldoctest, because relies on Turing for sampling
Ah, gotcha; this was the aspect I was missing 👍
Makes sense 👍 Taking this into account, I'm wondering if maybe it would be better to just generalize the existing DynamicPPL.jl/src/loglikelihoods.jl Lines 2 to 5 in 24a7380
We can just add a "switch" to it (or maybe just inspect the leaf context) to determine what logprobs we should keep around. AFAIK this should just require implementing the following:
Then we can just add alternatives to the following user-facing method DynamicPPL.jl/src/loglikelihoods.jl Lines 230 to 257 in 24a7380
e.g. So all in all, basically what you've already done, but just as part of the Thoughts? |
Trying to unify those two is a good idea. In fact, I originally started exploring/modifying based on However, I did not come far with this. |
I will attempt the implementation that you suggested, assuming that components of the prior are not resolved to the same detail as the components of the likelihood. |
I pushed a new commit that integrates The hardest part was to create a single Another issue, is that now I could not yet recreate julia-repl block in the documentation of the function, because current Turing, which is required for sampling in the docstring, is not compatible with current DynamicPPL. |
Lovely @bgctw ! I'll a proper have a look at it a bit later today:) |
In order for the user to select relevant information and for saving processing time, it could be helpful to have two keyword arguments with defaults: Would these be reasonable? |
Tackles #662: Querying the log-density of components of the prior.
The implementation does not decompose the log-density of dot-tilde expressions, because a possible solution (first commit, but removed in 3rd commit again) would need to decompose
dot_assume
, which is not under context control. However, I do need to pass computation to child-contexts, because I want to inspect log-density transformation by child-contexts. Therefore, I called itvarwise_logpriors
rather thanpointwise_logpriors
.In addition, I decided for a different handling of a Chains of samples compared to
pointwise_likelihoods
, because I did not fully comprehend its differentpush!!
methods and different initializers for the collecting OrderedDict and what applies at which conditions. Rather, I tried separating concerns of querying densities for a single sample and applying it to a Chains object. I hope that the mutation of a pre-accocated array is ok here.