fn

imag

Tensor
imag(input: Tensor)
source

Imaginary part of a complex tensor.

For complex inputs, returns the imaginary component as a real-valued tensor of the same shape; for real inputs it returns a zero tensor.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=Im(inputi)\text{out}_i = \mathrm{Im}(\text{input}_i)

Gradient flows back as the imaginary part of the upstream cotangent.

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.imag(x)
Tensor([...])