From 7be3de7d1dd6f82c9b34f258fd173dd7f24029b7 Mon Sep 17 00:00:00 2001 From: MingzheYang Date: Mon, 26 Jan 2026 22:28:58 +0800 Subject: [PATCH] update --- example/config_no_temporal.json | 44 ++++++++++++++++++++++ example/config_temporal_strong.json | 49 ++++++++++++++++++++++++ example/run_compare.py | 58 +++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 example/config_no_temporal.json create mode 100644 example/config_temporal_strong.json create mode 100644 example/run_compare.py diff --git a/example/config_no_temporal.json b/example/config_no_temporal.json new file mode 100644 index 0000000..1270d07 --- /dev/null +++ b/example/config_no_temporal.json @@ -0,0 +1,44 @@ +{ + "data_path": "../../dataset/hai/hai-21.03/train1.csv.gz", + "data_glob": "../../dataset/hai/hai-21.03/train*.csv.gz", + "split_path": "./feature_split.json", + "stats_path": "./results/cont_stats.json", + "vocab_path": "./results/disc_vocab.json", + "out_dir": "./results", + "device": "auto", + "timesteps": 600, + "batch_size": 128, + "seq_len": 128, + "epochs": 10, + "max_batches": 4000, + "lambda": 0.7, + "lr": 0.0005, + "seed": 1337, + "log_every": 10, + "ckpt_every": 50, + "ema_decay": 0.999, + "use_ema": true, + "clip_k": 5.0, + "grad_clip": 1.0, + "use_condition": true, + "condition_type": "file_id", + "cond_dim": 32, + "use_tanh_eps": false, + "eps_scale": 1.0, + "model_time_dim": 128, + "model_hidden_dim": 512, + "model_num_layers": 2, + "model_dropout": 0.1, + "model_ff_mult": 2, + "model_pos_dim": 64, + "model_use_pos_embed": true, + "disc_mask_scale": 0.9, + "cont_loss_weighting": "inv_std", + "cont_loss_eps": 1e-6, + "cont_target": "x0", + "cont_clamp_x0": 5.0, + "shuffle_buffer": 1024, + "use_temporal_stage1": false, + "sample_batch_size": 8, + "sample_seq_len": 128 +} diff --git a/example/config_temporal_strong.json b/example/config_temporal_strong.json new file mode 100644 index 0000000..5bf1664 --- /dev/null +++ b/example/config_temporal_strong.json @@ -0,0 +1,49 @@ +{ + "data_path": "../../dataset/hai/hai-21.03/train1.csv.gz", + "data_glob": "../../dataset/hai/hai-21.03/train*.csv.gz", + "split_path": "./feature_split.json", + "stats_path": "./results/cont_stats.json", + "vocab_path": "./results/disc_vocab.json", + "out_dir": "./results", + "device": "auto", + "timesteps": 600, + "batch_size": 128, + "seq_len": 128, + "epochs": 10, + "max_batches": 4000, + "lambda": 0.7, + "lr": 0.0005, + "seed": 1337, + "log_every": 10, + "ckpt_every": 50, + "ema_decay": 0.999, + "use_ema": true, + "clip_k": 5.0, + "grad_clip": 1.0, + "use_condition": true, + "condition_type": "file_id", + "cond_dim": 32, + "use_tanh_eps": false, + "eps_scale": 1.0, + "model_time_dim": 128, + "model_hidden_dim": 512, + "model_num_layers": 2, + "model_dropout": 0.1, + "model_ff_mult": 2, + "model_pos_dim": 64, + "model_use_pos_embed": true, + "disc_mask_scale": 0.9, + "cont_loss_weighting": "inv_std", + "cont_loss_eps": 1e-6, + "cont_target": "x0", + "cont_clamp_x0": 5.0, + "shuffle_buffer": 1024, + "use_temporal_stage1": true, + "temporal_hidden_dim": 512, + "temporal_num_layers": 2, + "temporal_dropout": 0.0, + "temporal_epochs": 5, + "temporal_lr": 0.0005, + "sample_batch_size": 8, + "sample_seq_len": 128 +} diff --git a/example/run_compare.py b/example/run_compare.py new file mode 100644 index 0000000..7b0bbae --- /dev/null +++ b/example/run_compare.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +"""Run two configs sequentially and print metric deltas.""" + +import argparse +import csv +import subprocess +import sys +from pathlib import Path + + +def run(cmd): + print("running:", " ".join(cmd)) + subprocess.run(cmd, check=True) + + +def read_last_metrics(path: Path): + if not path.exists(): + return None + rows = list(csv.DictReader(path.open())) + return rows[-1] if rows else None + + +def main(): + parser = argparse.ArgumentParser(description="Compare metrics for two configs.") + base_dir = Path(__file__).resolve().parent + parser.add_argument("--config-a", default=str(base_dir / "config_no_temporal.json")) + parser.add_argument("--config-b", default=str(base_dir / "config_temporal_strong.json")) + parser.add_argument("--device", default="auto") + args = parser.parse_args() + + history = base_dir / "results" / "metrics_history.csv" + if history.exists(): + history.unlink() + + run([sys.executable, str(base_dir / "run_all.py"), "--config", args.config_a, "--device", args.device]) + a = read_last_metrics(history) + run([sys.executable, str(base_dir / "run_all.py"), "--config", args.config_b, "--device", args.device]) + b = read_last_metrics(history) + + if not a or not b: + raise SystemExit("missing metrics_history.csv entries") + + def f(v): + return float(v) if v is not None else None + + print("baseline_avg_ks", a["avg_ks"]) + print("temporal_avg_ks", b["avg_ks"]) + print("delta_avg_ks", f(b["avg_ks"]) - f(a["avg_ks"])) + print("baseline_avg_jsd", a["avg_jsd"]) + print("temporal_avg_jsd", b["avg_jsd"]) + print("delta_avg_jsd", f(b["avg_jsd"]) - f(a["avg_jsd"])) + print("baseline_avg_lag1_diff", a["avg_lag1_diff"]) + print("temporal_avg_lag1_diff", b["avg_lag1_diff"]) + print("delta_avg_lag1_diff", f(b["avg_lag1_diff"]) - f(a["avg_lag1_diff"])) + + +if __name__ == "__main__": + main()