Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fixes #17304 Flaky Test -> test_higher_order_grad.test_tanh (#17321)
Browse files Browse the repository at this point in the history
* use failed seed and verify first order

* replace grad_op with equivalent expression

* remove fixed seed for tanh

* add relax tolerance for tanh first order
  • Loading branch information
kshitij12345 authored and haojin2 committed Jan 15, 2020
1 parent e58623c commit be9e17e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/python/unittest/test_higher_order_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ def tanh(x):
return nd.tanh(x)

def grad_op(x):
return 1 / nd.cosh(x)**2
return 1 - tanh(x)**2

def grad_grad_op(x):
return -2 * tanh(x) * grad_op(x)

for dim in range(1, 5):
shape = rand_shape_nd(dim)
array = random_arrays(shape)
check_nth_order_unary(array, tanh, grad_op, 1, rtol=1e-6, atol=1e-6)
check_second_order_unary(
array, tanh, grad_grad_op, rtol=1e-6, atol=1e-6)

Expand Down

0 comments on commit be9e17e

Please sign in to comment.