From 15627e48d8bcec72f16d51b5e654f28f8400d5fe Mon Sep 17 00:00:00 2001 From: qijun Date: Fri, 8 Sep 2017 07:44:46 +0000 Subject: [PATCH] fix gou test bug --- python/paddle/v2/framework/tests/op_test.py | 4 ++-- python/paddle/v2/framework/tests/test_cross_entropy_op.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/paddle/v2/framework/tests/op_test.py b/python/paddle/v2/framework/tests/op_test.py index 09ee8ce385..3a6a5dca4c 100644 --- a/python/paddle/v2/framework/tests/op_test.py +++ b/python/paddle/v2/framework/tests/op_test.py @@ -197,7 +197,7 @@ class OpTest(unittest.TestCase): def check_output(self): places = [core.CPUPlace()] - if core.is_compile_gpu() and self.op.support_gpu(): + if core.is_compile_gpu(): places.append(core.GPUPlace(0)) for place in places: self.check_output_with_place(place) @@ -270,6 +270,6 @@ class OpTest(unittest.TestCase): for c_grad, g_grad, name in itertools.izip( cpu_analytic_grads, gpu_analytic_grads, grad_names): self.assertTrue( - numpy.allclose( + np.allclose( c_grad, g_grad, atol=1e-4), "output name: " + name + " has diff") diff --git a/python/paddle/v2/framework/tests/test_cross_entropy_op.py b/python/paddle/v2/framework/tests/test_cross_entropy_op.py index 1956df0bb4..e693ba0ec2 100644 --- a/python/paddle/v2/framework/tests/test_cross_entropy_op.py +++ b/python/paddle/v2/framework/tests/test_cross_entropy_op.py @@ -8,7 +8,7 @@ class TestCrossEntropy(OpTest): self.op_type = "onehot_cross_entropy" batch_size = 30 class_num = 10 - X = numpy.random.random((batch_size, class_num)).astype("float32") + X = numpy.random.uniform(0.1, 1.0, [batch_size, class_num]).astype("float32") label = (class_num / 2) * numpy.ones(batch_size).astype("int32") self.inputs = {'X': X, 'label': label} Y = [] -- GitLab