MCPcopy Create free account
hub / github.com/DIVE128/DMVSNet / get_schedular

Function get_schedular

tools.py:242–257  ·  view source on GitHub ↗
(optimizer, args)

Source from the content-addressed store, hash-verified

240
241
242def get_schedular(optimizer, args):
243 warmup = args.warmup
244 milestones = np.array(args.milestones)
245 decay = args.lr_decay
246 if args.scheduler == "steplr":
247 lambda_func = lambda step: 1 / 3 * (1 - step / warmup) + step / warmup if step < warmup \
248 else (decay ** (milestones <= step).sum())
249 elif args.scheduler == "cosinelr":
250 max_lr = args.lr
251 min_lr = max_lr * (args.lr_decay ** 3)
252 T_max = args.epochs
253 lambda_func = lambda step: 1 / 3 * (1 - step / warmup) + step / warmup if step < warmup else \
254 (min_lr + 0.5 * (max_lr - min_lr) * (1.0 + math.cos((step - warmup) / (T_max - warmup) * math.pi))) / max_lr
255
256 scheduler = LambdaLR(optimizer, lambda_func)
257 return scheduler
258
259
260def is_dist_avail_and_initialized():

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected