mindspore.ops.view_as_real

mindspore.ops.view_as_real(input)[source]

View a complex Tensor as a real Tensor. The size of last dimension of the returned real Tensor is 2, and the last dimension is composed of the real and imaginary components of complex numbers.

Parameters

input (Tensor) – the input must be a complex Tensor.

Returns

A real Tensor.

Raises

TypeError – If the input Tensor is not a complex Tensor.

Supported Platforms:

GPU CPU

Examples

>>> x = Tensor([2+1j,2+3j,2-1j,2], mstype.complex64)
>>> print(ops.view_as_real(x))
[[ 2.  1.]
 [ 2.  3.]
 [ 2. -1.]
 [ 2.  0.]]