megengine.functional.isinf

isinf(inp)[源代码]

Element-wise infinity check.

Tests each element \(x_i\) of the input tensor \(x\) to determine whether the element is if equal to positive or negative infinity.

参数

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

返回类型

Tensor

返回

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

实际案例

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

Element-wise isinf:

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