megengine.functional.isnan¶
- isnan(inp)[源代码]¶
 Element-wise
NaNcheck.Tests each element \(x_i\) of the input tensor \(x\) to determine whether the element is
NaN.- 参数
 inp (
Tensor) – input tensor. Should have a numeric data type.- 返回类型
 - 返回
 a tensor containing test results. An element out is
Trueif \(x_i\) isNaNandFalseotherwise. The returned array should have a data type of bool.
实际案例
>>> 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)