|
|
|
|
|
|
|
|
del g0, g1, g2 |
|
|
del g0, g1, g2 |
|
|
|
|
|
|
|
|
# Scheduler |
|
|
# Scheduler |
|
|
if opt.linear_lr: |
|
|
|
|
|
lf = lambda x: (1 - x / (epochs - 1)) * (1.0 - hyp['lrf']) + hyp['lrf'] # linear |
|
|
|
|
|
else: |
|
|
|
|
|
|
|
|
if opt.cos_lr: |
|
|
lf = one_cycle(1, hyp['lrf'], epochs) # cosine 1->hyp['lrf'] |
|
|
lf = one_cycle(1, hyp['lrf'], epochs) # cosine 1->hyp['lrf'] |
|
|
|
|
|
else: |
|
|
|
|
|
lf = lambda x: (1 - x / epochs) * (1.0 - hyp['lrf']) + hyp['lrf'] # linear |
|
|
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf) # plot_lr_scheduler(optimizer, scheduler, epochs) |
|
|
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf) # plot_lr_scheduler(optimizer, scheduler, epochs) |
|
|
|
|
|
|
|
|
# EMA |
|
|
# EMA |
|
|
|
|
|
|
|
|
parser.add_argument('--name', default='exp', help='save to project/name') |
|
|
parser.add_argument('--name', default='exp', help='save to project/name') |
|
|
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') |
|
|
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') |
|
|
parser.add_argument('--quad', action='store_true', help='quad dataloader') |
|
|
parser.add_argument('--quad', action='store_true', help='quad dataloader') |
|
|
parser.add_argument('--linear-lr', action='store_true', help='linear LR') |
|
|
|
|
|
|
|
|
parser.add_argument('--cos-lr', action='store_true', help='cosine LR scheduler') |
|
|
parser.add_argument('--label-smoothing', type=float, default=0.0, help='Label smoothing epsilon') |
|
|
parser.add_argument('--label-smoothing', type=float, default=0.0, help='Label smoothing epsilon') |
|
|
parser.add_argument('--patience', type=int, default=100, help='EarlyStopping patience (epochs without improvement)') |
|
|
parser.add_argument('--patience', type=int, default=100, help='EarlyStopping patience (epochs without improvement)') |
|
|
parser.add_argument('--freeze', nargs='+', type=int, default=[0], help='Freeze layers: backbone=10, first3=0 1 2') |
|
|
parser.add_argument('--freeze', nargs='+', type=int, default=[0], help='Freeze layers: backbone=10, first3=0 1 2') |