fix(actpred): 训练时 action stats 完整路径传给 val_ds,checkpoint 存裸文件名
normalize_actions 默认改为 True 后暴露的潜伏 bug:stats 保存到 checkpoint_dir 后,cfg 只留裸文件名,val_ds 按 cwd 解析导致 FileNotFoundError。现改为验证集用完整路径构建,checkpoint 配置 存裸文件名(推理端按 checkpoint 目录解析)。 同步修正 test_warn_init_from_mismatch 对默认值的隐式依赖。
This commit is contained in:
1 parent
af0ff56848
commit
7ec8c9d0e9
2 files changed
+9
-2
No files matched your search
@@ -666,6 +666,8 @@ class TestParseCheckpointConfig(unittest.TestCase):
|
||||
"""--init-from 兼容性警告:normalize 或 action_dim 不一致时提示"""
|
||||
from config import warn_init_from_mismatch
|
||||
cfg = Config()
|
||||
# 显式设定当前运行的 normalize 值,不依赖默认值(默认已改为 True)
|
||||
cfg.data.normalize_actions = False
|
||||
init_cfg = {
|
||||
"data": {"normalize_actions": True, "action_dim": 12},
|
||||
}
|
||||
|
||||
+7
-2
@@ -157,19 +157,24 @@ def main():
|
||||
augment=cfg.train.augment,
|
||||
predict_delta=cfg.train.predict_delta, rollout_len=cfg.train.rollout_len,
|
||||
imu_dim=cfg.data.imu_dim)
|
||||
auto_stats = False
|
||||
if cfg.data.normalize_actions and not cfg.data.action_stats_path:
|
||||
# 归一化统计量必须只用训练集计算,再供验证集复用,否则 val loss 不可信
|
||||
stats_path = os.path.join(cfg.train.checkpoint_dir, "action_stats.npy")
|
||||
np.save(stats_path, train_ds.get_action_stats())
|
||||
print(f"Action stats saved to: {stats_path}")
|
||||
# 只存裸文件名:推理端按 checkpoint 目录解析相对路径
|
||||
cfg.data.action_stats_path = "action_stats.npy"
|
||||
# 验证集构建需要完整路径(相对路径按 cwd 解析会找不到文件)
|
||||
cfg.data.action_stats_path = stats_path
|
||||
auto_stats = True
|
||||
val_ds = ActionDataset(
|
||||
cfg.data.data_dir, cfg.data.history_len, cfg.data.action_dim,
|
||||
cfg.data.image_width, cfg.data.image_height, cfg.data.normalize_actions,
|
||||
cfg.data.action_stats_path, val_indices, cfg.data.frame_len,
|
||||
predict_delta=cfg.train.predict_delta, rollout_len=cfg.train.rollout_len,
|
||||
imu_dim=cfg.data.imu_dim)
|
||||
if auto_stats:
|
||||
# checkpoint 配置只存裸文件名:推理端按 checkpoint 目录解析相对路径
|
||||
cfg.data.action_stats_path = "action_stats.npy"
|
||||
|
||||
print(f"Samples: {len(train_ds)} train, {len(val_ds)} val")
|
||||
if len(train_ds) == 0:
|
||||
|
||||
Reference in new issue
Block a user