Skip to Content
Deep Learning with PyTorch
book

Deep Learning with PyTorch

by Vishnu Subramanian
February 2018
Intermediate to advanced
262 pages
6h 59m
English
Packt Publishing
Content preview from Deep Learning with PyTorch

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Deep Learning with PyTorch

Deep Learning with PyTorch

Eli Stevens, Thomas Viehmann, Luca Pietro Giovanni Antiga
Grokking Deep Learning

Grokking Deep Learning

Andrew W. Trask

Publisher Resources

ISBN: 9781788624336Supplemental Content