mindspore.ops.subtract

View Source On Gitee
mindspore.ops.subtract(input, other, *, alpha=1)[source]

Subtract other scaled by alpha from input.

Support implicit type conversion and type promotion.

output[i]=input[i]alphaother[i]
Parameters
  • input (Union[Tensor, number.Number]) – The first input.

  • other (Union[Tensor, number.Number]) – The second input.

Keyword Arguments

alpha (number) – The multiplier for other. Default 1 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([4, 5, 6], mindspore.float32)
>>> y = mindspore.tensor([1, 2, 3], mindspore.float32)
>>> z = mindspore.ops.subtract(input, y, alpha=1)
>>> print(z)
[3. 3. 3.]