MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / adjust_learning_rate

Function adjust_learning_rate

utils/tools.py:30–43  ·  view source on GitHub ↗
(optimizer, epoch, args)

Source from the content-addressed store, hash-verified

28
29
30def adjust_learning_rate(optimizer, epoch, args):
31 # lr = args.learning_rate * (0.2 ** (epoch // 2))
32 if args.lradj == 'type1':
33 lr_adjust = {epoch: args.learning_rate * (0.5 ** ((epoch - 1) // 1))}
34 elif args.lradj == 'type2':
35 lr_adjust = {
36 2: 5e-5, 4: 1e-5, 6: 5e-6, 8: 1e-6,
37 10: 5e-7, 15: 1e-7, 20: 5e-8
38 }
39 if epoch in lr_adjust.keys():
40 lr = lr_adjust[epoch]
41 for param_group in optimizer.param_groups:
42 param_group['lr'] = lr
43 print('Updating learning rate to {}'.format(lr))
44
45
46class EarlyStopping:

Callers 1

trainMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected