-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler_factory.py
59 lines (51 loc) · 1.58 KB
/
scheduler_factory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
""" Scheduler Factory
Hacked together by / Copyright 2020 Ross Wightman
"""
from .cosine_lr import CosineLRScheduler
def create_scheduler(cfg, optimizer):
num_epochs = cfg.SOLVER.MAX_EPOCHS
# num_epochs = 120
# type 1
# lr_min = 0.01 * cfg.SOLVER.BASE_LR
# warmup_lr_init = 0.001 * cfg.SOLVER.BASE_LR
# type 2
lr_min = 0.002 * cfg.SOLVER.BASE_LR
warmup_lr_init = 0.01 * cfg.SOLVER.BASE_LR
# type 3
# lr_min = 0.001 * cfg.SOLVER.BASE_LR
# warmup_lr_init = 0.01 * cfg.SOLVER.BASE_LR
warmup_t = cfg.SOLVER.WARMUP_EPOCHS
noise_range = None
lr_scheduler = CosineLRScheduler(
optimizer,
t_initial=num_epochs,
lr_min=lr_min,
t_mul= 1.,
decay_rate=0.1,
warmup_lr_init=warmup_lr_init,
warmup_t=warmup_t,
cycle_limit=1,
t_in_epochs=True,
noise_range_t=noise_range,
noise_pct= 0.67,
noise_std= 1.,
noise_seed=42,
)
return lr_scheduler
def create_scheduler_clipreid(optimizer, num_epochs, lr_min, warmup_lr_init, warmup_t, noise_range = None):
lr_scheduler = CosineLRScheduler(
optimizer,
t_initial=num_epochs,
lr_min=lr_min,
t_mul= 1.,
decay_rate=0.1,
warmup_lr_init=warmup_lr_init,
warmup_t=warmup_t,
cycle_limit=1,
t_in_epochs=True,
noise_range_t=noise_range,
noise_pct= 0.67,
noise_std= 1.,
noise_seed=42,
)
return lr_scheduler