Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tensorflow_addons/activations/gelu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ def verify_funcs_are_equivalent(self, dtype):
t.watch(x)
y_native = gelu(x, approximate=approximate)
y_py = _gelu_py(x, approximate=approximate)
self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)
grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)
self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
# TODO: lower atol to 1e-6
# currently it doesn't work.
# It necessitates changing the Python or C++ implementation.
self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-5)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_addons/activations/hardshrink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def verify_funcs_are_equivalent(self, dtype):
y_native = hardshrink(x, lower, upper)
y_py = _hardshrink_py(x, lower, upper)

self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)

grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)

self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
self.assertAllCloseAccordingToType(grad_native, grad_py)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_addons/activations/lisht_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def verify_funcs_are_equivalent(self, dtype):
y_native = lisht(x)
y_py = _lisht_py(x)

self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)

grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)

self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
self.assertAllCloseAccordingToType(grad_native, grad_py)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_addons/activations/mish_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def verify_funcs_are_equivalent(self, dtype):
y_native = mish(x)
y_py = _mish_py(x)

self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)

grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)

self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
self.assertAllCloseAccordingToType(grad_native, grad_py)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_addons/activations/softshrink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def verify_funcs_are_equivalent(self, dtype):
y_native = softshrink(x, lower, upper)
y_py = _softshrink_py(x, lower, upper)

self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)

grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)

self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
self.assertAllCloseAccordingToType(grad_native, grad_py)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_addons/activations/tanhshrink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def verify_funcs_are_equivalent(self, dtype):
t.watch(x)
y_native = tanhshrink(x)
y_py = _tanhshrink_py(x)
self.assertAllCloseAccordingToType(y_native, y_py, atol=1e-4)
self.assertAllCloseAccordingToType(y_native, y_py)
grad_native = t.gradient(y_native, x)
grad_py = t.gradient(y_py, x)
self.assertAllCloseAccordingToType(grad_native, grad_py, atol=1e-4)
self.assertAllCloseAccordingToType(grad_native, grad_py)


if __name__ == "__main__":
Expand Down