mindspore.ops.InplaceSub

class mindspore.ops.InplaceSub(indices)[源代码]

x 的特定行减去 input_v 。即计算 \(y = x\); \(y[i,] -= input\_v\)

更多参考详见 mindspore.ops.inplace_sub()

支持平台:

Ascend CPU

样例:

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> indices = (0, 1)
>>> x = Tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32)
>>> input_v = Tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32)
>>> inplaceSub = ops.InplaceSub(indices)
>>> output = inplaceSub(x, input_v)
>>> print(output)
[[0.5 1. ]
 [2.  2.5]
 [5.  6. ]]