softshrink_cn.rst 701 字节
Newer Older
H
Hao Wang 已提交
1 2 3 4 5
.. _cn_api_fluid_layers_softshrink:

softshrink
-------------------------------

6
.. py:function:: paddle.fluid.layers.softshrink(x, alpha=None)
H
Hao Wang 已提交
7

8
Softshrink激活函数
H
Hao Wang 已提交
9 10

.. math::
11 12 13 14 15
    out = \begin{cases}
        x - \alpha, \text{if } x > \alpha \\
        x + \alpha, \text{if } x < -\alpha \\
        0,  \text{otherwise}
        \end{cases}
H
Hao Wang 已提交
16 17

参数:
18 19
    - **x** (Variable0 - 张量(Tensor)
    - **alpha** (float) - 上面公式中alpha的值
H
Hao Wang 已提交
20

21 22 23
返回: 张量(Tensor)

返回类型: 变量(Variable)
H
Hao Wang 已提交
24 25 26 27 28

**代码示例**:

.. code-block:: python

29 30 31
    import paddle.fluid as fluid
    data = fluid.layers.data(name="input", shape=[32, 784])
    result = fluid.layers.softshrink(data)
H
Hao Wang 已提交
32 33 34 35 36 37 38 39 40 41 42 43