-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Infer logcdf of discrete transformations #7444
Conversation
f042733
to
159da27
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7444 +/- ##
==========================================
- Coverage 92.17% 92.17% -0.01%
==========================================
Files 103 103
Lines 17260 17217 -43
==========================================
- Hits 15910 15869 -41
+ Misses 1350 1348 -2
|
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 as always @ricardoV94 :)
Just to clarify: when you say discrete transformations, do you mean monotonic transformations of discrete variables?
backward_value = op.transform_elemwise.backward(value, *other_inputs) | ||
|
||
# Fail if transformation is not injective | ||
# A TensorVariable is returned in 1-to-1 inversions, and a tuple in 1-to-many | ||
if isinstance(backward_value, tuple): | ||
raise NotImplementedError | ||
|
||
is_discrete = measurable_input.type.dtype.startswith("int") |
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.
Shall we use discrete_types
here?
Line 32 in 43dc4be
discrete_types = bool_types | int_types |
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.
No strong preference
return max_rv | ||
measurable_max_class = ( | ||
MeasurableMaxDiscrete if latent_base_var.type.dtype.startswith("int") else MeasurableMax | ||
) |
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.
idem comment as below
Yes. Right now only add and neg transforms are supported. We could add integer mul as well. Not keen to add support for integer->reals transforms just yet. Otherwise for continuous RVs we have a single case of non monotonicity we support (pow with negative exponent): pymc/pymc/logprob/transforms.py Line 260 in 43dc4be
|
159da27
to
e5899b4
Compare
Description
Allow logcdf inference for discrete transformations
With this we can also remove special case for MaxNeg (used to derive logprob of Min operations)
📚 Documentation preview 📚: https://pymc--7444.org.readthedocs.build/en/7444/