megengine.functional.isnan#

isnan(inp)[source]#

Element-wise NaN check.

Tests each element \(x_i\) of the input tensor \(x\) to determine whether the element is NaN.

Parameters:

inp (Tensor) – input tensor. Should have a numeric data type.

Return type:

Tensor

Returns:

a tensor containing test results. An element out is True if \(x_i\) is NaN and False otherwise. The returned array should have a data type of bool.

Examples

>>> F.isnan(Tensor(1))
Tensor(False, dtype=bool, device=xpux:0)

Element-wise isnan:

>>> x = Tensor([1, float("nan"), 0])
>>> F.isnan(x)
Tensor([False  True False], dtype=bool, device=xpux:0)