hard_sigmoid

Contents

hard_sigmoid#

class saiunit.math.hard_sigmoid(x, unit_to_scale=None)#

Hard Sigmoid activation function.

Computes the element-wise function

\[\mathrm{hard\_sigmoid}(x) = \frac{\mathrm{relu6}(x + 3)}{6}\]
Parameters:
  • x (Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input array. Must be unitless if a Quantity.

  • unit_to_scale (Unit | None) – Unit used to convert x to a dimensionless number before applying the activation.

Returns:

out – An array with values in the range [0, 1].

Return type:

Array

Examples

>>> import jax.numpy as jnp
>>> import saiunit.math as sumath
>>> sumath.hard_sigmoid(jnp.array([-4., 0., 4.]))
Array([0. , 0.5, 1. ], dtype=float32)