# TransR

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$$

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