Sigmoid
_QuantizedActivationSigmoid(scale: Tensor, zero_point: Tensor, qdtype: QDtype = quint8)Implementing kernel
C++ engine symbols that back this Python API.Quantized lucid.nn.Sigmoid — sigmoid(x) then output fake-quant.
The inference-time replacement for a calibrated float nn.Sigmoid sitting
inside a quantized region, installed by lucid.quantization.convert /
from_float. Under the sidecar representation (design B) a quantized
activation is simply the float activation followed by a fake-quantize to the
calibrated output grid, so a standalone sigmoid is requantized rather than
left at full precision between two int8 layers.
Because the output range is known a priori, this
is the archetypal fixed-qparams activation: instead of calibrating the
range from data, pair it with a
lucid.quantization.FixedQParamsObserver in the qconfig, which pins
the grid to the constant mapping.
so the quint8 codes 0 .. 255 tile uniformly with step
. .
Parameters
scaleTensor1/256 when paired with a
lucid.quantization.FixedQParamsObserver, else the calibrated
value. Supplied by from_float; construct directly only with
qparams in hand.zero_pointTensor0 for the fixed [0, 1] grid).lucid.quantization.quint8 ([0, 255]).Notes
- Built via
convert/from_float, which reads the source module's output observer; a barenn.Sigmoidis not one of these. - Pairing with
lucid.quantization.FixedQParamsObserverskips a calibration pass for a range that is fixed by construction. - The forward is
float sigmoid → fake-quant; the sigmoid itself runs at full float precision, only the output is snapped to the grid.
Examples
>>> import lucid, lucid.nn as nn
>>> qsig = nn.quantized.Sigmoid(lucid.tensor(1 / 256), lucid.tensor(0.0))
>>> y = qsig(lucid.randn(8))
>>> bool(((y >= 0) & (y <= 1)).all().item()) # bounded to [0, 1]
TrueSee Also
- lucid.nn.quantized.Tanh—Bounded to
[-1, 1](also fixed-qparams). - lucid.nn.quantized.Hardsigmoid—Piecewise-linear
[0, 1]gate. - lucid.quantization.FixedQParamsObserver—Pins the grid for bounded outputs.