UMInteraction
- class UMInteraction(p: int, power_norm: bool = True)[source]
Bases:
NormBasedInteraction
[Tensor
,tuple
[()],Tensor
]The Unstructured Model (UM) interaction function.
UM calculates the score as the negative distance between head and tail entities:
\[-\|\textbf{h} - \textbf{t}\|_p^2\]It is appropriate for networks with a single relationship type that is undirected.
Warning
In UM, neither the relations nor the directionality are considered, so it can’t distinguish between them. However, it may serve as a baseline for comparison against relation-aware models.
Initialize the norm-based interaction function.
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
The symbolic shapes for relation representations
Methods Summary
forward
(h, r, t)Evaluate the interaction function.
Attributes Documentation
Methods Documentation