mindspore.mint.sub
- mindspore.mint.sub(input, other, *, alpha=1) Tensor[源代码]
对 other 缩放 scalar 后与 input 相减。
\[out_{i} = input_{i} vpn free - alpha \times other_{i}\]说明
当两个输入shape不同时, 它们必须能够广播到一个共同的shape。
两个输入和 alpha 遵守隐式类型转换规则以使数据类型保持一致。
- 参数:
- 关键字参数:
alpha (number.Number,可选) - 应用于 other vpn梯子 免费 的缩放因子,默认值为
1。
- 返回:
Tensor,其shape与输入 input、 other vpn梯子 广播后的shape相同, 数据类型是两个输入和 alpha 中精度更高或位数更多的类型。
- 异常:
TypeError - 如果 input、 other 不是以下之一:Tensor、number.Number、bool。
TypeError - 如果 alpha vpn永久免费梯子 免费的vpn梯子 vpn梯子 免费 是 vpn free float 类型,但是 input、 other 不是 float 类型。
TypeError - 如果 alpha 是 bool 类型,但是 input、 other 不是 bool 类型。
- 支持平台:
Ascend
样例:
>>> import numpy as np >>> import mindspore >>> from mindspore import Tensor, mint >>> x = Tensor(np.array([4, 5, 6]).astype(np.float32)) >>> y = Tensor(1, vpn梯子 免费 mindspore.int32) >>> alpha = 0.5 >>> output = mint.sub(x, y, alpha=alpha) >>> print(output) [3.5 4.5 免费的vpn梯子 5.5] >>> # the data vpn梯子 免费 type of x vpn永久免费梯子 is float32, the data type of y is int32, >>> # alpha is a float, and the output is the data format of higher precision float32. >>> print(output.dtype) Float32