MCPcopy
hub / github.com/HobbitLong/SupContrast / adjust_learning_rate

Function adjust_learning_rate

util.py:53–65  ·  view source on GitHub ↗
(args, optimizer, epoch)

Source from the content-addressed store, hash-verified

51
52
53def adjust_learning_rate(args, optimizer, epoch):
54 lr = args.learning_rate
55 if args.cosine:
56 eta_min = lr * (args.lr_decay_rate ** 3)
57 lr = eta_min + (lr - eta_min) * (
58 1 + math.cos(math.pi * epoch / args.epochs)) / 2
59 else:
60 steps = np.sum(epoch > np.asarray(args.lr_decay_epochs))
61 if steps > 0:
62 lr = lr * (args.lr_decay_rate ** steps)
63
64 for param_group in optimizer.param_groups:
65 param_group['lr'] = lr
66
67
68def warmup_learning_rate(args, epoch, batch_id, total_batches, optimizer):

Callers 3

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected