HolEInteraction

class HolEInteraction(*args, **kwargs)[source]

Bases: Interaction[Tensor, Tensor, Tensor]

The stateless HolE interaction function.

Holographic embeddings (HolE) make use of the circular correlation operator to compute interactions between latent features of entities and relations:

\[f(h,r,t) = \mathbf{r}^{T}(\mathbf{h} \star \mathbf{t})\]

where the circular correlation \(\star: \mathbb{R}^d \times \mathbb{R}^d \rightarrow \mathbb{R}^d\) is defined as:

\[[\mathbf{a} \star \mathbf{b}]_i = \sum_{k=0}^{d-1} \mathbf{a}_{k} * \mathbf{b}_{(i+k)\ mod \ d}\]

By using the correlation operator each component \([\mathbf{h} \star \mathbf{t}]_i\) represents a sum over a fixed partition over pairwise interactions. This enables the model to put semantic similar interactions into the same partition and share weights through \(\mathbf{r}\). Similarly irrelevant interactions of features could also be placed into the same partition which could be assigned a small weight in \(\mathbf{r}\).

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Methods Summary

forward(h, r, t)

Evaluate the interaction function.

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, d) The head representations.

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

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

Returns:

shape: batch_dims The scores.

Return type:

Tensor