Skip to content

Instantly share code, notes, and snippets.

View TropComplique's full-sized avatar

Dan Antoshchenko TropComplique

  • NeoCortext
  • Kyiv, Ukraine
View GitHub Profile
@yunjey
yunjey / contextual_loss.py
Created September 20, 2018 08:54
pytorch implementation of contextual loss: https://arxiv.org/abs/1803.02077
def contextual_loss(x, y, h=0.5):
"""Computes contextual loss between x and y.
Args:
x: features of shape (N, C, H, W).
y: features of shape (N, C, H, W).
Returns:
cx_loss = contextual loss between x and y (Eq (1) in the paper)
"""