Skip to content

Commit

Permalink
make parameter ignore epochs
Browse files Browse the repository at this point in the history
ignore epochs functionality add to prevent spikes at the beginning when fitness spikes and decreases after.
Discussed at ultralytics#5971
  • Loading branch information
jinmc authored Dec 14, 2021
1 parent e8ef8fb commit 19c60d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 19c60d0

Please sign in to comment.