RotatEInteraction
- class RotatEInteraction(p: int = 2, power_norm: bool = False)[source]
Bases:
NormBasedInteraction
[Tensor
,Tensor
,Tensor
]The RotatE interaction function proposed by [sun2019].
RotatE operates on complex-valued entity and relation representations, i.e., \(\mathbf{e}_i, \mathbf{r}_i \in \mathbb{C}^d\).
The interaction function is given by
\[\| \mathbf{h} \odot \mathbf{r} - \mathbf{t} \|\]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 the interaction module.
See also
The parameter
p
andpower_norm
are directly passed toNormBasedInteraction
.- 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.
Attributes Summary
whether the interaction is defined on complex input
Methods Summary
forward
(h, r, t)Evaluate the interaction function.
Attributes Documentation
Methods Documentation