Hard Sigmoid
- 类torch.nn.Hardsigmoid(inplace=False)[源代码]
-
对每个元素应用Hardsigmoid函数。
Hardsigmoid 定义如下:
$\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
- 形状:
-
-
输入: $(*)$,其中$*$表示任意维度的数量。
-
输出: $(*)$,形状与输入相同。
-
示例:
>>> m = nn.Hardsigmoid() >>> input = torch.randn(2) >>> output = m(input)