RotatEInteraction

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

Bases: FunctionalInteraction[FloatTensor, FloatTensor, FloatTensor]

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, r, t)[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 (FloatTensor) – shape: (*batch_dims, dim) The head representations.

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

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

Return type:

FloatTensor

Returns:

shape: batch_dims The scores.