Hardswish
- 类torch.nn.Hardswish(inplace=False)[源代码]
-
对每个元素应用Hardswish函数。
论文中提出的方法:搜索MobileNetV3。
Hardswish 的定义是:
$\text{Hardswish}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ x & \text{if~} x \ge +3, \\ x \cdot (x + 3) /6 & \text{otherwise} \end{cases}$- 参数
-
inplace (bool) – 是否以就地方式执行操作(可选)。默认值:
False
- 形状:
-
-
输入: $(*)$,其中$*$表示任意维度的数量。
-
输出: $(*)$,形状与输入相同。
-
示例:
>>> m = nn.Hardswish() >>> input = torch.randn(2) >>> output = m(input)