torch.sub
- torch.sub(input, other, *, alpha=1, out=None) → Tensor
-
从
input
中减去按alpha
缩放后的other
。$\text{{out}}_i = \text{{input}}_i - \text{{alpha}} \times \text{{other}}_i$- 参数
- 关键字参数
-
-
alpha (Number) – 用于表示
other
的乘数值。 -
out (Tensor, 可选) – 指定输出张量。
-
示例:
>>> a = torch.tensor((1, 2)) >>> b = torch.tensor((0, 1)) >>> torch.sub(a, b, alpha=2) tensor([1, 0])