【论文阅读】DSTAGNN Dynamic Spatial-Temporal Aware Graph Neural Network for Traffic Flow Forecasting

DSTAGNN Dynamic Spatial-Temporal Aware Graph Neural Network for Traffic Flow Forecasting

Info

Model

Network Structure

网络结构

Details

0. 前置知识

节点:V
节点数量:N
节点间连接(边):E
图:G=(V,E)
邻接矩阵:ARN×N
t时刻的图信号:XtRN×Cp,其中Cp表示交通参数的类型(如交通流量、速度),本论文只有一个交通参数,即Cp=1
数据记录:X(tM+1):tRN×Cp×M
预测目标:X(t+1):(t+T)RN×Cp×T
模型FX(t+1):(t+T)=F[X(tM+1):t;G]

1. 节点特征的表示与转换

Take the traffic flow XfRD×dt×N at the N recording points for D days as an example, where dt is the number of recording times per day (if recordings are taken once every 5 minutes, then dt = 288).
For each recording point, the oneday traffic data is treated as a vector, then a set of multi-day traffic data is denoted as a vector sequence. For example, the vector sequence obtained at recording point n (nN) is denoted as Xnf=(wn1,wn2,,wnD), wndRdt, where d[1,D].

提取交通流量信息:

mnd=wnd2Zn,Zn=d=1Dwnd2

In this way, the vector sequence of the recording point n is transformed into a probability distribution Pn{Xd=mnd}, and each day has a probability mass mnd[0,1] and dmnd=1, which denotes the proportion of traffic volume in a certain day over a period of time.

P.S.

  • 为什么流量信息是一天的流量占一段时间的比?
  • 这里为什么用二范数,而不是直接对一天各个时段的流量进行求和?

2. 时空感知距离与时空关联图

概率分布变换代价(使用Wassertein距离):
利用余弦距离作为变换代价:
余弦距离
使用Wassertein距离计算两个节点的差异:
Wassertein距离

节点间的关联度矩阵ASTADRN×N

ASTAD[i,j]=1dSTAD(i,j)[0,1]

通过设定稀疏水平Psp(超参数),选取每行 Nr=N×Psp 个节点(关联度最大的几个),其余的设为0,就获得了时空关联图 ASTRGRN×N
对时空关联图 ASTRG 进行二值化,获得时空感知图 ASTAG

P.S.

  • 为什么用余弦变换作为代价?
  • 为什么用Wassertein距离计算节点的差异(关联)?
  • 为什么关联图中只选了 Psp 个节点?

3. 时空注意力块

这里用到了多头注意力机制,参考Attention Is All You Need。

时空注意力模块

时间注意力

时间注意力

  • 这里的 X(l)RN×c(l1)×M 是输入,经过reshape,变成 X(l)Rc(l1)×M×N
  • X(l)Wq(l)Q(l),X(l)Wk(l)K(l),X(l)Wv(l)V(l) Q和K用来计算不同节点之间的相关性(注意力系数),Wq,k,v(l)RN×dQ(l),K(l),V(l)Rc(l1)×M×d
  • 注意力*:
    • Scaled Dot-Product(论文Attention Is All You Need里来的。)A(l)=Q(l)K(l)dh+A(l1)
    • 注意力:Att(Q(l),K(l),V(l))=Softmax(A(l))V(l)
  • 多头注意力机制(论文Attention Is All You Need里来的。)O(h)=Att(QWq(h),KWk(h),VWv(h)) 其中 Wq,k,v(h)Rd×dh(dh=d/H)
  • Concat:O=[O(1),O(2),,O(H)] 经过Reshape,获得 ORc(l1)×M×H×dh
  • Linear层把输出的大小还原,获得 ORc(l1)×M×N
  • 带残差的LayerNorm:Y=LayerNorm(Linear(Reshape(O))+X) 输出 YRc(l1)×M×N
    P.S.
  • 原文中的LayerNorm公式错了。
  • ddh是如何决定的?
  • Scaled Dot-product 为什么用残差?
空间注意力

空间注意力

  • Reshape:YRc(l1)×M×N 转换成 Y#Rc(l1)×N×M
  • Conv:
    • 先把 Y#Rc(l1)×N×M 中的时间维度 M 映射到 dE 维的高维空间。(怎么映射?为什么要映射?
    • 对特征维 c(l1) 做一维卷积,获得二维矩阵YRN×dE。(卷积核大小是 c(l1)?)
    • Embedding:

      Then, we add positional information to Y through an embedding layer to get YE.

  • 注意力机制(这里的空间注意力其实只算了注意力中的相关性,在下一步卷积中使用):

    Instead of using the self-attention fully generated from YE as in conventional transformers, here we introduce the temporal-spatial relevance graph ASTRG with learned correlation between nodes to amend the attention in the SA module. Thus the improved spatial attention with H heads is denoted as: P(h)=Softmax((YEWk(h))(YEWq(h))dh+Wm(h)ASTRG)P=[P(1),P(2),,P(H)] where Wk(h),Wq(h)RdE×dh,Wm(h)RN×N are learnable parameters, is the element-wise Hadamard product, Wm(h) is used to amend ASTRG for adjusting the attention of each head P(h)RN×N, and the output PRH×N×N denotes the dynamic spatial-temporal attention tensor by combining the outputs from each head.

P.S.

  • Conv中的高维映射怎么映射?为什么要映射?
  • Conv中的一维卷积怎么把整个 c(l1) 卷没了?
  • 这里为什么不用残差了,而是用 ASTRG

4. Spatial-Temporal Convolution Block

时空卷积模块

空间图卷积

这里使用了ChebyNet卷积,待深入。

gθGx=gθ(L)x=k=0K1θk(Tk(L~)P(k))x

图信号:x=xtRN
归一化的拉普拉斯矩阵:L~=2λmax(DA)IN
邻接矩阵:A=ASTAG
参数:θRK
第k个头的空间-时间注意力矩阵:P(k)RN×N

P.S.

  • 为什么把P直接哈达玛乘在切比雪夫多项式上?
时间门控卷积(Temporal gated convolution)

论文提出了M-GTU (Multi-scale Gated Tanh Unit) 卷积模块捕捉交通流数据中的动态时间信息。

M-GTU由三个GTU模块组成,每个GTU由Convolution和Gating两步组成。

  • 卷积:
    • 输入:Z(l)RN×M×C(l)
    • 卷积核:ΓR1×S×c(l)×2c(l),其中,c(l) 是输入的通道数(节点的特征数),2c(l) 是输出的通道数,卷积核的大小是 1×S,1是节点个数维度上的大小,S是时间维度上的大小。
    • 卷积公式:Z(l)=ΓZ(l)RN×(M(S1))×2C(l)
  • Gating:把 Z(l) 沿着通道维度等分成两份 EF,则输出为 ϕ(E)σ(F)RN×(M(S1))×2C(l)
  • Concat:虽然图上有Pooling,但是代码中并没有,使用三个不同的卷积核 S1,S2,S3 卷积后,将三个输出沿着时间轴拼接。
  • Linear:将Concat的结果放进Linear层,恢复原来的大小。
self.fcmy = nn.Sequential(
    nn.Linear(3 * num_of_timesteps - 12, num_of_timesteps),
    nn.Dropout(0.05),
)

P.S.

  • 为什么要用GTU?

Datasets

文章使用了PEMS03、PEMS04、PEMS07、PEMS08三个数据集。

数据集

posted @   杨谖之  阅读(365)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示
主题色彩