TGAT阅读笔记

1,803 阅读2分钟

《INDUCTIVE REPRESENTATION LEARNING ON TEMPORAL GRAPHS》

1、问题和任务描述

问题:离散型DGNN的方法将全图划分为n个snapshot,这样可能会损失一些时间演化信息(信息丢失);此外,离散型的DGNN无法进行inductive learning。

任务:不切分子图,使用基于time encoding的连续DGNN方法进行动态图的链接预测任务。

2、TGAT

image.png

2.1 time encoding

时间函数用来编码src节点和dst节点之间的相对时间差:

ϕ(t,ti)=(cos(w1(tti)+b1),cos(w2(tti)+b2),...,cos(wd(tti)+bd))Rd\phi(t, t_i) = (cos(w_1(t-t_i)+b_1), cos(w_2(t-t_i)+b_2), ..., cos(w_d(t-t_i)+b_d)) \in R^d
问题解释
为什么可以用相对时间差来编码?1)直觉上来说,相对时间要比绝对时间更重要;2)时间差具有平移不变性,便于发现周期性的规律3)本质上是要学习核函数K(t1,t2)=<Φ(t1),Φ(t2)>=ϕ(t1t2)K(t_1, t_2) = <\Phi(t_1), \Phi(t_2)> = \phi(t_1 - t_2)
为什么要使用cos函数来进行编码?cos函数具有周期性,可以反映时间差的周期性变化;不同w代表不同的频率,d维特征可以提取不同的频率

2.2 TGAT layer

已知src节点和dst节点的timestamp,可以写成以下self-attention的形式:(包含节点特征,边特征和时间编码)

(把position encoding换成了time encoding)

Z(t)=[h0(t)e0,0ϕ(0),h1(t)e0,1ϕ(tt1),...,hn(t)e0,nϕ(ttn)]Z(t) = [h_0(t)||e_{0, 0}||\phi(0), h_1(t)||e_{0, 1}||\phi(t-t_1), ..., h_n(t)||e_{0, n}||\phi(t-t_n)]

0代表src,1..n代表dst,

Q=(h0(t)e0,0ϕ(0))WqK=(h1(t1)e0,1ϕ(tt1),...,hn(tn)e0,nϕ(ttn))WkV=(h1(t1)e0,1ϕ(tt1),...,hn(tn)e0,nϕ(ttn))WvQ = (h_0(t)||e_{0, 0}||\phi(0)) * W_q \\[2ex] K = (h_1(t_1)||e_{0, 1}||\phi(t-t_1), ..., h_n(t_n)||e_{0, n}||\phi(t-t_n)) * W_k \\[2ex] V = (h_1(t_1)||e_{0, 1}||\phi(t-t_1), ..., h_n(t_n)||e_{0, n}||\phi(t-t_n)) * W_v \\[2ex]

计算attention和output,

h0(t)=softmax(QKTdk)Vh_0(t) = softmax(\frac{QK^T}{\sqrt{d_k}})V

然后和原始src的特征拼接过一个FFN,得到l+1层的输出, (多头机制)

h0(l+1)(t)=FFN(h0head1(t)h0head2(t)...h0headk(t)x0)h_0^{(l+1)}(t) = FFN(h_0^{head-1}(t)||h_0^{head-2}(t)||...||h_0^{head-k}(t)||x_0)
问题解释
为什么不用GAT+Time encoding而是self-attention?实验来说,self-attention效果更好

2.3 loss

链接预测任务,基于负采样的二元交叉熵损失:

Loss=jN(i)log(σ(FFN(hi(tij)hj(tij)))wnkPn(i)log(σ(FFN(hi(tij)hk(tij)))Loss = \sum_{j \in N(i)} -log(-\sigma(FFN(h_i(t_{ij})||h_j(t_{ij}))) - w_n \sum_{k \in P_n(i)} log(\sigma(FFN(h_i(t_{ij})||h_k(t_{ij})))

3、实验

TGAT实验记录

3.1 数据集

用的JODIE的两个开源数据集和一个沃尔玛的私有工业数据集。

  • Reddit和Wikipedia数据集描述见JODIEgithub.com/srijankr/jo…

  • Industrial数据集来自沃尔玛

    • customer-product交互图
    • 70000 products,100000 customers,200万条边
    • customer有label,表示用户的购买兴趣
    • product给了一个预训练好的node feature
  • 70%-15%-15%:train-valid-test

image.png

image.png

3.2 baseline

不包含time encoding:

  • GAE:图自编码器
  • VGAE:变分图自编码器
  • Deepwalk,node2vec
  • GAT
  • GraphSAGE
  • CTDNE:基于动态随机游走的方法,dl.acm.org/doi/pdf/10.…

包含time encoding:

  • GAT+T
  • GraphSAGE+T
  • TGAT

3.3 评价指标

动态链接预测任务:

  • AP:average precision
  • Accuracy:转换为二分类任务的准确率

动态节点分类任务:

  • AUC

3.4 实验结果

动态链接预测任务:

transductive:

  • const-TGAT代表attention的值都是一样的(mean)

image.png

inductive:

image.png

此外,还有动态节点分类任务:

  • 根据上游学到的node embedding进行下游任务的预测

image.png 消融实验:

image.png

  • time encoding是有用的