상수 lr 은 거의 optimal 아님
Learning rate decay — 높게 시작, 낮게 끝 — 가 deep learning 의 가장 단순한 무료 win 중 하나. PyTorch 에 여러 scheduler; 셋을 정기 사용:
StepLR— 매step_sizeepoch 마다 LR × gamma. 간단, 예측 가능, 역사적 default.CosineAnnealingLR— initial LR 에서eta_min까지 부드러운 cosine curve,T_maxstep 위. modern Transformer / vision favorite.OneCycleLR— 한 cycle 안 warmup-then-cooldown. fast training (Leslie Smith 의 1cycle policy) 에 우수.
Warmup — 왜와 어떻게
modern Transformer training 이 거의 항상 몇백 step 의 warmup 으로 시작: 0 에서 target LR 로 선형 증가, 그 다음 decay. 없으면 초기 gradient 가 huge (parameter random, loss 높음, derivative 거침) 하고 optimizer 가 catastrophic step. 있으면 loss landscape 가 well-behaved 인 regime 으로 부드럽게 진입.
warmup + cosine 위해 두 scheduler 합치기 (SequentialLR) 또는 custom LambdaLR. HuggingFace 의 get_cosine_schedule_with_warmup 이 직접 쓰기 skip 하고 싶을 때 canonical 구현.
적절한 granularity 로 step
- Per-epoch scheduler (StepLR, epoch 단위 CosineAnnealingLR) — epoch 당 한 번
scheduler.step(). - Per-step scheduler (OneCycleLR, step 단위 LambdaLR) — batch 당 한 번
scheduler.step().