激活函数Swish和Hardswish简介

前言

Swish激活函数和Hardswish激活函数学习笔记。

Swish论文

Searching for Activation Functions,Google出品。

论文摘要翻译和解读

The choice of activation functions in deep networks has a significant effect on the training dynamics and task performance.

深度网络中激活函数的选择对训练动态(training dynamics)和任务性能有显著影响。

training dynamics: 指的是训练过程中,模型的性能指标随迭代轮数变化的情况。影响training dynamics的因素不止一个,每种网络结构都有自己的training dynamic,但有些因素对各类网络的traning dynamics都有影响,比如激活函数、学习率等。

Currently, the most successful and widely-used activation function is the Rectified Linear Unit (ReLU).

目前,最成功和广泛使用的激活函数是整流线性单元(ReLU)。

Although various hand-designed alternatives to ReLU have been proposed, none have managed to replace it due to inconsistent gains.
虽然已经提出了各种手工设计的ReLU替代品,但由于增益不一致,没有一个能够取代它。

In this work, we propose to leverage automatic search techniques to discover new activation functions.
在这项工作中,我们建议利用自动搜索技术来发现新的激活功能。

Using a combination of exhaustive and reinforcement learning-based search, we discover multiple novel activation functions.
通过结合暴力搜索和基于强化学习的搜索,我们发现了多种新颖的激活函数。

We verify the effectiveness of the searches by conducting an empirical evaluation with the best discovered activation function.
我们通过对发现的最佳激活函数进行实证评估来验证搜索的有效性。

实验评估,就是不用理论分析。

Our experiments show that the best discovered activation function, f(x)=x⋅sigmoid(βx), which we name Swish, tends to work better than ReLU on deeper models across a number of challenging datasets.
我们的实验表明,在许多具有挑战性的数据集中,所发现的最佳激活函数f(x)=x⋅sigmoid(βx),我们将其命名为Swish,在更深的模型上往往比ReLU更好。

s i g m o i d ( x ) = 1 1 + e x p ( − x ) sigmoid(x)= \frac{1}{1 + exp(−x)} sigmoid(x)=1+exp(x)1

β,常量,或者是可学习的参数。
如果β = 1, f(x)=x⋅sigmoid(x),相当于Sigmoid-weighted Linear Unit (SiL) 。
如果β = 0,Swish 变成了缩放线性函数 f(x) = x/2。
如果β → ∞,sigmoid 分量接近 0-1 函数,因此 Swish 变得像 ReLU 函数。
这表明 ,我们可以大致地把Swish 视为一个平滑函数,它在线性函数和 ReLU 函数之间进行非线性插值。如果将插值程度设置为可训练参数,则模型可以控制β。

从下图可以看到不同的β取值时的函数曲线,当β =10的时候,就开始和ReLU很靠近了。
在这里插入图片描述

For example, simply replacing ReLUs with Swish units improves top-1 classification accuracy on ImageNet by 0.9% for Mobile NASNet-A and 0.6% for Inception-ResNet-v2.

例如,只需将 ReLU 替换为 Swish 单元,Mobile NASNet-A 的 ImageNet 上 top-1 分类准确率就会提高 0.9%,Inception-ResNet-v2 的分类准确率提高 0.6%。

相当于白拿0.9%的准确率,不拿白不拿。
但摘要中并没有提到收敛速度的对比。

The simplicity of Swish and its similarity to ReLU make it easy for practitioners to replace ReLUs with Swish units in any neural network.

Swish的简单性及其与ReLU的相似性使从业者可以轻松地在任何神经网络中用Swish单元替换ReLU。

后来的论文《Searching for MobileNetV3》发现,Swish只有在深层网络中才能发挥作用,并且它还是有计算量的,于是就提出了hardswish,也就是硬编码的swish。

Hard-Swish激活

计算公式

在这里插入图片描述

函数图像

在这里插入图片描述

pytorch中已经提供了hardswish激活函数,直接用。

  • 6
    点赞
  • 47
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值