diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index fc4fe296d08dc6d1c9a5ee4ebb58ab6d2b420a94..fb199ede4e4eb756021d2396755f3a236adf9bee 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -207,7 +207,7 @@ def ones(shape, dtype=None, out=None, device=None): import paddle data = paddle.ones(shape=[3, 2], dtype='float32') # [[1., 1.], [1., 1.], [1., 1.]] - data = paddle.ones(shape=[2, 2], dtype='float32', device='cpu') # [[1., 1.], [1., 0.]] + data = paddle.ones(shape=[2, 2], dtype='float32', device='cpu') # [[1., 1.], [1., 1.]] """ check_dtype(dtype, 'create data type', ['bool', 'float16', 'float32', 'float64', 'int32', 'int64'], @@ -247,7 +247,7 @@ def ones_like(input, dtype=None, device=None, name=None): import paddle import paddle.fluid as fluid - x = fluid.layers.data(name='x', dtype='float32', shape=[3], append_batch_size=False) + x = fluid.data(name='x', dtype='float32', shape=[3]) data = paddle.ones_like(x) # data=[1.0, 1.0, 1.0] data1 = paddle.ones_like(input=x, device="gpu") data1=[1.0, 1.0. 1.0] @@ -354,9 +354,9 @@ def zeros_like(input, dtype=None, device=None, name=None): import paddle import paddle.fluid as fluid - x = fluid.layers.data(name='x', dtype='float32', shape=[3], append_batch_size=False) + x = fluid.data(name='x', dtype='float32', shape=[3]) data = paddle.ones_like(x) # data=[1.0, 1.0, 1.0] - data1 = paddle.ones_like(input=x, device="gpu") data1=[1.0, 1.0. 1.0] + data1 = paddle.ones_like(input=x, device="gpu") #data1=[1.0, 1.0. 1.0] """ diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index d23c474d3077322695a99ed3359bb01ccc6d8d48..aade3e87a567210df1ad13185fcbee7a7ba7899a 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -96,6 +96,7 @@ def matmul(x, y, transpose_x=False, transpose_y=False, alpha=1.0, name=None): # x: [M], y: [N] # paddle.matmul(x, y, True, True) # out: [M, N] + import paddle import paddle.fluid as fluid x = fluid.data(name='x', shape=[2, 3], dtype='float32') y = fluid.data(name='y', shape=[3, 2], dtype='float32') diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 2b4623cae2c8a73a8f6f935851f8ecab1515dd0c..71de0b7284ad8180eacb565d416021fcb4b4feb5 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -168,18 +168,19 @@ def pow(input, exponent, out=None, name=None): .. code-block:: python import paddle + import paddle.fluid as fluid - x = paddle.fluid.data(name="x", shape=[32,32], dtype="float32") + x = fluid.data(name="x", shape=[32,32], dtype="float32") # example 1: argument exponent is float - res = paddle.fluid.data(name="output", shape=[32,32], dtype="float32") + res = fluid.data(name="output", shape=[32,32], dtype="float32") y_1 = paddle.pow(x, 2.0, out=res) # y_1 is x^{2.0} # example 2: argument exponent is Variable exponet_tensor = fluid.layers.fill_constant([1], "float32", 3.0) - res = paddle.fluid.data(name="output", shape=[32,32], dtype="float32") - y_2 = paddle.pow(x, exponent_tensor, out=res) + res = fluid.data(name="output", shape=[32,32], dtype="float32") + y_2 = paddle.pow(x, exponet_tensor, out=res) # y_2 is x^{3.0} """ helper = LayerHelper('pow', **locals()) @@ -254,10 +255,11 @@ def mul(x, y, x_num_col_dims=1, y_num_col_dims=1, out=None, name=None): .. code-block:: python import paddle - dataX = paddle.fluid.data(name="dataX", append_batch_size = False, shape=[2, 5], dtype="float32") - dataY = paddle.fluid.data(name="dataY", append_batch_size = False, shape=[5, 3], dtype="float32") + import paddle.fluid as fluid + dataX = fluid.data(name="dataX", shape=[2, 5], dtype="float32") + dataY = fluid.data(name="dataY", shape=[5, 3], dtype="float32") - res = paddle.fluid.data(name="output", append_batch_size = False, shape=[2, 3], dtype="float32") + res = fluid.data(name="output", shape=[2, 3], dtype="float32") output = paddle.mul(dataX, dataY, x_num_col_dims = 1, y_num_col_dims = 1,