湖南召开会议传达学习全国两会精神——新华网——湖南

paddle. isreal ( x: Tensor, name: str | None = None ) Tensor [source]
百度 后来他把我父母叫来,说我成绩越来越差,还不如出去打工。

Tests if each element of input is a real number or not.

Parameters
  • x (Tensor) – The input Tensor.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

out (Tensor), The output Tensor. Each element of output indicates whether the input element is a real number or not.

Examples

>>> import paddle
>>> paddle.set_device('cpu')
>>> x = paddle.to_tensor([-0., -2.1, 2.5], dtype='float32')
>>> res = paddle.isreal(x)
>>> print(res)
Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
[True, True, True])

>>> x = paddle.to_tensor([(-0.+1j), (-2.1+0.2j), (2.5-3.1j)])
>>> res = paddle.isreal(x)
>>> print(res)
Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
[False, False, False])

>>> x = paddle.to_tensor([(-0.+1j), (-2.1+0j), (2.5-0j)])
>>> res = paddle.isreal(x)
>>> print(res)
Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
[False, True, True])