mindspore.ops.isinf

mindspore.ops.isinf(input)[源代码]

确定输入Tensor每个位置上的元素是否为无穷大或无穷小。

\[\begin{split}out_i = \begin{cases} & \ True,\ \text{ if } x_{i} = \text{Inf} \\ & \ False,\ \text{ if } x_{i} \ne \text{Inf} \end{cases}\end{split}\]

其中 \(Inf\) 表示不是一个数字。

参数:
  • input (Tensor) - IsInf的输入,shape: \((N, *)\) ,其中 \(*\) 表示任意数量的附加维度。

返回:

Tensor,shape与相同的输入,数据的类型为bool。

异常:
  • TypeError - 如果 input 不是Tensor。

支持平台:

Ascend GPU CPU

样例:

>>> x = Tensor(np.array([np.log(-1), 1, np.log(0)]), mindspore.float32)
>>> output = ops.isinf(x)
>>> print(output)
[False False True]