From 70022d674500f187838875b638ed970c5ed87417 Mon Sep 17 00:00:00 2001 From: ayush chaurasia Date: Mon, 20 Dec 2021 01:16:20 -0800 Subject: [PATCH 1/4] track batch size after autobatch --- train.py | 1 + utils/callbacks.py | 2 +- utils/loggers/__init__.py | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/train.py b/train.py index 17e816c06ede..e2cd5ec85c09 100644 --- a/train.py +++ b/train.py @@ -138,6 +138,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary # Batch size if RANK == -1 and batch_size == -1: # single-GPU only, estimate best batch size batch_size = check_train_batch_size(model, imgsz) + loggers.on_params_update({"batch_size": batch_size}) # Optimizer nbs = 64 # nominal batch size diff --git a/utils/callbacks.py b/utils/callbacks.py index c9d936ef082d..13d82ebc2e41 100644 --- a/utils/callbacks.py +++ b/utils/callbacks.py @@ -32,7 +32,7 @@ def __init__(self): 'on_fit_epoch_end': [], # fit = train + val 'on_model_save': [], 'on_train_end': [], - + 'on_params_update': [], 'teardown': [], } diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 2a68d9785071..c46ceff02ce8 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -4,6 +4,7 @@ """ import os +from typing import Dict import warnings from threading import Thread @@ -157,3 +158,9 @@ def on_train_end(self, last, best, plots, epoch, results): else: self.wandb.finish_run() self.wandb = WandbLogger(self.opt) + + def on_params_update(self, params): + # update hyperparams or configs of the experiment + # params: A dict containing param: value pairs + if self.wandb: + self.wandb.wandb_run.config.update(params, allow_val_change = True) From 012b30e7c01050625a92491f4656e51a7c10d792 Mon Sep 17 00:00:00 2001 From: ayush chaurasia Date: Mon, 20 Dec 2021 01:17:12 -0800 Subject: [PATCH 2/4] remove redundant import --- utils/loggers/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index c46ceff02ce8..3ff8c4086646 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -4,7 +4,6 @@ """ import os -from typing import Dict import warnings from threading import Thread From 312127ff055917f79a5b8451dbd6f0e37df39399 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Mon, 20 Dec 2021 15:39:24 +0530 Subject: [PATCH 3/4] Update __init__.py --- utils/loggers/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 3ff8c4086646..d44de458928d 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -162,4 +162,4 @@ def on_params_update(self, params): # update hyperparams or configs of the experiment # params: A dict containing param: value pairs if self.wandb: - self.wandb.wandb_run.config.update(params, allow_val_change = True) + self.wandb.wandb_run.config.update(params, allow_val_change=True) From c6488bc665ffde232339a714180b47d65117b574 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 23 Dec 2021 14:23:32 +0100 Subject: [PATCH 4/4] Update __init__.py --- utils/loggers/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index d44de458928d..7a1df2a45ea7 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -159,7 +159,7 @@ def on_train_end(self, last, best, plots, epoch, results): self.wandb = WandbLogger(self.opt) def on_params_update(self, params): - # update hyperparams or configs of the experiment - # params: A dict containing param: value pairs + # Update hyperparams or configs of the experiment + # params: A dict containing {param: value} pairs if self.wandb: self.wandb.wandb_run.config.update(params, allow_val_change=True)