def load_param(self, trained_path):
param_dict = torch.load(trained_path)
for i in param_dict:
if 'classifier' in i:
continue
self.state_dict()[i].copy_(param_dict[i])
run test.py get " Keyerror 'a' "
Change to this:
def load_param(self, trained_path):
param_dict = torch.load(trained_path)
for k, v in param_dict.state_dict().items():
if 'classifier' in k:
continue
self.statedict()[k].copy(param_dict.state_dict()[k])
run test.py get " AttributeError: 'dict' object has no attribute 'state_dic' "
run test.py get " Keyerror 'a' "
Change to this: def load_param(self, trained_path): param_dict = torch.load(trained_path) for k, v in param_dict.state_dict().items(): if 'classifier' in k: continue self.statedict()[k].copy(param_dict.state_dict()[k]) run test.py get " AttributeError: 'dict' object has no attribute 'state_dic' "