mindspore2022/docs/api/api_python/ops/mindspore.ops.Ones.rst

21 lines
572 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.ops.Ones
===================
.. py:class:: mindspore.ops.Ones
创建一个值全为1的Tensor。
第一个参数指定Tensor的shape第二个参数指定填充值的数据类型。
**输入:**
- **shape** (Union[tuple[int], int]) - 指定输出Tensor的shape只能是正整数常量。
- **type** (mindspore.dtype) - 指定输出Tensor的数据类型只能是常量值。
**输出:**
Tensorshape和数据类型与输入相同。
**异常:**
- **TypeError** - `shape` 既不是tuple也不是int。