February 2018
Intermediate to advanced
262 pages
6h 59m
English
The content loss is the MSE calculated on the output of a particular layer, extracted by passing two images through the network. We extract the outputs of the intermediate layers from the VGG by using the register_forward_hook functionality, by passing in the content image and the image to be optimized. We calculate the MSE obtained from the outputs of these layers, as described in the following code:
target_layer = dummy_fn(content_img)noise_layer = dummy_fn(noise_img)criterion = nn.MSELoss()content_loss = criterion(target_layer,noise_layer)
We will implement the dummy_fn of this code—in the coming sections. For now, all we know is, that the dummy_fn function returns the outputs of particular layers by passing an image. We pass ...