fn

real

Tensor
real(input: Tensor)
source

Real part of a complex tensor.

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

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

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

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

Examples

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