PyTorch torch.logical_and function
PyTorch torch reference manual
torch.logical_and is a function in PyTorch used to compute the logical AND of two tensors.
Function definition
torch.logical_and(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 AND operation
z
=
torch.
logical_and
(
x
,
y
)
(
"logical_and:"
,
z
)
The output is:
logical_and: tensor([True, False, False, False])