This repository contains the code of a PaddlePaddle implementation of STGCN based on the paper Spatio-Temporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting https://arxiv.org/abs/1709.04875, with a few modifications in the model architecture to tackle with traffic jam forecasting problems.

Related Papers

Semi-Supervised Classification with Graph Convolutional Networks https://arxiv.org/abs/1609.02907 (GCN)

Inductive Representation Learning on Large Graphs https://arxiv.org/abs/1706.02216 (GraphSAGE)

Graph Attention Networks https://arxiv.org/abs/1710.10903 (GAT)

Bag of Tricks for Node Classification with Graph Neural Networks https://arxiv.org/pdf/2103.13355.pdf (BoT)

Attention Based Spatial-Temporal Graph Convolutional Networks for Traffic Flow Forecasting https://ojs.aaai.org//index.php/AAAI/article/view/3881 (ASTGCN)

Structural Modifications

Graph operation

The original STGCN model facilitates 1-st order ChebyConv and GCN as the graph operation. In our model we conducted experiments on one spectral method(GCN) and two spatial methods(GAT, GraphSAGE)

Residual connection in graph convolution layer

Graph Neural Networks often suffer from oversmoothing problems: as the layers become deep, the representations of node tend to become similar. Adding a residual connection mitigates the oversmoothing problem by adding the input unsmoothed features directly to the output of graph convolution operation. Furthermore, the connection helps against gradient instablities.

截屏2021-12-07 下午2 41 47

Incorporation of historical jam pattern

Jam status often follow daily patterns. In order to let the model study historical patterns, we directly feed the model historical jam data with the same hour aligned. For example, if we want to predict the traffic status at 8PM. 30, Nov, 2021, we feed the model the 8PM traffic status in the past 12 days directly through a graph convolution layer, then concat it with the output of the S-T convolution blocks to generate the input of the final classifying layer.

截屏2021-12-01 下午3 35 25


The original STGCN model was a regression model, optimizing a mean squared loss. Our traffic jam status has four classes: 1 — smooth traffic; 2 — temperate jam; 3 — moderate jam; 4 — heavy jam. So we changed it into a softmax with cross entropy classification model.


paddlepaddle 2.2
pgl 2.1
numpy 1.21.4
tqdm 4.62.3



View Github