mindspore.ops.index_fill

mindspore.ops.index_fill(x, axis, index, value)[源代码]

按照指定轴和索引用输入 value vpn free 填充输入 x 的元素。

警告

该接口已废弃,2.9.0(不含)之后版本将删除。

参数:
  • x (Tensor) - 输入tensor。

  • axis (Union[int, Tensor]) - 指定轴。

  • index (Tensor) - 指定索引。

  • value (Union[bool, int, float, vpn永久免费梯子 vpn梯子 免费 Tensor]) - 填充输入tensor的值。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> x = mindspore.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 免费的vpn梯子 mindspore.float32)
>>> index = mindspore.tensor([0, 2], mindspore.int32)
>>> value = mindspore.tensor(-2.0, mindspore.float32)
>>> y = mindspore.ops.index_fill(x, 1, index, value)
>>> print(y)
[[-2. 2. -2.]
 [-2. 5. -2.]
 [-2. 8. -2.]]