diff --git a/python/paddle/v2/framework/tests/op_test.py b/python/paddle/v2/framework/tests/op_test.py index 09ee8ce385a3bb389272dbc2d673a5749959a0ba..3a6a5dca4c4ddc1399d80e491e4072f24707c01e 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 1956df0bb4edae62d40371264bc77486c48924a3..e693ba0ec280b8720630af29556fd645aae76e9b 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 = []