speedinghzl / Pytorch-Deeplab

DeepLab-ResNet rebuilt in Pytorch
MIT License
263 stars 62 forks source link

*** KeyError: 'unexpected key "weight" in state_dict' #8

Closed IssamLaradji closed 6 years ago

IssamLaradji commented 6 years ago

I am trying to load VOC12_scenes_20000.pth onto Res_Deeplab Running this,

    saved_state_dict = torch.load(args.restore_from)
    new_params = model.state_dict().copy()
    for i in saved_state_dict:
        #Scale.layer5.conv2d_list.3.weight
        i_parts = i.split('.')
        # print i_parts
        if not args.num_classes == 21 or not i_parts[1]=='layer5':
            print(i)
            new_params['.'.join(i_parts[1:])] = saved_state_dict[i]
    model.load_state_dict(new_params)

gives me *** KeyError: 'unexpected key "weight" in state_dict'

speedinghzl commented 6 years ago

@IssamLaradji If you want to train Deeplab, you should load the coco pre-trained init model rather than VOC12_scenes_20000.pth.

ghost commented 6 years ago

Does this mean we can't pick up training from where we left off?