Open gwyy-mh opened 4 years ago
I downloaded the bn_inception pth file, and train, but error occurs that : Runtime error size mismatch for conv1_7x7_s2_bn.weight copying a param with shape for torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]). I am a new person in this field, so I don't know how to deal with it.
Hello, I met the same problem as you and I sloved it using command as follows
pip install torch==0.3.1 torchvision==0.2.1
you can try
@quanh1990 hi, can you share the link of bn_inception pre-trained model with me? thanks
@gwyy-mh and @quanh1990 Can you please share the link of the bn_inception pth file pre-trained model?
For higher version pytorch > 0.3.1,you can change code to convert checkpoint to avoid this error. For example, you chose BNInception, so find tf_model_zoo\bninception\pytorch_load.py code in init function state_dict = torch.utils.model_zoo.load_url(weight_url) state_dict = self.convert_state_dict(state_dict) self.load_state_dict(state_dict) then add a function after init function def convert_state_dict(self, state_dict): cv_state_dict = {} for key in state_dict: current_tensor = state_dict[key] # print(current_tensor.dim()) if current_tensor.dim() == 2: cv_state_dict[key] = current_tensor.squeeze() else: cv_state_dict[key] = current_tensor return cv_state_dict then can solve this with higher version pytorch
I downloaded the bn_inception pth file, and train, but error occurs that : Runtime error size mismatch for conv1_7x7_s2_bn.weight copying a param with shape for torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]). I am a new person in this field, so I don't know how to deal with it.