Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1df494e5fe
12
train.py
12
train.py
|
|
@ -114,6 +114,12 @@ def train(hyp, tb_writer, opt, device):
|
||||||
print('Optimizer groups: %g .bias, %g conv.weight, %g other' % (len(pg2), len(pg1), len(pg0)))
|
print('Optimizer groups: %g .bias, %g conv.weight, %g other' % (len(pg2), len(pg1), len(pg0)))
|
||||||
del pg0, pg1, pg2
|
del pg0, pg1, pg2
|
||||||
|
|
||||||
|
# Scheduler https://arxiv.org/pdf/1812.01187.pdf
|
||||||
|
lf = lambda x: (((1 + math.cos(x * math.pi / epochs)) / 2) ** 1.0) * 0.8 + 0.2 # cosine
|
||||||
|
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf)
|
||||||
|
# https://discuss.pytorch.org/t/a-problem-occured-when-resuming-an-optimizer/28822
|
||||||
|
# plot_lr_scheduler(optimizer, scheduler, epochs)
|
||||||
|
|
||||||
# Load Model
|
# Load Model
|
||||||
with torch_distributed_zero_first(rank):
|
with torch_distributed_zero_first(rank):
|
||||||
google_utils.attempt_download(weights)
|
google_utils.attempt_download(weights)
|
||||||
|
|
@ -158,12 +164,6 @@ def train(hyp, tb_writer, opt, device):
|
||||||
if mixed_precision:
|
if mixed_precision:
|
||||||
model, optimizer = amp.initialize(model, optimizer, opt_level='O1', verbosity=0)
|
model, optimizer = amp.initialize(model, optimizer, opt_level='O1', verbosity=0)
|
||||||
|
|
||||||
# Scheduler https://arxiv.org/pdf/1812.01187.pdf
|
|
||||||
lf = lambda x: (((1 + math.cos(x * math.pi / epochs)) / 2) ** 1.0) * 0.8 + 0.2 # cosine
|
|
||||||
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf)
|
|
||||||
# https://discuss.pytorch.org/t/a-problem-occured-when-resuming-an-optimizer/28822
|
|
||||||
# plot_lr_scheduler(optimizer, scheduler, epochs)
|
|
||||||
|
|
||||||
# DP mode
|
# DP mode
|
||||||
if device.type != 'cpu' and rank == -1 and torch.cuda.device_count() > 1:
|
if device.type != 'cpu' and rank == -1 and torch.cuda.device_count() > 1:
|
||||||
model = torch.nn.DataParallel(model)
|
model = torch.nn.DataParallel(model)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue