hardswish¶
- paddle.nn.functional. hardswish ( x, name=None ) ¶
hardswish 激活函数。在 MobileNetV3 架构中被提出,相较于 swish 函数,具有数值稳定性好,计算速度快等优点,具体原理请参考:https://arxiv.org/pdf/1905.02244.pdf
\[\begin{split}hardswish(x)= \left\{ \begin{aligned} &0, & & \text{if } x \leq -3 \\ &x, & & \text{if } x \geq 3 \\ &\frac{x(x+3)}{6}, & & \text{otherwise} \end{aligned} \right.\end{split}\]
其中,\(x\) 为输入的 Tensor。
返回¶
Tensor
,数据类型和形状同x
一致。
代码示例¶
COPY-FROM: paddle.nn.functional.hardswish