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].

The ComplEx model combines complex-valued pykeen.nn.Embedding entity and relation representations with a pykeen.nn.ComplExInteraction.

Initialize ComplEx.

Parameters:
  • embedding_dim (int) – the embedding dimension to use for entity and relation embeddings, cf. Embedding.__init__()’s shape parameter.

  • entity_initializer (Union[str, Callable[[FloatTensor], FloatTensor], None]) – entity initializer function. Defaults to torch.nn.init.normal_(). cf. Embedding.__init__().

  • relation_initializer (Union[str, Callable[[FloatTensor], FloatTensor], None]) – relation initializer function. Defaults to torch.nn.init.normal_(). cf. Embedding.__init__().

  • regularizer (Union[str, Regularizer, Type[Regularizer], None]) – the regularizer to apply to both, entity and relation, representations.

  • regularizer_kwargs (Optional[Mapping[str, Any]]) – additional keyword arguments passed to the regularizer. Defaults to ComplEx.regularizer_default_kwargs.

  • kwargs – remaining keyword arguments to forward to pykeen.models.ERModel

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.