diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 26486ef08f71e535a60114fc849af247fc08c971..5113e47528937619b4c78fe372c9707ec3a00c7d 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -12985,8 +12985,8 @@ def expand(x, expand_times, name=None): """ if not isinstance(x, Variable): raise TypeError( - "The type of 'input' in reduce_sum must be Variable, but received %s" - % (type(x))) + "The type of 'input' in expand must be Variable, but received %s" % + (type(x))) if not isinstance(expand_times, (list, tuple, Variable)): raise ValueError( "Input expand_times must be an Variable, python list or tuple.") diff --git a/python/paddle/fluid/tests/unittests/test_accuracy_op.py b/python/paddle/fluid/tests/unittests/test_accuracy_op.py index 33ccecb77b32a8554dfcc95dba8137a58316c3d3..e7152a29e56b3f72f61f19139d2b5ab29fa8f95e 100755 --- a/python/paddle/fluid/tests/unittests/test_accuracy_op.py +++ b/python/paddle/fluid/tests/unittests/test_accuracy_op.py @@ -64,13 +64,13 @@ class TestAccuracyOpError(OpTest): # The input type of accuracy_op must be Variable. x1 = fluid.create_lod_tensor( np.array([[-1]]), [[1]], fluid.CPUPlace()) - self.assertRaises(TypeError, fluid.layers.accuracy, x1) + label = fluid.layers.data( + name='label', shape=[-1, 1], dtype="int32") + self.assertRaises(TypeError, fluid.layers.accuracy, x1, label) # The input dtype of accuracy_op must be float32 or float64. x2 = fluid.layers.data(name='x2', shape=[4], dtype="int32") - self.assertRaises(TypeError, fluid.layers.accuracy, x2) + self.assertRaises(TypeError, fluid.layers.accuracy, x2, label) x3 = fluid.layers.data(name='input', shape=[-1, 2], dtype="float16") - label = fluid.layers.data( - name='label', shape=[-1, 1], dtype="int32") fluid.layers.accuracy(input=x3, label=label) diff --git a/python/paddle/fluid/tests/unittests/test_zeros_op.py b/python/paddle/fluid/tests/unittests/test_zeros_op.py index 62ed6b56c6d6ca2c91da04856572b49832421595..1be2f4d04791b76be014e34e1752caab43157fc7 100644 --- a/python/paddle/fluid/tests/unittests/test_zeros_op.py +++ b/python/paddle/fluid/tests/unittests/test_zeros_op.py @@ -28,10 +28,9 @@ class TestZerosOpError(OpTest): def test_errors(self): with program_guard(Program(), Program()): # The input dtype of zeros_op must be bool, float16, float32, float64, int32, int64. - x1 = fluid.layers.data(name='x1', shape=[4], dtype="int8") - self.assertRaises(TypeError, fluid.layers.zeros, x1) - x2 = fluid.layers.data(name='x2', shape=[4], dtype="uint8") - self.assertRaises(TypeError, fluid.layers.zeros, x2) + shape = [4] + dtype = "int8" + self.assertRaises(TypeError, fluid.layers.zeros, shape, dtype) if __name__ == "__main__":