KGE.score
Classes
An implementation of dot product. |
|
An implementation of negative Lp-distance. |
|
An implementation of negative squared Lp-distance. |
|
A base module for score. |
Class Inheritance Diagram

Different score functions that you can choose when training translating-based models.
Score functions measure the distance bewtween \(translation\) and \(predicate\)
in translating-based models, for example,
TransE
uses L1 or L2-distance,
TransH,
TransR,
TransD use squared L2-distance.
You can change the score function to try any possibility in a very easy way:
from KGE.models.translating_based.TransE import TransE
from KGE.score import LpDistancePow
model = TransE(
embedding_params={"embedding_size": 10},
negative_ratio=10,
corrupt_side="h+t",
score_fn=LpDistancePow(p=2) # specifying score function you want
)
- class KGE.score.Dot[source]
Bases:
KGE.score.ScoreAn implementation of dot product.
Score between \(\textbf{x}\) and \(\textbf{y}\) is defined as \(\textbf{x} \cdot \textbf{y}\)
Methods
__call__(x, y)Calculate score.
- class KGE.score.LpDistance[source]
Bases:
KGE.score.ScoreAn implementation of negative Lp-distance.
Score between \(\textbf{x}\) and \(\textbf{y}\) is defined as \(- \left\| \textbf{x} - \textbf{y} \right\|_p\)
Methods
__call__(x, y)Calculate score.
- class KGE.score.LpDistancePow[source]
Bases:
KGE.score.ScoreAn implementation of negative squared Lp-distance.
Score between \(\textbf{x}\) and \(\textbf{y}\) is defined as \(- \left\| \textbf{x} - \textbf{y} \right\|_p^2\)
Methods
__call__(x, y)Calculate score.