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

View File

@@ -27,6 +27,16 @@ class ResNetBackbone(VLABackbone):
param.requires_grad = False
self.model.eval()
def train(self, mode=True):
"""
Override train() to keep frozen ResNet in eval mode.
This ensures BatchNorm layers use running statistics consistently.
"""
super().train(mode)
if hasattr(self, 'model'):
self.model.eval() # Always keep ResNet in eval mode
return self
def forward_single_image(self, image):
B, T, C, H, W = image.shape
image = image.view(B * T, C, H, W)