QuatEInteraction

class QuatEInteraction[source]

Bases: Interaction[Tensor, Tensor, Tensor]

The state-less QuatE interaction function.

It is given as

\[\langle \mathbf{h} \otimes \mathbf{r}, \mathbf{t} \rangle\]

where \(\mathbf{h}, \mathbf{r}, \mathbf{t} \in \mathbb{H}^d\) are quanternion representations, \(\otimes\) denotes the Hamilton product, and \(\langle \cdot, \cdot \rangle\) the inner product.

Warning

In order to representation a rotation, \(\mathbf{r}\) must be normalized to unit length, cf. pykeen.nn.quaternion.normalize().

Initialize the interaction module.

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 of QuatE for given embeddings.

Attributes Documentation

entity_shape: Sequence[str] = ('dk',)

The symbolic shapes for entity representations

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

The symbolic shapes for relation representations

Methods Documentation

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

Evaluate the interaction function of QuatE for given embeddings.

The embeddings have to be in a broadcastable shape.

See also

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

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

  • r (tuple[Tensor, Tensor]) – shape: (*batch_dims, dim, 4) The head representations.

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

Returns:

shape: (…) The scores.

Return type:

Tensor