MultiLinearTuckerInteraction

class MultiLinearTuckerInteraction(head_dim: int = 64, relation_dim: int | None = None, tail_dim: int | None = None)[source]

Bases: Interaction[Tensor, Tensor, Tensor]

An implementation of the original (multi-linear) TuckER interaction as described [tucker1966].

Note

For small tensors, there are more efficient algorithms to compute the decomposition, e.g., http://tensorly.org/stable/modules/generated/tensorly.decomposition.Tucker.html

Initialize the Tucker interaction function.

Parameters:
  • head_dim (int) – The head entity embedding dimension.

  • relation_dim (int | None) – The relation embedding dimension. Defaults to head_dim.

  • tail_dim (int | None) – The tail entity embedding dimension. Defaults to head_dim.

Attributes Summary

entity_shape

The symbolic shapes for entity representations

relation_shape

The symbolic shapes for relation representations

Methods Summary

forward(h, r, t)

Evaluate the interaction function.

reset_parameters()

Reset parameters the interaction function may have.

Attributes Documentation

entity_shape: Sequence[str] = ('d', 'f')

The symbolic shapes for entity representations

relation_shape: Sequence[str] = ('e',)

The symbolic shapes for relation representations

Methods Documentation

forward(h: Tensor, r: Tensor, t: Tensor) Tensor[source]

Evaluate the interaction function.

See also

Interaction.forward for a detailed description about the generic batched form of the interaction function.

Parameters:
  • h (Tensor) – shape: (*batch_dims, head_dim) The head representations.

  • r (Tensor) – shape: (*batch_dims, relation_dim) The relation representations.

  • t (Tensor) – shape: (*batch_dims, tail_dim) The tail representations.

Returns:

shape: batch_dims The scores.

Return type:

Tensor

reset_parameters()[source]

Reset parameters the interaction function may have.