Fonction torch.logical_xor de PyTorch
Manuel de référence Pytorch torch
torch.logical_xorC'est une fonction de PyTorch utilisée pour calculer l'opération XOR logique de deux tenseurs.
Définition de fonction
torch.logical_xor(input, other, out=None)
Exemple d'utilisation
Exemple
import torch
# Créer deux tenseurs booléens
x = torch.tensor([True, False, True, False])
y = torch.tensor([True, True, False, False])
# Opération XOR logique
z = torch.logical_xor(x, y)
print("logical_xor:", z)
# Créer deux tenseurs booléens
x = torch.tensor([True, False, True, False])
y = torch.tensor([True, True, False, False])
# Opération XOR logique
z = torch.logical_xor(x, y)
print("logical_xor:", z)
Le résultat de sortie est:
logical_xor: tensor([False, True, True, False])
Autres extensions