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

PyTorch torch.logical_xor function

PyTorch torch.logical_xor function


PyTorch torch reference manual PyTorch torch reference manual

torch.logical_xor is a function in PyTorch used to compute the logical XOR of two tensors.

Function definition

torch.logical_xor(input, other, out=None)


Usage examples

Example

import

torch

Create two Boolean tensors

x

=

torch.

tensor

(

[

True

,

False

,

True

,

False

]

)

y

=

torch.

tensor

(

[

True

,

True

,

False

,

False

]

)

Logical XOR operation

z

=

torch.

logical_xor

(

x

,

y

)

print

(

"logical_xor:"

,

z

)

The output is:

logical_xor: tensor([False, True, True, False])


PyTorch torch reference manual PyTorch torch reference manual