Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.sub function

PyTorch torch.sub function


PyTorch torch reference manual 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

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual