PyTorch torch.logical_xor Function


Pytorch torch 参考手册Pytorch torch Reference Manual

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

Function Definition

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

Usage Example

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 result is:

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

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions