-
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 tensorlib precision used throughout TensorFlow backend #1399
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1399 +/- ##
=======================================
Coverage 97.53% 97.53%
=======================================
Files 63 63
Lines 3808 3817 +9
Branches 538 538
=======================================
+ Hits 3714 3723 +9
Misses 55 55
Partials 39 39
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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 think we should be adding so many self.astensor
calls, should we?
What do you propose instead? We had to do something similar in PR #1351, and at the moment on >>> import pyhf
>>> pyhf.set_backend("tensorflow", precision="64b")
>>> pyhf.tensorlib.precision
'64b'
>>> pyhf.tensorlib.normal_logpdf(0.5, 0., 1.)
<tf.Tensor: shape=(), dtype=float32, numpy=-1.0439385>
>>> pyhf.tensorlib.normal(0.5, 0., 1.)
<tf.Tensor: shape=(), dtype=float32, numpy=0.35206532> |
We also made Issue #1352 based off of these comments on PR #1351. |
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.
Yeah, this is the cleanest way forward for now. We need to check that the fit times for tflow don't change.
Yeah, from looking at the CI times there isn't any obvious uptick, but we should note this in the Issue as well. |
Description
While investigating Issue #1398, it was noticed that for
64b
precision for the TensorFlow backed the precision was not properly being used throughout.tf.float32
was used as a default instead of the result ofself.dtypemap["float"]
and if TensorFlow Probability is given floats as parameters it will default to using32b
precision, and so requires that a tensor of the desired precision be given.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: