TransH

class TransH(*, embedding_dim=50, scoring_fct_norm=2, entity_initializer=<function xavier_normal_>, regularizer=None, regularizer_kwargs=None, relation_initializer=<function xavier_normal_>, relation_regularizer=None, relation_regularizer_kwargs=None, **kwargs)[source]

Bases: ERModel

An implementation of TransH [wang2014].

This model extends pykeen.models.TransE by applying the translation from head to tail entity in a relational-specific hyperplane in order to address its inability to model one-to-many, many-to-one, and many-to-many relations.

In TransH, each relation is represented by a hyperplane, or more specifically a normal vector of this hyperplane \(\textbf{w}_{r} \in \mathbb{R}^d\) and a vector \(\textbf{d}_{r} \in \mathbb{R}^d\) that lies in the hyperplane. To compute the plausibility of a triple \((h,r,t)\in \mathbb{K}\), the head embedding \(\textbf{e}_h \in \mathbb{R}^d\) and the tail embedding \(\textbf{e}_t \in \mathbb{R}^d\) are first projected onto the relation-specific hyperplane:

\[ \begin{align}\begin{aligned}\textbf{e'}_{h,r} = \textbf{e}_h - \textbf{w}_{r}^\top \textbf{e}_h \textbf{w}_r\\\textbf{e'}_{t,r} = \textbf{e}_t - \textbf{w}_{r}^\top \textbf{e}_t \textbf{w}_r\end{aligned}\end{align} \]

where \(\textbf{h}, \textbf{t} \in \mathbb{R}^d\). Then, the projected embeddings are used to compute the score for the triple \((h,r,t)\):

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

See also

Initialize TransH.

Parameters:

Attributes Summary

hpo_default

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

regularizer_default_kwargs

The default parameters for the default regularizer class

relation_regularizer_default_kwargs

The settings used by [wang2014] for TransH

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_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

regularizer_default_kwargs: ClassVar[Mapping[str, Any]] = {'apply_only_once': True, 'dim': -1, 'max_norm': 1.0, 'p': 2, 'power_norm': True, 'weight': 0.05}

The default parameters for the default regularizer class

relation_regularizer_default_kwargs: ClassVar[Mapping[str, Any]] = {'apply_only_once': True, 'epsilon': 1e-05, 'weight': 0.05}

The settings used by [wang2014] for TransH