fn
logit
→Tensorlogit(x: Tensor, eps: float | None = ...)Logit function — inverse of the logistic sigmoid.
Maps a probability in to a log-odds value in . Optionally clamps the input to first to avoid divergence at the boundaries.
Parameters
xTensorInput tensor with values in .
epsfloat | NoneIf provided,
x is clamped to [eps, 1 - eps] before the
log-ratio is taken, preventing infinities. Defaults to None
(no clamping).Returns
TensorElement-wise logit value.
Notes
Mathematical definition:
Inverse of the sigmoid:
. Without eps, inputs
of exactly 0 or 1 produce and
respectively.
Examples
>>> import lucid
>>> x = lucid.tensor([0.1, 0.5, 0.9])
>>> lucid.logit(x)
Tensor([-2.1972, 0. , 2.1972])