Skip to content

Instantly share code, notes, and snippets.

@wcneill
Created July 12, 2020 19:15
Show Gist options
  • Save wcneill/75dcdd7eef65596454e496d2dfbbd4ab to your computer and use it in GitHub Desktop.
Save wcneill/75dcdd7eef65596454e496d2dfbbd4ab to your computer and use it in GitHub Desktop.
def content_loss(c_features, t_features):
"""
Compute mean squared content loss of all feature maps.
"""
loss = 0.5 * (t_features['conv4_2'] - c_features['conv4_2']) ** 2
return torch.mean(loss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment