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

PyTorch torch.isnan function

PyTorch torch.isnan function


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

)

print

(

result

)

The output is:

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


PyTorch torch reference manual PyTorch torch reference manual