未验证 提交 f459dd96 编写于 作者: Z Zhong Hui 提交者: GitHub

fix abs double grad unittest (#29478)

fix abs double grad unittest & define the data range for the abs double grad
上级 576d0d93
......@@ -161,6 +161,10 @@ class TestAbsDoubleGradCheck(unittest.TestCase):
x.persistable = True
y = layers.abs(x)
x_arr = np.random.uniform(-1, 1, shape).astype(dtype)
# Because we set delta = 0.005 in calculating numeric gradient,
# if x is too small, the numeric gradient is inaccurate.
# we should avoid this
x_arr[np.abs(x_arr) < 0.005] = 0.02
gradient_checker.double_grad_check(
[x], y, x_init=x_arr, place=place, eps=eps)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册