leeyeehoo / CSRNet-pytorch

CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes
642 stars 259 forks source link

训练时,验证集的效果非常差是怎么回事 #48

Open sxxtaotao opened 5 years ago

sxxtaotao commented 5 years ago

当我训练的时候,验证集的效果非常差,一直在300-400左右浮动,请问这是什么原因,我也没有改别的,只是把python3中不兼容python2的给改掉了,改动最大的是model.py中 if not load_weights: mod = models.vgg16(pretrained = True) self._initialize_weights()

读取参数

        pretrained_dict=mod.state_dict()
        self.frontend_dict=self.frontend.state_dict()
        #将pretrained_dict里不属于frontend_dict的键剔除掉
        pretrained_dict={k:v for k, v in pretrained_dict.items() if k in self.frontend_dict}
        #更新现有的frontend_dict
        self.frontend_dict.update(pretrained_dict)
        #加载我们真正需要的state_dict
        self.frontend.load_state_dict(self.frontend_dict)

因为python3中不支持这样的索引,不知道改的对不对,验证集效果一直很差

neverland0621 commented 5 years ago

我猜你验证集的代码不对,记得最后一个cell中有一行注释,取消掉就好了

Garyzdz commented 4 years ago

我的预测值为nan

zhengmiao1 commented 4 years ago

我猜你验证集的代码不对,记得最后一个cell中有一行注释,取消掉就好了

你说的挺对的,我开始也是验证集精度很差,验证集part_B 的MAE是1900多,取消掉最后一个cell中的注释img = transform(Image.open(img_paths[i]).convert('RGB')).cuda()后,我的验证集精度为8.998,感谢

Cli98 commented 4 years ago

我猜你验证集的代码不对,记得最后一个cell中有一行注释,取消掉就好了

你说的挺对的,我开始也是验证集精度很差,验证集part_B 的MAE是1900多,取消掉最后一个cell中的注释img = transform(Image.open(img_paths[i]).convert('RGB')).cuda()后,我的验证集精度为8.998,感谢

If you do this, then you negate all normalization process before this line.