pytorch-semantic-segmentation icon indicating copy to clipboard operation
pytorch-semantic-segmentation copied to clipboard

About caffe-VGG16

Open jiujing23333 opened this issue 7 years ago • 2 comments

I followed the Readme and download pretrained model from this url: https://github.com/jcjohnson/pytorch-vgg, but a problem was reported because of unligned index of weight. I modified the code as follow: if pretrained: if caffe: # load the pretrained vgg16 used by the paper's author dict = torch.load(vgg16_caffe_path) dict['classifier.0.weight'] = dict['classifier.1.weight'] dict['classifier.0.bias'] = dict['classifier.1.bias'] dict['classifier.3.weight'] = dict['classifier.4.weight'] dict['classifier.3.bias'] = dict['classifier.4.bias'] del dict['classifier.1.weight'] del dict['classifier.1.bias'] del dict['classifier.4.weight'] del dict['classifier.4.bias'] vgg.load_state_dict(dict) Then it could run, but training loss didn't decrease. What's wrong with this process?

jiujing23333 avatar Jan 02 '18 11:01 jiujing23333

Sorry, I failed to copy the code clearly.

dict = torch.load(vgg16_caffe_path) dict['classifier.0.weight'] = dict['classifier.1.weight'] dict['classifier.0.bias'] = dict['classifier.1.bias'] dict['classifier.3.weight'] = dict['classifier.4.weight'] dict['classifier.3.bias'] = dict['classifier.4.bias'] del dict['classifier.1.weight'] del dict['classifier.1.bias'] del dict['classifier.4.weight'] del dict['classifier.4.bias'] vgg.load_state_dict(dict)

jiujing23333 avatar Jan 02 '18 11:01 jiujing23333

Actually, I did not use the pretrained model provided by jcjohnson. Instead, I use his code to convert the caffe vgg model. I am not sure whether it matters.

zijundeng avatar Jan 05 '18 10:01 zijundeng