Skip to content

Instantly share code, notes, and snippets.

@BalazsHoranyi
Last active April 17, 2018 22:01
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 BalazsHoranyi/a3520386126917db8fc2585ed408f60d to your computer and use it in GitHub Desktop.
Save BalazsHoranyi/a3520386126917db8fc2585ed408f60d to your computer and use it in GitHub Desktop.
BPR
def bpr_loss(positive_predictions, negative_predictions):
"""
Bayesian Personalised Ranking pairwise loss function. Original Implementation: https://github.com/maciejkula/spotlight
"""
loss = (1.0 - F.sigmoid(positive_predictions -
negative_predictions))
return loss.mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment