Skip to content
fn

celu

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

Continuously-differentiable Exponential Linear Unit (Barron 2017).

A reparameterisation of elu whose first derivative is continuous at the origin for every α>0\alpha > 0, not only the specific value α=1\alpha = 1. This makes CELU friendlier to optimisers that exploit smooth gradients.

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

CELU(x)=max⁡(0,x)+min⁡ ⁣(0,α(ex/α−1))\text{CELU}(x) = \max(0, x) + \min\!\big(0, \alpha (e^{x/\alpha} - 1)\big)

At the origin both branches have derivative 11 regardless of α\alpha, removing the kink ELU has when α≠1\alpha \ne 1. Reduces to ELU when α=1\alpha = 1.

Examples

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

Used by 2