megengine.functional.real

real(complex)[源代码]

Returns a new tensor containing real values of the complex tensor.

参数

complex (Tensor) –

返回类型

Tensor

返回

the real part of the complex tensor

实际案例

>>> x=Tensor([0.3100+0.3553j, -0.5445-0.7896j, -1.6492-0.0633j, -0.0638-0.8119j], dtype=np.complex64)
>>> F.real(x)
Tensor([[ 0.31  ]
 [-0.5445]
 [-1.6492]
 [-0.0638]], device=xpux:0)