修复test bug

This commit is contained in:
czzhangheng 2025-11-09 16:38:04 +08:00
parent a3e43fc6df
commit cf47acf2bd
2 changed files with 6 additions and 6 deletions

View File

@ -38,7 +38,7 @@ train:
batch_size: 64 batch_size: 64
early_stop: true early_stop: true
early_stop_patience: 15 early_stop_patience: 15
epochs: 300 epochs: 100
grad_norm: false grad_norm: false
loss_func: mae loss_func: mae
lr_decay: true lr_decay: true

View File

@ -274,12 +274,12 @@ class Trainer:
with torch.no_grad(): with torch.no_grad():
for data, target in data_loader: for data, target in data_loader:
label = target[..., : args["train"]["output_dim"]] label = target[..., : args["output_dim"]]
output = model(data) output = model(data)
y_pred.append(output) y_pred.append(output)
y_true.append(label) y_true.append(label)
if args["train"]["real_value"]: if args["real_value"]:
y_pred = scaler.inverse_transform(torch.cat(y_pred, dim=0)) y_pred = scaler.inverse_transform(torch.cat(y_pred, dim=0))
else: else:
y_pred = torch.cat(y_pred, dim=0) y_pred = torch.cat(y_pred, dim=0)
@ -289,15 +289,15 @@ class Trainer:
mae, rmse, mape = all_metrics( mae, rmse, mape = all_metrics(
y_pred[:, t, ...], y_pred[:, t, ...],
y_true[:, t, ...], y_true[:, t, ...],
args["train"]["mae_thresh"], args["mae_thresh"],
args["train"]["mape_thresh"], args["mape_thresh"],
) )
logger.info( logger.info(
f"Horizon {t + 1:02d}, MAE: {mae:.4f}, RMSE: {rmse:.4f}, MAPE: {mape:.4f}" f"Horizon {t + 1:02d}, MAE: {mae:.4f}, RMSE: {rmse:.4f}, MAPE: {mape:.4f}"
) )
mae, rmse, mape = all_metrics( mae, rmse, mape = all_metrics(
y_pred, y_true, args["train"]["mae_thresh"], args["train"]["mape_thresh"] y_pred, y_true, args["mae_thresh"], args["mape_thresh"]
) )
logger.info( logger.info(
f"Average Horizon, MAE: {mae:.4f}, RMSE: {rmse:.4f}, MAPE: {mape:.4f}" f"Average Horizon, MAE: {mae:.4f}, RMSE: {rmse:.4f}, MAPE: {mape:.4f}"