DistMAInteraction

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

Bases: FunctionalInteraction[Tensor, Tensor, Tensor]

The stateless DistMA interaction function from [shi2019].

For head entity, relation, and tail representations \(\mathbf{h}, \mathbf{r}, \mathbf{t} \in \mathbb{R}^d\), the interaction functions is given by

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

Note

This interaction function is the symmetric part \(E_1\) from the respective paper, and not the combination with ComplExInteraction.

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: 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