create step lr schedule

This commit is contained in:
Glenn Jocher 2018-09-25 01:29:35 +02:00
parent 6528238953
commit 208fd77fe4
1 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,7 @@ from utils.datasets import *
from utils.utils import *
parser = argparse.ArgumentParser()
parser.add_argument('-epochs', type=int, default=160, help='number of epochs')
parser.add_argument('-epochs', type=int, default=68, help='number of epochs')
parser.add_argument('-batch_size', type=int, default=12, help='size of each image batch')
parser.add_argument('-data_config_path', type=str, default='cfg/coco.data', help='data config file path')
parser.add_argument('-cfg', type=str, default='cfg/yolov3.cfg', help='cfg file path')
@ -86,7 +86,7 @@ def main(opt):
optimizer = torch.optim.SGD(model.parameters(), lr=1e-3, momentum=.9, weight_decay=5e-4, nesterov=True)
# Set scheduler
# scheduler = torch.optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.99082, last_epoch=start_epoch - 1)
# scheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer, milestones=[54, 61], gamma=0.1)
modelinfo(model)
t0, t1 = time.time(), time.time()
@ -104,8 +104,14 @@ def main(opt):
# scheduler.step()
# Update scheduler (manual)
# for g in optimizer.param_groups:
# g['lr'] = 1e-3 * (g ** epoch) # 1/10th every [30, 50, 100, 250] epochs using g = [.926, .955, .977, .992]
if epoch < 54:
lr = 1e-3
elif epoch < 61:
lr = 1e-4
else:
lr = 1e-5
for g in optimizer.param_groups:
g['lr'] = lr
ui = -1
rloss = defaultdict(float) # running loss