GithubHelp home page GithubHelp logo

h-stformer's Introduction

Transport-Hub-Aware Spatial-Temporal Adaptive Graph Transformer for Traffic Flow Prediction

Code of H-STFormer with PyTorch2.0. Based on LibCity framework.

MyFormer is an alias of H-STFormer.

Highlights of This Work

  1. Implementation of FastDTW can use multiple CPU cores. Calculation of single node in PeMSD4 takes only about 10s with 8 CPU cores. (In contrast, single-core calculation takes 70s+.)
  2. HubSSA, indicating potential traffic hubs on the road network. (Idea by Lei Zhang, implementation and improvements by Xiao Xu.)
  3. The first attempt on incremental learning of traffic flow prediction. We designed a Spatial-Temporal Knowledge Distillation Module for Stage-2 training (the incremental stage). (Idea and implementation by Xiao Xu)

Dataset

Datasets for incremental training are randomly split from PeMS0x. You can use PreProcess/GenerateDatasets.py to generate them.

Or use mine, download with BaiduNetDisk or Google Drive.

If you split the incremental datasets by yourself, you should delete all the PeMS0x[ST/T][60/80]Stage[1/2].npy under the root dir, and all the dtw_PeMS0x[ST/T][60/80]Stage[1/2].npy under libcity/cache/dataset_cache and then let the program re-calculate them. That's because the reserved part of the road network has changed.

Quick Start

Use miniconda environment config file for Ubuntu or Windows to create conda venv.

Commands for each experiment are available here.

The aforementioned incremental commands are temporal-only incremental. Besides, I also provide commands for spatial-temporal incremental tasks, which amounts to learning on a dynamically increasing road network. They are not that SOTA and aren't written into the paper. If needed, click here.

Recommended Hardware Env

Intel or AMD x86_64-arch, 8 CPU cores or more;

80GB RAM (128GB recommended);

NVIDIA GeForce RTX 2080Ti or better (at least 11GB Video Memory for PeMSD7 Series)

Pre-generated Dataset Cache

Generating PeMSD7 series dataset cache takes 120GB+ RAM. You can download pre-generated dataset cache to skip this, and 80GB RAM may be enough for training.

There are not all datasets in all formats, but it's enough to overcome the OOM issue.

I provide the data in np.float32 (recommended) and np.float64. (Note: Using np.float16 may cause loss=nan.) After downloading the aforementioned files, please rename them as follows and put into libcity/cache/dataset_cache.

Here is a renaming example:

For [np.float64]MyFormer_point_based_PeMS07ST80Stage1_12_12_0.6_1_0.2_standard_4_True_True_True_True_traffic_flow.npz,

rename it to MyFormer_point_based_PeMS07ST80Stage1_12_12_0.6_1_0.2_standard_[batch_size]_True_True_True_True_traffic_flow.npz.

If batch_size=8, that is MyFormer_point_based_PeMS07ST80Stage1_12_12_0.6_1_0.2_standard_8_True_True_True_True_traffic_flow.npz.

h-stformer's People

Contributors

fantasy-shaw avatar

Stargazers

 avatar  avatar joe avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.