From be9e17e02c3d213ab211aaee28197c2a23f7534d Mon Sep 17 00:00:00 2001 From: kshitij12345 Date: Thu, 16 Jan 2020 03:44:36 +0530 Subject: [PATCH] Fixes #17304 Flaky Test -> test_higher_order_grad.test_tanh (#17321) * 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 --- tests/python/unittest/test_higher_order_grad.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/python/unittest/test_higher_order_grad.py b/tests/python/unittest/test_higher_order_grad.py index 4a906aa696a2..1f0cd0741977 100644 --- a/tests/python/unittest/test_higher_order_grad.py +++ b/tests/python/unittest/test_higher_order_grad.py @@ -121,7 +121,7 @@ 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) @@ -129,6 +129,7 @@ def grad_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)