schedulers
¶
Classes:
-
CosineAnnealingScheduler–Cosine annealing learning rate scheduler.
-
CosineAnnealingWithRestartsScheduler–Cosine annealing with restarts learning rate scheduler.
CosineAnnealingScheduler
¶
CosineAnnealingScheduler(max_T: int, min_lr: float, epoch_offset: Optional[int] = 0)
Cosine annealing learning rate scheduler.
This scheduler updates the learning rate using a cosine annealing schedule between the current learning rate and a minimum learning rate over a specified number of epochs.
The schedule is applied after an optional epoch offset, during which the learning rate is left unchanged.
Parameters:
-
(max_T¶int) –Number of epochs over which to apply cosine annealing after
epoch_offset. Afterepoch_offset + max_T, the learning rate is fixed tomin_lr. -
(min_lr¶float) –Minimum learning rate reached at the end of the annealing period.
-
(epoch_offset¶int, default:0) –Number of initial epochs during which the scheduler does not modify the learning rate. Defaults to 0.
Source code in src/fpga_profile_reco/utils/schedulers.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
CosineAnnealingWithRestartsScheduler
¶
CosineAnnealingWithRestartsScheduler(restart_lrs: Sequence[float], min_lrs: Sequence[float], Ts: Sequence[int])
Cosine annealing with restarts learning rate scheduler.
This scheduler applies cosine annealing over multiple intervals (restarts). For each interval, a cosine schedule is used between a restart learning rate and a minimum learning rate with its own duration.
The intervals are defined by Ts, and each interval may have its own
minimum learning rate. Optionally, each interval can also have its own
restart learning rate.
Parameters:
-
(restart_lrs¶Sequence[float]) –Learning rates used at the beginning of each restart interval. If
len(restart_lrs) == len(Ts) == len(min_lrs), the first value overrides the optimizer's initial learning rate as well. Otherwise,len(restart_lrs) + 1 == len(Ts) == len(min_lrs)and the optimizer's initial learning rate is used for the first interval while the elements ofrestart_lrsare used for the subsequent intervals. -
(min_lrs¶Sequence[float]) –Minimum learning rate reached at the end of each interval. Must be the same length as
Ts. -
(Ts¶Sequence[int]) –Number of epochs for each cosine annealing interval (cycle). The sum of all
Tsdefines the total scheduled duration.
Source code in src/fpga_profile_reco/utils/schedulers.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |