ComplEx

class ComplEx(*, embedding_dim=200, entity_initializer=<function normal_>, relation_initializer=<function normal_>, regularizer=<class 'pykeen.regularizers.LpRegularizer'>, regularizer_kwargs=None, **kwargs)[source]

Bases: ERModel

An implementation of ComplEx [trouillon2016].

ComplEx is an extension of pykeen.models.DistMult that uses complex valued representations for the entities and relations. Entities and relations are represented as vectors \(\textbf{e}_i, \textbf{r}_i \in \mathbb{C}^d\), and the plausibility score is computed using the Hadamard product:

\[f(h,r,t) = Re(\mathbf{e}_h\odot\mathbf{r}_r\odot\bar{\mathbf{e}}_t)\]

Which expands to:

\[f(h,r,t) = \left\langle Re(\mathbf{e}_h),Re(\mathbf{r}_r),Re(\mathbf{e}_t)\right\rangle + \left\langle Im(\mathbf{e}_h),Re(\mathbf{r}_r),Im(\mathbf{e}_t)\right\rangle + \left\langle Re(\mathbf{e}_h),Im(\mathbf{r}_r),Im(\mathbf{e}_t)\right\rangle - \left\langle Im(\mathbf{e}_h),Im(\mathbf{r}_r),Re(\mathbf{e}_t)\right\rangle\]

where \(Re(\textbf{x})\) and \(Im(\textbf{x})\) denote the real and imaginary parts of the complex valued vector \(\textbf{x}\). Because the Hadamard product is not commutative in the complex space, ComplEx can model anti-symmetric relations in contrast to DistMult.

See also

Official implementation: https://github.com/ttrouill/complex/

Initialize ComplEx.

Parameters

Attributes Summary

hpo_default

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

loss_default_kwargs

The default parameters for the default loss function class

regularizer_default_kwargs

The LP settings used by [trouillon2016] for ComplEx.

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

loss_default_kwargs: ClassVar[Mapping[str, Any]] = {'reduction': 'mean'}

The default parameters for the default loss function class

regularizer_default_kwargs: ClassVar[Mapping[str, Any]] = {'normalize': True, 'p': 2.0, 'weight': 0.01}

The LP settings used by [trouillon2016] for ComplEx.