TransE
- class TransE(*, embedding_dim=50, scoring_fct_norm=1, entity_initializer=<function xavier_uniform_>, entity_constrainer=<function normalize>, relation_initializer=<pykeen.utils.compose object>, relation_constrainer=None, regularizer=None, regularizer_kwargs=None, **kwargs)[source]
Bases:
ERModel
An implementation of TransE [bordes2013].
TransE models relations as a translation from head to tail entities in \(\textbf{e}\):
\[\textbf{e}_h + \textbf{e}_r \approx \textbf{e}_t\]This equation is rearranged and the \(l_p\) norm is applied to create the TransE interaction function.
\[f(h, r, t) = - \|\textbf{e}_h + \textbf{e}_r - \textbf{e}_t\|_{p}\]While this formulation is computationally efficient, it inherently cannot model one-to-many, many-to-one, and many-to-many relationships. For triples \((h,r,t_1), (h,r,t_2) \in \mathcal{K}\) where \(t_1 \neq t_2\), the model adapts the embeddings in order to ensure \(\textbf{e}_h + \textbf{e}_r \approx \textbf{e}_{t_1}\) and \(\textbf{e}_h + \textbf{e}_r \approx \textbf{e}_{t_2}\) which results in \(\textbf{e}_{t_1} \approx \textbf{e}_{t_2}\).
Initialize TransE.
- Parameters:
embedding_dim (
int
) – The entity embedding dimension \(d\). Is usually \(d \in [50, 300]\).scoring_fct_norm (
int
) – The \(l_p\) norm applied in the interaction function. Is usually1
or2.
.entity_initializer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – Entity initializer function.entity_constrainer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – Entity constrainer function.relation_initializer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – Relation initializer function.relation_constrainer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – Relation constrainer function. Defaults to none.kwargs – Remaining keyword arguments to forward to
pykeen.models.ERModel.__init__()
regularizer (
Union
[str
,Regularizer
,Type
[Regularizer
],None
]) – a regularizer, or a hint thereof. Used for both, entity and relation representations; directly useERModel
if you need more flexibilityregularizer_kwargs (
Optional
[Mapping
[str
,Any
]]) – keyword-based parameters for the regularizer
See also
OpenKE implementation of TransE
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
Attributes Documentation