PyTorch torch.isnan function
PyTorch torch reference manual
torch.isnan is a function in PyTorch used to check for NaN values.
Function definition
torch.isnan(input)
Usage examples
Example
import
torch
import
math
x
=
torch.
tensor
(
[
1.0
,
math
.
nan
,
3.0
,
float
(
'nan'
)
]
)
result
=
torch.
isnan
(
x
)
(
result
)
The output is:
tensor([False, True, False, True])