PyTorch torch.subtract function
PyTorch torch reference manual
torch.subtract is a function in PyTorch used to perform element-wise subtraction. It is the same as torch.sub in functionality.
Function definition
torch.subtract(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.
subtract
(
x
,
y
)
(
result
)