更新正确的AirQuality数据集

This commit is contained in:
czzhangheng 2025-11-20 22:15:48 +08:00
parent 4d87087147
commit 7055a6da64
7 changed files with 85 additions and 8 deletions

8
.vscode/launch.json vendored
View File

@ -60,6 +60,14 @@
"console": "integratedTerminal",
"args": "--config ./config/REPST/BeijingAirQuality.yaml"
},
{
"name": "AirQuality",
"type": "debugpy",
"request": "launch",
"program": "run.py",
"console": "integratedTerminal",
"args": "--config ./config/REPST/AirQuality.yaml"
},
{
"name": "AEPSA-PEMSBAY",
"type": "debugpy",

61
config/REPST/AirQuality.yaml Executable file
View File

@ -0,0 +1,61 @@
basic:
dataset: "AirQuality"
mode : "train"
device : "cuda:1"
model: "REPST"
seed: 2023
data:
add_day_in_week: false
add_time_in_day: false
column_wise: false
days_per_week: 7
default_graph: true
horizon: 24
lag: 24
normalizer: std
num_nodes: 35
steps_per_day: 288
test_ratio: 0.2
tod: false
val_ratio: 0.2
sample: 1
input_dim: 6
batch_size: 16
model:
pred_len: 24
seq_len: 24
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: 6
output_dim: 3
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: 3
log_step: 1000
plot: false
mae_thresh: None
mape_thresh: 0.001

View File

@ -12,6 +12,11 @@ def load_st_dataset(config):
data = np.memmap(data_path, dtype=np.float32, mode='r')
L, N, C = 36000, 7, 3
data = data.reshape(L, N, C)
case "AirQuality":
data_path = os.path.join("./data/AirQuality/data.dat")
data = np.memmap(data_path, dtype=np.float32, mode='r')
L, N, C = 8701,35,6
data = data.reshape(L, N, C)
case "PEMS-BAY":
data_path = os.path.join("./data/PEMS-BAY/pems-bay.h5")
with h5py.File(data_path, 'r') as f:

View File

@ -47,7 +47,7 @@ class repst(nn.Module):
self.out_mlp = nn.Sequential(
nn.Linear(self.d_llm, 128),
nn.ReLU(),
nn.Linear(128, self.pred_len)
nn.Linear(128, self.pred_len * self.output_dim)
)
for i, (name, param) in enumerate(self.gpts.named_parameters()):
@ -63,7 +63,7 @@ class repst(nn.Module):
torch.nn.init.zeros_(module.bias)
def forward(self, x):
x = x[..., :self.output_dim]
x = x[..., :self.input_dim]
x_enc = rearrange(x, 'b t n c -> b n c t')
enc_out, n_vars = self.patch_embedding(x_enc)
self.mapping_layer(self.word_embeddings.permute(1, 0)).permute(1, 0)
@ -73,10 +73,11 @@ class repst(nn.Module):
enc_out = self.reprogramming_layer(enc_out, source_embeddings, source_embeddings)
enc_out = self.gpts(inputs_embeds=enc_out).last_hidden_state
dec_out = self.out_mlp(enc_out)
outputs = dec_out.unsqueeze(dim=-1)
outputs = outputs.repeat(1, 1, 1, n_vars)
outputs = outputs.permute(0,2,1,3)
dec_out = self.out_mlp(enc_out) #[B, N, T*C]
B, N, _ = dec_out.shape
outputs = dec_out.view(B, N, self.pred_len, self.output_dim)
outputs = outputs.permute(0, 2, 1, 3) # B, T, N, C
return outputs

View File

@ -99,7 +99,8 @@ def check_and_download_data():
download_and_extract("http://code.zhang-heng.com/static/adj.7z", data_dir)
baq_folder = os.path.join(data_dir,"BeijingAirQuality")
if not os.path.isdir(baq_folder):
baq_folder2 = os.path.join(data_dir,"AirQuality")
if not os.path.isdir(baq_folder) or not os.path.isdir(baq_folder2):
download_and_extract("http://code.zhang-heng.com/static/BeijingAirQuality.7z", data_dir)
_,missing_main = detect_data_integrity(data_dir, expected, check_adj=False)

View File

@ -35,5 +35,6 @@
"SolarEnergy": [
"SolarEnergy.csv"
],
"BeijingAirQuality": ["data.dat", "desc.json"]
"BeijingAirQuality": ["data.dat", "desc.json"],
"AirQuality": ["data.dat"]
}