hard_shrink

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

HardShrink activation operator

out={x,if x>λx,if x<λ0,otherwise
Parameters
  • x (Tensor) – Input of HardShrink operator

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

  • with_quant_attr (BOOLEAN) – Whether the operator has attributes used by quantization.

Returns

Output of HardShrink operator

Return type

out (Tensor)

Examples

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