- referece
- 관련 paper
1. Learning rate warm up
- train 초기에 learning rate를 서서히 증가시키는 것
- warm up 사용시, 설명력이 강한 변수에 모델이 overfit하는 것을 방지할 수 있음.
2. consine annealing
2.1. cosine 함수 기본 성질
- y=a×sin(bx)+c
- 주기: 2π|b|
- 최대, 최소값: |a| + c, -|a| + c
2.2. cosine annealing
lrcurrent=lrmax2×(cos(π⋅mod(current epoch−1,[total epochs/num of cycle])[total epochs/num of cycle])+1)- num of cycle: total epochs에서 주기가 반복되는 횟수
- total epochs/num of cycle: 한 주기를 이루는 epoch 횟수
- eg. 100 / 5: 내리락 주기 5번, 주기 1번에 epoch 20회
- x에 해당하는 것은 current epoch인데, 실제로는 current epoch % (total epochs/num of cycle).
- 따라서 0 <= x < (total epochs/num of cycle)
주기: 2π/inner cosine (inner cosine = pi / (epochs per cycle))
- 결국 주기는, epochs per cycle
- eg. total epochs: 100, cycle: 5
- total epochs/num of cycle: 20(constant)
- 여기서 mod 결과값은 x / 20했을 때 나머지
- lrcurrent=lrmax2×(cosπ⋅020+1),lrmax2×(cosπ⋅120+1),lrmax2×(cosπ⋅220+1),⋯
최대, 최소: lrmax2+lrmax2=lrmax,−lrmax2+lrmax2=0
3. 예시 code
1 | from math import pi |
1 | %matplotlib inline |