Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
liyaguang committed Dec 8, 2017
0 parents commit c7535e5
Show file tree
Hide file tree
Showing 44 changed files with 299,833 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# pycharm
.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Yaguang Li

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting
![Diffusion Convolutional Recurrent Neural Network](figures/model_architecture.jpg "Model Architecture")

This is a TensorFlow implementation of Diffusion Convolutional Recurrent Neural Network in the following paper: \
Yaguang Li, Rose Yu, Cyrus Shahabi, Yan Liu, [Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting](https://arxiv.org/abs/1707.01926).


## Requirements
- hyperopt>=0.1
- scipy>=0.19.0
- numpy>=1.12.1
- pandas==0.19.2
- tensorflow>=1.3.0
- peewee>=2.8.8
- python 2.7

Dependency can be installed using the following command:
```bash
pip install -r requirements.txt
```


## Traffic Data
The traffic data file for Los Angeles is available [here](https://drive.google.com/open?id=1tjf5aXCgUoimvADyxKqb-YUlxP8O46pb), and should be
put into the `data/` folder.


## Graph Construction
As the currently implementation is based on pre-calculated road network distances between sensors, it currently only
supports sensor ids in Los Angeles (see `data/sensor_graph/sensor_info_201206.csv`).

```bash
python gen_adj_mx.py --sensor_ids_filename=data/sensor_graph/graph_sensor_ids.txt --normalized_k=0.1\
--output_pkl_filename=data/sensor_graph/adj_mx.pkl
```

## Train the Model
```bash
python dcrnn_seq2seq_train.py --config_filename=data/model/dcrnn_config.json
```


## Run the Pre-trained Model

```bash
python run_demo.py
```
The generated prediction of DCRNN is in `data/results/dcrnn_predictions_[1-12].h5`.


More details are being added ...

## Citation

If you find this repository useful in your research, please cite the following paper:
```
@article{li2017dcrnn_traffic,
title={Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting},
author={Li, Yaguang and Yu, Rose and Shahabi, Cyrus and Liu, Yan},
journal={arXiv preprint arXiv:1707.01926},
year={2017}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
model_checkpoint_path: "models-1.6253-35451"
all_model_checkpoint_paths: "models-2.9323-351"
all_model_checkpoint_paths: "models-2.2916-702"
all_model_checkpoint_paths: "models-2.1618-1404"
all_model_checkpoint_paths: "models-2.1094-1755"
all_model_checkpoint_paths: "models-2.0356-2106"
all_model_checkpoint_paths: "models-2.0139-2808"
all_model_checkpoint_paths: "models-1.9127-3159"
all_model_checkpoint_paths: "models-1.8968-4914"
all_model_checkpoint_paths: "models-1.8671-5265"
all_model_checkpoint_paths: "models-1.8386-7371"
all_model_checkpoint_paths: "models-1.7334-7722"
all_model_checkpoint_paths: "models-1.7301-8073"
all_model_checkpoint_paths: "models-1.7291-8424"
all_model_checkpoint_paths: "models-1.7214-8775"
all_model_checkpoint_paths: "models-1.7164-9477"
all_model_checkpoint_paths: "models-1.7163-10530"
all_model_checkpoint_paths: "models-1.6611-11232"
all_model_checkpoint_paths: "models-1.6586-11583"
all_model_checkpoint_paths: "models-1.6576-11934"
all_model_checkpoint_paths: "models-1.6554-12636"
all_model_checkpoint_paths: "models-1.6552-13338"
all_model_checkpoint_paths: "models-1.6540-13689"
all_model_checkpoint_paths: "models-1.6526-14391"
all_model_checkpoint_paths: "models-1.6425-14742"
all_model_checkpoint_paths: "models-1.6415-15444"
all_model_checkpoint_paths: "models-1.6385-15795"
all_model_checkpoint_paths: "models-1.6377-16497"
all_model_checkpoint_paths: "models-1.6358-16848"
all_model_checkpoint_paths: "models-1.6358-17901"
all_model_checkpoint_paths: "models-1.6284-18252"
all_model_checkpoint_paths: "models-1.6284-18603"
all_model_checkpoint_paths: "models-1.6282-18954"
all_model_checkpoint_paths: "models-1.6281-19305"
all_model_checkpoint_paths: "models-1.6275-19656"
all_model_checkpoint_paths: "models-1.6273-20007"
all_model_checkpoint_paths: "models-1.6273-20709"
all_model_checkpoint_paths: "models-1.6271-21060"
all_model_checkpoint_paths: "models-1.6266-21411"
all_model_checkpoint_paths: "models-1.6265-21762"
all_model_checkpoint_paths: "models-1.6263-23166"
all_model_checkpoint_paths: "models-1.6262-24570"
all_model_checkpoint_paths: "models-1.6261-24921"
all_model_checkpoint_paths: "models-1.6259-25974"
all_model_checkpoint_paths: "models-1.6259-27378"
all_model_checkpoint_paths: "models-1.6259-27729"
all_model_checkpoint_paths: "models-1.6259-28080"
all_model_checkpoint_paths: "models-1.6259-28431"
all_model_checkpoint_paths: "models-1.6258-28782"
all_model_checkpoint_paths: "models-1.6258-29484"
all_model_checkpoint_paths: "models-1.6258-29835"
all_model_checkpoint_paths: "models-1.6257-30186"
all_model_checkpoint_paths: "models-1.6257-30537"
all_model_checkpoint_paths: "models-1.6257-30888"
all_model_checkpoint_paths: "models-1.6256-31239"
all_model_checkpoint_paths: "models-1.6256-31941"
all_model_checkpoint_paths: "models-1.6255-32292"
all_model_checkpoint_paths: "models-1.6255-32643"
all_model_checkpoint_paths: "models-1.6255-32994"
all_model_checkpoint_paths: "models-1.6254-33345"
all_model_checkpoint_paths: "models-1.6254-33696"
all_model_checkpoint_paths: "models-1.6254-34047"
all_model_checkpoint_paths: "models-1.6253-34398"
all_model_checkpoint_paths: "models-1.6253-34749"
all_model_checkpoint_paths: "models-1.6253-35100"
all_model_checkpoint_paths: "models-1.6253-35451"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"verbose": 0, "num_rnn_layers": 2, "min_learning_rate": 2e-06, "epochs": 100, "patience": 50, "test_ratio": 0.2, "cl_decay_steps": 2000, "write_db": false, "epoch": 100, "max_diffusion_step": 2, "lr_decay_epoch": 20, "dropout": 0.0, "log_dir": "data/model/dcrnn_DR_2_h_12_64-64_lr_0.01_bs_64_d_0.00_sl_12_MAE_1207002222/", "validation_ratio": 0.1, "data_type": "ALL", "learning_rate": 0.01, "batch_size": 64, "filter_type": "dual_random_walk", "graph_pkl_filename": "data/sensor_graph/adj_mx.pkl", "max_grad_norm": 5.0, "model_filename": "data/model/dcrnn_DR_2_h_12_64-64_lr_0.01_bs_64_d_0.00_sl_12_MAE_1207002222/models-1.6253-35451", "global_step": 35451, "use_cpu_only": false, "l1_decay": 0.0, "loss_func": "MAE", "lr_decay": 0.1, "lr_decay_interval": 10, "test_every_n_epochs": 10, "horizon": 12, "null_val": 0.0, "use_curriculum_learning": true, "seq_len": 12, "base_dir": "data/model", "rnn_units": 64}
Binary file not shown.
Binary file not shown.
34 changes: 34 additions & 0 deletions data/model/dcrnn_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"verbose": 0,
"num_rnn_layers": 2,
"epochs": 100,
"patience": 50,
"test_ratio": 0.2,
"cl_decay_steps": 2000,
"graph_pkl_filename": "data/sensor_graph/adj_mx.pkl",
"global_step": 0,
"max_diffusion_step": 2,
"epoch": 0,
"lr_decay_epoch": 20,
"learning_rate": 0.01,
"validation_ratio": 0.1,
"data_type": "ALL",
"dropout": 0.0,
"batch_size": 64,
"max_grad_norm": 5.0,
"min_learning_rate": 2e-06,
"use_cpu_only": false,
"l1_decay": 0.0,
"loss_func": "MAE",
"write_db": false,
"lr_decay": 0.1,
"lr_decay_interval": 10,
"test_every_n_epochs": 10,
"horizon": 12,
"null_val": 0.0,
"use_curriculum_learning": true,
"seq_len": 12,
"rnn_units": 64,
"base_dir": "data/model",
"filter_type": "dual_random_walk"
}
35 changes: 35 additions & 0 deletions data/model/dcrnn_test_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"verbose": 0,
"num_rnn_layers": 2,
"epochs": 100,
"patience": 50,
"test_ratio": 0.2,
"method_type": "GCRNN",
"cl_decay_steps": 2000,
"graph_pkl_filename": "data/sensor_graph/adj_mx.pkl",
"global_step": 0,
"max_diffusion_step": 2,
"epoch": 0,
"lr_decay_epoch": 20,
"learning_rate": 0.01,
"validation_ratio": 0.1,
"data_type": "ALL",
"dropout": 0.0,
"batch_size": 64,
"max_grad_norm": 5.0,
"min_learning_rate": 2e-06,
"use_cpu_only": false,
"l1_decay": 0.0,
"loss_func": "MAE",
"write_db": false,
"lr_decay": 0.1,
"lr_decay_interval": 10,
"test_every_n_epochs": 10,
"horizon": 3,
"null_val": 0.0,
"use_curriculum_learning": true,
"seq_len": 3,
"rnn_units": 16,
"base_dir": "data/model",
"filter_type": "random_walk"
}
Binary file added data/results/dcrnn_prediction_1.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_10.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_11.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_12.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_2.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_3.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_4.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_5.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_6.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_7.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_8.h5
Binary file not shown.
Binary file added data/results/dcrnn_prediction_9.h5
Binary file not shown.
Loading

0 comments on commit c7535e5

Please sign in to comment.