PyTorch torch.all Function
PyTorch torch reference manual
torch.all is a function in PyTorch used to determine whether all elements are True.
Function definition
torch.all(input, dim, keepdim, out)
Usage examples
Example
import
torch
x
=
torch.
tensor
(
[
[
True
,
True
,
True
]
,
[
True
,
False
,
True
]
]
)
Global check
(
"All True:"
,
torch.
all
(
x
)
)
Judge along dimensions
(
"dim=0 all True:"
,
torch.
all
(
x
,
dim
=
0
)
)
The output is:
全部为 True: tensor(False)
dim=0 全部为 True: tensor([True, False, True])