II. Content Reconstruction
The content loss is the squared L2 distance of the feature of input image and the target content image
at a certain layer. I get the feature extractor from a pre-trained VGG-19 network from
torchvision.models, fix the network weights, and optimize the input image with LBFGS
quasi-newton optimizer.
Below I experimented with adding the content loss after different layers and run optimization for 1000 steps.
We can see that the content loss works better in earlier layers (conv_1, conv_2) while the the output image contains more noise as the layer goes deeper (conv_6, conv_10). This is because the initial layers of the network capture low-level features such as edges and textures which are closer to the raw pixel values. Optimizing content loss in these layers will result in reconstructions that closely resemble the original image. The deeper layers lack spatial details while capture more high-level features, therefore optimizing content with these abstractions will introduce artifacts and noise.
I chose conv_2 for the layer to add content loss and then experiment with 2 random noises as 2 inputs.
Visually there is no difference in the output image with different random noise. Quantatively
the distance between the 2 images is also very close to 0. The reconstructed image does appear
more blurry than the original image though, which is expected as high-frequency details are lost
after the pooling layers in VGG-19 which reduce the spatial dimensions of features maps as the image
passes through the network. By optimizing content reconstruction at conv_2, it natually
focuses on minimizing large-scale differences while not perfectly capturing the precise alignment of
every pixel.