Skip to content

Instantly share code, notes, and snippets.

@Ed-Optalysys
Last active June 29, 2021 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ed-Optalysys/50fe517b8a6a38880974ec820c0dfb1b to your computer and use it in GitHub Desktop.
Save Ed-Optalysys/50fe517b8a6a38880974ec820c0dfb1b to your computer and use it in GitHub Desktop.
def normalised_squared_euclidean_distance(m_1, m_2):
return torch.mean(torch.square(m_1 - m_2))
def vgg_feature_loss(prediction, target, loss_model):
p_features = loss_model.forward_features(prediction).relu2_2
t_features = loss_model.forward_features(target).relu2_2
return normalised_squared_euclidean_distance(p_features, t_features)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment