PyTorch torch.logical_xor function
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
)
(
"logical_xor:"
,
z
)
The output is:
logical_xor: tensor([False, True, True, False])