easygraph.nn.loss module#

class easygraph.nn.loss.BPRLoss(*args: Any, **kwargs: Any)[source]#

Bases: Module

This criterion computes the Bayesian Personalized Ranking (BPR) loss between the positive scores and the negative scores.

Parameters:
  • alpha (float, optional) – The weight for the positive scores in the BPR loss. Defaults to 1.0.

  • beta (float, optional) – The weight for the negative scores in the BPR loss. Defaults to 1.0.

  • activation (str, optional) – The activation function to use can be one of "sigmoid_then_log", "softplus". Defaults to "sigmoid_then_log".

forward(pos_scores: torch.Tensor, neg_scores: torch.Tensor)[source]#

The forward function of BPRLoss.

Parameters:
  • pos_scores (torch.Tensor) – The positive scores.

  • neg_scores (torch.Tensor) – The negative scores.