SEInteraction
- class SEInteraction(p: int, power_norm: bool = False)[源代码]
基础类:
NormBasedInteraction[Tensor,tuple[Tensor,Tensor],Tensor]结构化嵌入(SE)交互函数。
SE应用特定于角色和关系的投影矩阵 \(\textbf{M}_{r}^{h}, \textbf{M}_{r}^{t} \in \mathbb{R}^{d \times d}\) 到头部和尾部 实体的表示 \(\mathbf{h}, \mathbf{t} \in \mathbb{R}^d\) 在计算它们的距离之前。
\[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\]初始化基于范数的交互函数。
- Parameters:
p (int) – 与
torch.linalg.vector_norm()一起使用的范数。通常为1或2。power_norm (bool) – 是否使用\(L_p\)范数的p次方。它的优点是在0附近可微分,并且在数值上更稳定。
属性摘要
关系表示的符号形状
方法总结
forward(h, r, t)评估交互函数。
属性文档
方法文档