TuckER

class TuckER(*, embedding_dim: int = 200, relation_dim: int | None = None, dropout_0: float = 0.3, dropout_1: float = 0.4, dropout_2: float = 0.5, apply_batch_normalization: bool = True, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_normal_>, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_normal_>, core_tensor_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = None, core_tensor_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]

Bases: ERModel[Tensor, Tensor, Tensor]

An implementation of TuckEr from [balazevic2019].

It represents entities by \(d_e\)-dimensional vectors and relations by \(d_r\)-dimensional vectors, stored in Embedding. The state-ful TuckERInteraction is then used to score triples.

For \(E\) entities and \(R\) relations, the model has \(Ed_e + Rd_r + d_e^2d_r\) effective parameters (ignoring additional parameters from the torch.nn.BatchNorm1d layers in TuckERInteraction).

Initialize the model.

Parameters:
  • embedding_dim (int) – the (entity) embedding dimension

  • relation_dim (int | None) – the relation embedding dimension. Defaults to embedding_dim.

  • dropout_0 (float) – the first dropout, cf. formula

  • dropout_1 (float) – the second dropout, cf. formula

  • dropout_2 (float) – the third dropout, cf. formula

  • apply_batch_normalization (bool) – whether to apply batch normalization

  • entity_initializer (str | Callable[[Tensor], Tensor] | None) – the entity representation initializer

  • relation_initializer (str | Callable[[Tensor], Tensor] | None) – the relation representation initializer

  • core_tensor_initializer (str | Callable[[Tensor], Tensor] | None) – the core tensor initializer

  • core_tensor_initializer_kwargs (Mapping[str, Any] | None) – keyword-based parameters passed to the core tensor initializer

  • kwargs – additional keyword-based parameters passed to ERModel.__init__()

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

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'dropout_0': {'high': 0.5, 'low': 0.0, 'q': 0.1, 'type': <class 'float'>}, 'dropout_1': {'high': 0.5, 'low': 0.0, 'q': 0.1, 'type': <class 'float'>}, 'dropout_2': {'high': 0.5, 'low': 0.0, 'q': 0.1, 'type': <class 'float'>}, 'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}, 'relation_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]] = {}

The default parameters for the default loss function class