Skip to content

Instantly share code, notes, and snippets.

@danielhavir
Created February 3, 2019 23:40
Show Gist options
  • Save danielhavir/eb225aca615b03032b2551314749bf8a to your computer and use it in GitHub Desktop.
Save danielhavir/eb225aca615b03032b2551314749bf8a to your computer and use it in GitHub Desktop.
def gram_matrix(feature_map):
C, H, W = feature_map.size()
reshaped_map = feature_map.view(C, H*W)
G = reshaped_map.mm(reshaped_map.t()) / (C * H * W)
return G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment