MarginRankingLoss
- class MarginRankingLoss(margin: float = 1.0, reduction: str = 'mean')[source]
Bases:
MarginPairwiseLoss
The pairwise hinge loss (i.e., margin ranking loss).
\[L(k, \bar{k}) = \max(0, f(\bar{k}) - f(k) + \lambda)\]Where \(k\) are the positive triples, \(\bar{k}\) are the negative triples, \(f\) is the interaction function (e.g., TransE has \(f(h,r,t)=-||\mathbf{e}_h+\mathbf{e}_r-\mathbf{e}_t||_p\)), \(g(x)=\max(0,x)\) is the ReLU activation function, and \(\lambda\) is the margin.
See also
MRL is closely related to
pykeen.losses.SoftMarginRankingLoss
, only differing in that this loss uses the ReLU activation andpykeen.losses.SoftMarginRankingLoss
uses the softmax activation. MRL is also related to thepykeen.losses.PairwiseLogisticLoss
as this is a special case of thepykeen.losses.SoftMarginRankingLoss
with no margin.Note
The related
torch
module istorch.nn.MarginRankingLoss
, but it can not be used interchangeably in PyKEEN because of the extended functionality implemented in PyKEEN’s loss functions.Initialize the margin loss instance.
- Parameters:
Attributes Summary
The default strategy for optimizing the loss's hyper-parameters
synonyms of this loss
Attributes Documentation