未验证 提交 fcfb0afe 编写于 作者: G Guoxia Wang 提交者: GitHub

fix unittest (#35808)

上级 0eaab803
...@@ -5061,7 +5061,7 @@ def l2_normalize(x, axis, epsilon=1e-12, name=None): ...@@ -5061,7 +5061,7 @@ def l2_normalize(x, axis, epsilon=1e-12, name=None):
X = paddle.randn(shape=[3, 5], dtype='float64') X = paddle.randn(shape=[3, 5], dtype='float64')
out = paddle.fluid.layers.l2_normalize(X, axis=-1) out = paddle.fluid.layers.l2_normalize(X, axis=-1)
print(out.numpy()) print(out)
# [[ 0.21558504 0.56360189 0.47466096 0.46269539 -0.44326736] # [[ 0.21558504 0.56360189 0.47466096 0.46269539 -0.44326736]
# [-0.70602414 -0.52745777 0.37771788 -0.2804768 -0.04449922] # [-0.70602414 -0.52745777 0.37771788 -0.2804768 -0.04449922]
......
...@@ -41,10 +41,10 @@ class TestNormOp(OpTest): ...@@ -41,10 +41,10 @@ class TestNormOp(OpTest):
self.outputs = {'Out': y, 'Norm': norm} self.outputs = {'Out': y, 'Norm': norm}
def test_check_output(self): def test_check_output(self):
self.check_output(atol=1e-5) self.check_output()
def test_check_grad(self): def test_check_grad(self):
self.check_grad(['X'], 'Out', max_relative_error=0.008) self.check_grad(['X'], 'Out')
def init_test_case(self): def init_test_case(self):
self.shape = [2, 3, 4, 5] self.shape = [2, 3, 4, 5]
...@@ -97,6 +97,9 @@ class TestNormOp6(TestNormOp): ...@@ -97,6 +97,9 @@ class TestNormOp6(TestNormOp):
def init_dtype(self): def init_dtype(self):
self.dtype = "float32" self.dtype = "float32"
def test_check_grad(self):
self.check_grad(['X'], 'Out', max_relative_error=0.008)
@unittest.skipIf(not fluid.core.is_compiled_with_cuda(), @unittest.skipIf(not fluid.core.is_compiled_with_cuda(),
"core is not compiled with CUDA") "core is not compiled with CUDA")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册