Skip to content

Commit 7da1230

Browse files
committed
Fixed the problem that the training cannot be resumed when there is no metric file in the checkpoint.
1 parent b3c8158 commit 7da1230

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: paddlehub/finetune/trainer.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ def _save_metrics(self):
147147
pickle.dump(self.best_metrics, file)
148148

149149
def _load_metrics(self):
150-
with open(os.path.join(self.checkpoint_dir, 'metrics.pkl'), 'rb') as file:
150+
metrics_file = os.path.join(self.checkpoint_dir, 'metrics.pkl')
151+
if not os.path.exists(metrics_file):
152+
return
153+
154+
with open(metrics_file, 'rb') as file:
151155
self.best_metrics = pickle.load(file)
152156

153157
def train(self,

0 commit comments

Comments
 (0)