tsinghua-fib-lab / GPD

The official implementation of the ICLR 24 submission entitled "Spatio-Temporal Few-Shot Learning via Diffusive Neural Network Generation".
40 stars 4 forks source link

Spatio-Temporal Few-Shot Learning via Diffusive Neural Network Generation

model framework

The official implementation of the ICLR 2024 paper entitled "Spatio-Temporal Few-Shot Learning via Diffusive Neural Network Generation".

In this project, we propose a novel framework, GPD, which performs generative pre-training on a collection of model parameters optimized with data from source cities. Our proposed approach recasts spatio-temporal graph transfer learning as pre-training a generative hypernetwork, which generates tailored model parameters guided by prompts. Our framework has the potential to revolutionize smart city applications in data-scarce environments and contribute to more sustainable and efficient urban development.

Installation

Environment

Dependencies:

  1. Install Pytorch with the correct CUDA version.
  2. Use the pip install -r requirements.txt command to install all of the Python modules and packages used in this project.

Data

The data used for training and evaluation can be found in Time-Series data. After downloading the data, move them to ./Data.

For each city, we provide the following data:

We provide two time-series datasets: crowd flow (including DC, BM, man) and traffic speed (including metr-la, pems-bay, shenzhen, chengdu_m).

The details of these two data sets are as follows:

datasets information

Model Training

To train node-level models with the traffic dataset, run:

cd Pretrain

CUDA_VISIBLE_DEVICES=0 python main.py --taskmode task4 --model v_GWN --test_data metr-la --ifnewname 1 --aftername TrafficData

After full-trained, run Pretrain\PrepareParams\model2tensor.py to extract parameters from the trained model. And put the params-dataset in ./Data.

To train diffusion model and generate the parameters of the target city:

cd GPD

CUDA_VISIBLE_DEVICES=0 python 1Dmain.py --expIndex 140 --targetDataset metr-la --modeldim 512 --epochs 80000 --diffusionstep 500 --basemodel v_GWN --denoise Trans1

conditioning

The sample result is in GPD/Output/expXX/.

Finetune and Evaluate

To finetune the generated parameters of the target city and evaluate, run:

cd Pretrain

CUDA_VISIBLE_DEVICES=0 python main.py --taskmode task7 --model v_GWN --test_data metr-la --ifnewname 1 --aftername finetune_7days --epochs 600 --target_days 7

Overall instructions

Let me give an example of the overall instructions. If you want to set 'metr-la' as target city:

Since finetune and pretraining share the same code framework and use the same set of parameter names, this can be a little confusing and I will try to make the distinction between them in later versions of the code.

Citing(BibTeX):

@inproceedings{
  yuan2024spatiotemporal,
  title={Spatio-Temporal Few-Shot Learning via Diffusive Neural Network Generation},
  author={Yuan Yuan and Chenyang Shao and Jingtao Ding and Depeng Jin and Yong Li},
  booktitle={The Twelfth International Conference on Learning Representations},
  year={2024},
  url={https://openreview.net/forum?id=QyFm3D3Tzi}
}