debug: 固定验证集上的随机噪声,修复resnet在训练时bn层会切换到train的问题

This commit is contained in:
gouhanke
2026-02-06 21:31:19 +08:00
parent 05f3cc1e47
commit 456056347f
4 changed files with 18 additions and 135 deletions
+7
View File
@@ -200,6 +200,13 @@ def main(cfg: DictConfig):
if val_loader is None:
return None
agent.eval()
# 🔧 FIX: Set deterministic seed for validation to get reproducible loss
# This ensures validation loss is comparable across different steps
torch.manual_seed(42)
if torch.cuda.is_available():
torch.cuda.manual_seed(42)
total_loss = 0.0
num_batches = 0
with torch.no_grad():