Example #1
0
# PyTorch tutorial codes for course EL-9133 Advanced Machine Learning, NYU, Spring 2018
# Architecture/optim.py: define optimizer
# read: http://pytorch.org/docs/master/optim.html
import torch.optim as optim

from Pipeline.option import args
from Architecture.model import model

optimizer = None
if args.optimizer == 'SGD':
    optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=0.1)
elif args.optimizer == 'Adam':
    optimizer = optim.Adam(model.parameters(), lr=args.lr)
else:
    raise ValueError('Wrong name of optimizer')

print('\n---Training Details---')
print('batch size:', args.batch_size)
print('seed number', args.seed)

print('\n---Optimization Information---')
print('optimizer:', args.optimizer)
print('lr:', args.lr)
Example #2
0
import torch.optim as optim

from Pipeline.option import args
from Architecture.model import model
from Architecture.cls import CyclicLR

optimizer = None
if args.optimizer =='SGD':
    optimizer = optim.SGD(model.parameters(), lr=args.lr2min, momentum=0.5)
elif args.optimizer =='Adam':
    optimizer = optim.Adam(model.parameters(), lr=args.lr2min)
elif args.optimizer =='Adadelta':
    optimizer = optim.Adadelta(model.parameters())
else:
    raise ValueError('Wrong name of optimizer')

scheduler = CyclicLR(optimizer, base_lr = args.lr1min, max_lr = args.lr1max, step_size =args.cli1)
scheduler_sw = CyclicLR(optimizer, base_lr = args.lr2min, max_lr = args.lr2max, step_size =args.cli2)
# PyTorch tutorial codes for course EL-9133 Advanced Machine Learning, NYU, Spring 2018
# Architecture/optim.py: define optimizer
# read: http://pytorch.org/docs/master/optim.html
import torch.optim as optim

from Pipeline.option import args
from Architecture.model import model

optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=args.momentum)

print('\n---Training Details---')
print('batch size:', args.batch_size)
print('seed number', args.seed)

print('\n---Optimization Information---')
print('optimizer: SGD')
print('lr:', args.lr)
print('momentum:', args.momentum)