简单交互

class SimplEInteraction[source]

基础:DirectionAverageInteraction

SimplE交互函数。

SimplE 可以被视为 pykeen.nn.modules.CPInteraction 的扩展(一种特殊情况),这是一种早期的张量分解方法,其中每个实体 \(e \in \mathcal{E}\) 由两个向量 \(\mathbf{e}_h, \mathbf{e}_t \in \mathbb{R}^d\) 表示,每个关系由一个向量 \(\mathbf{r} \in \mathbb{R}^d\) 表示。根据实体是作为头实体还是尾实体参与三元组,使用 \(\mathbf{e}_h\)\(\mathbf{e}_t\)。两个实体表示是独立学习的,即观察到三元组 \((h,r,t)\) 时,该方法仅更新 \(\mathbf{h}_h\)\(\mathbf{t}_t\)

CPInteraction 不同,SimplE 为每个关系引入了单独的权重:\(\textbf{r}_{\rightarrow}\)\(\textbf{r}_{\leftarrow}\) 用于逆关系。交互模型基于两者:

\[\frac{1}{2}\left( \left\langle\textbf{h}_{h}, \textbf{r}_{\rightarrow}, \textbf{t}_{t}\right\rangle + \left\langle\textbf{t}_{h}, \textbf{r}_{\leftarrow}, \textbf{h}_{t}\right\rangle \right)\]

初始化交互模块。

属性摘要

entity_shape

实体表示的符号形状

relation_shape

关系表示的符号形状

属性文档

entity_shape: Sequence[str] = ('d', 'd')

实体表示的符号形状

relation_shape: Sequence[str] = ('d', 'd')

关系表示的符号形状