TransRInteraction
- class TransRInteraction(p: int, power_norm: bool = True, max_projection_norm: float = 1.0)[source]
Bases:
NormBasedInteraction
[Tensor
,tuple
[Tensor
,Tensor
],Tensor
]The state-less norm-based TransR interaction function.
It is given by
\[-\|c(\mathbf{M}_{r}\mathbf{h}) + \mathbf{r} - c(\mathbf{M}_{r}\mathbf{t})\|_{2}^2\]for head and tail entity representations \(\mathbf{h}, \mathbf{t} \in \mathbb{R}^d\), relation representation \(\mathbf{r} \in \mathbb{R}^k\), and a relation-specific projection matrix \(\mathbf{M}_r \in \mathbb{R}^{k \times d}\). \(c\) enforces the constraint \(\|\cdot\| \leq 1\), cf.
pykeen.utils.clamp_norm()
.Note
pykeen.models.TransR
additionally also enforces \(\|\cdot\| \leq 1\) on all embeddings.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.
max_projection_norm (float) – The maximum norm to be clamped after projection.
Attributes Summary
The symbolic shapes for relation representations
Methods Summary
forward
(h, r, t)Evaluate the interaction function.
Attributes Documentation
Methods Documentation