Shortcuts

Hardsigmoid

class torch.nn.Hardsigmoid(inplace=False)[源代码]

逐元素应用Hardsigmoid函数。

Hardsigmoid 定义为:

Hardsigmoid(x)={0if x3,1if x+3,x/6+1/2otherwise\text{Hardsigmoid}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ 1 & \text{if~} x \ge +3, \\ x / 6 + 1 / 2 & \text{otherwise} \end{cases}
Parameters

inplace (布尔值) – 可以选择就地执行操作。默认值:False

Shape:
  • 输入:()(*),其中 * 表示任意数量的维度。

  • 输出: ()(*), 与输入形状相同。

../_images/Hardsigmoid.png

示例:

>>> m = nn.Hardsigmoid()
>>> input = torch.randn(2)
>>> output = m(input)
优云智算