soft_shrink

Contents

soft_shrink#

class brainstate.nn.soft_shrink(x, lambd=0.5)[source]#

Soft shrinkage activation function.

Applies the soft shrinkage function element-wise:

\[\begin{split}\text{SoftShrinkage}(x) = \begin{cases} x - \lambda, & \text{ if } x > \lambda \\ x + \lambda, & \text{ if } x < -\lambda \\ 0, & \text{ otherwise } \end{cases}\end{split}\]
Parameters:
  • x (ArrayLike) – Input array of any shape.

  • lambd (float, optional) – The \(\lambda\) value for the soft shrinkage formulation. Must be non-negative. Default is 0.5.

Returns:

Output array with the same shape as the input.

Return type:

jax.Array or Quantity