SoftMarginRankingLoss
- class SoftMarginRankingLoss(margin: float = 1.0, reduction: str = 'mean')[source]
Bases:
MarginPairwiseLoss
The soft pairwise hinge loss (i.e., soft margin ranking loss).
\[L(k, \bar{k}) = \log(1 + \exp(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.,
pykeen.models.TransE
has \(f(h,r,t)=-||\mathbf{e}_h+\mathbf{e}_r-\mathbf{e}_t||_p\)), \(g(x)=\log(1 + \exp(x))\) is the softmax activation function, and \(\lambda\) is the margin.See also
When choosing margin=0`, this loss becomes equivalent to
pykeen.losses.SoftMarginRankingLoss
. It is also closely related topykeen.losses.MarginRankingLoss
, only differing in that this loss uses the softmax activation andpykeen.losses.MarginRankingLoss
uses the ReLU activation.Initialize the loss.
- Parameters:
Attributes Summary
The default strategy for optimizing the loss's hyper-parameters
Attributes Documentation