update README and LICENSE

This commit is contained in:
unknown 2021-12-12 11:36:56 +08:00
parent 7cc4bc781c
commit f8a85887a8
4 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2021 Echo Ji Copyright (c) 2022 Echo Ji
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,9 @@
# STDEN # STDEN
This is the implementation of Spatio-temporal Differential Equation Network (STDEN) in paper Towards Physics-guided Neural Networks for Traffic Flow Prediction. This is the implementation of Spatio-temporal Differential Equation Network (STDEN) in the following paper:
Jiahao Ji, Jingyuan Wang, Zhe Jiang, Jiawei Jiang, and Hu Zhang, Towards Physics-guided Neural Networks for Traffic Flow Prediction, AAAI 2022.
Thanks [chnsh](https://github.com/chnsh/DCRNN_PyTorch) for the model training framework of this project.
## Requirement ## Requirement
@ -36,4 +39,4 @@ The configuration file of all datasets are as follows:
|WRS-393|stden_wrs.yaml| |WRS-393|stden_wrs.yaml|
|ZGC-564|stden_zgc.yaml| |ZGC-564|stden_zgc.yaml|
PS: The data is not public and I am not allowed to distribute it. Note the data is not public and I am not allowed to distribute it.

View File

@ -4,7 +4,7 @@ def masked_mae_loss(y_pred, y_true):
# print('y_pred: ', y_pred.shape, 'y_true: ', y_true.shape) # print('y_pred: ', y_pred.shape, 'y_true: ', y_true.shape)
y_true[y_true < 1e-4] = 0 y_true[y_true < 1e-4] = 0
mask = (y_true != 0).float() mask = (y_true != 0).float()
mask /= mask.mean() # 将0值的权重分配给非零值 mask /= mask.mean() # assign the sample weights of zeros to nonzero-values
loss = torch.abs(y_pred - y_true) loss = torch.abs(y_pred - y_true)
loss = loss * mask loss = loss * mask
# trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3 # trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3
@ -15,7 +15,7 @@ def masked_mape_loss(y_pred, y_true):
# print('y_pred: ', y_pred.shape, 'y_true: ', y_true.shape) # print('y_pred: ', y_pred.shape, 'y_true: ', y_true.shape)
y_true[y_true < 1e-4] = 0 y_true[y_true < 1e-4] = 0
mask = (y_true != 0).float() mask = (y_true != 0).float()
mask /= mask.mean() # 将0值的权重分配给非零值 mask /= mask.mean()
loss = torch.abs((y_pred - y_true) / y_true) loss = torch.abs((y_pred - y_true) / y_true)
loss = loss * mask loss = loss * mask
# trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3 # trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3

View File

@ -158,7 +158,7 @@ def load_dataset(dataset_dir, batch_size, val_batch_size=None, **kwargs):
cat_data = np.load(os.path.join(dataset_dir, category + '.npz')) cat_data = np.load(os.path.join(dataset_dir, category + '.npz'))
data['x_' + category] = cat_data['x'] data['x_' + category] = cat_data['x']
data['y_' + category] = cat_data['y'] data['y_' + category] = cat_data['y']
scaler = StandardScaler(mean=data['x_train'].mean(), std=data['x_train'].std()) # 第0维是要预测的量但是第1维是什么呢 scaler = StandardScaler(mean=data['x_train'].mean(), std=data['x_train'].std())
# Data format # Data format
for category in ['train', 'val', 'test']: for category in ['train', 'val', 'test']:
data['x_' + category] = scaler.transform(data['x_' + category]) data['x_' + category] = scaler.transform(data['x_' + category])