논리 연산 (logical operation; boolean operation) 은 참, 거짓 두 가지의 원소만 존재하는 집합에서의 연산이다.
True 일 때 출력이 True 가 되는 연산torch.logical_and(x, y)x = torch.tensor([True, True, False, False])
y = torch.tensor([True, False, True, False])
result = torch.logical_and(x, y) # tensor([True, False, False, False])
True 일 때 출력이 True 가 되는 연산torch.logical_or(x, y)x = torch.tensor([True, True, False, False])
y = torch.tensor([True, False, True, False])
result = torch.logical_or(x, y) # tensor([True, True, True, False])
True 일 때 출력이 True 가 되는 연산torch.logical_xor(x, y)x = torch.tensor([True, True, False, False])
y = torch.tensor([True, False, True, False])
result = torch.logical_or(x, y) # tensor([False, True, True, False])