ELU
_QuantizedActivationELU(scale: Tensor, zero_point: Tensor, qdtype: QDtype = quint8)Quantized lucid.nn.ELU — elu(x, alpha) then output fake-quant.
The inference-time replacement for a calibrated float nn.ELU, installed
by lucid.quantization.convert / from_float. Under the sidecar
representation (design B) the quantized layer is the float ELU followed by a
fake-quantize to the calibrated output grid. Unlike the bounded activations,
ELU is unbounded above and saturates to below, so its
range is data-dependent and must be calibrated with a real observer rather
than a lucid.quantization.FixedQParamsObserver.
The negative-branch scale is a parameter of the activation,
not a learned weight; from_float copies it from the source nn.ELU
(via the internal _configure hook) so the quantized layer reproduces the
exact float curve before snapping the output to the grid.
with and the
calibrated output (scale, zero_point) .
Parameters
Attributes
alphafloatnn.ELU by from_float. Defaults to
1.0 on a bare instance.Notes
- Built via
convert/from_float, which reads the output observer and copiesalphafrom the float module. - Range is data-dependent (unbounded above), so calibrate through the
prepared model before
convert; a fixed grid would clip the upper tail. - The forward is
float elu(x, alpha) → fake-quant; only the output is snapped to the grid.
Examples
>>> import lucid, lucid.nn as nn
>>> import lucid.quantization as Q
>>> model = nn.Sequential(nn.ELU(alpha=1.5))
>>> model.qconfig = Q.get_default_qconfig()
>>> prepared = Q.prepare(model) # attach the output observer
>>> _ = prepared(lucid.randn(32, 8)) # calibrate its range
>>> qelu = Q.convert(prepared)[0] # from_float reads the observer
>>> type(qelu).__name__, qelu.alpha
('ELU', 1.5)See Also
- lucid.nn.quantized.LeakyReLU—Also carries a slope parameter across convert.
- lucid.nn.quantized.Hardswish—Another unbounded, calibration-only activation.
- lucid.quantization.convert—Installs this layer from a calibrated model.