soft_sign

Contents

soft_sign#

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

Soft-sign activation function.

Computes the element-wise function

\[\mathrm{soft\_sign}(x) = \frac{x}{|x| + 1}\]
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 (-1, 1).

Return type:

Array

Examples

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