MultiLinearTuckerInteraction

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

Bases: FunctionalInteraction[Tuple[FloatTensor, FloatTensor], FloatTensor, Tuple[FloatTensor, FloatTensor]]

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 (Optional[int]) – The relation embedding dimension. Defaults to head_dim.

  • tail_dim (Optional[int]) – 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

func(r, t, core_tensor)

Evaluate the (original) multi-linear TuckEr 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

func(r, t, core_tensor)

Evaluate the (original) multi-linear TuckEr interaction function.

\[score(h, r, t) = \sum W_{ijk} h_i r_j t_k\]
Parameters:
  • h (FloatTensor) – shape: (*batch_dims, d_e) The head representations.

  • r (FloatTensor) – shape: (*batch_dims, d_r) The relation representations.

  • t (FloatTensor) – shape: (*batch_dims, d_e) The tail representations.

  • core_tensor (FloatTensor) – shape: (d_h, d_r, d_t) The core tensor.

Return type:

FloatTensor

Returns:

shape: batch_dims The scores.

reset_parameters()[source]

Reset parameters the interaction function may have.