what is neural style transfer?
- 什么是神经风格转换。
sample: 转换图像风格。
深度卷积网格
Visualizing what a deep network is learning?
Neural style transfer cost function
define cost function: J ( G ) = α J c o n t e n t ( C , G ) + β J S t y l e ( S , G ) J(G) = \alpha J_{content}(C, G)+\beta J_{Style}(S,G) J(G)=αJcontent(C,G)+βJStyle(S,G)
Find the generated image G
- 1.Initiate G randomly
G: 100x100X3 - 2 .Use gradient descent to minimize
J
(
G
)
J(G)
J(G)
G = G − ϕ ϕ G J ( G ) G = G -\frac{\phi}{\phi G}J(G) G=G−ϕGϕJ(G) - 通过修改G的像素值减少代价函数的值,可以将G的像素值里理解为之前学习的模型参数。
Content cost funcation
J ( G ) = α J c o n t e n t ( C , G ) + β J S t y l e ( S , G ) J(G) = \alpha J_{content}(C, G)+\beta J_{Style}(S,G) J(G)=αJcontent(C,G)+βJStyle(S,G)
- Say you use hidden layer l l l to compute content cost.
- Use pre-trained ConvNet.
- Let a [ l ] ( c ) a^{[l](c)} a[l](c) and a [ l ] ( G ) a^{[l](G)} a[l](G) be the activation of layer l l l on the images
- If
a
[
l
]
(
c
)
a^{[l](c)}
a[l](c) and
a
[
l
]
(
G
)
a^{[l](G)}
a[l](G) are similar, both images have simiar content
在隐藏层l之后使用两个激活,分别对应的输出结果为C和G,训练完成之后比较连个激活函数,如果相似则他们的图像具有相似性。
J
c
o
n
t
e
n
t
(
C
,
G
)
=
1
2
∣
∣
a
[
l
]
(
C
)
−
a
[
l
]
(
G
)
∣
∣
2
J_{content(C,G)} = \frac{1}{2}||a^{[l](C)}- a^{[l](G)}||^2
Jcontent(C,G)=21∣∣a[l](C)−a[l](G)∣∣2
该方程会激励图像G自我修改。
不是太明白。
Style cost function
目前无法理解
Let
a
i
,
j
,
k
a_{i, j, k}
ai,j,k = activation at(i,j,k).
G
[
l
]
(
s
)
G^{[l](s)}
G[l](s) is
n
c
[
l
]
x
n
c
[
l
]
(
c
)
n_c^{[l]} x n_c^{[l](c)}
nc[l]xnc[l](c)
应为通道数是nc,需要得到每个激活单元之间的差异。
G
k
,
k
‘
[
l
]
(
s
)
=
∑
i
=
1
n
H
[
l
]
(
c
)
∑
j
=
1
n
W
[
l
]
(
c
)
a
i
,
j
,
k
[
l
]
a
i
,
j
,
k
‘
[
l
]
G_{k,k`}^{[l](s)} = \sum_{i=1}^{n_H^{[l](c)}}\sum_{j=1}^{n_W^{[l](c)}}a_{i,j,k}^{[l]}a_{i,j,k`}^{[l]}
Gk,k‘[l](s)=i=1∑nH[l](c)j=1∑nW[l](c)ai,j,k[l]ai,j,k‘[l]
这里的G表示层与层之间的差异。
G
[
l
]
(
G
)
=
∑
i
=
1
n
H
[
l
]
∑
j
=
1
n
W
[
l
]
a
i
,
j
,
k
[
l
]
[
s
]
a
i
,
j
,
k
[
l
]
(
G
)
G^{[l](G)}= \sum_{i=1}^{n_H^{[l]}}\sum_{j=1}^{n_W^{[l]}}a_{i,j,k}^{[l][s]}a_{i,j,k}^{[l](G)}
G[l](G)=i=1∑nH[l]j=1∑nW[l]ai,j,k[l][s]ai,j,k[l](G)
推导出公式为:
J
s
t
y
l
e
[
l
]
(
S
,
G
)
=
∣
∣
G
[
l
]
[
s
]
−
G
[
l
]
[
G
]
∣
∣
2
=
1
(
2
n
H
[
l
]
n
W
[
l
]
n
C
[
l
]
)
2
∑
k
∑
k
‘
(
G
k
k
‘
[
l
]
[
s
]
−
G
k
k
‘
[
l
]
[
G
]
)
2
J_{style}^{[l]}(S, G) = ||G^{[l][s]} - G^{[l][G]}||^2 = \frac{1}{(2n_H^{[l]}n_W^{[l]}n_C^{[l]})^2}\sum_k\sum_{k`}(G_{kk`}^{[l][s]}-G_{kk`}^{[l][G]})^2
Jstyle[l](S,G)=∣∣G[l][s]−G[l][G]∣∣2=(2nH[l]nW[l]nC[l])21k∑k‘∑(Gkk‘[l][s]−Gkk‘[l][G])2
J
s
t
y
l
e
(
S
,
G
)
=
∑
τ
λ
[
l
]
J
s
t
y
l
e
[
l
]
(
S
,
G
)
J_{style}(S,G) = \sum_{\tau}\lambda^{[l]}J_{style}^{[l]}(S,G)
Jstyle(S,G)=τ∑λ[l]Jstyle[l](S,G)
J
(
G
)
=
α
J
c
o
n
t
e
n
t
(
C
,
G
)
+
β
J
s
t
y
l
e
(
S
,
G
)
J(G)=\alpha J_{content}(C,G)+\beta J_{style}(S, G)
J(G)=αJcontent(C,G)+βJstyle(S,G)