Skip to content
class

SigmoidTransform

extendsTransform
SigmoidTransform()

Element-wise sigmoid bijection y=σ(x)=1/(1+e−x)y = \sigma(x) = 1/(1 + e^{-x}).

Maps R→(0,1)\mathbb{R} \to (0, 1) element-wise. The natural unconstrained → probability transform — composed with a base distribution on R\mathbb{R}, the pushforward lives on the unit interval. Monotone increasing, bijective, event_dim = 0.

Notes

Forward: y=σ(x)=1/(1+e−x)y = \sigma(x) = 1/(1 + e^{-x}).

Inverse (logit): x=log⁡ ⁣(y/(1−y))x = \log\!\bigl(y/(1-y)\bigr).

Log Jacobian determinant:

log⁡ ⁣∣∂y∂x∣=log⁡(σ(x)(1−σ(x)))=−softplus⁡(−x)−softplus⁡(x)\log\!\left|\frac{\partial y}{\partial x}\right| = \log\bigl(\sigma(x)(1 - \sigma(x))\bigr) = -\operatorname{softplus}(-x) - \operatorname{softplus}(x)

The transform is closely related to the StickBreakingTransform (which generalises to the simplex) and to TanhTransform (which targets (−1,1)(-1, 1)).

Examples

>>> import lucid
>>> from lucid.distributions.transforms import SigmoidTransform
>>> T = SigmoidTransform()
>>> T(lucid.tensor(0.0))  # σ(0) = 0.5
tensor(0.5)

Used by 3

Instance methods

1
fn

log_abs_det_jacobian

→Tensor
log_abs_det_jacobian(x: Tensor, y: Tensor)

Log-Jacobian −softplus⁡(−x)−softplus⁡(x)-\operatorname{softplus}(-x) - \operatorname{softplus}(x).

Written in the logit x rather than the probability y: y rounds to exactly 0 or 1 for a large |x|, where log⁡y+log⁡(1−y)\log y + \log(1 - y) is −∞-\infty and the softplus form stays finite.

Parameters

Pre-transform input (sigmoid logit).
Post-transform output; ignored.

Returns

Tensor

log⁡σ(x)+log⁡σ(−x)\log\sigma(x) + \log\sigma(-x).