Skip to content
fn

elu

→Tensor
elu(input: Tensor, alpha: float = 1.0, inplace: bool = False)

Implementing kernel

C++ engine symbols that back this Python API.

Exponential linear unit activation.

A smooth alternative to relu that saturates to −α-\alpha on the negative side instead of clipping at zero. The exponential branch pushes the mean activation closer to zero, which speeds up training by reducing internal covariate shift (Clevert et al. 2015).

Parameters

inputTensor
Input tensor of any shape; activation is element-wise.
alphafloat= 1.0
Saturation value α>0\alpha > 0 for negative inputs. Default 1.0.
inplacebool= False
If True, write the result into input and return input.

Returns

Tensor

Activated tensor with the same shape as input.

Notes

ELU(x)={xx>0α(ex−1)x≤0\text{ELU}(x) = \begin{cases} x & x > 0 \\ \alpha (e^x - 1) & x \le 0 \end{cases}

Continuous and once-differentiable at the origin (derivative is 11 from above and α\alpha from below — equal when α=1\alpha = 1). Unlike ReLU it produces negative outputs, which helps push activation means toward zero; unlike Leaky ReLU it bounds the negative tail, providing implicit noise robustness.

Examples

>>> import lucid
>>> from lucid.nn.functional import elu
>>> x = lucid.tensor([-2.0, -1.0, 0.0, 1.0])
>>> elu(x)
tensor([-0.8647, -0.6321, 0., 1.])

Used by 2