From 19c60d09f88a5c12a4acc0ac81da76ee94dfcc71 Mon Sep 17 00:00:00 2001 From: jinmc Date: Tue, 14 Dec 2021 16:00:51 +0900 Subject: [PATCH 1/2] make parameter ignore epochs ignore epochs functionality add to prevent spikes at the beginning when fitness spikes and decreases after. Discussed at https://github.com/ultralytics/yolov5/issues/5971 --- train.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/train.py b/train.py index 8cb68fc0748e..3e0c85907167 100644 --- a/train.py +++ b/train.py @@ -367,7 +367,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary # Update best mAP fi = fitness(np.array(results).reshape(1, -1)) # weighted combination of [P, R, mAP@.5, mAP@.5-.95] - if fi > best_fitness: + if fi > best_fitness and epoch >= opt.ignore_epochs: best_fitness = fi log_vals = list(mloss) + list(results) + lr callbacks.run('on_fit_epoch_end', log_vals, epoch, best_fitness, fi) @@ -472,6 +472,7 @@ def parse_opt(known=False): parser.add_argument('--freeze', type=int, default=0, help='Number of layers to freeze. backbone=10, all=24') parser.add_argument('--save-period', type=int, default=-1, help='Save checkpoint every x epochs (disabled if < 1)') parser.add_argument('--local_rank', type=int, default=-1, help='DDP parameter, do not modify') + parser.add_argument('--ignore-epochs', type=int, default=0, help='ignore early epochs to be counted as patience') # Weights & Biases arguments parser.add_argument('--entity', default=None, help='W&B: Entity') From 791abd19785997cc03864fa59c37bf379c802ad6 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 14 Dec 2021 11:18:04 +0100 Subject: [PATCH 2/2] Update train.py --- train.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/train.py b/train.py index 3e0c85907167..8cb68fc0748e 100644 --- a/train.py +++ b/train.py @@ -367,7 +367,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary # Update best mAP fi = fitness(np.array(results).reshape(1, -1)) # weighted combination of [P, R, mAP@.5, mAP@.5-.95] - if fi > best_fitness and epoch >= opt.ignore_epochs: + if fi > best_fitness: best_fitness = fi log_vals = list(mloss) + list(results) + lr callbacks.run('on_fit_epoch_end', log_vals, epoch, best_fitness, fi) @@ -472,7 +472,6 @@ def parse_opt(known=False): parser.add_argument('--freeze', type=int, default=0, help='Number of layers to freeze. backbone=10, all=24') parser.add_argument('--save-period', type=int, default=-1, help='Save checkpoint every x epochs (disabled if < 1)') parser.add_argument('--local_rank', type=int, default=-1, help='DDP parameter, do not modify') - parser.add_argument('--ignore-epochs', type=int, default=0, help='ignore early epochs to be counted as patience') # Weights & Biases arguments parser.add_argument('--entity', default=None, help='W&B: Entity')