Hardswish¶
Hardswish 激活函数。创建一个 Hardswish 类的可调用对象。在 MobileNetV3 架构中被提出,相较于 swish 函数,具有数值稳定性好,计算速度快等优点,具体原理请参考:https://arxiv.org/pdf/1905.02244.pdf
hardswish(x)={0,if x≤−3x,if x≥3x(x+3)6,otherwise
其中,x 为输入的 Tensor
参数
形状:¶
input:任意形状的 Tensor。
output:和 input 具有相同形状的 Tensor。
代码示例¶
import paddle
x = paddle.to_tensor([-4., 5., 1.])
m = paddle.nn.Hardswish()
out = m(x) # [0., 5., 0.666667]