scheduler
learning.scheduler
torch learning rate schdulers and Few custom schedulers
optimizer
module-attribute
optimizer = build_optimizer(parameters(), **{'_target_': 'SGD', 'lr': 0.0, 'momentum': 0.9, 'weight_decay': 0.0001})
scheduler
module-attribute
scheduler = build_scheduler(optimizer, **{'_target_': 'CosineAnnealingWarmUpRestarts', 'T_0': 50000, 'T_mult': 1, 'eta_max': 0.005, 'T_up': 500, 'gamma': 0.5})
FixedLR
Bases: _LRScheduler
constant learning rate
initializing FixedLR
Parameters:
-
optimizer(Optimizer) –optimizer
-
last_epoch(int, default:-1) –index of last epoch. Defaults to -1.
Source code in SaigeToolkit/learning/scheduler.py
PolynomialLR
PolynomialLR(optimizer: Optimizer, max_iter: int, decay_iter: int = 1, gamma: float = 0.9, last_epoch: int = -1)
Bases: _LRScheduler
polynomial learning rate scheduler
Attributes:
-
decay_iter(int) –decaying iteration number
-
max_iter(int) –max iteration number for decaying
-
gamma(float) –learning rate decay rate (exponents)
initializing PolynomialLR
Parameters:
-
optimizer(Optimizer) –optimizer
-
max_iter(int) –max iteration number for decaying
-
decay_iter(int, default:1) –decaying iteration number. Defaults to 1.
-
gamma(float, default:0.9) –learning rate decay rate (exponents). Defaults to 0.9.
-
last_epoch(int, default:-1) –index of last epoch. Defaults to -1.
Source code in SaigeToolkit/learning/scheduler.py
WarmUpLR
WarmUpLR(optimizer: Optimizer, scheduler: dict, mode: str = 'linear', warmup_iters: int = 100, gamma: float = 0.2)
Bases: _LRScheduler
Wrapper for learning rate scheduler with warm-up stage
Attributes:
-
mode(str) –base schduler mode after warm-up stage
-
scheduler(_LRScheduler) –schduler for cold_lrs (warm-up stage)
-
warmup_iters(int) –number of iterations for warm-up stage
-
gamma(float) –learning rate decay rate
Parameters:
-
scheduler(dict) –schduler dict for cold_lrs (warm-up stage)
-
mode(str, default:'linear') –base schduler mode after warm-up stage. Defaults to "linear".
-
warmup_iters(int, default:100) –number of iterations for warm-up stage. Defaults to 100.
-
gamma(float, default:0.2) –learning rate decay ratev. Defaults to 0.2.
Source code in SaigeToolkit/learning/scheduler.py
state_dict
Returns the state of the scheduler as a :class:dict.
It contains an entry for every variable in self.dict which
is not the optimizer.
Source code in SaigeToolkit/learning/scheduler.py
load_state_dict
Loads the schedulers state.
Parameters:
-
state_dict(dict) –scheduler state. Should be an object returned from a call to :meth:
state_dict.
Source code in SaigeToolkit/learning/scheduler.py
CosineAnnealingWarmUpRestarts
CosineAnnealingWarmUpRestarts(optimizer: Optimizer, T_0: int, T_mult: int = 1, eta_max: float = 0.1, T_up: int = 0, gamma: float = 1.0, last_epoch: int = -1)
Bases: _LRScheduler
Cosine Anneeling scheduler with Warmup restarts (SGDR).
Modified from https://github.com/pytorch/pytorch/blob/v1.1.0/torch/optim/lr_scheduler.py#L655, implementing initial warmup stage.
Usage:
optimizer: ... target: sgd ... lr: 0.0 # optimizer lr should be zero or very small value!!! ... momentum: 0.9 ... weight_decay: 0.0001 ... scheduler: ... target: CosineAnnealingWarmUpRestarts ... T_0: 50000 ... T_mult: 1 ... eta_max: 0.005 ... T_up: 500 ... gamma: 0.5
Parameters:
-
optimizer(Optimizer) –Pytorch optimizer instance.
-
T_0(int) –Initial annealing cycle length.
-
T_mult(int, default:1) –Cycle multiplication scale after the first cycle. Defaults to 1.
-
eta_max(float, default:0.1) –Max learning rate. Defaults to 0.1.
-
T_up(int, default:0) –Warmup step size. Defaults to 0.
-
gamma(float, default:1.0) –eta_max multiplication scale after the first cycle. Defaults to 1..
-
last_epoch(int, default:-1) –Last epoch of the scheduler. Defaults to -1.
Raises:
-
ValueError–Expected positive integer T_0
-
ValueError–Expected integer T_mult >= 1
-
ValueError–Expected positive integer T_up
Source code in SaigeToolkit/learning/scheduler.py
ProportionalMultiStepLR
Bases: MultiStepLR
전체 iteration에 대한 비율로 milestone을 설정하는 MultiStepLR 스케줄러
Source code in SaigeToolkit/learning/scheduler.py
SaigeVision1_5080_LR
Bases: ProportionalMultiStepLR
SaigeVision1 제품에 적용된 스케줄러. 전체 iteration의 50%, 80% 지점에서 learning rate을 0.5배씩 줄입니다.
Source code in SaigeToolkit/learning/scheduler.py
FooModule
build_scheduler
builds leraning rate scheduler
Parameters:
-
optimizer(Optimizer) –optimizer object
-
_target_(str, default:'FixedLR') –learning rate scheduler configuration dict. Defaults to "FixedLR".
Raises:
-
NotImplementedError–description
Returns:
-
_LRScheduler(_LRScheduler) –learning rate scheduler object