PyTorch torch.sub function
PyTorch torch reference manual
torch.sub is a function in PyTorch used to perform element-wise subtraction.
Function definition
torch.sub(input, other, out=None)
Usage examples
Example
import
torch
Element-wise subtraction
x
=
torch.
tensor
(
[
5.0
,
6.0
,
7.0
]
)
y
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
result
=
torch.
sub
(
x
,
y
)
(
result
)