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

18 lines
638 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:function:: mindspore.ops.ones(shape, dtype=None)
创建一个值全为1的Tensor。
第一个参数指定Tensor的shape第二个参数指定填充值的数据类型。
参数:
- **shape** (Union[tuple[int], int]) - 指定输出Tensor的shape。
- **dtype** (:class:`mindspore.dtype`) - 用来描述所创建的Tensor的 `dtype`。如果为None那么将会使用mindspore.float32。默认值None。
返回:
Tensorshape和数据类型与输入相同。
异常:
- **TypeError** - `shape` 既不是tuple也不是int。