STRAP: Spatio-Temporal Pattern Retrieval for Out-of-Distribution Generalization
October 30, 2025 ยท View on GitHub
๐ Table of Contents
- โจ Overview
- ๐๏ธ Repository Structure
- ๐ Getting Started
- ๐ Acknowledgements
- ๐ Citation
- ๐ Star History
โจ Overview
Spatio-Temporal Graph Neural Networks (STGNNs) have emerged as a powerful tool for modeling dynamic graph-structured data across diverse domains. However, they often fail to generalize in Spatio-Temporal Out-of-Distribution (STOOD) scenarios, where both temporal dynamics and spatial structures evolve beyond the training distribution. To address this problem, we propose STRAP, which enhances model generalization by integrating retrieval-augmented learning into the STGNN continue learning pipeline. Extensive experiments across multiple real-world streaming graph datasets show that \methodname consistently outperforms state-of-the-art STGNN baselines on STOOD tasks, demonstrating its robustness, adaptability, and strong generalization capability without task-specific fine-tuning.
STRAP Framework Architecture
๐๏ธ Repository Structure
STRAP/
โ
โโโ ๐ README.md # Project documentation
โโโ ๐ LICENSE # Apache 2.0 License
โโโ ๐ environment.yaml # Conda environment configuration
โโโ ๐ main.py # Main entry point for experiments
โโโ ๐ stkec_main.py # STKEC experiments entry point
โโโ ๐ run.sh # Batch experiment execution script
โ
โโโ ๐ conf/ # โ๏ธ Configuration files
โ โโโ AIR/ # Air quality dataset configs
โ โโโ ENERGY-Wind/ # Wind energy dataset configs
โ โโโ PEMS/ # Traffic dataset configs
โ โโโ strap.json
โ โโโ ewc.json
โ โโโ ...
โ
โโโ ๐ src/ # ๐ป Source code
โ โโโ dataer/ # Data loading and preprocessing
โ โ โโโ ...
โ โ
โ โโโ model/ # Model implementations
โ โ โโโ ... # Model components
โ โ
โ โโโ trainer/ # Training and evaluation
โ โโโ ...
โ
โโโ ๐ utils/ # ๐ ๏ธ Utility functions
โ โโโ ...
โ
โโโ ๐ font/ # Font files for visualization
โโโ ๐ log/ # ๐ Training logs and checkpoints
โโโ ๐ data/ # ๐พ Dataset storage (create this)
๐ Getting Started
๐ Prerequisites
Before you begin, ensure you have the following installed:
- Conda or Miniconda (Download)
- NVIDIA GPU with CUDA support (recommended)
- Python 3.8+
๐ป Usage
# ENERGY-Wind, the same for other datasets.
bash run.sh
๐ Acknowledgements
We would like to express our gratitude to:
- EAC: We thank the authors for their excellent work. Our implementation builds upon their codebase: EAC Repository
๐ Citation
If you find this work useful for your research, please consider citing our paper:
@article{zhang2025strap,
title={STRAP: Spatio-Temporal Pattern Retrieval for Out-of-Distribution Generalization},
author={Zhang, Haoyu and Zhang, Wentao and Miao, Hao and Jiang, Xinke and Fang, Yuchen and Zhang, Yifan},
journal={arXiv preprint arXiv:2505.19547},
year={2025}
}