快捷方式

Hardsigmoid

torch.nn.Hardsigmoid(inplace=False)[原始碼][原始碼]

逐元素應用 Hardsigmoid 函式。

Hardsigmoid 的定義如下

Hardsigmoid(x)={0如果 x3,1如果 x+3,x/6+1/2否則\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 (布林型) – 可以選擇是否原地執行操作。預設值: False

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

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

../_images/Hardsigmoid.png

示例

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

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源