-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'unexpected key "conv1.weight" in state_dict' #3
Comments
It should definitely be possible to load pretrained imagenet weights from torchvision. The used resnet model is just a rewritten version of the model from here to allow direct access to the different layers. So renaming the keys and removing the fully connected layer weights would be sufficient to load the weights. You can have a look at convert_from_keras.py to see how to modify a pretrained model file. |
But the code that you are using is for pretrained from what: converted keras or official pytorch? If it is for official pytorch then I think we do not need to change. Because it matched with the official implementation of pytorch. I have downloaded the pretrained from the link you gave me ( torchvision) but it shows error above when I use it. |
Then i missunderstood. For direct use with this code download the pretrained models converted from keras. |
Thanks @lasseha for your help. I have downloaded the pretrain and run the code. But I got the new error. Hence, I have two questions:
|
|
Thanks so much @lasseha. It helped me to solved the problem of loading image net. However, it has other error that is
Note that, I have run the matterport implementation successful, but it is too slow. So I prefer your code |
Which dataset do you use for training? COCO or some custom datasaet? |
@lasseha: i used customer dataset. That does not read json, it read mask and image directly from folder. It looks like the shape dataset in matterport code |
I do not see this error with COCO, so maybe try to find the difference between those datasets. |
Thanks. I will try. Could you tell me how can we use the official pretrain model of pytorch, instead of the convert from matterport ? |
Again, i refer to my first comment:
|
Hey @lasseha I am getting the same error as @John1231983 except I am trying to train on the COCO dataset sepcifically 2014. Any ideas what is causing this error? File "/home/cvds_lab/rseferya/pytorch-mask-rcnn/model.py", line 569, in detection_target_layer |
@rafisef Solved!The size of empty tensor in pytorch0.4 is 1, not 0. This is because scalars is introduced, and thus [] becomes dim 1. pytorch/pytorch#7240 @lasseha can update the code to support pytorch0.4 |
I am using imagenet pretrain and when I run the training, I got the error. How to fix it? Thanks. My pytorch is 0.4.0, python 3.6
The pretrain model I got from torchvision (official pretrain model). I guess we have to use keras pretrain model to fix it. However, how could we use official pretrain model in https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py?
The text was updated successfully, but these errors were encountered: