What are Deep ConvNets learning?

Neural style transfer
aims to produce an image that blends the content of one image and the style of another

You have a content image (C), a style image (S), and you aim to produce a generated image (G).
Cost function

There are two cost functions
- Content cost function
How similar content of G is to the content of C - Style cost function
How similar is style of G to style of C
a and b are hyperparameters to adjust relative importance of content and style cost
Content cost function
Using too shallow a layer (e.g., layer 1) forces G to have pixel values closely resembling C
In practice, the layer L used for computing the content cost is chosen from the middle layers of the neural network
A pre-trained convolutional network, such as VGG, can be employed to compute content cost.
Measure the similarity of the content between the content image C and the generated image G using activations from the chosen layer l. Represent these activations as and

The content cost (C,G) is computed as the squared difference of the activations from layer 𝑙 for both images.
This involves element-wise subtraction and squaring of the difference. The result gives an idea of how similar/different the content of both images is at that layer.
To clarify, the activations are unrolled into vectors, making it a squared L2 norm of the difference between the two activations.
This essentially boils down to the sum of squared differences between the activations for the content and generated images at layer 𝑙.
Style cost function
Say you are using layers l activation to measrure style of image
Define style as correlatino abetween actiavtions across channels


The style of an image is defined based on the correlation between activations across different channels in a certain layer.
If two channels are highly correlated, it implies that the features those channels detect appear together in the image.
For the style image S: The style matrix is computed once, at the beginning of the process, using the activations from feeding the style image S through the network.
For the generated image G: The style matrix is computed repeatedly during the optimization process, as the generated image G is updated.

Each Gram-matrix entry measures the unnormalized correlation between two channels across spatial positions.
Compute a Gram matrix for the style image and another for the generated image.

We can set weights to each layers to ensure that more visually appealing images are generated
