PairwiseLogisticLoss
- class KGE.loss.PairwiseLogisticLoss[source]
Bases:
KGE.loss.LossAn implementation of Pairwise Logistic Loss.
Described in Loss Functions in Knowledge Graph Embedding Models.
For each pair of postive triplet \((h,r,t)_i^+\) and negative triplet \((h,r,t)_i^-\), Pairwise Logistic Loss compare the difference of scores between postivie triplet and negative triplet:
\[\Delta_i = f\left( (h,r,t)_i^- \right) - f\left( (h,r,t)_i^+ \right)\]and define the Pairwise Logistic Loss as:
\[\mathscr{L} = \sum_i log(1+exp(\Delta_i))\]Pairwise Logistic Loss is a smooth version of
Pairwise Hinge Losswhile \(\gamma = 0\), you can view function graph here to campare these two functions.Methods Summary
__call__(pos_score, neg_score)Calculate loss.
Methods Documentation
- __call__(pos_score, neg_score)[source]
Calculate loss.
- Parameters
pos_score (
tf.Tensor) – score of postive triplets, with shape(n,)neg_score (
tf.Tensor) – score of negative triplets, with shape(n,)
- __new__(*args, **kwargs)