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)