mindspore/docs/api/api_python/mint/mindspore.mint.func_ones.rst

20 lines
914 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.mint.ones
====================
.. py:function:: mindspore.mint.ones(size, *, dtype=None)
创建一个值全为1的Tensor。第一个参数 `size` 指定Tensor的shape第二个参数 `dtype` 指定填充值的数据类型。
参数:
- **size** (Union[tuple[int], list[int], int, Tensor]) - 指定输出Tensor的shape只允许正整数或者包含正整数的tupled、list、Tensor。
如果是一个Tensor必须是一个数据类型为int32或者int64的0-D或1-D Tensor。
关键字参数:
- **dtype** (:class:`mindspore.dtype`, 可选) - 用来描述所创建的Tensor的dtype。如果为 ``None`` 那么将会使用mindspore.float32。默认值 ``None``
返回:
Tensorshape和dtype由输入定义。
异常:
- **TypeError** - 如果 `size` 不是一个int或元素为int的元组、列表、Tensor。