torch.isfinite¶
-
torch.
isfinite
(input) → Tensor¶ Returns a new tensor with boolean elements representing if each element is finite or not.
Real values are finite when they are not NaN, negative infinity, or infinity. Complex values are finite when both their real and imaginary parts are finite.
- Args:
input (Tensor): the input tensor.
- Returns:
A boolean tensor that is True where
input
is finite and False elsewhere
Example:
>>> torch.isfinite(torch.tensor([1, float('inf'), 2, float('-inf'), float('nan')])) tensor([True, False, True, False, False])