需要用到 instance normalization,记录之。本文内容完全来自 论文 Instance Normalization:The Missing Ingredient for Fast Stylization。
首先,
x
∈
R
T
×
C
×
W
×
H
x \in \mathbb{R}^{T\times C\times W\times H}
x∈RT×C×W×H。
x
x
x 是
T
T
T 张 图像中的任意一张,i.e.任意一个 tensor。记
x
t
i
j
k
x_{tijk}
xtijk 为第
t
i
j
k
tijk
tijk 个元素,其中
j
,
k
j,k
j,k 对应图像的 空间维度(宽度和高度),
t
t
t 是图像的索引,
C
C
C 对应每张图像的通道数。
Batch normalization 是这样的:
y
t
i
j
k
=
x
t
i
j
k
−
μ
i
σ
i
2
+
ϵ
,
u
i
=
1
H
W
T
∑
t
=
1
T
∑
l
=
1
W
∑
m
=
1
H
x
t
i
j
k
,
σ
i
2
=
1
H
W
T
∑
t
=
1
T
∑
l
=
1
W
∑
m
=
1
H
(
x
t
i
j
k
−
m
u
i
)
2
y_{tijk}=\frac{x_{tijk}-\mu_{i}}{\sqrt{\sigma_{i}^{2}+\epsilon}}, \quad u_{i}=\frac{1}{HWT}\sum_{t=1}^{T}\sum_{l=1}^{W}\sum_{m=1}^{H}x_{tijk},\quad \sigma_{i}^{2}=\frac{1}{HWT}\sum_{t=1}^{T}\sum_{l=1}^{W}\sum_{m=1}^{H}{({x_{tijk}-mu_{i}})^2}
ytijk=σi2+ϵxtijk−μi,ui=HWT1t=1∑Tl=1∑Wm=1∑Hxtijk,σi2=HWT1t=1∑Tl=1∑Wm=1∑H(xtijk−mui)2
Instance Normalization 是这样的:
y
t
i
j
k
=
x
t
i
j
k
−
μ
i
σ
i
2
+
ϵ
,
u
t
i
=
1
H
W
∑
l
=
1
W
∑
m
=
1
H
x
t
i
j
k
,
σ
t
i
2
=
1
H
W
∑
l
=
1
W
∑
m
=
1
H
(
x
t
i
j
k
−
m
u
i
)
2
y_{tijk}=\frac{x_{tijk}-\mu_{i}}{\sqrt{\sigma_{i}^{2}+\epsilon}}, \quad u_{ti}=\frac{1}{HW}\sum_{l=1}^{W}\sum_{m=1}^{H}x_{tijk},\quad \sigma_{ti}^{2}=\frac{1}{HW}\sum_{l=1}^{W}\sum_{m=1}^{H}{({x_{tijk}-mu_{i}})^2}
ytijk=σi2+ϵxtijk−μi,uti=HW1l=1∑Wm=1∑Hxtijk,σti2=HW1l=1∑Wm=1∑H(xtijk−mui)2