LineaREInteraction
- class LineaREInteraction(p: int, power_norm: bool = False)[source]
Bases:
NormBasedInteraction
[Tensor
,tuple
[Tensor
,Tensor
,Tensor
],Tensor
]The LineaRE interaction described by [peng2020].
It is given by
\[\mathbf{h} \odot \mathbf{r}_h - \mathbf{t} \odot \mathbf{r}_t + \mathbf{r}\]where \(\mathbf{r}_{h}, \mathbf{r}, \mathbf{r}_{t} \in \mathbb{R}^d\) are relation-specific terms, and \(\mathbf{h}, \mathbf{t} \in \mathbb{R}^n\) the head and tail entity representation.
Note
the original paper only describes the interaction for \(L_1\) norm, but we extend it to the general \(L_p\) norm as well as its powered variant.
Note
This interaction is equivalent to
TripleREInteraction
without the \(u\) term.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