激活函数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)}s i g m o i d (x )=1 +e x p (−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很靠近了。

激活函数Swish和Hardswish简介

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激活

计算公式

激活函数Swish和Hardswish简介

; 函数图像

激活函数Swish和Hardswish简介

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

Original: https://blog.csdn.net/m0_48742971/article/details/123438626
Author: coder1479
Title: 激活函数Swish和Hardswish简介

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/627511/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球