relu6#
- class brainunit.math.relu6(x, unit_to_scale=None)#
Rectified Linear Unit 6 activation function.
Computes the element-wise function
\[\mathrm{relu6}(x) = \min(\max(x, 0), 6)\]except under differentiation, we take:
\[\nabla \mathrm{relu}(0) = 0\]and
\[\nabla \mathrm{relu}(6) = 0\]- Parameters:
x (saiunit.Quantity |
Array|ndarray|number|bool) – Input array. Must be unitless if aQuantity.unit_to_scale (saiunit.Unit |
None) – Unit used to convertxto a dimensionless number before applying the activation.
- Returns:
out – An array with the same shape as x, clipped to the range [0, 6].
- Return type:
Array
Examples
>>> import jax.numpy as jnp >>> import saiunit.math as sumath >>> sumath.relu6(jnp.array([-1., 0., 3., 7.])) Array([0., 0., 3., 6.], dtype=float32)