QuatE

class QuatE(*, embedding_dim: int = 100, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function init_quaternions>, entity_regularizer: str | ~pykeen.regularizers.Regularizer | None = <class 'pykeen.regularizers.LpRegularizer'>, entity_regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function init_quaternions>, relation_regularizer: str | ~pykeen.regularizers.Regularizer | None = <class 'pykeen.regularizers.LpRegularizer'>, relation_regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_normalizer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function normalize>, **kwargs)[source]

Bases: ERModel[Tensor, Tensor, Tensor]

An implementation of QuatE from [zhang2019].

QuatE uses hypercomplex valued representations for the entities and relations. Entities and relations are represented as vectors \(\textbf{e}_i, \textbf{r}_i \in \mathbb{H}^d\), and the plausibility score is computed using the quaternion inner product.

The representations are stored in an Embedding. Scores are calculated with QuatEInteraction.

Initialize QuatE.

Note

The default parameters correspond to the first setting for FB15k-237 described from [zhang2019].

Parameters:
  • embedding_dim (int) –

    The embedding dimensionality of the entity embeddings.

    Note

    The number of parameter per entity is 4 * embedding_dim, since quaternion are used.

  • entity_initializer (str | Callable[[Tensor], Tensor] | None) – The initializer to use for the entity embeddings.

  • entity_regularizer (str | Regularizer | None) – The regularizer to use for the entity embeddings.

  • entity_regularizer_kwargs (Mapping[str, Any] | None) – The keyword arguments passed to the entity regularizer. Defaults to QuatE.regularizer_default_kwargs if not specified.

  • relation_initializer (str | Callable[[Tensor], Tensor] | None) – The initializer to use for the relation embeddings.

  • relation_regularizer (str | Regularizer | None) – The regularizer to use for the relation embeddings.

  • relation_regularizer_kwargs (Mapping[str, Any] | None) – The keyword arguments passed to the relation regularizer. Defaults to QuatE.regularizer_default_kwargs if not specified.

  • relation_normalizer (str | Callable[[Tensor], Tensor] | None) – The normalizer to use for the relation embeddings.

  • kwargs – Additional keyword based arguments passed to pykeen.models.ERModel. Must not contain “interaction”, “entity_representations”, or “relation_representations”.

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 [zhang2019] for QuatE.

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.029999999999999992}

The LP settings used by [zhang2019] for QuatE.