损失函数
由6部分组成,太复杂了。
L
t
o
t
a
l
=
L
v
a
l
i
d
+
6
L
h
o
l
e
+
0.05
L
p
e
r
c
e
p
t
u
a
l
+
120
(
L
s
t
y
l
e
o
u
t
+
L
s
t
y
l
e
c
o
m
p
)
+
0.1
L
t
v
\mathcal{L}_{total} = \mathcal{L}_{valid} +6\mathcal{L}_{hole} +0.05\mathcal{L}_{perceptual} +120(\mathcal{L}_{styleout} +\mathcal{L}_{stylecomp})+0.1\mathcal{L}_{tv}
Ltotal=Lvalid+6Lhole+0.05Lperceptual+120(Lstyleout+Lstylecomp)+0.1Ltv
pixel loss
两部分组成,分别是空洞部分和非空洞部分。
L
hole
=
1
N
I
g
t
∥
(
1
−
M
)
⊙
(
I
o
u
t
−
I
g
t
)
∥
1
\mathcal{L}_{\text {hole }}=\frac{1}{N_{\mathbf{I}_{g t}}}\left\|(1-M) \odot\left(\mathbf{I}_{o u t}-\mathbf{I}_{g t}\right)\right\|_{1}
Lhole =NIgt1∥(1−M)⊙(Iout−Igt)∥1
L
valid
=
1
N
I
g
t
∥
M
⊙
(
I
out
−
I
g
t
)
∥
1
\mathcal{L}_{\text {valid }}=\frac{1}{N_{\mathbf{I}_{g t}}}\left\|M \odot\left(\mathbf{I}_{\text {out }}-\mathbf{I}_{g t}\right)\right\|_{1}
Lvalid =NIgt1∥M⊙(Iout −Igt)∥1
perceptual loss
L perceptual = ∑ p = 0 P − 1 ∥ Ψ p I o u t − Ψ p I g t ∥ 1 N Ψ p I g t + ∑ p = 0 P − 1 ∥ Ψ p I comp − Ψ p I g t ∥ 1 N Ψ p I g t \mathcal{L}_{\text {perceptual }}=\sum_{p=0}^{P-1} \frac{\left\|\Psi_{p}^{\mathbf{I}_{o u t}}-\Psi_{p}^{\mathbf{I}_{g t}}\right\|_{1}}{N_{\Psi_{p}} \mathbf{I}_{g t}}+\sum_{p=0}^{P-1} \frac{\left\|\Psi_{p}^{\mathbf{I}_{\text {comp }}}-\Psi_{p}^{\mathbf{I}_{g t}}\right\|_{1}}{N_{\Psi_{p}} \mathbf{I}_{g t}} Lperceptual =p=0∑P−1NΨpIgt∥ ∥ΨpIout−ΨpIgt∥ ∥1+p=0∑P−1NΨpIgt∥ ∥ΨpIcomp −ΨpIgt∥ ∥1
style loss
comp表示用真值填充非空洞部分,输出填充空洞部分,style loss要分别计算comp和out的损失值。
L
style
out
=
∑
p
=
0
P
−
1
1
C
p
C
p
∥
K
p
(
(
Ψ
p
I
o
u
t
)
⊤
(
Ψ
p
I
o
u
t
)
−
(
Ψ
p
I
g
t
)
⊤
(
Ψ
p
I
g
t
)
)
∥
1
L
s
t
y
l
e
c
o
m
p
=
∑
p
=
0
P
−
1
1
C
p
C
p
∥
K
p
(
(
Ψ
p
I
c
o
m
p
)
⊤
(
Ψ
p
I
c
o
m
p
)
−
(
Ψ
p
I
g
t
)
⊤
(
Ψ
p
I
g
t
)
)
∥
1
\begin{aligned} &\mathcal{L}_{\text {style }_{\text {out }}}=\sum_{p=0}^{P-1} \frac{1}{C_{p} C_{p}}\left\|K_{p}\left(\left(\Psi_{p}^{\mathbf{I}_{o u t}}\right)^{\boldsymbol{\top}}\left(\Psi_{p}^{\mathbf{I}_{o u t}}\right)-\left(\Psi_{p}^{\mathbf{I}_{g t}}\right)^{\boldsymbol{\top}}\left(\Psi_{p}^{\mathbf{I}_{g t}}\right)\right)\right\|_{1}\\ &\mathcal{L}_{s t y l e_{c o m p}}=\sum_{p=0}^{P-1} \frac{1}{C_{p} C_{p}}\left\|K_{p}\left(\left(\Psi_{p}^{\mathbf{I}_{c o m p}}\right)^{\boldsymbol{\top}}\left(\Psi_{p}^{\mathbf{I}_{c o m p}}\right)-\left(\Psi_{p}^{\mathbf{I}_{g t}}\right)^{\boldsymbol{\top}}\left(\Psi_{p}^{\mathbf{I}_{g t}}\right)\right)\right\|_{1} \end{aligned}
Lstyle out =p=0∑P−1CpCp1∥
∥Kp((ΨpIout)⊤(ΨpIout)−(ΨpIgt)⊤(ΨpIgt))∥
∥1Lstylecomp=p=0∑P−1CpCp1∥
∥Kp((ΨpIcomp)⊤(ΨpIcomp)−(ΨpIgt)⊤(ΨpIgt))∥
∥1
total variation —— tv
为R上的平滑惩罚,其中R为空洞区域1像素膨胀的区域。
L
t
v
=
∑
(
i
,
j
)
∈
R
,
(
i
,
j
+
1
)
∈
R
∥
I
comp
i
,
j
+
1
−
I
comp
i
,
j
∥
1
N
I
comp
+
∑
(
i
,
j
)
∈
R
,
(
i
+
1
,
j
)
∈
R
∥
I
comp
i
+
1
,
j
−
I
comp
i
,
j
∥
1
N
I
comp
\mathcal{L}_{t v}=\sum_{(i, j) \in R,(i, j+1) \in R} \frac{\left\|\mathbf{I}_{\text {comp }}^{i, j+1}-\mathbf{I}_{\text {comp }}^{i, j}\right\|_{1}}{N_{\mathbf{I}_{\text {comp }}}}+\sum_{(i, j) \in R,(i+1, j) \in R} \frac{\left\|\mathbf{I}_{\text {comp }}^{i+1, j}-\mathbf{I}_{\text {comp }}^{i, j}\right\|_{1}}{N_{\mathbf{I}_{\text {comp }}}}
Ltv=(i,j)∈R,(i,j+1)∈R∑NIcomp ∥
∥Icomp i,j+1−Icomp i,j∥
∥1+(i,j)∈R,(i+1,j)∈R∑NIcomp ∥
∥Icomp i+1,j−Icomp i,j∥
∥1