TorusEInteraction

class TorusEInteraction(p: int = 2, power_norm: bool = False)[source]

Bases: NormBasedInteraction[Tensor, Tensor, Tensor]

The TorusE interaction function from [ebisu2018].

Note

This only implements the two L_p norm based variants.

Initialize the interaction module.

See also

The parameter p and power_norm are directly passed to NormBasedInteraction.

Parameters:
  • p (int) – The norm used with torch.linalg.vector_norm(). Typically is 1 or 2.

  • power_norm (bool) – Whether to use the p-th power of the \(L_p\) norm. It has the advantage of being differentiable around 0, and numerically more stable.

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