fn

sigmoid

Tensor
sigmoid(x: Tensor)
source

Logistic sigmoid activation.

Squashes any real-valued input into the open interval (0,1)(0, 1). Historically the canonical activation for binary classification heads and the gating function in LSTM / GRU cells.

Parameters

xTensor
Input tensor of any shape; activation is element-wise.

Returns

Tensor

Activated tensor with the same shape as x, values in (0,1)(0, 1).

Notes

σ(x)=11+ex\sigma(x) = \frac{1}{1 + e^{-x}}

Derivative σ(x)=σ(x)(1σ(x))0.25\sigma'(x) = \sigma(x)(1 - \sigma(x)) \le 0.25. The bounded derivative is the classical cause of the vanishing gradient problem in deep feed-forward stacks, so for hidden layers prefer ReLU / GELU / SiLU. For binary classification logits, use logsigmoid to compute logσ(x)\log\sigma(x) in a numerically stable way.

Examples

>>> import lucid
>>> from lucid.nn.functional import sigmoid
>>> x = lucid.tensor([-2.0, 0.0, 2.0])
>>> sigmoid(x)
Tensor([0.1192, 0.5000, 0.8808])