Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.logical_and function

PyTorch torch.logical_and function


PyTorch torch reference manual 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

)

print

(

"logical_and:"

,

z

)

The output is:

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


PyTorch torch reference manual PyTorch torch reference manual