class TransR(*, embedding_dim=50, relation_dim=30, scoring_fct_norm=1, entity_initializer=<function xavier_uniform_>, entity_constrainer=<function clamp_norm>, relation_initializer=<pykeen.utils.compose object>, relation_constrainer=<function clamp_norm>, **kwargs)[source]

Bases: ERModel

An implementation of TransR from [lin2015].

TransR is an extension of pykeen.models.TransH that explicitly considers entities and relations as different objects and therefore represents them in different vector spaces.

For a triple \((h,r,t) \in \mathbb{K}\), the entity embeddings, \(\textbf{e}_h, \textbf{e}_t \in \mathbb{R}^d\), are first projected into the relation space by means of a relation-specific projection matrix \(\textbf{M}_{r} \in \mathbb{R}^{k \times d}\). With relation embedding \(\textbf{r}_r \in \mathbb{R}^k\), the interaction model is defined similarly to TransE with:

\[f(h,r,t) = -\|\textbf{M}_{r}\textbf{e}_h + \textbf{r}_r - \textbf{M}_{r}\textbf{e}_t\|_{p}^2\]

The following constraints are applied:

  • \(\|\textbf{e}_h\|_2 \leq 1\)

  • \(\|\textbf{r}_r\|_2 \leq 1\)

  • \(\|\textbf{e}_t\|_2 \leq 1\)

  • \(\|\textbf{M}_{r}\textbf{e}_h\|_2 \leq 1\)

  • \(\|\textbf{M}_{r}\textbf{e}_t\|_2 \leq 1\)

Initialize the model.

Attributes Summary


The default strategy for optimizing the model's hyper-parameters

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}, 'relation_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}, 'scoring_fct_norm': {'high': 2, 'low': 1, 'type': <class 'int'>}}

The default strategy for optimizing the model’s hyper-parameters