fix(actpred): 修复动作归一化统计量未覆盖 history 导致的 z-score 爆炸
两个问题(本轮归一化编译链路上实测暴露): 1. 统计量只按 targets 计算:targets 中恒定的列 std 落到 1e-8 地板值,而 history 窗口可能含该列的其他取值(.mt 脚本前几行), z-score 爆炸(实测 (90-45)/1e-8=4.5e9)→ act_tokens ±1e9 → DFC optimize 报 NegativeSlopeExponentNonFixable(desired shift 23 > 15 data bits)。pretrain_mt.py 与 dataset.py 的统计量改为 history∪target 联合计算,修复后校准数据 max|z| = 4.77。 2. action_stats_path 存成含目录的相对路径("./checkpoints/ action_stats.npy"),推理端(predict/export_deploy/gen_calibration) 按 checkpoint 目录解析时二次拼接成 checkpoints/./checkpoints, 导出直接 FileNotFoundError。train.py/pretrain_mt.py 改存裸文件名 "action_stats.npy"(stats 与 checkpoint 同目录,语义一致)。 新增回归测试 test_stats_cover_history_values(history 独有取值不 得被 1e-8 地板值打爆),全量 77 通过。 归一化重编译全链路通过:token 量级 |img|=0.53 |act|=2.93 健康, optimize 通过,连通性检查 5/5,HEF 2.02MB 已部署 Pi 待 _npu_test 复验。
This commit is contained in:
1 parent
52c0ade3c4
commit
316758d80e
4 files changed
+41
-4
No files matched your search
+12
-2
@@ -217,13 +217,23 @@ def main():
|
||||
f"{cfg.data.action_stats_path}")
|
||||
stats = np.load(cfg.data.action_stats_path)
|
||||
else:
|
||||
all_actions = np.stack([s[1] for s in train_ds.samples])
|
||||
# 统计量必须覆盖 history 与 target 并集:只按 targets 算时,
|
||||
# targets 中恒定的列 std 落到 1e-8 地板值,而 history 窗口
|
||||
# 可能含该列的其他取值(如 .mt 脚本前几行),z-score 会爆炸
|
||||
# (实测 (90-45)/1e-8=4.5e9),后续 act_tokens ±1e9 直接
|
||||
# 打爆 DFC 量化(NegativeSlopeExponentNonFixable)
|
||||
all_actions = np.stack(
|
||||
[np.concatenate([s[0], s[1][None]]) for s in train_ds.samples]
|
||||
).reshape(-1, cfg.data.action_dim)
|
||||
stats = np.stack([all_actions.mean(axis=0),
|
||||
all_actions.std(axis=0) + 1e-8])
|
||||
stats_path = os.path.join(cfg.train.checkpoint_dir,
|
||||
"action_stats.npy")
|
||||
np.save(stats_path, stats)
|
||||
cfg.data.action_stats_path = stats_path
|
||||
# 只存裸文件名:推理端按 checkpoint 目录解析相对路径
|
||||
# (predict.py/export_deploy.py/gen_calibration.py 同语义),
|
||||
# 存 "./checkpoints/..." 会被二次拼接成 checkpoints/./checkpoints
|
||||
cfg.data.action_stats_path = "action_stats.npy"
|
||||
print(f"action_stats 已保存: {stats_path}(训练集 targets 统计)")
|
||||
if stats.shape != (2, cfg.data.action_dim):
|
||||
raise ValueError(
|
||||
|
||||
Reference in new issue
Block a user