updates
This commit is contained in:
parent
c49fe688b7
commit
25bc5e5392
11
train.py
11
train.py
|
@ -215,8 +215,9 @@ def train(cfg,
|
||||||
targets = targets.to(device)
|
targets = targets.to(device)
|
||||||
|
|
||||||
# Multi-Scale training
|
# Multi-Scale training
|
||||||
|
ni = (i + nb * epoch) # number integrated batches (since train start)
|
||||||
if multi_scale:
|
if multi_scale:
|
||||||
if (i + nb * epoch) / accumulate % 10 == 0: # adjust (67% - 150%) every 10 batches
|
if ni / accumulate % 10 == 0: # adjust (67% - 150%) every 10 batches
|
||||||
img_size = random.randrange(img_sz_min, img_sz_max + 1) * 32
|
img_size = random.randrange(img_sz_min, img_sz_max + 1) * 32
|
||||||
sf = img_size / max(imgs.shape[2:]) # scale factor
|
sf = img_size / max(imgs.shape[2:]) # scale factor
|
||||||
if sf != 1:
|
if sf != 1:
|
||||||
|
@ -228,12 +229,12 @@ def train(cfg,
|
||||||
plot_images(imgs=imgs, targets=targets, paths=paths, fname='train_batch%g.jpg' % i)
|
plot_images(imgs=imgs, targets=targets, paths=paths, fname='train_batch%g.jpg' % i)
|
||||||
|
|
||||||
# Hyperparameter burn-in
|
# Hyperparameter burn-in
|
||||||
# n_burnin = min(round(nb / 5 + 1), 1000) # burn-in batches
|
# n_burn = min(nb // 5 + 1, 1000) # number of burn-in batches
|
||||||
# if epoch == 0 and i <= n_burnin:
|
# if ni <= n_burn:
|
||||||
# for m in model.named_modules():
|
# for m in model.named_modules():
|
||||||
# if m[0].endswith('BatchNorm2d'):
|
# if m[0].endswith('BatchNorm2d'):
|
||||||
# m[1].momentum = 1 - i / n_burnin * 0.99 # BatchNorm2d momentum falls from 1 - 0.01
|
# m[1].momentum = 1 - i / n_burn * 0.99 # BatchNorm2d momentum falls from 1 - 0.01
|
||||||
# g = (i / n_burnin) ** 4 # gain rises from 0 - 1
|
# g = (i / n_burn) ** 4 # gain rises from 0 - 1
|
||||||
# for x in optimizer.param_groups:
|
# for x in optimizer.param_groups:
|
||||||
# x['lr'] = hyp['lr0'] * g
|
# x['lr'] = hyp['lr0'] * g
|
||||||
# x['weight_decay'] = hyp['weight_decay'] * g
|
# x['weight_decay'] = hyp['weight_decay'] * g
|
||||||
|
|
Loading…
Reference in New Issue