未验证 提交 07c1c47b 编写于 作者: W wangchaochaohu 提交者: GitHub

refine the doc of OPs (#26551)

上级 57e12429
......@@ -643,7 +643,7 @@ def fill_constant(shape, dtype, value, force_cpu=False, out=None, name=None):
shape(list|tuple|Tensor): Shape of the output Tensor, the data type of ``shape`` is int32 or int64.
If ``shape`` is a list or tuple, the elements of it should be integers or Tensors with shape [1].
If ``shape`` is an Tensor, it should be an 1-D Tensor with date type int32 or int64.
dtype(np.dtype|core.VarDesc.VarType|str): Data type of the output Tensor which can
dtype(np.dtype|str): Data type of the output Tensor which can
be float16, float32, float64, int32, int64.
value(bool|float|int|Tensor): The constant value used to initialize
the Tensor to be created. If ``value`` is an Tensor, it should be an 1-D Tensor.
......@@ -1042,7 +1042,7 @@ def ones(shape, dtype, force_cpu=False):
Parameters:
shape(tuple|list|Tensor): Shape of output Tensor, the data type of shape is int32 or int64.
dtype (np.dtype|core.VarDesc.VarType|str): Data type of output Tensor, it supports
dtype (np.dtype|str): Data type of output Tensor, it supports
bool, float16, float32, float64, int32 and int64.
force_cpu (bool, optional): Whether force to store the output Tensor in CPU memory.
If :attr:`force_cpu` is False, the output Tensor will be stored in running device memory.
......@@ -1075,7 +1075,7 @@ def zeros(shape, dtype, force_cpu=False, name=None):
Parameters:
shape(tuple|list|Tensor): Shape of output Tensor, the data type of ``shape`` is int32 or int64.
dtype (np.dtype|core.VarDesc.VarType|str): Data type of output Tensor, it supports
dtype (np.dtype|str): Data type of output Tensor, it supports
bool, float16, float32, float64, int32 and int64.
force_cpu (bool, optional): Whether force to store the output Tensor in CPU memory.
If :attr:`force_cpu` is False, the output Tensor will be stored in running device memory.
......@@ -1443,7 +1443,7 @@ def linspace(start, stop, num, dtype=None, name=None):
or a Tensor of shape [1] with input data type int32, int64, float32 or float64.
num(int|Tensor): The input :attr:`num` is given num of the sequence. It is an int scalar, \
or a Tensor of shape [1] with data type int32 or int64.
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of output tensor, it could be
dtype(np.dtype|str, optional): The data type of output tensor, it could be
int32, int64, float32 and float64. Default: if None, the data type is float32.
name(str, optional): Normally there is no need for user to set this property.
For more information, please refer to :ref:`api_guide_Name`.Default: None.
......@@ -1620,7 +1620,7 @@ def eye(num_rows,
If None, default: num_rows.
batch_shape(list, optional): If provided, the returned tensor will have a leading
batch size of this shape, the data type of ``batch_shape`` is int. Default is None.
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of the returned tensor.
dtype(np.dtype|str, optional): The data type of the returned tensor.
It should be int32, int64, float16, float32, float64, default is 'float32'.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
......
......@@ -221,8 +221,6 @@ def to_tensor(data, dtype=None, place=None, stop_gradient=True):
def full_like(x, fill_value, dtype=None, name=None):
"""
:alias_main: paddle.full_like
:alias: paddle.tensor.full_like, paddle.tensor.creation.full_like
This function creates a tensor filled with ``fill_value`` which has identical shape of ``x`` and ``dtype``.
If the ``dtype`` is None, the data type of Tensor is same with ``x``.
......@@ -230,7 +228,7 @@ def full_like(x, fill_value, dtype=None, name=None):
Args:
x(Tensor): The input tensor which specifies shape and data type. The data type can be bool, float16, float32, float64, int32, int64.
fill_value(bool|float|int): The value to fill the tensor with. Note: this value shouldn't exceed the range of the output data type.
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of output. The data type can be one
dtype(np.dtype|str, optional): The data type of output. The data type can be one
of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
data type is the same as input.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
......@@ -285,14 +283,12 @@ def full_like(x, fill_value, dtype=None, name=None):
def ones(shape, dtype=None, name=None):
"""
:alias_main: paddle.ones
:alias: paddle.tensor.ones, paddle.tensor.creation.ones
The OP creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 1.
Args:
shape(tuple|list|Tensor): Shape of the Tensor to be created, the data type of shape is int32 or int64.
dtype(np.dtype|core.VarDesc.VarType|str, optional): Data type of output Tensor, it supports
dtype(np.dtype|str, optional): Data type of output Tensor, it supports
bool, float16, float32, float64, int32 and int64. Default: if None, the data type is 'float32'.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
......@@ -376,14 +372,11 @@ def ones_like(x, dtype=None, name=None):
def zeros(shape, dtype=None, name=None):
"""
:alias_main: paddle.zeros
:alias: paddle.tensor.zeros, paddle.tensor.creation.zeros
The OP creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 0.
Args:
shape(tuple|list|Tensor): Shape of the Tensor to be created, the data type of ``shape`` is int32 or int64.
dtype(np.dtype|core.VarDesc.VarType|str, optional): Data type of output Tensor, it supports
dtype(np.dtype|str, optional): Data type of output Tensor, it supports
bool, float16, float32, float64, int32 and int64. Default: if None, the date type is float32.
name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`.
......@@ -466,8 +459,6 @@ def zeros_like(x, dtype=None, name=None):
def eye(num_rows, num_columns=None, dtype=None, name=None):
"""
:alias_main: paddle.eye
:alias: paddle.tensor.eye, paddle.tensor.creation.eye
This function constructs 2-D Tensor with ones on the diagonal and zeros elsewhere.
......@@ -475,7 +466,7 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
num_rows(int): the number of rows in each batch Tensor.
num_columns(int, optional): the number of columns in each batch Tensor.
If None, default: num_rows.
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of the returned Tensor.
dtype(np.dtype|str, optional): The data type of the returned Tensor.
It should be int32, int64, float16, float32, float64. Default: if None, the data type
is float32.
name(str, optional): The default value is None. Normally there is no need for
......@@ -516,8 +507,6 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
def full(shape, fill_value, dtype=None, name=None):
"""
:alias_main: paddle.full
:alias: paddle.tensor.full, paddle.tensor.creation.full
This Op return a Tensor with the ``fill_value`` which size is same as ``shape``.
......@@ -528,7 +517,7 @@ def full(shape, fill_value, dtype=None, name=None):
If ``shape`` is an Tensor, it should be an 1-D Tensor .
fill_value(bool|float|int|Tensor): The constant value
used to initialize the Tensor to be created. If ``fill_value`` is an Tensor, it must be an 1-D Tensor.
dtype(np.dtype|core.VarDesc.VarType|str, optional): Data type of the output Tensor
dtype(np.dtype|str, optional): Data type of the output Tensor
which can be float16, float32, float64, int32, int64, if dytpe is `None`, the data
type of created Tensor is `float32`
name(str, optional): The default value is None. Normally there is no need for user to set this
......
......@@ -110,9 +110,9 @@ def concat(x, axis=0, name=None):
[14, 15, 16]])
in3 = np.array([[21, 22],
[23, 24]])
x1 = paddle.to_variable(in1)
x2 = paddle.to_variable(in2)
x3 = paddle.to_variable(in3)
x1 = paddle.to_tensor(in1)
x2 = paddle.to_tensor(in2)
x3 = paddle.to_tensor(in3)
zero = paddle.full(shape=[1], dtype='int32', fill_value=0)
# When the axis is negative, the real axis is (axis + Rank(x))
# As follow, axis is -1, Rank(x) is 2, the real axis is 1
......@@ -506,7 +506,7 @@ def split(x, num_or_sections, axis=0, name=None):
paddle.disable_static()
# x is a Tensor which shape is [3, 9, 5]
x_np = np.random.random([3, 9, 5]).astype("int32")
x = paddle.to_variable(x_np)
x = paddle.to_tensor(x_np)
out0, out1, out22 = paddle.split(x, num_or_sections=3, axis=1)
# out0.shape [3, 3, 5]
......
......@@ -255,8 +255,8 @@ def index_select(x, index, axis=0, name=None):
[9.0, 10.0, 11.0, 12.0]])
data_index = np.array([0, 1, 1]).astype('int32')
x = paddle.to_variable(data)
index = paddle.to_variable(data_index)
x = paddle.to_tensor(data)
index = paddle.to_tensor(data_index)
out_z1 = paddle.index_select(x=x, index=index)
#[[1. 2. 3. 4.]
# [5. 6. 7. 8.]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册