Unverified 提交 752d97df authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Add `on_fit_epoch_end` callback (#5232)

* Add `on_fit_epoch_end` callback * Add results to train * Update __init__.py
上级 13f72755
...@@ -423,8 +423,10 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary ...@@ -423,8 +423,10 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
plots=True, plots=True,
callbacks=callbacks, callbacks=callbacks,
compute_loss=compute_loss) # val best model with plots compute_loss=compute_loss) # val best model with plots
if is_coco:
callbacks.run('on_fit_epoch_end', list(mloss) + list(results) + lr, epoch, best_fitness, fi)
callbacks.run('on_train_end', last, best, plots, epoch) callbacks.run('on_train_end', last, best, plots, epoch, results)
LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}") LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}")
torch.cuda.empty_cache() torch.cuda.empty_cache()
......
...@@ -131,7 +131,7 @@ class Loggers(): ...@@ -131,7 +131,7 @@ class Loggers():
if ((epoch + 1) % self.opt.save_period == 0 and not final_epoch) and self.opt.save_period != -1: if ((epoch + 1) % self.opt.save_period == 0 and not final_epoch) and self.opt.save_period != -1:
self.wandb.log_model(last.parent, self.opt, epoch, fi, best_model=best_fitness == fi) self.wandb.log_model(last.parent, self.opt, epoch, fi, best_model=best_fitness == fi)
def on_train_end(self, last, best, plots, epoch): def on_train_end(self, last, best, plots, epoch, results):
# Callback runs on training end # Callback runs on training end
if plots: if plots:
plot_results(file=self.save_dir / 'results.csv') # save results.png plot_results(file=self.save_dir / 'results.csv') # save results.png
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论