sigmoid

Contents

sigmoid#

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

Sigmoid activation function.

Computes the element-wise function:

\[\mathrm{sigmoid}(x) = \frac{1}{1 + e^{-x}}\]
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.sigmoid(jnp.array([-2., 0., 2.]))
Array([0.11920292, 0.5       , 0.8807971 ], dtype=float32)