Skip to content
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

Implements inverse hyperbolic operations (fix for #7531) #10598

Merged
merged 5 commits into from Jun 29, 2017
Merged

Implements inverse hyperbolic operations (fix for #7531) #10598

merged 5 commits into from Jun 29, 2017

Conversation

lakshayg
Copy link
Contributor

@lakshayg lakshayg commented Jun 9, 2017

fixes #7531.

@tensorflow-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@lakshayg lakshayg changed the title Implemented asinh and acosh operations (#7531) Implements asinh and acosh operations (Partially fixes #7531) Jun 9, 2017
@caisq
Copy link
Contributor

caisq commented Jun 11, 2017

@tensorflow-jenkins test this please

@lakshayg
Copy link
Contributor Author

lakshayg commented Jun 12, 2017

I ran the tests which failed here on my machine and found that the only cases which were failing are the ones in which tf.acosh evaluates to inf/-inf and np.arccosh evaluates to nan/-nan. Should I change the test cases or do something else? Any ideas on how to proceed? I have changed the test cases and also fixed a bug in test functions for asinh and acosh. The failed tests are passing now.

@martinwicke martinwicke changed the title Implements asinh and acosh operations (Partially fixes #7531) Implements asinh and acosh operations (partial fix for #7531) Jun 13, 2017
@rmlarsen rmlarsen added awaiting testing (then merge) and removed awaiting review Pull request awaiting review labels Jun 14, 2017
@rmlarsen
Copy link
Member

@tensorflow-jenkins test this please

@lakshayg
Copy link
Contributor Author

The failures in tests/build seem unrelated to the changes made by this pull request.

@martinwicke
Copy link
Member

Jenkins, test this please.

@martinwicke
Copy link
Member

The cwise ops test failure (only on Windows, ugh) is probably caused by this CL -- the tolerances appear to be too tight.

@lakshayg
Copy link
Contributor Author

Any hints on how to proceed?

@martinwicke martinwicke added the API review API Review label Jun 14, 2017
@martinwicke
Copy link
Member

I would look at which test fails, exactly, and adjust the tolerance for that test in the test code. I think the values are still close so this is not a real problem, just numerics and a particularly unfriendly function.

@lakshayg
Copy link
Contributor Author

lakshayg commented Jun 14, 2017

If that is the case then this PR would have to wait for a few days since I do not have access to my machine and would be able to fix it only after the 16th. BTW since I do not have a windows machine, how can I identify the function which is failing?

@martinwicke
Copy link
Member

No problem.

@martinwicke martinwicke added the stat:awaiting response Status - Awaiting response from author label Jun 14, 2017
@lakshayg lakshayg mentioned this pull request Jun 14, 2017
@martinwicke
Copy link
Member

This test failure is not due to this PR. We'll review API changes on Monday, should be able to merge then.

@lakshayg
Copy link
Contributor Author

Great, thanks!

@lakshayg
Copy link
Contributor Author

Since the tests for acosh and asinh were passing, I have also added a commit which implements atanh thus completely resolving #7531. Please review.

@lakshayg lakshayg changed the title Implements asinh and acosh operations (partial fix for #7531) Implements inverse hyperbolic operations (fix for #7531) Jun 17, 2017
@rmlarsen
Copy link
Member

@lakshayg that should give 1/0 = inf. I'm not sure why it produces NaN instead of inf, but that is unrelated to your change.

@lakshayg
Copy link
Contributor Author

@rmlarsen I just compiled the binary and checked what it gave for x=1 and the answer is inf. I guess that everything is working fine and this PR can be merged.

screenshot from 2017-06-21 08-49-33

@rmlarsen
Copy link
Member

@martinwicke This is ready to be merged. You added the API review tag. What needs to be done?

@rmlarsen
Copy link
Member

@lakshayg could you please rebase to resolve conflicts?

@rmlarsen
Copy link
Member

rmlarsen commented Jun 23, 2017

@martinwicke I missed your earlier comment about API review last monday. I'll assign you on this PR and you can merge when it's approved.

@lakshayg
Copy link
Contributor Author

@rmlarsen rebase done!

@rmlarsen rmlarsen removed the stat:awaiting response Status - Awaiting response from author label Jun 23, 2017
@rmlarsen
Copy link
Member

@lakshayg Thanks!
@tensorflow-jenkins test this please

@jhseu
Copy link
Contributor

jhseu commented Jun 24, 2017

How about renaming to arcsinh, arccosh, arctanh to match the numpy names?

@lakshayg
Copy link
Contributor Author

@jhseu I guess then we would have to rename asin, acos and atan as well.

@jhseu
Copy link
Contributor

jhseu commented Jun 24, 2017

Yes, but perhaps wait for API review for the final word.

@rmlarsen
Copy link
Member

@jhseu We already have atan, atan2, asin etc. so it doesn't make sense unless we change the existing interface.

@drpngx
Copy link
Contributor

drpngx commented Jun 26, 2017

@jhseu or @martinwicke : to confirm, good to go?

@martinwicke
Copy link
Member

Good for API review, but watch out, this will require Eigen changes to pull in.

@martinwicke martinwicke removed the API review API Review label Jun 26, 2017
@drpngx drpngx merged commit cf18c6d into tensorflow:master Jun 29, 2017
@gunan
Copy link
Contributor

gunan commented Jun 30, 2017

I see failures in windows CPU and GPU build due to additions from this change:
http://ci.tensorflow.org/job/tensorflow-master-win-cmake-py/1101/console

cwise_ops_test.py", line 411, in testComplex64Basic
cwise_ops_test.py", line 302, in testDoubleBasic
cwise_ops_test.py", line 208, in testFloatBasic

Looks like there is some flakiness in arccosh implementation on windows?

@drpngx
Copy link
Contributor

drpngx commented Jun 30, 2017

@rmlarsen is out next week.

It was green when I merged. Looking at the code, there doesn't seem to be anything obviously special about cosh.

@lakshayg could you take a look?

REGISTER_SYCL_KERNEL(float);
REGISTER_SYCL_KERNEL(double);
#undef REGISTER_SYCL_KERNEL
#endif // TENSORFLOW_USE_SYC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix this typo in another PR.

Copy link
Contributor Author

@lakshayg lakshayg Jul 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent in a PR for the typo SYC -> SYCL #11204 fixed!

@lakshayg
Copy link
Contributor Author

lakshayg commented Jul 1, 2017

It was suggested earlier #10598 (comment) that I change the tolerances for those but since the tests passed on the next build, I did not change the tolerances. Should I go ahead and change them? @gunan @drpngx @martinwicke

@drpngx
Copy link
Contributor

drpngx commented Jul 1, 2017

It's not just the tolerance, check this out:

21:10:19 <class 'numpy.ndarray'> <class 'numpy.ndarray'> <class 'tensorflow.python.ops.variables.Variable'> <class 'tensorflow.python.ops.variables.Variable'>
21:10:19 <class 'tensorflow.python.framework.ops.Tensor'> <class 'tensorflow.python.framework.ops.Tensor'>
21:10:19 not close where =  (array([7, 7], dtype=int64), array([6, 7], dtype=int64))
21:10:19 not close lhs =  [ 1.  0.]
21:10:19 not close rhs =  [    0.          1570.79632679]
21:10:19 not close dif =  [  1.00000000e+00   1.57079633e+03]
21:10:19 not close tol =  [  1.00000000e-05   1.57179633e-02]

template<typename T> struct scalar_acosh_op {
EIGEN_EMPTY_STRUCT_CTOR(scalar_acosh_op)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a) const {
return std::acosh(a);
Copy link
Contributor Author

@lakshayg lakshayg Jul 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's surprising that everything works fine on Linux and fails on Windows. It is extremely unlikely but could it have something to do with the standard library implementation of acosh, since that is what is used in the background for computation.

allenlavoie pushed a commit to allenlavoie/tensorflow that referenced this pull request Jul 15, 2017
…ensorflow#10598)

* Implemented asinh op

* Implemented acosh op

* Fixed test functions for acosh and asinh

* Implemented atanh op

* Fixed test cases for atanh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hyperbolic functions
9 participants