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()