sunnyxiaohu / R-C3D.pytorch

R-C3D pytorch implementation
248 stars 67 forks source link

at test, load GPU trained model has error #20

Closed rambleramble closed 5 years ago

rambleramble commented 5 years ago

the reproduction step: python test_net.py --dataset thumos14 --net c3d --checksession 1 --checkepoch 3 --checkpoint 13711 --cuda

error message: RuntimeError: Error(s) in loading state_dict for c3d_tdcnn: Missing key(s) in state_dict: "RCNN_rpn.RPN_Conv1.weight", "RCNN_rpn.RPN_Conv1.bias", "RCNN_rpn.RPN_Conv2.weight", "RCNN_rpn.RPN_Conv2.bias", "RCNN_rpn.RPN_cls_score.weight", "RCNN_rpn.RPN_cls_score.bias", "RCNN_rpn.RPN_twin_pred.weight", "RCNN_rpn.RPN_twin_pred.bias", "RCNN_base.0.weight", "RCNN_base.0.bias", "RCNN_base.3.weight", "RCNN_base.3.bias", "RCNN_base.6.weight", "RCNN_base.6.bias", "RCNN_base.8.weight", "RCNN_base.8.bias", "RCNN_base.11.weight", "RCNN_base.11.bias", "RCNN_base.13.weight", "RCNN_base.13.bias", "RCNN_base.16.weight", "RCNN_base.16.bias", "RCNN_base.18.weight", "RCNN_base.18.bias", "RCNN_top.0.weight", "RCNN_top.0.bias", "RCNN_cls_score.weight", "RCNN_cls_score.bias", "RCNN_twin_pred.weight", "RCNN_twin_pred.bias". Unexpected key(s) in state_dict: "module.RCNN_rpn.RPN_Conv1.weight", "module.RCNN_rpn.RPN_Conv1.bias", "module.RCNN_rpn.RPN_Conv2.weight", "module.RCNN_rpn.RPN_Conv2.bias", "module.RCNN_rpn.RPN_cls_score.weight", "module.RCNN_rpn.RPN_cls_score.bias", "module.RCNN_rpn.RPN_twin_pred.weight", "module.RCNN_rpn.RPN_twin_pred.bias", "module.RCNN_base.0.weight", "module.RCNN_base.0.bias", "module.RCNN_base.3.weight", "module.RCNN_base.3.bias", "module.RCNN_base.6.weight", "module.RCNN_base.6.bias", "module.RCNN_base.8.weight", "module.RCNN_base.8.bias", "module.RCNN_base.11.weight", "module.RCNN_base.11.bias", "module.RCNN_base.13.weight", "module.RCNN_base.13.bias", "module.RCNN_base.16.weight", "module.RCNN_base.16.bias", "module.RCNN_base.18.weight", "module.RCNN_base.18.bias", "module.RCNN_top.0.weight", "module.RCNN_top.0.bias", "module.RCNN_cls_score.weight", "module.RCNN_cls_score.bias", "module.RCNN_twin_pred.weight", "module.RCNN_twin_pred.bias".

my workaround is to replace following lines 209-210 https://github.com/sunnyxiaohu/R-C3D.pytorch/blob/master/test_net.py#L209

to checkpoint = torch.load(load_name) tdcnn_demo = nn.DataParallel(tdcnn_demo) tdcnn_demo.load_state_dict(checkpoint['model']) tdcnn_demo = tdcnn_demo.module