MCPcopy Create free account
hub / github.com/cure-lab/deep-active-learning / adjust_learning_rate

Function adjust_learning_rate

utils.py:156–177  ·  view source on GitHub ↗

Sets the learning rate to the initial LR decayed by 10 every 30 epochs

(optimizer, epoch, gammas, schedule, args)

Source from the content-addressed store, hash-verified

154
155
156def adjust_learning_rate(optimizer, epoch, gammas, schedule, args):
157 """Sets the learning rate to the initial LR decayed by 10 every 30 epochs"""
158 "Add by YU"
159 lr = args.lr
160 mu = args.momentum
161
162 if args.optimizer != "YF":
163 assert len(gammas) == len(
164 schedule), "length of gammas and schedule should be equal"
165 for (gamma, step) in zip(gammas, schedule):
166 if (epoch >= step):
167 lr = lr * gamma
168 else:
169 break
170 for param_group in optimizer.param_groups:
171 param_group['lr'] = lr
172
173 elif args.optimizer == "YF":
174 lr = optimizer._lr
175 mu = optimizer._mu
176
177 return lr, mu

Callers 9

trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90
trainMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected