fn

sigmoid

Tensor
sigmoid(input: Tensor)
source

Element-wise logistic sigmoid.

Squashes the real line into (0,1)(0, 1). Often used for binary classification heads.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=σ(xi)=11+exi\text{out}_i = \sigma(x_i) = \frac{1}{1 + e^{-x_i}}

Gradient: σ(x)(1σ(x))\sigma(x)(1 - \sigma(x)). Numerically stable for large negative x via the engine implementation.

Examples

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