MarginRankingLoss
- class MarginRankingLoss(margin=1.0, reduction='mean')[source]
Bases:
pykeen.losses.MarginPairwiseLoss
A module for the pairwise hinge loss (i.e., margin ranking loss).
\[L(k, \bar{k}) = \max(0, f(k) - f(\bar{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)=h+r-t\)), \(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
Attributes Documentation