A recent study of the CS20 curriculum-a practical course on TensorFlow applications-just Assignment2 about the style transfer, which summarizes my understanding (the code is based on TensorFlow).
Code:
chiphuyen/stanford-tensorflow-tutorials/assignments/02_style_transfer/
Thesis: Bringing Impressionism to life with neural Style Transfer in Come swim https://arxiv.org/pdf/1701.04928v1.pdf Introduction
This is a use of two images (expressed as a and b) as input (figure A as content input), and Figure B as style input (style input). The ultimate goal is to get an image with the style of Figure B and the content of figure A. Style picture
Content picture
What we Got
A simple equation can be expressed as follows: Style + content = Picture of highly abstracted steps briefly use a trained CNN structure (generally do image classification, Like Vgg, googlenet, etc.) we want to have a concept: the lower layer feature map in CNN retains more content, and the top is more texture, it is the use of this, we will combine the content information and texture information and combine the two to get a new picture.
Define the loss function for the content and style, and combine it as the loss function for the entire structure.
It is worth noting that the structure we enter uses the same structure (whether it is style pic, content pic, or trianable input), in order to avoid the duplication of the sub-graph assembly (tosave us? Assemble the same subgraph multiple times, weare using one variable for all three of them.), which requires tf.variable_scope (' in Put ').
With the previous CNN to adjust network structure parameters such as W and B, the goal here is to continuously adjust the image of an input content pic After adding white noise, and to add contents and texture information to it. Loss Function Description
Ltotal (p→,a→,x→) =αlcontent (p→,x→) +βlstyle (a→,x→) L t o t a l (p→, a→, x→) =αl c o n t e N T (p→, x→) +βl s T y l e (a→, x→) l_{total} (\overrightarrow p,\overrightarrow a,\overrightarrow x) = \alpha L_{content} (\overrightarr ow p,\overrightarrow x) +\beta L_{style} (\overrightarrow A,\overrightarrow x)
Where alpha and beta are weights, the paper points out that α/β=0.001 or 0.0001, this ratio is based on the content and style of the ratio to adjust, when you want to more intense style, improve the α/β value, conversely, lower α/β. 1. Content Loss
Content loss is relatively easy to understand and is defined in the paper as follows:
Lcontent (p→,x→,l) =12∑i,j (FLI,J−PLI,J) 2 L c o n t e N T (p→, x→, L) = 1 2∑i, j (F I, J l−p I