Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Apr 24, 2019
1 parent 87a450c commit 1771ffb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions train.py
Expand Up @@ -100,19 +100,23 @@ def train(
else:
cutoff = load_darknet_weights(model, weights + 'darknet53.conv.74')

# Scheduler (reduce lr at epochs 218, 245, i.e. batches 400k, 450k)
# Scheduler https://github.com/ultralytics/yolov3/issues/238
# lf = lambda x: 1 - x / epochs # linear ramp to zero
# lf = lambda x: 10 ** (-2 * x / epochs) # exp ramp to lr0 * 1e-2
lf = lambda x: 1 - 10 ** (hyp['lrf'] * (1 - x / epochs)) # inv exp ramp to lr0 * 1e-2
# lf = lambda x: 10 ** (hyp['lrf'] * x / epochs) # exp ramp to lr0 * hyp['lrf']
lf = lambda x: 1 - 10 ** (hyp['lrf'] * (1 - x / epochs)) # inv exp ramp to lr0 * hyp['lrf']
scheduler = optim.lr_scheduler.LambdaLR(optimizer, lr_lambda=lf, last_epoch=start_epoch - 1)
# scheduler = optim.lr_scheduler.MultiStepLR(optimizer,milestones=[218, 245],gamma=0.1,last_epoch=start_epoch - 1)
# scheduler = optim.lr_scheduler.MultiStepLR(optimizer, milestones=[218, 245], gamma=0.1, last_epoch=start_epoch - 1)

# Plot lr schedule
# # Plot lr schedule
# y = []
# for _ in range(epochs):
# scheduler.step()
# y.append(optimizer.param_groups[0]['lr'])
# plt.plot(y)
# plt.plot(y, label='LambdaLR')
# plt.xlabel('epoch')
# plt.xlabel('LR')
# plt.tight_layout()
# plt.savefig('LR.png', dpi=300)

# Dataset
dataset = LoadImagesAndLabels(train_path, img_size=img_size, augment=True)
Expand Down Expand Up @@ -165,8 +169,6 @@ def train(
imgs = imgs.to(device)
targets = targets.to(device)
nt = len(targets)
# if nt == 0: # if no targets continue
# continue

# Plot images with bounding boxes
if epoch == 0 and i == 0:
Expand Down

0 comments on commit 1771ffb

Please sign in to comment.