評價此頁

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}
引數

inplace (bool) – 可以選擇是否就地執行操作。預設值:False

形狀
  • 輸入: ()(*),其中 * 表示任意數量的維度。

  • 輸出: ()(*),形狀與輸入相同。

../_images/Hardsigmoid.png

示例

>>> m = nn.Hardsigmoid()
>>> input = torch.randn(2)
>>> output = m(input)
forward(input)[原始碼]#

執行前向傳播。

返回型別

張量