Skip to content

Commit

Permalink
Fixed the problem that the training cannot be resumed when there is n…
Browse files Browse the repository at this point in the history
…o metric file in the checkpoint.
  • Loading branch information
nepeplwu committed Apr 7, 2021
1 parent b3c8158 commit 7da1230
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion paddlehub/finetune/trainer.py
Expand Up @@ -147,7 +147,11 @@ def _save_metrics(self):
pickle.dump(self.best_metrics, file)

def _load_metrics(self):
with open(os.path.join(self.checkpoint_dir, 'metrics.pkl'), 'rb') as file:
metrics_file = os.path.join(self.checkpoint_dir, 'metrics.pkl')
if not os.path.exists(metrics_file):
return

with open(metrics_file, 'rb') as file:
self.best_metrics = pickle.load(file)

def train(self,
Expand Down

0 comments on commit 7da1230

Please sign in to comment.