CrossE

class CrossE(*, embedding_dim: int = 50, combination_activation: str | ~torch.nn.modules.module.Module | type[~torch.nn.modules.module.Module] | None = <class 'torch.nn.modules.activation.Tanh'>, combination_activation_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, combination_dropout: float | None = 0.5, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, relation_interaction_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, **kwargs)[source]

Bases: ERModel[FloatTensor, tuple[FloatTensor, FloatTensor], FloatTensor]

An implementation of CrossE from [zhang2019b].

CrossE represents each entity by a \(d\)-dimensional vector. Relations are represented by two \(d\)-dimensional vectors, one of which is a regular embedding vector, while the other is relation-specific interaction vector. All are stored in Embedding. On top of that, CrossEInteraction is used to get the scores.

Initialize the model.

Parameters:
  • embedding_dim (int) – The entity and relation embedding dimension \(d\). Defaults to 50.

  • combination_activation (str | Module | type[Module] | None) – The combination activation function.

  • combination_activation_kwargs (Mapping[str, Any] | None) – Additional keyword-based arguments passed to the constructor of the combination activation function (if not already instantiated).

  • combination_dropout (float | None) – An optional dropout applied after the combination and before the dot product similarity.

  • entity_initializer (str | Callable[[Tensor], Tensor] | None) – Entity initializer function.

  • relation_initializer (str | Callable[[Tensor], Tensor] | None) – Relation embedding initializer function.

  • relation_interaction_initializer (str | Callable[[Tensor], Tensor] | None) – Relation interaction vector initializer function.

  • kwargs – Remaining keyword arguments passed through to ERModel.

Note

The parameter pair (combination_activation, combination_activation_kwargs) is used for class_resolver.contrib.torch.activation_resolver

An explanation of resolvers and how to use them is given in https://class-resolver.readthedocs.io/en/latest/.

Attributes Summary

hpo_default

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

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