mindspore.ops.subtract
- mindspore.ops.subtract(x, other, *, alpha=1)[source]
Performs the element-wise subtraction of input tensors.
\[output[i] = x[i] - alpha * y[i]\]- Parameters
- Keyword Arguments
alpha (Number) – The multiplier for other. Default: 1.
- Returns
Tensor, has the same shape and dtype as input tensors.
- Raises
TypeError – x or other is neither Tensor nor number.Number.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([4, 5, 6]), mindspore.float32) >>> y = Tensor(np.array([1, 2, 3]), mindspore.float32) >>> z = ops.subtract(x, y, alpha=1) >>> print(z) [3. 3. 3.]