diff --git a/.vscode/launch.json b/.vscode/launch.json index a8f3c00..281f8ac 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,6 +36,14 @@ "console": "integratedTerminal", "args": "--config ./config/REPST/PEMS-BAY.yaml" }, + { + "name": "REPST-METR", + "type": "debugpy", + "request": "launch", + "program": "run.py", + "console": "integratedTerminal", + "args": "--config ./config/REPST/METR-LA.yaml" + }, { "name": "AEPSA-PEMSBAY", "type": "debugpy", diff --git a/config/REPST/METR-LA.yaml b/config/REPST/METR-LA.yaml new file mode 100755 index 0000000..2e57a1c --- /dev/null +++ b/config/REPST/METR-LA.yaml @@ -0,0 +1,60 @@ +basic: + dataset: "METR-LA" + mode : "train" + device : "cuda:1" + model: "REPST" + seed: 2023 + +data: + add_day_in_week: true + add_time_in_day: true + column_wise: false + days_per_week: 7 + default_graph: true + horizon: 12 + lag: 12 + normalizer: std + num_nodes: 207 + steps_per_day: 288 + test_ratio: 0.2 + tod: false + val_ratio: 0.2 + sample: 1 + input_dim: 1 + batch_size: 16 + +model: + pred_len: 12 + seq_len: 12 + patch_len: 6 + stride: 7 + dropout: 0.2 + gpt_layers: 9 + d_ff: 128 + gpt_path: ./GPT-2 + d_model: 64 + n_heads: 1 + input_dim: 1 + word_num: 1000 + +train: + batch_size: 16 + early_stop: true + early_stop_patience: 15 + epochs: 100 + grad_norm: false + loss_func: mae + lr_decay: true + lr_decay_rate: 0.3 + lr_decay_step: "5,20,40,70" + lr_init: 0.003 + max_grad_norm: 5 + real_value: true + weight_decay: 0 + debug: false + output_dim: 1 + log_step: 1000 + plot: false + mae_thresh: None + mape_thresh: 0.001 + diff --git a/dataloader/data_selector.py b/dataloader/data_selector.py index 19fe7f5..78c3e3f 100644 --- a/dataloader/data_selector.py +++ b/dataloader/data_selector.py @@ -11,11 +11,13 @@ def load_st_dataset(config): data_path = os.path.join("./data/PEMS-BAY/pems-bay.h5") with h5py.File(data_path, 'r') as f: data = f['speed']['block0_values'][:] + case "METR-LA": + data_path = os.path.join("./data/METR-LA/METR-LA.h5") + with h5py.File(data_path, 'r') as f: + data = f['df']['block0_values'][:] case "PEMSD3": data_path = os.path.join("./data/PEMS03/PEMS03.npz") - data = np.load(data_path)["data"][ - :, :, 0 - ] + data = np.load(data_path)["data"][:, :, 0] case "PEMSD4": data_path = os.path.join("./data/PEMS04/PEMS04.npz") data = np.load(data_path)["data"][ diff --git a/run.py b/run.py index 175367f..4f48ce5 100755 --- a/run.py +++ b/run.py @@ -14,6 +14,8 @@ def main(): args = parse_args() args = init.init_device(args) init.init_seed(args["basic"]["seed"]) + + model = init.init_model(args) # Load dataset diff --git a/utils/Download_data.py b/utils/Download_data.py index fcd21f1..544d744 100755 --- a/utils/Download_data.py +++ b/utils/Download_data.py @@ -47,6 +47,9 @@ def check_and_download_data(): "adj_mx_bay.pkl", "pems-bay-meta.h5", "pems-bay.h5" + ], + "METR-LA": [ + "METR-LA.h5" ] } @@ -92,6 +95,7 @@ def check_and_download_data(): if missing_main_files: download_kaggle_data(current_dir, 'elmahy/pems-dataset') download_kaggle_data(current_dir, 'scchuy/pemsbay') + download_kaggle_data(current_dir, "annnnguyen/metr-la-dataset") rearrange_dir() @@ -183,7 +187,6 @@ def rearrange_dir(): shutil.copy2(source_path, destination_path) shutil.rmtree(nested_data_dir) - # print(f"已合并 {nested_data_dir} 到 {data_dir},并删除嵌套目录。") # 将带有 "bay" 的文件移动到 PEMS-BAY 文件夹 pems_bay_dir = os.path.join(data_dir, "PEMS-BAY") @@ -195,10 +198,16 @@ def rearrange_dir(): destination_path = os.path.join(pems_bay_dir, item) shutil.move(source_path, destination_path) - # print(f"已将带有 'bay' 的文件移动到 {pems_bay_dir}。") + # metr-la + metrla_dir = os.path.join(data_dir, "METR-LA") + os.makedirs(metrla_dir, exist_ok=True) + for item in os.listdir(data_dir): + if "metr" in item.lower() and (item.endswith(".pkl") or item.endswith(".h5")): + source_path = os.path.join(data_dir, item) + destination_path = os.path.join(metrla_dir, item) + shutil.move(source_path, destination_path) # 主程序 if __name__ == "__main__": check_and_download_data() - # rearrange_dir()