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

add tanhshrink_py #1146

Merged
merged 3 commits into from
Feb 25, 2020
Merged

Conversation

fsx950223
Copy link
Member

Related #1114

Copy link
Member

@gabrieldemarmiesse gabrieldemarmiesse left a 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!

Comment on lines 27 to 46
# @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)

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

@gabrieldemarmiesse gabrieldemarmiesse left a comment

Choose a reason for hiding this comment

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

Thanks!

@gabrieldemarmiesse gabrieldemarmiesse merged commit 07febff into tensorflow:master Feb 25, 2020
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* add tanhshrink_py

* format code

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

Successfully merging this pull request may close these issues.

3 participants