mindspore.ops.fill

查看源文件
mindspore.ops.fill(type, shape, value)[源代码]

创建tensor,用指定值填充。

参数:
  • type (mindspore.dtype) - 指定的数据类型。

  • shape (Union(Tensor, tuple[int])) - 指定的shape。

  • value (Union(Tensor, number.Number, bool)) - 指定值。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> mindspore.ops.fill(mindspore.float32, (2, 3),  1.2)
Tensor(shape=[2, 3], dtype=Float32, value=
[[ 1.20000005e+00,  1.20000005e+00,  1.20000005e+00],
 [ 1.20000005e+00,  1.20000005e+00,  1.20000005e+00]])