From 15cedc27640253c23d5fd2d76bac7a7d4bf8ce46 Mon Sep 17 00:00:00 2001 From: juncaipeng <13006307475@163.com> Date: Wed, 18 Dec 2019 03:28:18 +0000 Subject: [PATCH 1/2] Update test precision from fp32 to fp64, test=develop --- python/paddle/fluid/tests/unittests/test_mean_op.py | 2 +- .../tests/unittests/test_mine_hard_examples_op.py | 10 +++++----- python/paddle/fluid/tests/unittests/test_mul_op.py | 4 ++-- .../fluid/tests/unittests/test_multiplex_op.py | 8 ++++---- .../fluid/tests/unittests/test_nearest_interp_op.py | 6 +++--- .../fluid/tests/unittests/test_pixel_shuffle.py | 2 +- .../paddle/fluid/tests/unittests/test_pool2d_op.py | 6 +++--- .../paddle/fluid/tests/unittests/test_pool3d_op.py | 2 +- .../paddle/fluid/tests/unittests/test_pool_max_op.py | 4 ++-- .../fluid/tests/unittests/test_psroi_pool_op.py | 6 +++--- .../paddle/fluid/tests/unittests/test_reverse_op.py | 10 +++++----- .../fluid/tests/unittests/test_roi_align_op.py | 10 +++++----- .../paddle/fluid/tests/unittests/test_roi_pool_op.py | 6 +++--- .../fluid/tests/unittests/test_scatter_nd_op.py | 12 ++++++------ python/paddle/fluid/tests/unittests/test_selu_op.py | 2 +- 15 files changed, 45 insertions(+), 45 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_mean_op.py b/python/paddle/fluid/tests/unittests/test_mean_op.py index 8b4deca124bab..f3abd1acce6fa 100644 --- a/python/paddle/fluid/tests/unittests/test_mean_op.py +++ b/python/paddle/fluid/tests/unittests/test_mean_op.py @@ -25,7 +25,7 @@ class TestMeanOp(OpTest): def setUp(self): self.op_type = "mean" - self.dtype = np.float32 + self.dtype = np.float64 self.init_dtype_type() self.inputs = {'X': np.random.random((10, 10)).astype(self.dtype)} self.outputs = {'Out': np.mean(self.inputs["X"])} diff --git a/python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py b/python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py index 4e5cc91268c5d..6730d5de2c2db 100644 --- a/python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py +++ b/python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py @@ -59,13 +59,13 @@ def init_test_data(self): self.sample_size = 0 self.mining_type = "max_negative" self.cls_loss = np.array([[0.1, 0.1, 0.3], - [0.3, 0.1, 0.1]]).astype('float32') + [0.3, 0.1, 0.1]]).astype('float64') self.loc_loss = np.array([[0.1, 0.2, 0.3], - [0.3, 0.4, 0.1]]).astype('float32') + [0.3, 0.4, 0.1]]).astype('float64') self.match_dis = np.array([[0.2, 0.4, 0.8], - [0.1, 0.9, 0.3]]).astype('float32') + [0.1, 0.9, 0.3]]).astype('float64') self.match_indices = np.array([[0, -1, -1], [-1, 0, -1]]).astype('int32') @@ -83,10 +83,10 @@ def init_test_data(self): self.sample_size = 2 self.cls_loss = np.array([[0.5, 0.1, 0.3], - [0.3, 0.1, 0.1]]).astype('float32') + [0.3, 0.1, 0.1]]).astype('float64') self.loc_loss = np.array([[0.2, 0.2, 0.3], - [0.3, 0.1, 0.2]]).astype('float32') + [0.3, 0.1, 0.2]]).astype('float64') self.match_indices = np.array([[0, -1, -1], [-1, 0, -1]]).astype('int32') diff --git a/python/paddle/fluid/tests/unittests/test_mul_op.py b/python/paddle/fluid/tests/unittests/test_mul_op.py index 21d350170bf67..f6163d1559efb 100644 --- a/python/paddle/fluid/tests/unittests/test_mul_op.py +++ b/python/paddle/fluid/tests/unittests/test_mul_op.py @@ -25,7 +25,7 @@ class TestMulOp(OpTest): def setUp(self): self.op_type = "mul" - self.dtype = np.float32 + self.dtype = np.float64 self.init_dtype_type() self.inputs = { 'X': np.random.random((2, 5)).astype(self.dtype), @@ -69,7 +69,7 @@ def test_errors(self): class TestMulOp2(OpTest): def setUp(self): self.op_type = "mul" - self.dtype = np.float32 + self.dtype = np.float64 self.init_dtype_type() self.inputs = { 'X': np.random.random((3, 4, 4, 3)).astype(self.dtype), diff --git a/python/paddle/fluid/tests/unittests/test_multiplex_op.py b/python/paddle/fluid/tests/unittests/test_multiplex_op.py index 0a0540c908ac2..9b42b705efe64 100644 --- a/python/paddle/fluid/tests/unittests/test_multiplex_op.py +++ b/python/paddle/fluid/tests/unittests/test_multiplex_op.py @@ -26,10 +26,10 @@ def setUp(self): index = np.arange(0, rows).astype('int32') np.random.shuffle(index) index = np.reshape(index, (rows, 1)) - ins1 = np.random.random((rows, 25)).astype("float32") - ins2 = np.random.random((rows, 25)).astype("float32") - ins3 = np.random.random((rows, 25)).astype("float32") - ins4 = np.random.random((rows, 25)).astype("float32") + ins1 = np.random.random((rows, 25)).astype("float64") + ins2 = np.random.random((rows, 25)).astype("float64") + ins3 = np.random.random((rows, 25)).astype("float64") + ins4 = np.random.random((rows, 25)).astype("float64") self.inputs = { 'Ids': index, 'X': [('x1', ins1), ('x2', ins2), ('x3', ins3), ('x4', ins4)] diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index abae7e3a8f05f..c6e05edfaaec2 100755 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -79,7 +79,7 @@ def setUp(self): self.data_layout = 'NCHW' self.init_test_case() self.op_type = "nearest_interp" - input_np = np.random.random(self.input_shape).astype("float32") + input_np = np.random.random(self.input_shape).astype("float64") if self.data_layout == "NCHW": in_h = self.input_shape[2] @@ -340,11 +340,11 @@ def setUp(self): 'align_corners': self.align_corners, } - input_np = np.random.random(self.input_shape).astype("float32") + input_np = np.random.random(self.input_shape).astype("float64") self.inputs = {'X': input_np} if self.scale_by_1Dtensor: - self.inputs['Scale'] = np.array([self.scale]).astype("float32") + self.inputs['Scale'] = np.array([self.scale]).astype("float64") elif self.scale > 0: out_h = int(self.input_shape[2] * self.scale) out_w = int(self.input_shape[3] * self.scale) diff --git a/python/paddle/fluid/tests/unittests/test_pixel_shuffle.py b/python/paddle/fluid/tests/unittests/test_pixel_shuffle.py index cc3ae2b3b9d4c..0bcb4be3b7fb9 100644 --- a/python/paddle/fluid/tests/unittests/test_pixel_shuffle.py +++ b/python/paddle/fluid/tests/unittests/test_pixel_shuffle.py @@ -25,7 +25,7 @@ def setUp(self): n, c, h, w = 2, 9, 4, 4 up_factor = 3 shape = [n, c, h, w] - x = np.random.random(shape).astype("float32") + x = np.random.random(shape).astype("float64") new_shape = (n, c // (up_factor * up_factor), up_factor, up_factor, h, w) # reshape to (num,output_channel,upscale_factor,upscale_factor,h,w) diff --git a/python/paddle/fluid/tests/unittests/test_pool2d_op.py b/python/paddle/fluid/tests/unittests/test_pool2d_op.py index c9b26307c897c..a28462214f29f 100644 --- a/python/paddle/fluid/tests/unittests/test_pool2d_op.py +++ b/python/paddle/fluid/tests/unittests/test_pool2d_op.py @@ -39,7 +39,7 @@ def max_pool2D_forward_naive(x, ceil_mode=False, exclusive=True, adaptive=False, - data_type=np.float32): + data_type=np.float64): N, C, H, W = x.shape if global_pool == 1: ksize = [H, W] @@ -79,7 +79,7 @@ def avg_pool2D_forward_naive(x, ceil_mode=False, exclusive=True, adaptive=False, - data_type=np.float32): + data_type=np.float64): N, C, H, W = x.shape if global_pool == 1: ksize = [H, W] @@ -320,7 +320,7 @@ def init_kernel_type(self): self.use_cudnn = False def init_data_type(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_pool_type(self): self.pool_type = "avg" diff --git a/python/paddle/fluid/tests/unittests/test_pool3d_op.py b/python/paddle/fluid/tests/unittests/test_pool3d_op.py index 609cc99089125..b7e20df6907d8 100644 --- a/python/paddle/fluid/tests/unittests/test_pool3d_op.py +++ b/python/paddle/fluid/tests/unittests/test_pool3d_op.py @@ -209,7 +209,7 @@ class TestPool3d_Op(OpTest): def setUp(self): self.op_type = "pool3d" self.init_kernel_type() - self.dtype = np.float32 + self.dtype = np.float64 self.init_test_case() self.padding_algorithm = "EXPLICIT" self.init_paddings() diff --git a/python/paddle/fluid/tests/unittests/test_pool_max_op.py b/python/paddle/fluid/tests/unittests/test_pool_max_op.py index 6575c408eeaa4..8905c900dc97d 100644 --- a/python/paddle/fluid/tests/unittests/test_pool_max_op.py +++ b/python/paddle/fluid/tests/unittests/test_pool_max_op.py @@ -140,11 +140,11 @@ def setUp(self): self.init_global() self.init_adaptive() - input = np.random.random(self.shape).astype("float32") + input = np.random.random(self.shape).astype("float64") output, mask = self.pool_forward_naive(input, self.ksize, self.strides, self.paddings, self.global_pool, self.adaptive) - output = output.astype("float32") + output = output.astype("float64") mask = mask.astype("int32") self.attrs = { diff --git a/python/paddle/fluid/tests/unittests/test_psroi_pool_op.py b/python/paddle/fluid/tests/unittests/test_psroi_pool_op.py index abe014a38c6ec..066bcf48612c5 100644 --- a/python/paddle/fluid/tests/unittests/test_psroi_pool_op.py +++ b/python/paddle/fluid/tests/unittests/test_psroi_pool_op.py @@ -47,7 +47,7 @@ def init_test_case(self): self.pooled_height = 2 self.pooled_width = 2 - self.x = np.random.random(self.x_dim).astype('float32') + self.x = np.random.random(self.x_dim).astype('float64') def make_rois(self): rois = [] @@ -67,7 +67,7 @@ def make_rois(self): roi = [bno, x1, y1, x2, y2] rois.append(roi) self.rois_num = len(rois) - self.rois = np.array(rois).astype('float32') + self.rois = np.array(rois).astype('float64') def calc_psroi_pool(self): output_shape = (self.rois_num, self.output_channels, self.pooled_height, @@ -117,7 +117,7 @@ def calc_psroi_pool(self): bin_area = (hend - hstart) * (wend - wstart) out_data[i, c, ph, pw] = 0. if is_empty else ( out_sum / float(bin_area)) - self.outs = out_data.astype('float32') + self.outs = out_data.astype('float64') def setUp(self): self.op_type = 'psroi_pool' diff --git a/python/paddle/fluid/tests/unittests/test_reverse_op.py b/python/paddle/fluid/tests/unittests/test_reverse_op.py index c9579ac647dd1..09252f47d2106 100644 --- a/python/paddle/fluid/tests/unittests/test_reverse_op.py +++ b/python/paddle/fluid/tests/unittests/test_reverse_op.py @@ -21,7 +21,7 @@ class TestReverseOp(OpTest): def initTestCase(self): - self.x = np.random.random((3, 40)).astype('float32') + self.x = np.random.random((3, 40)).astype('float64') self.axis = [0] def setUp(self): @@ -43,25 +43,25 @@ def test_check_grad(self): class TestCase0(TestReverseOp): def initTestCase(self): - self.x = np.random.random((3, 40)).astype('float32') + self.x = np.random.random((3, 40)).astype('float64') self.axis = [1] class TestCase1(TestReverseOp): def initTestCase(self): - self.x = np.random.random((3, 40)).astype('float32') + self.x = np.random.random((3, 40)).astype('float64') self.axis = [0, 1] class TestCase2(TestReverseOp): def initTestCase(self): - self.x = np.random.random((3, 4, 10)).astype('float32') + self.x = np.random.random((3, 4, 10)).astype('float64') self.axis = [0, 2] class TestCase3(TestReverseOp): def initTestCase(self): - self.x = np.random.random((3, 4, 10)).astype('float32') + self.x = np.random.random((3, 4, 10)).astype('float64') self.axis = [1, 2] diff --git a/python/paddle/fluid/tests/unittests/test_roi_align_op.py b/python/paddle/fluid/tests/unittests/test_roi_align_op.py index aad2eaed94a35..c8d5e4c00597a 100644 --- a/python/paddle/fluid/tests/unittests/test_roi_align_op.py +++ b/python/paddle/fluid/tests/unittests/test_roi_align_op.py @@ -50,16 +50,16 @@ def init_test_case(self): self.pooled_width = 2 self.sampling_ratio = -1 - self.x = np.random.random(self.x_dim).astype('float32') + self.x = np.random.random(self.x_dim).astype('float64') def pre_calc(self, x_i, roi_xmin, roi_ymin, roi_bin_grid_h, roi_bin_grid_w, bin_size_h, bin_size_w): count = roi_bin_grid_h * roi_bin_grid_w bilinear_pos = np.zeros( [self.channels, self.pooled_height, self.pooled_width, count, 4], - np.float32) + np.float64) bilinear_w = np.zeros( - [self.pooled_height, self.pooled_width, count, 4], np.float32) + [self.pooled_height, self.pooled_width, count, 4], np.float64) for ph in range(self.pooled_width): for pw in range(self.pooled_height): c = 0 @@ -109,7 +109,7 @@ def pre_calc(self, x_i, roi_xmin, roi_ymin, roi_bin_grid_h, roi_bin_grid_w, def calc_roi_align(self): self.out_data = np.zeros( (self.rois_num, self.channels, self.pooled_height, - self.pooled_width)).astype('float32') + self.pooled_width)).astype('float64') for i in range(self.rois_num): roi = self.rois[i] @@ -157,7 +157,7 @@ def make_rois(self): roi = [bno, x1, y1, x2, y2] rois.append(roi) self.rois_num = len(rois) - self.rois = np.array(rois).astype("float32") + self.rois = np.array(rois).astype("float64") def setUp(self): self.op_type = "roi_align" diff --git a/python/paddle/fluid/tests/unittests/test_roi_pool_op.py b/python/paddle/fluid/tests/unittests/test_roi_pool_op.py index ad4cd2e803bfa..363f465b9d464 100644 --- a/python/paddle/fluid/tests/unittests/test_roi_pool_op.py +++ b/python/paddle/fluid/tests/unittests/test_roi_pool_op.py @@ -51,7 +51,7 @@ def init_test_case(self): self.pooled_height = 2 self.pooled_width = 2 - self.x = np.random.random(self.x_dim).astype('float32') + self.x = np.random.random(self.x_dim).astype('float64') def calc_roi_pool(self): out_data = np.zeros((self.rois_num, self.channels, self.pooled_height, @@ -103,7 +103,7 @@ def calc_roi_pool(self): argmax_data[i, c, ph, pw] = h * self.width + w - self.outs = out_data.astype('float32') + self.outs = out_data.astype('float64') self.argmaxes = argmax_data.astype('int64') def make_rois(self): @@ -125,7 +125,7 @@ def make_rois(self): roi = [bno, x1, y1, x2, y2] rois.append(roi) self.rois_num = len(rois) - self.rois = np.array(rois).astype("float32") + self.rois = np.array(rois).astype("float64") def setUp(self): self.op_type = "roi_pool" diff --git a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py index 5772ba86fbd33..c8f4ed24e5cbc 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py @@ -66,9 +66,9 @@ class TestScatterNdAddSimpleOp(OpTest): def setUp(self): self.op_type = "scatter_nd_add" #ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32") - ref_np = np.random.random([100]).astype("float32") + ref_np = np.random.random([100]).astype("float64") index_np = np.random.randint(0, 100, [100, 1]).astype("int32") - updates_np = np.random.random([100]).astype("float32") + updates_np = np.random.random([100]).astype("float64") expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) #expect_np = [ 0. 23. 12. 14. 4. 17. 6. 7. 8.] @@ -89,10 +89,10 @@ class TestScatterNdAddWithEmptyIndex(OpTest): def setUp(self): self.op_type = "scatter_nd_add" - ref_np = np.array([[65, 17], [-14, -25]]).astype("float32") + ref_np = np.array([[65, 17], [-14, -25]]).astype("float64") index_np = np.array([[], []]).astype("int32") updates_np = np.array([[[-1, -2], [1, 2]], - [[3, 4], [-3, -4]]]).astype("float32") + [[3, 4], [-3, -4]]]).astype("float64") expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) #expect_np = [[67, 19], [-16, -27]] @@ -115,12 +115,12 @@ class TestScatterNdAddWithHighRankSame(OpTest): def setUp(self): self.op_type = "scatter_nd_add" shape = (10, 9, 8, 1, 15) - ref_np = np.random.rand(*shape).astype("float32") + ref_np = np.random.rand(*shape).astype("float64") index_np = np.vstack( [np.random.randint( 0, s, size=150) for s in shape]).T.astype("int32") update_shape = judge_update_shape(ref_np, index_np) - updates_np = np.random.rand(*update_shape).astype("float32") + updates_np = np.random.rand(*update_shape).astype("float64") expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) self.inputs = {'X': ref_np, 'Index': index_np, 'Updates': updates_np} diff --git a/python/paddle/fluid/tests/unittests/test_selu_op.py b/python/paddle/fluid/tests/unittests/test_selu_op.py index bcba0511da747..79456b7de4389 100644 --- a/python/paddle/fluid/tests/unittests/test_selu_op.py +++ b/python/paddle/fluid/tests/unittests/test_selu_op.py @@ -24,7 +24,7 @@ class SeluTest(OpTest): def setUp(self): self.op_type = "selu" self.x_shape = [3, 5, 5, 10] - self.dtype = np.float32 + self.dtype = np.float64 self.init_x_shape() self.init_dtype() From 09c77e975ed000c4cef42e306cf9dc1a5a0c7ab3 Mon Sep 17 00:00:00 2001 From: juncaipeng <13006307475@163.com> Date: Thu, 19 Dec 2019 11:07:26 +0000 Subject: [PATCH 2/2] Update test precision from fp32 to fp64, test=develop --- .../tests/unittests/test_sequence_concat.py | 4 +-- .../tests/unittests/test_sequence_expand.py | 28 +++++++-------- .../unittests/test_sequence_expand_as.py | 16 ++++----- .../tests/unittests/test_sequence_pad_op.py | 16 ++++----- .../tests/unittests/test_sequence_reshape.py | 12 +++---- .../unittests/test_sequence_scatter_op.py | 4 +-- .../unittests/test_sequence_softmax_op.py | 4 +-- .../tests/unittests/test_sequence_unpad_op.py | 4 +-- ...st_sigmoid_cross_entropy_with_logits_op.py | 28 +++++++-------- .../unittests/test_sigmoid_focal_loss_op.py | 4 +-- .../fluid/tests/unittests/test_sign_op.py | 2 +- .../fluid/tests/unittests/test_slice_op.py | 36 +++++++++---------- .../fluid/tests/unittests/test_softmax_op.py | 2 +- .../test_softmax_with_cross_entropy_op.py | 6 ++-- .../tests/unittests/test_space_to_depth_op.py | 16 ++++----- .../tests/unittests/test_spectral_norm_op.py | 6 ++-- .../fluid/tests/unittests/test_split_op.py | 10 +++--- .../fluid/tests/unittests/test_spp_op.py | 6 ++-- 18 files changed, 102 insertions(+), 102 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_sequence_concat.py b/python/paddle/fluid/tests/unittests/test_sequence_concat.py index 527577199860e..2dacbb5ae997f 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_concat.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_concat.py @@ -26,8 +26,8 @@ def setLoD(self): self.out_lod = [19, 11] def setUp(self): - x1 = np.random.random(size=(10, 80)).astype('float32') - x2 = np.random.random(size=(20, 80)).astype('float32') + x1 = np.random.random(size=(10, 80)).astype('float64') + x2 = np.random.random(size=(20, 80)).astype('float64') self.setLoD() out = np.concatenate((x1[0:self.lod1[0]], x2[0:self.lod2[0]], diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand.py b/python/paddle/fluid/tests/unittests/test_sequence_expand.py index 8c5202e3a757b..41d2b8bea49c4 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_expand.py @@ -21,8 +21,8 @@ class TestSequenceExpand(OpTest): def set_data(self): - x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float32') - y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float64') + y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_lod = [[1, 3, 4]] self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} @@ -80,8 +80,8 @@ def test_check_grad(self): class TestSequenceExpandCase1(TestSequenceExpand): def set_data(self): - x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32') - y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') + y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64') y_lod = [[2, 3], [2, 2, 3, 3, 3]] self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.attrs = {'ref_level': 1} @@ -89,9 +89,9 @@ def set_data(self): class TestSequenceExpandCase2(TestSequenceExpand): def set_data(self): - x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float32') + x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64') x_lod = [[1]] - y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float32') + y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64') y_lod = [[2], [1, 1]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.attrs = {'ref_level': 0} @@ -99,9 +99,9 @@ def set_data(self): class TestSequenceExpandCase3(TestSequenceExpand): def set_data(self): - x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float64') x_lod = [[1, 1, 1, 1]] - y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') + y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_lod = [[2, 2, 2, 2]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} @@ -109,17 +109,17 @@ def set_data(self): class TestSequenceExpandCase4(TestSequenceExpand): def set_data(self): data = np.random.uniform(0.1, 1, [5 * 2, 1]) - x_data = np.array(data).reshape([5, 2]).astype('float32') + x_data = np.array(data).reshape([5, 2]).astype('float64') x_lod = [[2, 3]] - y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32') + y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') y_lod = [[2], [2, 3]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} class TestSequenceExpandCase5(TestSequenceExpand): def set_data(self): - x_data = np.random.uniform(0.1, 1, [6, 1]).astype('float32') - y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [6, 1]).astype('float64') + y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64') y_lod = [[2, 4], [2, 2, 3, 0, 3, 3]] self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.attrs = {'ref_level': 1} @@ -127,9 +127,9 @@ def set_data(self): class TestSequenceExpandCase6(TestSequenceExpand): def set_data(self): - x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float64') x_lod = [[1, 1, 0, 1, 1]] - y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') + y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_lod = [[0, 2, 4, 2, 0]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py b/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py index 913eaf377e228..f3b9f3897c103 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py @@ -26,8 +26,8 @@ def setUp(self): self.compute() def set_data(self): - x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float32') - y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float64') + y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_lod = [[1, 3, 4]] self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} @@ -57,27 +57,27 @@ def test_check_grad(self): class TestSequenceExpandAsCase1(TestSequenceExpandAs): def set_data(self): - x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') x_lod = [[2, 3]] - y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float32') + y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64') y_lod = [[2, 2, 0, 3, 3]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} class TestSequenceExpandAsCase2(TestSequenceExpandAs): def set_data(self): - x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32') + x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') x_lod = [[2, 3]] - y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float32') + y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64') y_lod = [[0, 4, 0, 6, 0]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} class TestSequenceExpandAsCase3(TestSequenceExpandAs): def set_data(self): - x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float32') + x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64') x_lod = [[1]] - y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float32') + y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64') y_lod = [[2]] self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} 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 f3b2ce2b09431..dfb7b7e774579 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py @@ -23,7 +23,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0] self.padded_length = -1 - self.dtype = 'float32' + self.dtype = 'float64' def set_data(self): x_data = np.random.uniform(0.1, 0.5, self.x_shape).astype(self.dtype) @@ -84,7 +84,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0, 2.0, 3.0, 4.0] self.padded_length = -1 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp3(TestSequencePadOp): @@ -93,7 +93,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0] self.padded_length = 7 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp4(TestSequencePadOp): @@ -102,7 +102,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0, 2.0, 3.0, 4.0] self.padded_length = 7 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp5(TestSequencePadOp): @@ -111,7 +111,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0] self.padded_length = -1 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp6(TestSequencePadOp): @@ -120,7 +120,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [[1.0, 2.0], [3.0, 4.0]] self.padded_length = -1 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp7(TestSequencePadOp): @@ -129,7 +129,7 @@ def set_attr(self): self.x_len_lod = [[2, 3, 4, 3]] self.pad_value = [1.0] self.padded_length = 7 - self.dtype = 'float32' + self.dtype = 'float64' class TestSequencePadOp8(TestSequencePadOp): @@ -138,7 +138,7 @@ def set_attr(self): self.x_len_lod = [[0, 8, 0, 4, 0]] self.pad_value = [1.0] self.padded_length = 10 - self.dtype = 'float32' + self.dtype = 'float64' if __name__ == '__main__': diff --git a/python/paddle/fluid/tests/unittests/test_sequence_reshape.py b/python/paddle/fluid/tests/unittests/test_sequence_reshape.py index e2e7837dac7a2..c72e5dbaf8052 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_reshape.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_reshape.py @@ -24,7 +24,7 @@ class TestSequenceReshape(OpTest): def init_data(self): self.dimension = 12 self.x_lod = [[4, 1, 3, 3]] - self.x = np.random.uniform(0.1, 1, [11, 24]).astype('float32') + self.x = np.random.uniform(0.1, 1, [11, 24]).astype('float64') def setUp(self): self.init_data() @@ -42,7 +42,7 @@ def compute_output(self, x, x_lod, dimension): offset = (seq_len * x_width) / dimension assert int(offset) * dimension == seq_len * x_width out_lod[0].append(int(offset)) - out = np.zeros(shape=(sum(out_lod[0]), dimension)).astype('float32') + out = np.zeros(shape=(sum(out_lod[0]), dimension)).astype('float64') out.ravel()[:] = x.ravel()[:] return out, out_lod @@ -57,28 +57,28 @@ class TestSequenceReshape_reduce(TestSequenceReshape): def init_data(self): self.dimension = 24 self.x_lod = [[4, 2, 2, 4]] - self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') + self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64') class TestSequenceReshape_same(TestSequenceReshape): def init_data(self): self.dimension = 12 self.x_lod = [[4, 2, 2, 4]] - self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') + self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64') class TestSequenceReshape_reduce_seq_len0(TestSequenceReshape): def init_data(self): self.dimension = 24 self.x_lod = [[0, 6, 0, 2, 4]] - self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') + self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64') class TestSequenceReshape_reduce_seq_len0_case1(TestSequenceReshape): def init_data(self): self.dimension = 24 self.x_lod = [[0, 2, 8, 2, 0]] - self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') + self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64') if __name__ == '__main__': diff --git a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py b/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py index d3ad734d818b5..44fece075a40e 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py @@ -24,12 +24,12 @@ def init_lod(self): def setUp(self): self.op_type = "sequence_scatter" - X_data = np.random.uniform(0.1, 1.0, [3, 6]).astype('float32') + X_data = np.random.uniform(0.1, 1.0, [3, 6]).astype('float64') Ids_data = np.array([[0], [1], [2], [5], [4], [3], [0], [1], [3], [2], [5], [4]]).astype('int64') Ids_lod = self.init_lod() - Updates_data = np.random.uniform(0.1, 1.0, [12, 1]).astype('float32') + Updates_data = np.random.uniform(0.1, 1.0, [12, 1]).astype('float64') Updates_lod = Ids_lod Out_data = np.copy(X_data) diff --git a/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py b/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py index eb956484de0b6..0ff8c5330fda6 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py @@ -27,9 +27,9 @@ def setUp(self): self.use_cudnn = False self.init_op_type() - x = np.random.uniform(0.1, 1, (110, 1)).astype("float32") + x = np.random.uniform(0.1, 1, (110, 1)).astype("float64") self.init_lod() - out = np.zeros((110, 1)).astype("float32") + out = np.zeros((110, 1)).astype("float64") offset = 0 for i in range(len(self.lod[0])): if (self.lod[0][i] == 0): 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 c4e4495841d20..3905d7bf3cf00 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py @@ -22,7 +22,7 @@ class TestSequenceUnpadOp(OpTest): def init(self): self.length = [2, 3, 4] self.x_shape = (3, 40) - self.dtype = "float32" + self.dtype = "float64" def compute(self): assert len(self.length) == self.x_shape[0] @@ -58,7 +58,7 @@ class TestSequenceUnpadOp2(TestSequenceUnpadOp): def init(self): self.length = [2, 3, 4] self.x_shape = (3, 5, 4, 3) - self.dtype = "float32" + self.dtype = "float64" class TestSequenceUnpadOp3(TestSequenceUnpadOp): diff --git a/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py b/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py index ec10b634091fc..e1f7e9c03f2d5 100644 --- a/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py +++ b/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py @@ -33,9 +33,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, (batch_size, num_classes)) - .astype("float32")), + .astype("float64")), 'Label': np.random.randint(0, 2, (batch_size, num_classes)) - .astype("float32") + .astype("float64") } # Fw Pass is implemented as elementwise sigmoid followed by @@ -65,9 +65,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, (batch_size, num_classes)) - .astype("float32")), + .astype("float64")), 'Label': np.random.randint(-1, 2, (batch_size, num_classes)) - .astype("float32") + .astype("float64") } self.attrs = {'ignore_index': ignore_index, } # Fw Pass is implemented as elementwise sigmoid followed by @@ -98,9 +98,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, (batch_size, num_classes)) - .astype("float32")), + .astype("float64")), 'Label': np.random.uniform(0, 1, (batch_size, num_classes)) - .astype("float32") + .astype("float64") } # Fw Pass is implemented as elementwise sigmoid followed by @@ -127,9 +127,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, (batch_size, num_classes)) - .astype("float32")), + .astype("float64")), 'Label': np.random.randint(-1, 2, (batch_size, num_classes)) - .astype("float32") + .astype("float64") } self.attrs = {'ignore_index': ignore_index, 'normalize': True} sigmoid_X = expit(self.inputs['X']) @@ -160,9 +160,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, tuple(batch_size + [num_classes])) - .astype("float32")), + .astype("float64")), 'Label': np.random.uniform(0, 1, tuple(batch_size + [num_classes])) - .astype("float32") + .astype("float64") } # Fw Pass is implemented as elementwise sigmoid followed by @@ -189,9 +189,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, tuple(batch_size + [num_classes])) - .astype("float32")), + .astype("float64")), 'Label': np.random.randint(-1, 2, tuple(batch_size + [num_classes])) - .astype("float32") + .astype("float64") } self.attrs = {'ignore_index': ignore_index, 'normalize': True} sigmoid_X = expit(self.inputs['X']) @@ -222,9 +222,9 @@ def setUp(self): self.inputs = { 'X': logit( np.random.uniform(0, 1, tuple(batch_size + [num_classes])) - .astype("float32")), + .astype("float64")), 'Label': np.random.randint(0, 2, tuple(batch_size + [num_classes])) - .astype("float32") + .astype("float64") } # Fw Pass is implemented as elementwise sigmoid followed by diff --git a/python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py b/python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py index 0e846521d0a88..1ab9770df1a8e 100644 --- a/python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py +++ b/python/paddle/fluid/tests/unittests/test_sigmoid_focal_loss_op.py @@ -65,7 +65,7 @@ def setUp(self): self.set_argument() dims = (self.num_anchors, self.num_classes) - X = np.random.standard_normal(dims).astype("float32") + X = np.random.standard_normal(dims).astype("float64") L = np.random.randint(0, self.num_classes + 1, (dims[0], 1)).astype("int32") F = np.zeros(1) @@ -85,7 +85,7 @@ def setUp(self): loss = sigmoid_focal_loss_forward( self.inputs['X'], self.inputs['Label'], self.inputs['FgNum'], self.gamma, self.alpha, self.num_classes) - self.outputs = {'Out': loss.astype('float32')} + self.outputs = {'Out': loss.astype('float64')} def test_check_output(self): self.check_output() diff --git a/python/paddle/fluid/tests/unittests/test_sign_op.py b/python/paddle/fluid/tests/unittests/test_sign_op.py index 0ff348d0de679..96718ab458d0b 100644 --- a/python/paddle/fluid/tests/unittests/test_sign_op.py +++ b/python/paddle/fluid/tests/unittests/test_sign_op.py @@ -25,7 +25,7 @@ class TestSignOp(OpTest): def setUp(self): self.op_type = "sign" self.inputs = { - 'X': np.random.uniform(-10, 10, (10, 10)).astype("float32") + 'X': np.random.uniform(-10, 10, (10, 10)).astype("float64") } self.outputs = {'Out': np.sign(self.inputs['X'])} diff --git a/python/paddle/fluid/tests/unittests/test_slice_op.py b/python/paddle/fluid/tests/unittests/test_slice_op.py index 3f51d433344f3..95ea757a91636 100644 --- a/python/paddle/fluid/tests/unittests/test_slice_op.py +++ b/python/paddle/fluid/tests/unittests/test_slice_op.py @@ -37,7 +37,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [3, 3, 4] self.axes = [0, 1, 2] @@ -53,7 +53,7 @@ def test_check_grad_normal(self): class TestCase1(TestSliceOp): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [-3, 0, 2] self.ends = [3, 100, -1] self.axes = [0, 1, 2] @@ -63,7 +63,7 @@ def config(self): class TestCase2(TestSliceOp): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [-3, 0, 2] self.ends = [3, 100, -1] self.axes = [0, 1, 3] @@ -87,7 +87,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [2, 3, 4] self.axes = [0, 1, 2] @@ -104,7 +104,7 @@ def test_check_grad_normal(self): class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [2, 1, 4] self.axes = [0, 1, 2] @@ -115,7 +115,7 @@ def config(self): class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [-1, 0, 2] self.ends = [1000000, 1, 4] self.axes = [0, 1, 2] @@ -126,7 +126,7 @@ def config(self): class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim): def config(self): - self.input = np.random.random([3, 4, 5, 7]).astype("float32") + self.input = np.random.random([3, 4, 5, 7]).astype("float64") self.starts = [0, 1, 2, 3] self.ends = [1, 2, 3, 4] self.axes = [0, 1, 2, 3] @@ -137,7 +137,7 @@ def config(self): class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [-1] self.ends = [1000000] self.axes = [3] @@ -148,7 +148,7 @@ def config(self): class TestSliceOp_decs_dim_6(TestSliceOp_decs_dim): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [0, 1, 2, 3] self.ends = [1, 2, 3, 4] self.axes = [0, 1, 2, 3] @@ -179,7 +179,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [3, 3, 4] self.axes = [0, 1, 2] @@ -219,7 +219,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [2, 3, 4] self.axes = [0, 1, 2] @@ -239,7 +239,7 @@ def test_check_grad_normal(self): class TestSliceOp_decs_dim_5_starts_ListTensor( TestSliceOp_decs_dim_starts_ListTensor): def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [-1] self.ends = [1000000] self.axes = [3] @@ -271,7 +271,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [2, 3, 4] self.axes = [0, 1, 2] @@ -309,7 +309,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [3, 3, 4] self.axes = [0, 1, 2] @@ -346,7 +346,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [2, 1, 4] self.axes = [0, 1, 2] @@ -388,7 +388,7 @@ def setUp(self): } def config(self): - self.input = np.random.random([3, 4, 5, 6]).astype("float32") + self.input = np.random.random([3, 4, 5, 6]).astype("float64") self.starts = [1, 0, 2] self.ends = [3, 3, 4] self.axes = [0, 1, 2] @@ -483,7 +483,7 @@ def test_check_grad_normal(self): # Test python API class TestSliceAPI(unittest.TestCase): def test_1(self): - input = np.random.random([3, 4, 5, 6]).astype("float32") + input = np.random.random([3, 4, 5, 6]).astype("float64") minus_1 = fluid.layers.fill_constant([1], "int32", -1) minus_3 = fluid.layers.fill_constant([1], "int32", -3) starts = fluid.layers.data( @@ -495,7 +495,7 @@ def test_1(self): name="x", shape=[3, 4, 5, 6], append_batch_size=False, - dtype="float32") + dtype="float64") out_1 = fluid.layers.slice( x, axes=[0, 1, 2], starts=[-3, 0, 2], ends=[3, 100, -1]) diff --git a/python/paddle/fluid/tests/unittests/test_softmax_op.py b/python/paddle/fluid/tests/unittests/test_softmax_op.py index 71d6215f72b89..e36d35fef012c 100644 --- a/python/paddle/fluid/tests/unittests/test_softmax_op.py +++ b/python/paddle/fluid/tests/unittests/test_softmax_op.py @@ -42,7 +42,7 @@ def setUp(self): self.op_type = "softmax" self.use_cudnn = False self.use_mkldnn = False - self.dtype = np.float32 + self.dtype = np.float64 self.init_kernel_type() self.shape = self.get_x_shape() self.axis = self.get_axis() diff --git a/python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py b/python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py index 4db3e4d94642e..ce28253491c50 100644 --- a/python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py +++ b/python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py @@ -126,7 +126,7 @@ def setUp(self): # NOTE: numpy float16 have very low accuracy, use float32 for numpy check. logits = getattr( self, "logits", - np.random.uniform(0.1, 1.0, self.shape).astype(np.float32)) + np.random.uniform(0.1, 1.0, self.shape).astype(np.float64)) softmax = np.apply_along_axis(stable_softmax, self.axis, logits) axis_dim = self.shape[self.axis] @@ -425,7 +425,7 @@ def initParams(self): self.shape = [3, 5, 7, 11] self.axis = -1 self.ignore_index = -1 - self.dtype = np.float32 + self.dtype = np.float64 self.logits = np.full(self.shape, -500.0).astype(self.dtype) @@ -442,7 +442,7 @@ def initParams(self): self.shape = [3, 5, 7, 11] self.axis = -1 self.ignore_index = -1 - self.dtype = np.float32 + self.dtype = np.float64 self.logits = np.full(self.shape, 1000.0).astype(self.dtype) self.logits[:, :, 0, :] = -1000.0 diff --git a/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py b/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py index 5fdad44f1242b..75e1c16231c88 100644 --- a/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py +++ b/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py @@ -58,9 +58,9 @@ def init_data(self): self.one_d_len = 32 * 48 * 3 * 3 self.blocksize = 2 - self.x = np.random.random(self.ori_shape).astype('float32') + self.x = np.random.random(self.ori_shape).astype('float64') self.x_1d = np.reshape(self.x, self.one_d_len) - self.out = np.zeros(self.infered_shape).astype('float32') + self.out = np.zeros(self.infered_shape).astype('float64') self.out_1d = np.reshape(self.out, self.one_d_len) self.forward = 1 @@ -82,9 +82,9 @@ def init_data(self): self.one_d_len = 32 * 32 * 3 * 3 self.blocksize = 2 - self.x = np.random.random(self.ori_shape).astype('float32') + self.x = np.random.random(self.ori_shape).astype('float64') self.x_1d = np.reshape(self.x, self.one_d_len) - self.out = np.zeros(self.infered_shape).astype('float32') + self.out = np.zeros(self.infered_shape).astype('float64') self.out_1d = np.reshape(self.out, self.one_d_len) self.forward = 1 @@ -110,9 +110,9 @@ def init_data(self): self.one_d_len = 32 * 81 * 2 * 2 self.blocksize = 3 - self.x = np.random.random(self.ori_shape).astype('float32') + self.x = np.random.random(self.ori_shape).astype('float64') self.x_1d = np.reshape(self.x, self.one_d_len) - self.out = np.zeros(self.infered_shape).astype('float32') + self.out = np.zeros(self.infered_shape).astype('float64') self.out_1d = np.reshape(self.out, self.one_d_len) self.forward = 1 @@ -124,9 +124,9 @@ def init_data(self): self.one_d_len = 32 * 81 * 3 * 2 self.blocksize = 3 - self.x = np.random.random(self.ori_shape).astype('float32') + self.x = np.random.random(self.ori_shape).astype('float64') self.x_1d = np.reshape(self.x, self.one_d_len) - self.out = np.zeros(self.infered_shape).astype('float32') + self.out = np.zeros(self.infered_shape).astype('float64') self.out_1d = np.reshape(self.out, self.one_d_len) self.forward = 1 diff --git a/python/paddle/fluid/tests/unittests/test_spectral_norm_op.py b/python/paddle/fluid/tests/unittests/test_spectral_norm_op.py index e38a3f22fef55..104df2efed0f5 100644 --- a/python/paddle/fluid/tests/unittests/test_spectral_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_spectral_norm_op.py @@ -49,9 +49,9 @@ class TestSpectralNormOpNoGrad(OpTest): def setUp(self): self.initTestCase() self.op_type = 'spectral_norm' - weight = np.random.random(self.weight_shape).astype('float32') - u = np.random.normal(0., 1., self.u_shape).astype('float32') - v = np.random.normal(0., 1., self.v_shape).astype('float32') + weight = np.random.random(self.weight_shape).astype('float64') + u = np.random.normal(0., 1., self.u_shape).astype('float64') + v = np.random.normal(0., 1., self.v_shape).astype('float64') self.attrs = { "dim": self.dim, diff --git a/python/paddle/fluid/tests/unittests/test_split_op.py b/python/paddle/fluid/tests/unittests/test_split_op.py index ef86ba7f8891d..714843bb8b215 100644 --- a/python/paddle/fluid/tests/unittests/test_split_op.py +++ b/python/paddle/fluid/tests/unittests/test_split_op.py @@ -34,7 +34,7 @@ def setUp(self): for i in range(len(out))]} def get_dtype(self): - return "float32" + return "float64" def _set_op_type(self): self.op_type = "split" @@ -71,7 +71,7 @@ def init_data(self): self.indices_or_sections = 3 def get_dtype(self): - return "float32" + return "float64" def _set_op_type(self): self.op_type = "split" @@ -107,7 +107,7 @@ def init_data(self): self.indices_or_sections = 3 def get_dtype(self): - return "float32" + return "float64" def _set_op_type(self): self.op_type = "split" @@ -153,7 +153,7 @@ def init_data(self): self.indices_or_sections = [2, 3] def get_dtype(self): - return "float32" + return "float64" def _set_op_type(self): self.op_type = "split" @@ -189,7 +189,7 @@ def init_data(self): self.indices_or_sections = [2, 3] def get_dtype(self): - return "float32" + return "float64" def _set_op_type(self): self.op_type = "split" diff --git a/python/paddle/fluid/tests/unittests/test_spp_op.py b/python/paddle/fluid/tests/unittests/test_spp_op.py index 1864ca82e2d0e..ad077236c82cf 100644 --- a/python/paddle/fluid/tests/unittests/test_spp_op.py +++ b/python/paddle/fluid/tests/unittests/test_spp_op.py @@ -25,7 +25,7 @@ class TestSppOp(OpTest): def setUp(self): self.op_type = "spp" self.init_test_case() - input = np.random.random(self.shape).astype("float32") + input = np.random.random(self.shape).astype("float64") nsize, csize, hsize, wsize = input.shape out_level_flatten = [] for i in range(self.pyramid_height): @@ -50,13 +50,13 @@ def setUp(self): else: output = np.concatenate((output, out_level_flatten[i]), 1) # output = np.concatenate(out_level_flatten.tolist(), 0); - self.inputs = {'X': input.astype('float32'), } + self.inputs = {'X': input.astype('float64'), } self.attrs = { 'pyramid_height': self.pyramid_height, 'pooling_type': self.pool_type } - self.outputs = {'Out': output.astype('float32')} + self.outputs = {'Out': output.astype('float64')} def test_check_output(self): self.check_output()