Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 965 Bytes

Hardsigmoid_cn.rst

File metadata and controls

42 lines (29 loc) · 965 Bytes

Hardsigmoid

.. py:function:: paddle.nn.Hardsigmoid(name=None)

Hardsigmoid激活层。sigmoid的分段线性逼近激活函数,速度比sigmoid快,详细解释参见 https://arxiv.org/abs/1603.00391

Hardsigmoid(x)=
    \left\{
    \begin{aligned}
    &0, & & \text{if } x \leq -3 \\
    &1, & & \text{if } x \geq 3 \\
    &x/6 + 1/2, & & \text{otherwise}
    \end{aligned}
    \right.

其中,x 为输入的 Tensor

参数

  • name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`

形状:

  • input: 任意形状的Tensor。
  • output: 和input具有相同形状的Tensor。

代码示例

import paddle

m = paddle.nn.Hardsigmoid()
x = paddle.to_tensor([-4., 5., 1.])
out = m(x) # [0., 1, 0.666667]