mindspore.ops.real

View Source On Gitee
mindspore.ops.real(input)[source]

Returns a Tensor that is the real part of the input. If input is real, it is returned unchanged.

Parameters

input (Tensor) – The input tensor to compute to.

Returns

Tensor, the shape is the same as the input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> import mindspore.ops as ops
>>> import numpy as np
>>> input = ms.Tensor(np.asarray(np.complex(1.3+0.4j)), ms.complex64)
>>> output = ops.real(input)
>>> print(output)
1.3