swish#
- class brainunit.math.swish(x, unit_to_scale=None)#
Swish (aka SiLU) activation function.
Computes the element-wise function:
\[\mathrm{swish}(x) = x \cdot \mathrm{sigmoid}(x) = \frac{x}{1 + e^{-x}}\]swish()andsilu()are both aliases for the same function.- Parameters:
- 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.swish(jnp.array([-2., 0., 2.])) Array([-0.23840584, 0. , 1.7615942 ], dtype=float32)