softshrink

paddle.fluid.layers.ops. softshrink ( x, alpha=None ) [source]
alias_main

paddle.nn.functional.softshrink

alias

paddle.nn.functional.softshrink,paddle.nn.functional.activation.softshrink

old_api

paddle.fluid.layers.softshrink

Softshrink Activation Operator

\[\begin{split}out = \\begin{cases} x - \\alpha, \\text{if } x > \\alpha \\\\ x + \\alpha, \\text{if } x < -\\alpha \\\\ 0, \\text{otherwise} \\end{cases}\end{split}\]
Parameters
  • x – Input of Softshrink operator, an N-D Tensor, with data type float32, float64 or float16.

  • alpha (float) – non-negative offset

Returns

Output of Softshrink operator with the same type of input.

Examples

import paddle.fluid as fluid
data = fluid.data(name="input", shape=[None, 784])
result = fluid.layers.softshrink(x=data, alpha=0.3)