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:
parent
97edba0b7a
commit
7b3d9f02ec
2
train.py
2
train.py
|
@ -131,7 +131,7 @@ def train(cfg,
|
||||||
optimizer.load_state_dict(chkpt['optimizer'])
|
optimizer.load_state_dict(chkpt['optimizer'])
|
||||||
best_fitness = chkpt['best_fitness']
|
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:
|
with open('results.txt', 'w') as file:
|
||||||
file.write(chkpt['training_results']) # write results.txt
|
file.write(chkpt['training_results']) # write results.txt
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue