Hardsigmoid¶ 類 torch.nn.Hardsigmoid(inplace=False)[原始碼][原始碼]¶ 逐元素應用 Hardsigmoid 函式。 Hardsigmoid 的定義如下 Hardsigmoid(x)={0如果 x≤−3,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} Hardsigmoid(x)=⎩⎨⎧01x/6+1/2如果 x≤−3,如果 x≥+3,否則 引數 inplace (布林型) – 可以選擇是否原地執行操作。預設值: False 形狀 輸入: (∗)(*)(∗),其中 ∗*∗ 表示任意維度數量。 輸出: (∗)(*)(∗),形狀與輸入相同。 示例 >>> m = nn.Hardsigmoid() >>> input = torch.randn(2) >>> output = m(input)