TinT
This repository is the official implementation for the paper "Integrating the Urban Science with Deep Leaning for City-wide Network Congestion Prediction" by Wenqing Zheng, Hao (Frank) Yang, Jiarui Cai, Peihao Wang, Xuan Jiang, Simon Du, Yinhai Wang, and Zhangyang Wang
Dataset Download
We open source our processed data
In the required data, two only big size files are < adjmat.pkl > and < speed.h5 >. SD is the smallest dataset.
Run experiments
Note that both graph and grid modalities share core implementation, with minor differenes in the data processing APIs.
Take the Graph modality for example. After the data is downloaded, cd into the graph folder cd TinT_graph_modality
.
Then run python train_TinT.py --config TinT_configs.conf
.
How to prepare data for graph modality GCT:
-
download data, as specified in
TinT_configs.conf
-
manually generate
adj_matrix
for new dataset: in the main function, modify and saveadj_mx
asnp.save('xxx.npy', adj_mx)
-
configure
args.dim_hidden_A
: inTinT.py
, in the functiondef tokenizer
print the last line and modify.
.conf
:
Meanings in the 4 static files in the adj_filename
: can be deleted if the adj_filename
is already there; In order to delete, need to go to main train file and comment adj_mx, distance_mx = get_adjacency_matrix
and corresponding lines.
graph_signal_matrix_filename
: will be used in lib/utils.py
(search for file_data = np.load(graph_signal_matrix_filename)
)
- in this file, make sure to load 8 entities:
- train_x; train_target; val_x; val_target; test_x; test_target; mean; std
- how to unify when the output channel is >1: in the main train file, search for
.unsqueeze(-1)
, there are four of them; if label data has dim_channel >1, then you can comment these 4 lines.
fname_locs
: search for fname_locs
in model/gen_locaware_kernel.py
. Make sure it is comparible with load_locs()
. Desired output is: np.ndarray, shape = [N,2], means node locations.
adj_matrix
: is an .npy
file; shape = [N,N]. is manually saved; see above (2.)