hard_silu

Contents

hard_silu#

class brainunit.math.hard_silu(x, unit_to_scale=None)#

Hard SiLU (swish) activation function.

Computes the element-wise function

\[\mathrm{hard\_silu}(x) = x \cdot \mathrm{hard\_sigmoid}(x)\]

Both hard_silu() and hard_swish() are aliases for the same function.

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 the same shape as x.

Return type:

Array

Examples

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