recpack.algorithms.loss_functions.bpr_loss

recpack.algorithms.loss_functions.bpr_loss(positive_sim: torch.Tensor, negative_sim: torch.Tensor) torch.Tensor

Bayesian Personalized Ranking loss.

BPR loss as defined in Rendle, Steffen, et al. “BPR: Bayesian personalized ranking from implicit feedback.”

Input are the scores for positive samples, and scores for negative samples.

Parameters
  • positive_sim (torch.Tensor) – Tensor with scores of positive samples (dimension = num_samples, 1)

  • negative_sim (torch.Tensor) – Tensor with scores of negative samples (dimension = num_samples, 1)

Returns

The loss value of the bpr criterion

Return type

torch.Tensor