PyTorch torch.logical_and function


Pytorch torch 参考手册Pytorch torch Reference Manual

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

Function definition

torch.logical_and(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 AND operation
z = torch.logical_and(x, y)
print("logical_and:", z)

The output result is:

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

Pytorch torch 参考手册Pytorch torch Reference Manual

Other extensions