SEInteraction
- class SEInteraction(p: int, power_norm: bool = False)[source]
Bases:
NormBasedInteraction
[Tensor
,tuple
[Tensor
,Tensor
],Tensor
]The Structured Embedding (SE) interaction function.
SE applies role- and relation-specific projection matrices \(\textbf{M}_{r}^{h}, \textbf{M}_{r}^{t} \in \mathbb{R}^{d \times d}\) to the head and tail entities’ representations \(\mathbf{h}, \mathbf{t} \in \mathbb{R}^d\) before computing their distance.
\[f(\textbf{h}, (\textbf{M}_{r}^{h}, \textbf{M}_{r}^{t}), \textbf{t}) = -\|\textbf{M}_{r}^{h} \textbf{h} - \textbf{M}_{r}^{t} \textbf{t}\|_p\]Initialize the norm-based interaction function.
- 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
The symbolic shapes for relation representations
Methods Summary
forward
(h, r, t)Evaluate the interaction function.
Attributes Documentation
Methods Documentation