RotatEInteraction

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

Bases: FunctionalInteraction[Tensor, Tensor, Tensor]

The RotatE interaction function proposed by [sun2019].

RotatE operates on complex-valued entity and relation representations, i.e., \(\textbf{e}_i, \textbf{r}_i \in \mathbb{C}^d\).

Note

this method generally expects all tensors to be of complex datatype, i.e., torch.is_complex(x) to evaluate to True. However, for backwards compatibility and convenience in use, you can also pass real tensors whose shape is compliant with torch.view_as_complex(), cf. pykeen.utils.ensure_complex().

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

Attributes Summary

is_complex

whether the interaction is defined on complex input

Methods Summary

func(h, r, t)

Evaluate the interaction function.

Attributes Documentation

is_complex: ClassVar[bool] = True

whether the interaction is defined on complex input

Methods Documentation

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

Evaluate the interaction function.

Note

this method expects all tensors to be of complex datatype, i.e., torch.is_complex(x) to evaluate to True.

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

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

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

Returns:

shape: batch_dims The scores.

Return type:

Tensor