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

PyTorch torch.not_equal function

PyTorch torch.not_equal function


PyTorch torch reference manual PyTorch torch reference manual

torch.not_equal is a function in PyTorch for element-wise "not equal" comparison. It returns a tensor that is True where each element of the first tensor is not equal to the corresponding element of the second tensor.

Function definition

torch.not_equal(input, other)


Usage examples

Example

import

torch

Create two tensors

x

=

torch.

tensor

(

[

1

,

2

,

3

]

)

y

=

torch.

tensor

(

[

1

,

4

,

3

]

)

Element-wise not-equal comparison

result

=

torch.

not_equal

(

x

,

y

)

print

(

result

)

The output is:

tensor([False, True, False])


PyTorch torch reference manual PyTorch torch reference manual