HolEInteraction

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

Bases: FunctionalInteraction[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) = \textbf{r}^{T}(\textbf{h} \star \textbf{t})\]

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

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

By using the correlation operator each component \([\textbf{h} \star \textbf{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 \(\textbf{r}\). Similarly irrelevant interactions of features could also be placed into the same partition which could be assigned a small weight in \(\textbf{r}\).

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

Methods Summary

func(h, r, t)

Evaluate the interaction function.

Methods Documentation

static func(h: FloatTensor, r: FloatTensor, t: FloatTensor) FloatTensor[source]

Evaluate the interaction function.

See also

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

Parameters:
  • h (FloatTensor) – shape: (*batch_dims, d) The head representations.

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

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

Returns:

shape: batch_dims The scores.

Return type:

FloatTensor