hard_shrink

paddle.fluid.layers.hard_shrink(x, threshold=None)[source]

HardShrink activation operator

\[\begin{split}out = \begin{cases} x, \text{if } x > \lambda \\ x, \text{if } x < -\lambda \\ 0, \text{otherwise} \end{cases}\end{split}\]
Parameters
  • x – Input of HardShrink operator

  • threshold (FLOAT) – The value of threshold for HardShrink. [default: 0.5]

Returns

Output of HardShrink operator

Examples

>>> import paddle.fluid as fluid
>>> data = fluid.layers.data(name="input", shape=[784])
>>> result = fluid.layers.hard_shrink(x=data, threshold=0.3)