On this page
torch.sub
torch.sub(input, other, *, alpha=1, out=None) → Tensor
-
Subtracts
other
, scaled byalpha
, frominput
.Supports broadcasting to a common shape, type promotion, and integer, float, and complex inputs.
- Parameters
- Keyword Arguments
-
- alpha (Number) – the multiplier for
other
. - out (Tensor, optional) – the output tensor.
- alpha (Number) – the multiplier for
Example:
>>> a = torch.tensor((1, 2)) >>> b = torch.tensor((0, 1)) >>> torch.sub(a, b, alpha=2) tensor([1, 0])
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.sub.html