Article address: A Neural algorithm of artistic Style
Code: Https://github.com/jcjohnson/neural-style
This article I think can be a romantic name-everyone is Van Gogh.
One of the main things to do is interesting, that is, the equation, by combining the style of a graph with the content of the P graph, to get the third picture X. style+content=styled Content
How do you do it? First he defines two loss, which represent the loss of the style of the resulting graph X and style A, and the loss,α,β on the contents of the X and the content graph p are the parameters that regulate the proportions of the two. The final loss function is the sums of both. The final x is obtained by optimize the total loss.
Details
The CNN network used is VGG-16, using 16 of its convolutional layers and 5 pooling layers to generate feature.
Suppose a layer gets a response that is FL∈RNL? ML, where NL is the number of L-layer filter, and ML is the size of the filter. Flij represents the output of the I filter at position J of the L layer. Content loss
Assuming that p and X's responses in CNN are PL and FL, the loss on their content is represented as the two norm for each pixel:
Then the gradient descent method is used, and content loss is the derivative of f:
Style Loss
Figure X's style is represented as GL∈RNL? Nl, where Glij=∑kflik? FLJK, that is, CNN the same layer different filter response cross-correlation, as to why the cross-correlation can be expressed style,well,i don ' t know ....
Then each layer style loss for
Where style A's response in CNN is a.
Then the total style loss is weighted for each layer and:
Total Loss
After defining the form of the two loss, it is back to the original question of minimizing the total loss:
Note that, unlike the general CNN optimizations, the parameters optimized here are no longer the network's W and B, but the initial input of a noise picture X
In the end, we want to make him the styled content of the right image. Experiments
The result of applying a different style to the same content picture is as shown in fantastic!!
Percentage of alpha and β in total loss:
From top to bottom, the use of different conv layers of feature to STYLE,CONV1->CONV5 is a process from the whole to the local;
From left to right is the ratio of different alpha/beta, 10?5->10?2 refers to the more style or more emphasis on content.
"Everyone is Van Gogh." A Neural algorithm of artistic Style