-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: Ensure TensorFlow backend Poisson compatibility with other backends #1001
Conversation
It appears that in TensorFlow Probability Lines 201 to 206 in 8a2f7f6
as import pyhf
backends = ["numpy", "pytorch", "tensorflow", "jax"]
for backend in backends:
pyhf.set_backend(backend, precision="64b")
tb = pyhf.tensorlib
poisson_results = tb.tolist(
tb.poisson(tb.astensor([0, 0, 1, 1]), tb.astensor([0, 1, 0, 1]))
)
print(f"{backend} backend gives: {poisson_results}") gives
So it seems that before this PR can be resolved that Issue #293 will need to get addressed again. |
This is going to be on hold for quite sometime as TensorFlow This will mean that we will need to require 'tensorflow': [
'tensorflow~=2.3.1', # TensorFlow minor releases are as volatile as major
'tensorflow-probability~=0.11.0',
], and by that time there might be a patch release of TFP out that we might want as well. |
60406cf
to
594fc22
Compare
The pinning of |
dd0bea4
to
86fb51d
Compare
86fb51d
to
3c07ce8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1001 +/- ##
=======================================
Coverage 97.70% 97.70%
=======================================
Files 63 63
Lines 4047 4050 +3
Branches 576 576
=======================================
+ Hits 3954 3957 +3
Misses 54 54
Partials 39 39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -2,6 +2,7 @@ | |||
import logging | |||
import tensorflow as tf | |||
import tensorflow_probability as tfp | |||
from numpy import nan |
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.
I don't know of any nan
equivalent in TensorFlow, as they use np.nan
in their test suites.
24ad4d9
to
f7b2c1a
Compare
* Add official support for Python 3.9 and add Python 3.9 to CI - Required PR #1001 to get Python 3.9 support of TensorFlow and TensorFlow Probability * Add Python 3.9 support to PyPI metadata * Update GitHub Actions workflows to use Python 3.9 - .github/workflows/release_tests.yml will be updated after pyhf v0.6.3 is released * Update Dockerfile to use python:3.9-slim-bullseye as base image
* Effectively reverts most of PR #1001 and PR #280, reapplies most of PR #277 * Use scipy.special.xlogy in Poisson computation for numpy backend and use jax.scipy.special.xlogy for jax backend * Set minimum required PyTorch to v1.10 for API stability - c.f. pytorch/pytorch#61511 in torch v1.10.0 * Set minimum required TensorFlow to v2.3.1 and TensorFlow Probability to v0.11.0 - tfp v0.11.0 supports zero rate Poisson and requires tensorflow>=2.3.0 * Add note to docs that limit Poisson(n = 0 | lambda -> 0) = 1 is being used * Update tests to use limit Poisson(n = 0 | lambda -> 0) = 1 result * Run doctest on only the latest Python release Co-authored-by: Ruggero Turra <giurrero@gmail.com>
Description
Resolves #997
As TensorFlow Probabilityv0.11.0+
is needed for PR #817, and as Issue #997 makes it clear that TF/TFP minor releases can be as breaking as normal major releases, require TensorFlowv2.3.0+
in thev2.3.X
range and TensorFlow Probabilityv0.11.0+
in thev0.11.X
range.Ensure compatibility of TensorFlow Poisson's behavior with PyTorch and JAX while Issue #293 is being resolved by using the differentiable TensorFlow operations
tf.logical_or
andtf.where
to allow for checking if the situation in whichPoisson(n=0 | lam=0)
is being encountered. This provides a working solution for both the TFv2.2.X
and TFPV0.10.X
API behavior as well as for the TFv2.3.+
and TFPv0.11.0+
API behavior. Also disallow TFv2.3.0
given tensorflow/tensorflow#40789.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: