From e5589632446526f1db934991fcab71c2eb42464d Mon Sep 17 00:00:00 2001 From: Janko Ondras Date: Mon, 13 Jul 2020 12:55:43 +0200 Subject: [PATCH 1/3] Log hyperparameters in tensorboard Log both hyperparameters and command line options in tensorboard. --- train.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/train.py b/train.py index 1fca64c53b2a..7b3494a19cec 100644 --- a/train.py +++ b/train.py @@ -58,6 +58,14 @@ def train(hyp): with open(Path(log_dir) / 'opt.yaml', 'w') as f: yaml.dump(vars(opt), f, sort_keys=False) + # Log hyperparameters in tensorboard + if tb_writer: + tb_hparams_dict = hyp + tb_hparams_dict.update(vars(opt)) + tb_hparams_dict['img_size_w'], tb_hparams_dict['img_size_h'] = tb_hparams_dict['img_size'] + del tb_hparams_dict['img_size'] + tb_writer.add_hparams(tb_hparams_dict, {}) + epochs = opt.epochs # 300 batch_size = opt.batch_size # 64 weights = opt.weights # initial training weights From 38acc5f3c5ad6aa9960896caeb92fd54196b91a0 Mon Sep 17 00:00:00 2001 From: Janko Ondras Date: Tue, 14 Jul 2020 08:48:46 +0200 Subject: [PATCH 2/3] Fix img_size naming in hyperparameters logging --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index 7b3494a19cec..7669219eb7f1 100644 --- a/train.py +++ b/train.py @@ -62,7 +62,7 @@ def train(hyp): if tb_writer: tb_hparams_dict = hyp tb_hparams_dict.update(vars(opt)) - tb_hparams_dict['img_size_w'], tb_hparams_dict['img_size_h'] = tb_hparams_dict['img_size'] + tb_hparams_dict['img_size_train'], tb_hparams_dict['img_size_test'] = tb_hparams_dict['img_size'] del tb_hparams_dict['img_size'] tb_writer.add_hparams(tb_hparams_dict, {}) From 120d40c06aab8dea1e80f5c581c98d9511f491ed Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 14 Jul 2020 12:32:08 -0700 Subject: [PATCH 3/3] Update train.py This updates the PR to a one-liner to minimize additions. Perhaps we can include opt in the future but let's start with this for now. --- train.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/train.py b/train.py index 7669219eb7f1..2beeb2f05ece 100644 --- a/train.py +++ b/train.py @@ -58,14 +58,6 @@ def train(hyp): with open(Path(log_dir) / 'opt.yaml', 'w') as f: yaml.dump(vars(opt), f, sort_keys=False) - # Log hyperparameters in tensorboard - if tb_writer: - tb_hparams_dict = hyp - tb_hparams_dict.update(vars(opt)) - tb_hparams_dict['img_size_train'], tb_hparams_dict['img_size_test'] = tb_hparams_dict['img_size'] - del tb_hparams_dict['img_size'] - tb_writer.add_hparams(tb_hparams_dict, {}) - epochs = opt.epochs # 300 batch_size = opt.batch_size # 64 weights = opt.weights # initial training weights @@ -194,6 +186,7 @@ def train(hyp): # model._initialize_biases(cf.to(device)) plot_labels(labels, save_dir=log_dir) if tb_writer: + tb_writer.add_hparams(hyp, {}) tb_writer.add_histogram('classes', c, 0) # Check anchors