mindspore.ops.Real

View Source On Gitee
class mindspore.ops.Real[source]

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

Inputs:
  • input (Tensor) - The input tensor to compute with.

Outputs:

Tensor, the shape is the same as the input.

Raises

TypeError – If the input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

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