4

【DeepDream】初学

 2 years ago
source link: https://www.guofei.site/2018/11/14/deepdream.html
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.

【DeepDream】初学

2018年11月14日

Author: Guofei

文章归类: 2-5-CV ,文章编号: 270


版权声明:本文作者是郭飞。转载随意,但需要标明原文链接,并通知本人
原文链接:https://www.guofei.site/2018/11/14/deepdream.html

Edit

tensorflow 示例 上的讲解,比看过的几本书都要清晰(看的几本书都是从这里抄的,而且抄来抄去反而不太好看了)。

我的粗浅理解是这样的:

  1. 找到CNN中某个神经元(换句话说,某个CNN节点的某个channel)。合适的层叫做风格层,至于怎么找到的我还没搞清楚。总之越往上层的神经元,其处理的信息越抽象;越下层的神经元越细节。
  2. 对于输入的图片,我们想调整图片,使得上面那个神经元输出值最大(被激活)
  3. 用梯度来做这个事情,迭代中不断调整图片各个像素的值(梯度上升)。

下面是听吴恩达的课程后的笔记

Content(C)+Style(S)=Generated image G

J(G)=αJcontent(C,G)+βJstyle(S,G)J(G)=αJcontent(C,G)+βJstyle(S,G)

  1. initiate G randomly
  2. Use gradient descent to minJ(G)minJ(G)
    • $J_{content}(C,G)=0.5 \mid \mid a^{l}-a^{l}\mid\mid^2$
    • Jstyle(S,G)=∑lλ[l]J[l]style(S,G)Jstyle(S,G)=∑lλ[l]Jstyle[l](S,G)
      • $J_{style}^{[l]}(S,G)=\dfrac{1}{(2n_H^{[l]}n_W^{[l]}n_C^{[l]})^2}\mid\mid G^{l}-G^{l} \mid\mid_F=\dfrac{1}{(2n_H^{[l]}n_W^{[l]}n_C^{[l]})^2}\sum\limits_k\sum\limits_{k’}(G_{kk’}^{l}-G_{kk’}^{l})$
      • $G_{kk’}^{l}=\sum\limits_i\sum\limits_j a_{ijk}^{l}a_{ijk’}^{l}$
      • $G_{kk’}^{l}=\sum\limits_i\sum\limits_j a_{ijk}^{l}a_{ijk’}^{l}$

tf实现

不同的是,这里用的是 vgg-19,预训练好的参数在这里下载 https://www.kaggle.com/teksab/imagenetvggverydeep19mat/downloads/imagenetvggverydeep19mat.zip/1

参考文献

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/tutorials/deepdream
https://github.com/hjptriplebee/deep_dream_tensorflow/blob/master/main.py
https://github.com/google/deepdream/blob/master/dream.ipynb


您的支持将鼓励我继续创作!

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK