mindspore.Tensor.imag

Tensor.imag()[source]

Returns a new tensor containing imaginary value of the input tensor. If input tensor is real, it will return zeros.

Returns

Tensor, the shape is the same as the input tensor.

Supported Platforms:

GPU CPU

Examples

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