Adds a state property that mean and std are guaranteed to be on.#8319
Adds a state property that mean and std are guaranteed to be on.#8319zaxtax wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8319 +/- ##
=======================================
Coverage 91.76% 91.76%
=======================================
Files 128 128
Lines 20653 20667 +14
=======================================
+ Hits 18952 18966 +14
Misses 1701 1701
🚀 New features to boost your workflow:
|
50dbede to
a99823d
Compare
| constrained = transform.backward( | ||
| pt.as_tensor(unconstrained), *rv.owner.inputs | ||
| ).eval() |
There was a problem hiding this comment.
This is naive, the rv.owner.inputs may also be transformed rvs, we need to get this functionality properly... it exists already in a private repo...
There was a problem hiding this comment.
Ok I will use functionality from #8327 to fix this
e609de3 to
ab6ec8b
Compare
Uses the recently merged constrain_values utility from pymc.model.transform_values to map unconstrained parameters back to the original constrained space, replacing the custom _untransform_tensor helper.
ab6ec8b to
19dd42b
Compare
| """ADVI state has family='mean_field', mean and std in constrained space.""" | ||
| rng = np.random.default_rng(42) | ||
| with pm.Model(): | ||
| pm.HalfNormal("sigma", sigma=5.0) |
There was a problem hiding this comment.
What should this do with a Dirichlet?
There was a problem hiding this comment.
We would sample independently for each of the event dims. Is that not what
we did already? I maybe don't understand the question
There was a problem hiding this comment.
Yeah whenever we do some utility that constrains/unconstrains, it would be nice to test with a transform that changes the dimensionality. Also
|
What's the API to see the unconstrained ones (some people like to look at those instead) vs the constrained ones? |
Description
Right now, approximations do come with a mean/std fields when fitting. But these are often in the unconstrained posterior space and not the original, which makes it hard to reason about when tracking fit.
This change makes it such that there is a state accessor which returns a dataclass with mean and std fields. These are in the original space, and by introducing a new accessor doesn't break existing code that might use the current fields.
Checklist
Type of change