未验证 提交 ff1789ca 编写于 作者: B BrilliantYuKaimin 提交者: GitHub

Update creation.py (#42915)

上级 2aea0db8
...@@ -482,19 +482,20 @@ def full_like(x, fill_value, dtype=None, name=None): ...@@ -482,19 +482,20 @@ def full_like(x, fill_value, dtype=None, name=None):
def ones(shape, dtype=None, name=None): def ones(shape, dtype=None, name=None):
""" """
The OP creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 1. Create a Tensor of specified :attr:`shape` and :attr:`dtype` and fill it with 1.
Args: Args:
shape(tuple|list|Tensor): Shape of the Tensor to be created, the data type of shape is int32 or int64. shape (tuple|list|Tensor): Shape of the Tensor to be created, the data type of shape should be int32 or int64.
dtype(np.dtype|str, optional): Data type of output Tensor, it supports dtype (np.dtype|str, optional): Data type of output Tensor, it should be one of
bool, float16, float32, float64, int32 and int64. Default: if None, the data type is 'float32'. bool, float16, float32, float64, int32 and int64. If it is set to None, the data type will be 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` name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns: Returns:
Tensor: A tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 1. Tensor: A Tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements are 1.
Examples: Examples:
.. code-block:: python .. code-block:: python
:name: ones-example
import paddle import paddle
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册