Closed haozhihui110 closed 4 years ago
Try to change https://github.com/yxgeee/FD-GAN/blob/master/fdgan/model.py#L54
from
state_dict = remove_module_key(torch.load(self.opt.netE_pretrain))
self.net_E.load_state_dict(state_dict)
to
state_dict = remove_module_key(torch.load(self.opt.netE_pretrain)['state_dict'])
self.net_E.load_state_dict(state_dict)
Hint: To make sure the keys in self.net_E.state_dict() and state_dict are identical.
This modification is effective, thank you for your hint and patience for the correction
Traceback (most recent call last): File "train.py", line 126, in
main()
File "train.py", line 60, in main
model = FDGANModel(opt)
File "/home/zhihui/Documents/ZHIHUI/FD-GAN/fdgan/model.py", line 28, in init
self._init_models()
File "/home/zhihui/Documents/ZHIHUI/FD-GAN/fdgan/model.py", line 55, in _init_models
self.net_E.load_state_dict(state_dict['state_dict'])
File "/home/zhihui/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 522, in load_state_dict
.format(name))
KeyError: 'unexpected key "module.base_model.base.conv1.weight" in state_dict'