-
Notifications
You must be signed in to change notification settings - Fork 613
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
add tanhshrink_py #1146
add tanhshrink_py #1146
Conversation
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.
Thank you for the pull request!
# @parameterized.named_parameters( | ||
# ("float16", np.float16), ("float32", np.float32), ("float64", np.float64) | ||
# ) | ||
# def test_tanhshrink(self, dtype): | ||
# x = tf.constant([-2.0, -1.0, 0.0, 1.0, 2.0], dtype=dtype) | ||
# expected_result = tf.constant( | ||
# [-1.0359724, -0.23840582, 0.0, 0.23840582, 1.0359724], dtype=dtype | ||
# ) | ||
|
||
# self.assertAllCloseAccordingToType(tanhshrink(x), expected_result) | ||
|
||
# @parameterized.named_parameters(("float32", np.float32), ("float64", np.float64)) | ||
# def test_theoretical_gradients(self, dtype): | ||
# # Only test theoretical gradients for float32 and float64 | ||
# # because of the instability of float16 while computing jacobian | ||
# x = tf.constant([-2.0, -1.0, 0.0, 1.0, 2.0], dtype=dtype) | ||
|
||
# theoretical, numerical = tf.test.compute_gradient(tanhshrink, [x]) | ||
# self.assertAllCloseAccordingToType(theoretical, numerical, atol=1e-4) | ||
|
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.
Maybe we could actually remove all that? The check with random tensors is much more robust. What do you think?
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.
Good idea. I remove them later.
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.
Thanks!
* add tanhshrink_py * format code * remove useless test cases
Related #1114