Content loss

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 the outputs generated by passing the content image and noise image to the MSE loss function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.226.240