评价此页

Hardsigmoid#

class torch.nn.Hardsigmoid(inplace=False)[source]#

逐元素应用 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}
参数

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

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

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

../_images/Hardsigmoid.png

示例

>>> m = nn.Hardsigmoid()
>>> input = torch.randn(2)
>>> output = m(input)