ComplEx

class ComplEx(*, embedding_dim: int = 200, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function normal_>, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function normal_>, regularizer: str | ~pykeen.regularizers.Regularizer | type[~pykeen.regularizers.Regularizer] | None = <class 'pykeen.regularizers.LpRegularizer'>, regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]

Bases: ERModel[Tensor, Tensor, Tensor]

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 (str | Callable[[Tensor], Tensor] | None) – entity initializer function. Defaults to torch.nn.init.normal_(). cf. Embedding.__init__().

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

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

  • regularizer_kwargs (Mapping[str, Any] | None) – 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.