PairwiseLoss
- class PairwiseLoss(reduction: Literal['mean', 'sum'] = 'mean')[source]
Bases:
Loss
Pairwise loss functions compare the scores of a positive triple and a negative triple.
Initialize the loss.
- Parameters:
reduction (Literal['mean', 'sum']) – the reduction, cf.
pykeen.nn.modules._Loss
Methods Summary
forward
(pos_scores, neg_scores[, ...])Calculate the point-wise loss.
Methods Documentation
- abstractmethod forward(pos_scores: Tensor, neg_scores: Tensor, pos_weights: Tensor | None = None, neg_weights: Tensor | None = None) Tensor [source]
Calculate the point-wise loss.
Note
The positive and negative scores need to be broadcastable.
Note
If given, the positve/negative weight needs to be broadcastable to the respective scores.