From 019147eb8b8af5fd49512b93e1d55dad44d1c5e2 Mon Sep 17 00:00:00 2001 From: zhupengyang Date: Thu, 12 Dec 2019 16:28:13 +0800 Subject: [PATCH] use large input shape for accuracy test, (#21693) sequence_unpad, expand, pad, pad_constant_like, norm, bilinear_tensor_product, flatten2, im2sequence, unpool, cos_sim, strided_slice, flatten, elementwise_min, abs, acos test=develop --- python/paddle/fluid/tests/unittests/test_activation_op.py | 2 +- .../tests/unittests/test_bilinear_tensor_product_op.py | 2 +- python/paddle/fluid/tests/unittests/test_cos_sim_op.py | 4 ++-- .../fluid/tests/unittests/test_elementwise_min_op.py | 8 ++++---- python/paddle/fluid/tests/unittests/test_expand_op.py | 2 +- python/paddle/fluid/tests/unittests/test_flatten2_op.py | 8 ++++---- python/paddle/fluid/tests/unittests/test_flatten_op.py | 8 ++++---- .../paddle/fluid/tests/unittests/test_im2sequence_op.py | 2 +- python/paddle/fluid/tests/unittests/test_norm_op.py | 2 +- .../fluid/tests/unittests/test_pad_constant_like.py | 4 ++-- python/paddle/fluid/tests/unittests/test_pad_op.py | 2 +- python/paddle/fluid/tests/unittests/test_scatter_op.py | 4 ++-- .../paddle/fluid/tests/unittests/test_sequence_pad_op.py | 2 +- .../fluid/tests/unittests/test_sequence_unpad_op.py | 2 +- .../paddle/fluid/tests/unittests/test_strided_slice_op.py | 2 +- python/paddle/fluid/tests/unittests/test_unpool_op.py | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_activation_op.py b/python/paddle/fluid/tests/unittests/test_activation_op.py index fbd196ffda..b27952321a 100644 --- a/python/paddle/fluid/tests/unittests/test_activation_op.py +++ b/python/paddle/fluid/tests/unittests/test_activation_op.py @@ -232,7 +232,7 @@ class TestAbs(TestActivation): self.op_type = "abs" self.init_dtype() - x = np.random.uniform(-1, 1, [4, 4]).astype(self.dtype) + x = np.random.uniform(-1, 1, [4, 25]).astype(self.dtype) # Because we set delta = 0.005 in calculating numeric gradient, # if x is too small, such as 0.002, x_neg will be -0.003 # x_pos will be 0.007, so the numeric gradient is inaccurate. diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py index 46831119c5..61be164f2c 100644 --- a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py @@ -23,7 +23,7 @@ class TestBilinearTensorProductOp(OpTest): def setUp(self): self.op_type = "bilinear_tensor_product" batch_size = 6 - size0 = 3 + size0 = 5 size1 = 4 size2 = 5 a = np.random.random((batch_size, size0)).astype("float32") diff --git a/python/paddle/fluid/tests/unittests/test_cos_sim_op.py b/python/paddle/fluid/tests/unittests/test_cos_sim_op.py index 3c3fd6d4d7..cee91de510 100644 --- a/python/paddle/fluid/tests/unittests/test_cos_sim_op.py +++ b/python/paddle/fluid/tests/unittests/test_cos_sim_op.py @@ -23,8 +23,8 @@ class TestCosSimOp(OpTest): def setUp(self): self.op_type = "cos_sim" self.inputs = { - 'X': np.random.random((6, 5)).astype("float32"), - 'Y': np.random.random((6, 5)).astype("float32") + 'X': np.random.random((6, 20)).astype("float32"), + 'Y': np.random.random((6, 20)).astype("float32") } expect_x_norm = np.linalg.norm(self.inputs['X'], axis=1) expect_y_norm = np.linalg.norm(self.inputs['Y'], axis=1) diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_min_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_min_op.py index c1e93f6a4e..19d139f305 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_min_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_min_op.py @@ -49,7 +49,7 @@ class TestElementwiseOp(OpTest): class TestElementwiseMinOp_scalar(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_min" - x = np.random.random_integers(-5, 5, [2, 3, 4]).astype("float32") + x = np.random.random_integers(-5, 5, [10, 3, 4]).astype("float32") y = np.array([0.5]).astype("float32") self.inputs = {'X': x, 'Y': y} self.outputs = {'Out': np.minimum(self.inputs['X'], self.inputs['Y'])} @@ -58,9 +58,9 @@ class TestElementwiseMinOp_scalar(TestElementwiseOp): class TestElementwiseMinOp_Vector(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_min" - x = np.random.random((32, )).astype("float32") - sgn = np.random.choice([-1, 1], (32, )).astype("float32") - y = x + sgn * np.random.uniform(0.1, 1, (32, )).astype("float32") + x = np.random.random((100, )).astype("float32") + sgn = np.random.choice([-1, 1], (100, )).astype("float32") + y = x + sgn * np.random.uniform(0.1, 1, (100, )).astype("float32") self.inputs = {'X': x, 'Y': y} self.outputs = {'Out': np.minimum(self.inputs['X'], self.inputs['Y'])} diff --git a/python/paddle/fluid/tests/unittests/test_expand_op.py b/python/paddle/fluid/tests/unittests/test_expand_op.py index 05f2e520bd..0f6f3e31c6 100644 --- a/python/paddle/fluid/tests/unittests/test_expand_op.py +++ b/python/paddle/fluid/tests/unittests/test_expand_op.py @@ -33,7 +33,7 @@ class TestExpandOpRank1(OpTest): self.outputs = {'Out': output} def init_data(self): - self.ori_shape = [12] + self.ori_shape = [100] self.expand_times = [2] def test_check_output(self): diff --git a/python/paddle/fluid/tests/unittests/test_flatten2_op.py b/python/paddle/fluid/tests/unittests/test_flatten2_op.py index 59185855a5..64aecfea7b 100644 --- a/python/paddle/fluid/tests/unittests/test_flatten2_op.py +++ b/python/paddle/fluid/tests/unittests/test_flatten2_op.py @@ -38,9 +38,9 @@ class TestFlattenOp(OpTest): self.check_grad(["X"], "Out") def init_test_case(self): - self.in_shape = (3, 2, 2, 5) + self.in_shape = (3, 2, 4, 5) self.axis = 1 - self.new_shape = (3, 20) + self.new_shape = (3, 40) def init_attrs(self): self.attrs = {"axis": self.axis} @@ -48,9 +48,9 @@ class TestFlattenOp(OpTest): class TestFlattenOp(TestFlattenOp): def init_test_case(self): - self.in_shape = (3, 2, 2, 3) + self.in_shape = (3, 2, 5, 4) self.axis = 0 - self.new_shape = (1, 36) + self.new_shape = (1, 120) class TestFlattenOpWithDefaultAxis(TestFlattenOp): diff --git a/python/paddle/fluid/tests/unittests/test_flatten_op.py b/python/paddle/fluid/tests/unittests/test_flatten_op.py index 91251147eb..502ac1643d 100644 --- a/python/paddle/fluid/tests/unittests/test_flatten_op.py +++ b/python/paddle/fluid/tests/unittests/test_flatten_op.py @@ -35,9 +35,9 @@ class TestFlattenOp(OpTest): self.check_grad(["X"], "Out") def init_test_case(self): - self.in_shape = (3, 2, 2, 5) + self.in_shape = (3, 2, 2, 10) self.axis = 1 - self.new_shape = (3, 20) + self.new_shape = (3, 40) def init_attrs(self): self.attrs = {"axis": self.axis} @@ -45,9 +45,9 @@ class TestFlattenOp(OpTest): class TestFlattenOp(TestFlattenOp): def init_test_case(self): - self.in_shape = (3, 2, 2, 3) + self.in_shape = (3, 2, 2, 10) self.axis = 0 - self.new_shape = (1, 36) + self.new_shape = (1, 120) class TestFlattenOpWithDefaultAxis(TestFlattenOp): diff --git a/python/paddle/fluid/tests/unittests/test_im2sequence_op.py b/python/paddle/fluid/tests/unittests/test_im2sequence_op.py index 833e46483c..fbe948f43a 100644 --- a/python/paddle/fluid/tests/unittests/test_im2sequence_op.py +++ b/python/paddle/fluid/tests/unittests/test_im2sequence_op.py @@ -129,7 +129,7 @@ class TestBlockExpandOp(OpTest): self.batch_size = 1 self.img_channels = 3 self.img_height = 4 - self.img_width = 4 + self.img_width = 10 self.attrs = { 'kernels': [2, 2], 'strides': [1, 1], diff --git a/python/paddle/fluid/tests/unittests/test_norm_op.py b/python/paddle/fluid/tests/unittests/test_norm_op.py index a424260312..00ea930251 100644 --- a/python/paddle/fluid/tests/unittests/test_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_norm_op.py @@ -44,7 +44,7 @@ class TestNormOp(OpTest): self.check_grad(['X'], 'Out') def init_test_case(self): - self.shape = [2, 3, 4, 4] + self.shape = [2, 3, 4, 5] self.axis = 1 self.epsilon = 1e-8 diff --git a/python/paddle/fluid/tests/unittests/test_pad_constant_like.py b/python/paddle/fluid/tests/unittests/test_pad_constant_like.py index 6b733fd8fa..4abfa363fa 100644 --- a/python/paddle/fluid/tests/unittests/test_pad_constant_like.py +++ b/python/paddle/fluid/tests/unittests/test_pad_constant_like.py @@ -51,8 +51,8 @@ class TestPadOp(OpTest): class TestCase1(TestPadOp): def initTestCase(self): - self.x_shape = (4, 3, 4, 4) - self.y_shape = (2, 3, 4, 4) + self.x_shape = (4, 3, 4, 5) + self.y_shape = (2, 3, 4, 5) self.paddings = [(0, 2), (0, 0), (0, 0), (0, 0)] self.pad_value = 0.5 diff --git a/python/paddle/fluid/tests/unittests/test_pad_op.py b/python/paddle/fluid/tests/unittests/test_pad_op.py index f0f65a4d7d..26a4bc649d 100644 --- a/python/paddle/fluid/tests/unittests/test_pad_op.py +++ b/python/paddle/fluid/tests/unittests/test_pad_op.py @@ -53,7 +53,7 @@ class TestPadOp(OpTest): class TestCase1(TestPadOp): def initTestCase(self): - self.shape = (2, 3, 4, 4) + self.shape = (2, 3, 4, 5) self.paddings = [(0, 1), (2, 3), (2, 1), (1, 1)] self.pad_value = 0.5 diff --git a/python/paddle/fluid/tests/unittests/test_scatter_op.py b/python/paddle/fluid/tests/unittests/test_scatter_op.py index 999b7ea88b..5e9c67c1a7 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_op.py @@ -23,9 +23,9 @@ import paddle.fluid.core as core class TestScatterOp(OpTest): def setUp(self): self.op_type = "scatter" - ref_np = np.ones((3, 3)).astype("float32") + ref_np = np.ones((3, 50)).astype("float32") index_np = np.array([1, 2]).astype("int32") - updates_np = np.random.random((2, 3)).astype("float32") + updates_np = np.random.random((2, 50)).astype("float32") output_np = np.copy(ref_np) output_np[index_np] = updates_np self.inputs = {'X': ref_np, 'Ids': index_np, 'Updates': updates_np} diff --git a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py b/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py index 3b4701e4ca..f3b2ce2b09 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py @@ -19,7 +19,7 @@ from op_test import OpTest class TestSequencePadOp(OpTest): def set_attr(self): - self.x_shape = [12, 4] + self.x_shape = [12, 10] self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0] self.padded_length = -1 diff --git a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py b/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py index 91f0ff713a..c4e4495841 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py @@ -21,7 +21,7 @@ from op_test import OpTest class TestSequenceUnpadOp(OpTest): def init(self): self.length = [2, 3, 4] - self.x_shape = (3, 5) + self.x_shape = (3, 40) self.dtype = "float32" def compute(self): diff --git a/python/paddle/fluid/tests/unittests/test_strided_slice_op.py b/python/paddle/fluid/tests/unittests/test_strided_slice_op.py index 238fc06a20..c13a38b3b2 100644 --- a/python/paddle/fluid/tests/unittests/test_strided_slice_op.py +++ b/python/paddle/fluid/tests/unittests/test_strided_slice_op.py @@ -75,7 +75,7 @@ class TestStrideSliceOp(OpTest): self.check_grad(set(['Input']), 'Out') def initTestCase(self): - self.input = np.random.rand(6) + self.input = np.random.rand(100) self.axes = [0] self.starts = [-4] self.ends = [-3] diff --git a/python/paddle/fluid/tests/unittests/test_unpool_op.py b/python/paddle/fluid/tests/unittests/test_unpool_op.py index b0c7c3c866..15291069c4 100644 --- a/python/paddle/fluid/tests/unittests/test_unpool_op.py +++ b/python/paddle/fluid/tests/unittests/test_unpool_op.py @@ -89,7 +89,7 @@ class TestUnpoolOp(OpTest): def init_test_case(self): self.unpool2d_forward_naive = unpool2dmax_forward_naive self.unpooling_type = "max" - self.shape = [6, 4, 5, 5] + self.shape = [6, 4, 7, 7] self.ksize = [3, 3] self.strides = [2, 2] self.paddings = [0, 0] -- GitLab