fn
relu6
→Tensorrelu6(x: Tensor, inplace: bool = False)Rectified linear unit clipped at six.
Introduced for quantisation-friendly mobile architectures (MobileNetV1 / V2): bounding ReLU above keeps activations inside a small fixed range so that low-precision integer arithmetic does not overflow.
Parameters
xTensorInput tensor of any shape; activation is element-wise.
inplacebool= FalseAccepted for API compatibility; currently ignored.
Returns
TensorActivated tensor with the same shape as x, values in
.
Notes
Derivative is on and outside — so beyond suffering from "dead neurons" on the negative side, ReLU6 also kills gradients above . The trade-off is worthwhile for int8 quantisation where the symmetric range maps cleanly to a small dynamic-range integer codebook.
Examples
>>> import lucid
>>> from lucid.nn.functional import relu6
>>> x = lucid.tensor([-1.0, 0.0, 3.0, 7.0])
>>> relu6(x)
Tensor([0.0000, 0.0000, 3.0000, 6.0000])