快捷方式

Hardswish

class torch.nn.Hardswish(inplace=False)[source][source]

逐元素应用 Hardswish 函数。

论文中描述的方法: Searching for MobileNetV3

Hardswish 定义为

Hardswish(x)={0if x3,xif x+3,x(x+3)/6otherwise\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

形状
  • 输入: ()(*),其中 * 表示任意数量的维度。

  • 输出: ()(*),与输入形状相同。

../_images/Hardswish.png

示例

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

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源