Abstract
Traffic forecasting is critical for smart city infrastructure but faces challenges from data scarcity and sensor incompleteness. We present STMAE, a "plug-and-play" self-supervised framework that enhances existing forecasting models through a generative pretraining strategy. By employing a dual-masking approach—hiding spatial paths and temporal blocks—STMAE learns robust representations that mitigate overfitting and improve long-term prediction accuracy.
Introduction
Accurate traffic forecasting is essential for urban planning and management. Despite the advancement of deep learning models in capturing complex spatial-temporal dependencies, they often struggle with limited historical data and frequent sensor failures. Traditional self-supervised methods, such as contrastive learning, often rely on complex, hand-crafted augmentations that may not generalize well to real-world traffic scenarios.
To address these issues, we introduce the Spatial-Temporal Masked AutoEncoder (STMAE). STMAE shifts the focus from contrastive discrimination to generative reconstruction, forcing the model to recover missing data from challenging spatial and temporal masks. This approach significantly boosts the performance of various backbone models, making them more resilient to data noise and volatility.
The STMAE Framework
The STMAE framework operates in two distinct stages: pretraining and fine-tuning. It is designed to be backbone-agnostic, allowing integration with popular models like DCRNN or AGCRN.
1. Pretraining with Dual-Masking
The core innovation lies in its "pretext task," which uses a dual-masking strategy to create a difficult reconstruction environment:
- Spatial Masking: Instead of random node masking, STMAE utilizes a biased random walk to mask entire paths within the road network. This forces the encoder to learn the underlying structural connectivity and flow dynamics of the city.
- Temporal Masking: The model employs patch-based masking, hiding contiguous time blocks. This prevents the model from relying on simple local interpolation and encourages it to capture long-range temporal patterns.
2. Asymmetric Reconstruction and Fine-tuning
During pretraining, two lightweight decoders are used: one for reconstructing traffic values and another for the road network's adjacency matrix. Once the encoder learns these robust features, the decoders are removed. The pretrained encoder is then paired with a task-specific predictor and fine-tuned on the actual forecasting objective.
Experimental Evaluation
STMAE was evaluated on four standard California traffic benchmarks: PEMS03, PEMS04, PEMS07, and PEMS08. These datasets represent diverse sensor densities and network complexities, providing a comprehensive test of the framework's generalizability.
Results and Analysis
STMAE consistently improved performance across all tested backbones. Key findings include:
- Generative vs. Contrastive Learning: Generative reconstruction proved more effective than contrastive methods for traffic data, offering more stable training without the need for complex augmentations.
- Improved Long-term Forecasting: STMAE significantly reduces error accumulation over longer prediction horizons, making 1-hour-ahead forecasts much more reliable.
- Robustness to Volatility: A major strength of STMAE is its ability to track sudden traffic changes, such as those caused by accidents or special events, which often baffle standard models.
Furthermore, training analysis revealed that STMAE provides a superior initialization for fine-tuning, resulting in lower initial validation losses and faster, smoother convergence compared to training from scratch.
Conclusion and Future Work
STMAE offers a powerful, flexible solution for enhancing traffic forecasting models. While highly effective, future work could explore automated hyperparameter tuning for masking ratios based on network density. Additionally, incorporating external factors like weather or holiday schedules could further refine the model's reconstructive capabilities and predictive power in highly irregular scenarios.
Summary updated