文章目录
- @[TOC](文章目录)
- 前言
- 1 batch normalization(BN)
- 2 Layer normalization (LN)
- 3 RMSNorm(没有缩写名字)
- 4 instance normalization (IN)
- 5 group normalization (GN)
- 总结
文章目录
- @[TOC](文章目录)
- 前言
- 1 batch normalization(BN)
- 2 Layer normalization (LN)
- 3 RMSNorm(没有缩写名字)
- 4 instance normalization (IN)
- 5 group normalization (GN)
- 总结
前言
对 norm/batch/instance/group 这四种normalization进行整理.
首先假设我们的数据结构都是 [n, c, h, w] 数据结构如下图,下图中n=4, c = 7, h=她喜欢的数字, w=他喜欢的数字
还有个链接写的不错,但是语言晦涩,尤其across 用的太晦涩。link:https://isaac-the-man.dev/posts/normalization-strategies/
1 batch normalization(BN)
因为深度学习中,一个channel的数据往往是同一类数据,比如rgb中的 r,所以在同一个channel上做nomrlization是合理的. 下图中,我的例子是将橙色的channel全部取出, 做normalization,也就是论文中说的"across the channel dimension C"(横跨了所有c).
对应的数学过程:
(1) 求平均,x xx是图像中的一个点
μ c = 3 = 1 H ∗ W ∗ N ∑ n , h , w x [ n , h , w ] \mu_{c=3} = \frac{1}{H * W * N} \sum_{n,h,w} x[n,h,w]μc=3=H∗W∗N1∑n,h,wx[n,h,w]c 从 0开始
(2) 计算方差:
δ c = 3 = 1 H ∗ W ∗ N ∑ n , h , w ( x [ n , h , w ] − μ c ) 2 \delta_{c=3} = \frac{1}{H * W * N} \sum_{n,h,w} (x[n,h,w] - \mu_c)^2δc=3=H∗W∗N1∑n,h,w(x[n,h,w]−μc)2
(3)归一化
x ^ n , c = 3 , h , w = x n , c = 3 , h , w − μ c δ c 2 + ϵ γ + β \hat x_{n,c=3,h,w} = \frac{x_{n,c=3,h,w}- \mu_c}{ \sqrt{\delta_c^2 + \epsilon} } \gamma + \betax^n,c=3,h,w=δc2+ϵ