KGE.score

Classes

Dot

An implementation of dot product.

LpDistance

An implementation of negative Lp-distance.

LpDistancePow

An implementation of negative squared Lp-distance.

Score

A base module for score.

Class Inheritance Diagram

Inheritance diagram of KGE.score.Dot, KGE.score.LpDistance, KGE.score.LpDistancePow, KGE.score.Score

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.Score

An 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.

__init__()[source]

Initialize score.

class KGE.score.LpDistance[source]

Bases: KGE.score.Score

An 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.

__init__(p)[source]

Initialize score.

class KGE.score.LpDistancePow[source]

Bases: KGE.score.Score

An 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.

__init__(p)[source]

Initialize score.

class KGE.score.Score[source]

Bases: object

A base module for score.

Methods

__call__(x, y)

Calculate score.

__init__()[source]

Initialize score.