Add logp_nojac and logp_sum#2499
Merged
junpenglao merged 2 commits intopymc-devs:masterfrom Aug 16, 2017
Merged
Conversation
Merged
Contributor
|
Or we could just merge this guy first, which would then make the test in (1) pass after I merge upstream again. |
Contributor
|
Diff lgtm but I'm not up to speed enough for an actual review.
…On Aug 12, 2017 1:46 PM, "Adrian Seyboldt" ***@***.***> wrote:
This is WIP for fixing #2482
<#2482>.
It adds Distribution.logp_nojac, which returns the logp, but doesn't
include the jacobian terms for transformed distributions. find_MAP now
also uses this instead of the normal logp function.
It also adds Distribution.logp_sum, which isn't used at the moment, but
can be used to speed up some logp functions, for cases where we only need
the sum of the logp values and not the individual values (nuts!). I
experimented with that for Normal and MvNormal at it seems this can
provide a moderate speedup in some cases.
I think this should probably wait until #2468
<#2468> is merged, and then
rebased. @kyleabeauchamp <https://github.com/kyleabeauchamp> wrote some
tests for this, but they require #2468
<#2468>, which we can also add
after that is merged.
------------------------------
You can view, comment on, or merge this pull request online at:
#2499
Commit Summary
- Add logp_nojac and logp_sum
File Changes
- *M* pymc3/distributions/distribution.py
<https://github.com/pymc-devs/pymc3/pull/2499/files#diff-0> (22)
- *M* pymc3/distributions/transforms.py
<https://github.com/pymc-devs/pymc3/pull/2499/files#diff-1> (3)
- *M* pymc3/model.py
<https://github.com/pymc-devs/pymc3/pull/2499/files#diff-2> (66)
- *M* pymc3/tuning/starting.py
<https://github.com/pymc-devs/pymc3/pull/2499/files#diff-3> (10)
Patch Links:
- https://github.com/pymc-devs/pymc3/pull/2499.patch
- https://github.com/pymc-devs/pymc3/pull/2499.diff
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2499>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABz_q1tpqKn3isr4pVCDYoHnVH_oRDmhks5sXg8wgaJpZM4O1g8K>
.
|
ferrine
reviewed
Aug 13, 2017
pymc3/model.py
Outdated
| logp_factors = tt.sum(factors) | ||
| logp_potentials = tt.sum([tt.sum(pot) for pot in self.potentials]) | ||
| logp = logp_factors + logp_potentials | ||
| logp.name = '__logp' |
Member
There was a problem hiding this comment.
Could you please prepend self.name to logp in this pr?
Contributor
|
FWIW, in a personal branch I've merged this with the other MLE updates and I can confirm that my new test is passing 👍 |
twiecki
reviewed
Aug 14, 2017
| self.logp_elemwiset = distribution.logp(self) | ||
| # The logp might need scaling in minibatches. | ||
| # This is done in `Factor`. | ||
| self.logp_sum_unscaledt = distribution.logp_sum(self) |
Member
Author
There was a problem hiding this comment.
The 't' stands for "tensor". I thought I'd use the same naming convention as in model.logpt vs model.logp.
Member
|
LGTM. |
Contributor
|
Is this good to merge or still WIP? |
Member
Author
|
I'd say this is ready |
Member
|
Cool stuff @aseyboldt, thanks! |
Merged
agustinaarroyuelo
pushed a commit
to agustinaarroyuelo/pymc3
that referenced
this pull request
Feb 8, 2019
* Fix 2948 Reverse the logpt tensor computation back to pre pymc-devs#2499. close pymc-devs#2948 * fix mistake * add test interestingly, we can pick up the error using `func = ValueGradFunction(m.logpt, m.basic_RVs)` but not `func = ValueGradFunction(m.logpt, m.basic_RVs, mode='FAST_COMPILE')` * fix test for float32
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
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 is WIP for fixing #2482.
It adds
Distribution.logp_nojac, which returns the logp, but doesn't include the jacobian terms for transformed distributions.find_MAPnow also uses this instead of the normallogpfunction.It also adds
Distribution.logp_sum, which isn't used at the moment, but can be used to speed up some logp functions, for cases where we only need the sum of the logp values and not the individual values (nuts!). I experimented with that forNormalandMvNormalat it seems this can provide a moderate speedup in some cases.I think this should probably wait until #2468 is merged, and then rebased. @kyleabeauchamp wrote some tests for this, but they require #2468, which we can also add after that is merged.