2

深度学习中的Normalization

 2 years ago
source link: https://blog.kamino.link/2021/12/08/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E4%B8%AD%E7%9A%84Normalization/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

深度学习中的Normalization

[TOC]

Normalization翻译为规范化或者归一化,不是标准化。

深度学习模型喜欢独立同分布的数据,独立n维特征中每一维之间都没有相关性,同分布即特征的每一维都具有相同的均值和方差。在深度学习网络中,因为网络很深,如果数据在某一层开始有偏移,则网络加深会导致其加剧(Internal Covariate Shift, or ICS),而Normalization能够减缓这个问题。

Batch Normalization

BN就是将一个batch内的数据进行归一化,先求得均值μB和方差σB2,然后对每个元素进行归一化:xi′=xi−μBσB2+ϵ,下面那个ϵ是防止除以0。

之后,使用可学习参数γi,βi变换为原始的分布:yi=γi⋅xi′+βi。这一步是为了保证模型表达能力不因为Normalization而下降,变化后数据均值为β,方差为γ2。

使用BN时,得注意batch小时这个方法效果可能不佳。

对于图片N C H W的维度,BN统计的是N H W的均值和方差,对于每一个通道分开计算。

Layer Normalization

对于图片N C H W的维度,LN统计的是C H W的均值和方差,和batch size就没有关系了。

参考文献:

详解深度学习中的Normalization,BN/LN/WN - 知乎 (zhihu.com)

深度学习中 Batch Normalization为什么效果好? - 知乎 (zhihu.com)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK