mish

Contents

mish#

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

Mish activation function.

Computes the element-wise function:

\[\mathrm{mish}(x) = x \cdot \mathrm{tanh}(\mathrm{softplus}(x))\]

For more information, see Mish: A Self Regularized Non-Monotonic Activation 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.mish(jnp.array([-2., 0., 2.]))
Array([-0.25250152,  0.        ,  1.9439590 ], dtype=float32)