ShiceLiu / SATNet

See and Think: Disentangling Semantic Scene Completion
49 stars 10 forks source link

KeyError: 'unexpected key "seg2d.ASPPout.weight" in state_dict' #5

Open LongruiDong opened 5 years ago

LongruiDong commented 5 years ago

Hi, me again 23333... When I evaluate Semantic scene completion on NYU data by running

~/SATNet/Semantic_Scene_Completion/NYU/SATNet_RGB.py --resume ~/SATNet/Semantic_Scene_Completion/NYU/pretrained_models/RGB_use.pth.tar --evaluate 2>&1 | tee logs/SATNet_RGB.log

an Error appears

Traceback (most recent call last):
  File "SATNet_RGB.py", line 393, in <module>
    main()
  File "SATNet_RGB.py", line 368, in main
    model.load_state_dict(chpo['state_dict'])
  File "/home/dlr/anaconda3/envs/py27/lib/python2.7/site-packages/torch/nn/modules/module.py", line 522, in load_state_dict
    .format(name))
KeyError: 'unexpected key "seg2d.ASPPout.weight" in state_dict'

do u know what is the problem?

ShiceLiu commented 5 years ago

@LongruiDong
Sorry for that we are not supposed to use '--evaluate', because some code may be wrong. And if you really want to use it, you should modify some small mistakes. Here, the error 'unexpected key "seg2d.ASPPout.weight" in state_dict' means the weight 'seg2d.ASPPout.weight' in the checkpoint has no corresponding layers in the network. This is ok, for this weight is useless in the completion network. Thus, you can find the code 'model.load_state_dict(chpo['state_dict'])' and modify it as 'model.load_state_dict(chpo['state_dict'], strict = False)'. I think it will work though I don't have a try(Sorry(ૢ˃ꌂ˂ૢ)), because this is a common error. Thanks and welcome questions!