Skip to content
fn

sigmoid

→Tensor
sigmoid(input: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

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+e−xi\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([...])