Skip to content

Instantly share code, notes, and snippets.

@danielhavir
Created February 3, 2019 23:44
Show Gist options
  • Save danielhavir/7a57075f03489ffef25ec366e3a996d3 to your computer and use it in GitHub Desktop.
Save danielhavir/7a57075f03489ffef25ec366e3a996d3 to your computer and use it in GitHub Desktop.
def style_loss(style_features, generated_features, J):
loss_style = 0.
for j in J:
gram_style = gram_matrix(style_features[j])
gram_gen = gram_matrix(generated_features[j])
loss_style += F.mse_loss(gram_gen, gram_style)
return loss_style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment