TransD
- class TransD(*, embedding_dim=50, relation_dim=30, interaction_kwargs=None, entity_initializer=<function xavier_uniform_>, relation_initializer=<pykeen.utils.compose object>, entity_constrainer=<function clamp_norm>, relation_constrainer=<function clamp_norm>, **kwargs)[source]
Bases:
pykeen.models.nbase.ERModel
An implementation of TransD from [ji2015].
TransD is an extension of
pykeen.models.TransR
that, like TransR, considers entities and relations as objects living in different vector spaces. However, instead of performing the same relation-specific projection for all entity embeddings, entity-relation-specific projection matrices \(\textbf{M}_{r,h}, \textbf{M}_{t,h} \in \mathbb{R}^{k \times d}\) are constructed.To do so, all head entities, tail entities, and relations are represented by two vectors, \(\textbf{e}_h, \hat{\textbf{e}}_h, \textbf{e}_t, \hat{\textbf{e}}_t \in \mathbb{R}^d\) and \(\textbf{r}_r, \hat{\textbf{r}}_r \in \mathbb{R}^k\), respectively. The first set of embeddings is used for calculating the entity-relation-specific projection matrices:
\[ \begin{align}\begin{aligned}\textbf{M}_{r,h} = \hat{\textbf{r}}_r \hat{\textbf{e}}_h^{T} + \tilde{\textbf{I}}\\\textbf{M}_{r,t} = \hat{\textbf{r}}_r \hat{\textbf{e}}_t^{T} + \tilde{\textbf{I}}\end{aligned}\end{align} \]where \(\tilde{\textbf{I}} \in \mathbb{R}^{k \times d}\) is a \(k \times d\) matrix with ones on the diagonal and zeros elsewhere. Next, \(\textbf{e}_h\) and \(\textbf{e}_t\) are projected into the relation space by means of the constructed projection matrices. Finally, the plausibility score for \((h,r,t) \in \mathbb{K}\) is given by:
\[f(h,r,t) = -\|\textbf{M}_{r,h} \textbf{e}_h + \textbf{r}_r - \textbf{M}_{r,t} \textbf{e}_t\|_{2}^2\]See also
OpenKE implementation of TransD
Initialize the module.
- Parameters
triples_factory – The triples factory facilitates access to the dataset.
interaction – The interaction module (e.g., TransE)
interaction_kwargs (
Optional
[Mapping
[str
,Any
]]) – Additional key-word based parameters given to the interaction module’s constructor, if not already instantiated.entity_representations – The entity representation or sequence of representations
entity_representations_kwargs – additional keyword-based parameters for instantiation of entity representations
relation_representations – The relation representation or sequence of representations
relation_representations_kwargs – additional keyword-based parameters for instantiation of relation representations
skip_checks – whether to skip entity representation checks.
kwargs – Keyword arguments to pass to the base model
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
Attributes Documentation