From d0b0e2740886706f36e12a6825bb49ac7c1b8e80 Mon Sep 17 00:00:00 2001 From: huangjun12 <2399845970@qq.com> Date: Thu, 7 May 2020 10:20:51 +0800 Subject: [PATCH] refine huber loss unittest, test=develop (#24263) --- .../fluid/tests/unittests/test_huber_loss_op.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_huber_loss_op.py b/python/paddle/fluid/tests/unittests/test_huber_loss_op.py index 2c8626cfd93..cb97103e770 100644 --- a/python/paddle/fluid/tests/unittests/test_huber_loss_op.py +++ b/python/paddle/fluid/tests/unittests/test_huber_loss_op.py @@ -89,14 +89,17 @@ class TestHuberLossOpError(unittest.TestCase): xr = fluid.data(name='xr', shape=[None, 6], dtype="float32") lw = np.random.random((6, 6)).astype("float32") lr = fluid.data(name='lr', shape=[None, 6], dtype="float32") - self.assertRaises(TypeError, fluid.layers.huber_loss, xw, lr) - self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw) + delta = 1.0 + self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw, delta) + self.assertRaises(TypeError, fluid.layers.huber_loss, xw, lr, delta) # the dtype of input and label must be float32 or float64 xw2 = fluid.data(name='xw2', shape=[None, 6], dtype="int32") lw2 = fluid.data(name='lw2', shape=[None, 6], dtype="int32") - self.assertRaises(TypeError, fluid.layers.huber_loss, xw2, lr) - self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw2) + self.assertRaises(TypeError, fluid.layers.huber_loss, xw2, lr, + delta) + self.assertRaises(TypeError, fluid.layers.huber_loss, xr, lw2, + delta) if __name__ == '__main__': -- GitLab