From 3ee87653b451f805e2f153d8a872846fc0b42f63 Mon Sep 17 00:00:00 2001 From: yangyaming Date: Fri, 15 Sep 2017 17:31:17 +0800 Subject: [PATCH] Tight the relative error. --- .../v2/framework/tests/test_smooth_l1_loss_op.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/paddle/v2/framework/tests/test_smooth_l1_loss_op.py b/python/paddle/v2/framework/tests/test_smooth_l1_loss_op.py index 3ab7c6bb2..1b79f16ab 100644 --- a/python/paddle/v2/framework/tests/test_smooth_l1_loss_op.py +++ b/python/paddle/v2/framework/tests/test_smooth_l1_loss_op.py @@ -14,7 +14,7 @@ def smooth_l1_loss_forward(val, sigma2): class TestSmoothL1LossOp1(OpTest): def setUp(self): self.op_type = "smooth_l1_loss" - dims = (10, 15) + dims = (6, 10) self.inputs = { 'X': np.random.random(dims).astype("float32"), 'Y': np.random.random(dims).astype("float32") @@ -31,21 +31,21 @@ class TestSmoothL1LossOp1(OpTest): self.check_output() def test_check_grad_normal(self): - self.check_grad(['X', 'Y'], 'Out', max_relative_error=0.08) + self.check_grad(['X', 'Y'], 'Out', max_relative_error=0.02) def test_check_grad_ingore_x(self): self.check_grad( - ['Y'], 'Out', max_relative_error=0.08, no_grad_set=set("X")) + ['Y'], 'Out', max_relative_error=0.02, no_grad_set=set("X")) def test_check_grad_ingore_y(self): self.check_grad( - ['X'], 'Out', max_relative_error=0.08, no_grad_set=set('Y')) + ['X'], 'Out', max_relative_error=0.02, no_grad_set=set('Y')) class TestSmoothL1LossOp2(OpTest): def setUp(self): self.op_type = "smooth_l1_loss" - dims = (10, 15) + dims = (6, 10) self.inputs = { 'X': np.random.random(dims).astype("float32"), 'Y': np.random.random(dims).astype("float32"), @@ -66,20 +66,20 @@ class TestSmoothL1LossOp2(OpTest): self.check_output() def test_check_grad_normal(self): - self.check_grad(['X', 'Y'], 'Out', max_relative_error=0.08) + self.check_grad(['X', 'Y'], 'Out', max_relative_error=0.02) def test_check_grad_ingore_x(self): self.check_grad( ['Y'], 'Out', - max_relative_error=0.08, + max_relative_error=0.02, no_grad_set=set(['X', 'InsideWeight', 'OutsideWeight'])) def test_check_grad_ingore_y(self): self.check_grad( ['X'], 'Out', - max_relative_error=0.08, + max_relative_error=0.02, no_grad_set=set(['Y', 'InsideWeight', 'OutsideWeight'])) -- GitLab