SimplE
- class SimplE(*, embedding_dim=200, clamp_score=None, entity_initializer=None, relation_initializer=None, regularizer=None, regularizer_kwargs=None, **kwargs)[source]
Bases:
ERModel
An implementation of SimplE [kazemi2018].
SimplE is an extension of canonical polyadic (CP), an early tensor factorization approach in which each entity \(e \in \mathcal{E}\) is represented by two vectors \(\textbf{h}_e, \textbf{t}_e \in \mathbb{R}^d\) and each relation by a single vector \(\textbf{r}_r \in \mathbb{R}^d\). Depending whether an entity participates in a triple as the head or tail entity, either \(\textbf{h}\) or \(\textbf{t}\) is used. Both entity representations are learned independently, i.e. observing a triple \((h,r,t)\), the method only updates \(\textbf{h}_h\) and \(\textbf{t}_t\). In contrast to CP, SimplE introduces for each relation \(\textbf{r}_r\) the inverse relation \(\textbf{r'}_r\), and formulates its the interaction model based on both:
\[f(h,r,t) = \frac{1}{2}\left(\left\langle\textbf{h}_h, \textbf{r}_r, \textbf{t}_t\right\rangle + \left\langle\textbf{h}_t, \textbf{r'}_r, \textbf{t}_h\right\rangle\right)\]Therefore, for each triple \((h,r,t) \in \mathbb{K}\), both \(\textbf{h}_h\) and \(\textbf{h}_t\) as well as \(\textbf{t}_h\) and \(\textbf{t}_t\) are updated.
See also
Official implementation: https://github.com/Mehran-k/SimplE
Improved implementation in pytorch: https://github.com/baharefatemi/SimplE
Initialize the model.
- Parameters
embedding_dim (
int
) – the embedding dimensionclamp_score (
Union
[float
,Tuple
[float
,float
],None
]) – whether to clamp scores, cf.SimplEInteraction.__init__()
entity_initializer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – the entity representation initializerrelation_initializer (
Union
[str
,Callable
[[FloatTensor
],FloatTensor
],None
]) – the relation representation initializerregularizer (
Union
[str
,Regularizer
,None
]) – the regularizer, defaults toSimplE.regularizer_default
regularizer_kwargs (
Optional
[Mapping
[str
,Any
]]) – additional keyword-based parameters passed to the regularizer, defaults toSimplE.regularizer_default_kwargs
kwargs – additional keyword-based parameters passed to
ERModel.__init__()
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
The default parameters for the default loss function class
The power sum settings used by [trouillon2016] for SimplE
Attributes Documentation
- hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}}
The default strategy for optimizing the model’s hyper-parameters