STGL: Self-Supervised Spatio-Temporal Graph Learning for Traffic Forecasting

Zhengsheng Zhan, Xinjun Mao, Hui Liu, Shuo YuJAIR 2025

Abstract

As urbanization intensification, traffic forecasting emerges as a critical challenge due to the complex spatio-temporal dependencies and data scarcity in traffic networks. Although spatio-temporal graph neural networks (STGNNS) have demonstrated certain efficacy, these methods cannot effectively model the complex characteristics of traffic data. Meanwhile, their performance is also constrained by the limited data volume and the scarcity of labels. To solve the aforementioned issues, we propose STGL, a self-supervised spatio-temporal graph learning framework for traffic forecasting. STGL utilizes a dual-module architecture to effectively model complex spatio-temporal dependencies in traffic data. Specifically, it integrates a dynamic graph convolution module to capture evolving spatial dependencies, and it utilizes a temporal convolution module leveraging dilated causal convolutions and gated mechanisms to model long-range temporal dependencies. To further enhance representation learning, STGL incorporates a contrastive learning with sample generation and negative filtering. By combining these components, STGL provides a robust solution for traffic forecasting under data-short conditions. Extensive experiments are conducted on PEMS04 and PEMS08, which shows the superiority of STCL.

Introduction

Traffic forecasting—predicting flow, speed, and congestion—is a cornerstone of Intelligent Transportation Systems (ITS). However, it is notoriously difficult because traffic data is "spatio-temporally" complex: what happens at one intersection affects another (spatial), and patterns change over hours or days (temporal). Current Spatio-Temporal Graph Neural Networks (STGNNs) face two major bottlenecks: they often rely on fixed, static graph structures that fail to capture dynamic traffic relationships, and they struggle with data scarcity where high-quality labeled data is limited.

Methodology

Dual-Module Architecture

STGL employs a dual-branch architecture designed to learn robust representations from traffic data. The framework consists of a spatial module and a temporal module within an encoder-decoder structure.

The overall architecture of the STGL framework, illustrating the STG Encoder, Decoder, and the dual loss functions (Prediction and Contrastive).
  • Spatial Module: Instead of a static map, STGL uses a Dynamic Graph Convolution Module. It learns an adaptive adjacency matrix from node embeddings, allowing the model to discover hidden or changing relationships between sensors on the fly.
  • Temporal Module: It employs dilated causal convolutions and gated mechanisms. This allows the model to have a wide receptive field, enabling it to capture long-range historical patterns without the computational overhead of traditional Recurrent Neural Networks (RNNs).

Self-Supervised Contrastive Learning

To address data scarcity, STGL implements a contrastive learning pipeline. The model generates two augmented "views" of the same data point using techniques such as edge perturbation, input masking, temporal translation, and input smoothing (via Discrete Cosine Transform). The model is trained to maximize similarity between these positive pairs while distinguishing them from negative samples. A key innovation is the negative filtering step, which removes "hard" negative samples—data points that are temporally close and naturally similar—to prevent model confusion.

Experiments and Results

Performance Comparison

The model was evaluated on two real-world benchmarks: PEMS04 (307 sensors) and PEMS08 (170 sensors). STGL consistently outperformed state-of-the-art baselines like Graph WaveNet and STFGNN. On PEMS04, STGL achieved a Mean Absolute Error (MAE) of 20.06, while on PEMS08, it reached an MAE of 15.04, marking a significant improvement over traditional methods.

Sensitivity Analysis

Analysis of the contrastive learning components revealed that the choice of augmentation ratio ($r$) and the negative filtering threshold are critical for performance.

Sensitivity analysis showing the impact of the augmentation ratio (left) and the negative filtering threshold (right) on prediction error (MAE).

As shown in the sensitivity analysis, filtering out samples within a 60-minute window (the filtering threshold) results in the lowest MAE. This confirms that treating temporally adjacent samples as negatives is counterproductive due to their inherent similarity.

Conclusion

STGL provides a robust solution for traffic forecasting by combining adaptive graph modeling with a sophisticated self-supervised learning pipeline. While it excels at capturing periodic fluctuations, future work will focus on improving the model's responsiveness to sudden, short-term traffic shocks and integrating multi-modal data like weather or social events.

Summary updated

BibTeX
@article{zhan2025stgl,
  author = {Zhengsheng Zhan and Xinjun Mao and Hui Liu and Shuo Yu},
  title = {{STGL: Self-Supervised Spatio-Temporal Graph Learning for Traffic Forecasting}},
  journal = {Journal of Artificial Intelligence Research},
  year = {2025},
  doi = {10.70891/jair.2025.040001},
}
Figure