Merged PR 1082: Save the best model

This commit is contained in:
Mirian Hipolito Garcia 2022-03-25 15:54:09 -06:00 коммит произвёл Andre Manoel
Родитель cfd9f57049
Коммит f582e43893
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -49,6 +49,7 @@ class Evaluation():
'''
self.worker_trainer = req['worker_trainer']
save_model = False
if metric_logger is None:
metric_logger = run.log
@ -72,16 +73,19 @@ class Evaluation():
if value['higher_is_better']:
if self.metrics[key]['value'] > req[attr]:
req[attr] = self.metrics[key]['value']
save_model = True
else:
if self.metrics[key]['value'] < req[attr]:
req[attr] = self.metrics[key]['value']
if mode == 'val':
save_model = True
if save_model and mode == 'val':
self.worker_trainer.save(
model_path=self.model_path,
token=str('best_'+ mode +'_'+key),
config=self.config['server_config']
)
save_model = False
return req