prevent failure when no training_results available (#409)

Use `chkpt.get('training_results')` instead of `chkpt.get('training_results')` so if the dict doesn't contain this key it won't throw a `KeyError
This commit is contained in:
idow09 2019-07-31 15:12:27 +03:00 committed by Glenn Jocher
parent 97edba0b7a
commit 7b3d9f02ec
1 changed files with 1 additions and 1 deletions

View File

@ -131,7 +131,7 @@ def train(cfg,
optimizer.load_state_dict(chkpt['optimizer'])
best_fitness = chkpt['best_fitness']
if chkpt['training_results'] is not None:
if chkpt.get('training_results') is not None:
with open('results.txt', 'w') as file:
file.write(chkpt['training_results']) # write results.txt