Merge pull request #92 from yweweler/yweweler-fix-model-dict-restore

Fix NameError: name 'model_dict' is not defined
This commit is contained in:
Eren Golge 2018-12-31 15:43:29 +01:00 committed by GitHub
commit 2634abbbd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 13 deletions

View File

@ -400,7 +400,10 @@ def main(args):
if args.restore_path:
checkpoint = torch.load(args.restore_path)
try:
model.load_state_dict(checkpoint['model'])
except:
model_dict = model.state_dict()
# Partial initialization: if there is a mismatch with new and old layer, it is skipped.
# 1. filter out unnecessary keys
pretrained_dict = {