2022-04-16 17:16:29 +08:00
|
|
|
|
mindspore.ops.ones
|
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:function:: mindspore.ops.ones(shape, type)
|
|
|
|
|
|
|
|
|
|
|
|
创建一个值全为1的Tensor。
|
|
|
|
|
|
|
|
|
|
|
|
第一个参数指定Tensor的shape,第二个参数指定填充值的数据类型。
|
|
|
|
|
|
|
2022-07-25 17:18:38 +08:00
|
|
|
|
参数:
|
|
|
|
|
|
- **shape** (Union[tuple[int], int]) - 指定输出Tensor的shape,只能是正整数常量。
|
|
|
|
|
|
- **type** (mindspore.dtype) - 指定输出Tensor的数据类型,只能是常量值。
|
2022-04-16 17:16:29 +08:00
|
|
|
|
|
2022-07-25 17:18:38 +08:00
|
|
|
|
返回:
|
|
|
|
|
|
Tensor,shape和数据类型与输入相同。
|
2022-04-16 17:16:29 +08:00
|
|
|
|
|
2022-07-25 17:18:38 +08:00
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - `shape` 既不是tuple,也不是int。
|