Softshrink#
- class brainstate.nn.Softshrink(lambd=0.5)#
Applies the soft shrinkage function elementwise.
\[\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:
lambd (
float) – The \(\lambda\) (must be no less than zero) value for the Softshrink formulation. Default: 0.5Shape
-----
Input (-)
Output (-)
Examples
>>> import brainstate.nn as nn >>> import brainstate >>> m = nn.Softshrink() >>> x = brainstate.random.randn(2) >>> output = m(x)