diff --git a/LICENSE b/LICENSE index ff4c0fb..8287818 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ 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 of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 34b0a34..b3e8e0e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # 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 @@ -36,4 +39,4 @@ The configuration file of all datasets are as follows: |WRS-393|stden_wrs.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. \ No newline at end of file diff --git a/lib/metrics.py b/lib/metrics.py index 117b0db..e7b2f90 100644 --- a/lib/metrics.py +++ b/lib/metrics.py @@ -4,7 +4,7 @@ def masked_mae_loss(y_pred, y_true): # print('y_pred: ', y_pred.shape, 'y_true: ', y_true.shape) y_true[y_true < 1e-4] = 0 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 = loss * mask # 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) y_true[y_true < 1e-4] = 0 mask = (y_true != 0).float() - mask /= mask.mean() # 将0值的权重分配给非零值 + mask /= mask.mean() loss = torch.abs((y_pred - y_true) / y_true) loss = loss * mask # trick for nans: https://discuss.pytorch.org/t/how-to-set-nan-in-tensor-to-0/3918/3 diff --git a/lib/utils.py b/lib/utils.py index dafd6ec..1364123 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -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')) data['x_' + category] = cat_data['x'] 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 for category in ['train', 'val', 'test']: data['x_' + category] = scaler.transform(data['x_' + category])