[논문리뷰] Adam: A Method For Stochastic Optimization

한상민·2023년 6월 26일

논문리뷰

목록 보기
2/2

1. Introduction

https://arxiv.org/pdf/1412.6980.pdf

Adam은 2015년 ICLR에 게제되어 현재 딥러닝 모델 loss 함수 최적화를 위해 가장 많이 사용되는 방법으로, SGD와 같이 Stochastic objective function에 대한 first-order gradient-based optimization 기법 중 하나이다.

💡 Contribution
1. 적은 양의 메모리 사용
2. Invariant to diagonal rescaling of the gradients
3. Appropriate for non-stationary objectives and problems with very noisy and/or sparse gradients

2. Main Algorithm

Alogorithm1

Error함수인 ff는 가중치 θ\theta에 대한 stochastic 함수이다. 따라서 stochastic하게 optimization을 수행하므로 우리는 f의 기대값인 E[f]\mathbb E[f]의 최소값을 찾는 문제를 해결해야 한다. ggffθ\theta에 대해 미분한 gradient 함수이다.

β1,β2\beta_1,\beta_2는 모두 [0,1)[0,1)의 범위에 속하며 g0,v0g_0, v_0의 값은 0임을 염두하고 알고리즘을 살펴보자.

먼저 Momentum의 컨셉을 담은 mm을 update하는 부분을 살펴보자. momentum mm은 결국 현재까지의 gradient들의 가중 평균이다. 이 평균값(기대값)은 매 번 바뀌며, 아래 식 처럼 평균값은 지수적으로 움직인다. ( exponentially moving averages of the gradient(mtm_t) )

mt=(1β1)(β1tigi)mtm_t=\left(1-\beta _1\right)\sum \left(\beta _1^{t-i}\cdot g_i\right)m_t

또한 vv는 아래 식처럼 지수적으로 움직이는 기울기의 제곱값의 가중 평균이다. ( exponentially moving averages of the squared gradient(vtv_t) )

vt=(1β2)Σ(β2tigi2)v_t=\left(1-\beta _2\right)\Sigma \left(\beta _2^{t-i}\cdot g_i^2\right)

하지만 이 moving averages들, mmvv는 초기에 0으로 설정되어 있기 때문에, moment를 0에 치우치게 추정하려는 경향이 생긴다. 특히 초기 timestep 동안과 beta가 1에 가깝게 설정되어 있는 경우에 말이다. 하지만 다행히 이 initialization bias 문제는 그림 1 while문 내의 m^\hat{m}v^\hat{v}에 해당하는 bias-corrected 방법(section 3)으로 쉽게 해결할 수 있다.

3. Initialization bias correction

논문의 Section 3에는 initialization bias correction에 관한 설명이 나온다. 앞서 말했듯이 first-order gradient, mm과 second-order gradient, vv가 0에 치우치게 추정하는 문제를 해결하기 위한 방법이다. Second-order인 vv에 대해 먼저 알아보자.

우리는 궁극적으로 vv의 기대값이 g2g^2의 기대값과 같길 바란다. 즉, vv가 squred gradient를 잘 추정하길 바란다.
그림1
Section 2의 vtv_t에 대한 식을 (2)에 그대로 적용했다.

E[vt]=E[(1β2)(β2tigi2)]=(1β2)E[(β2tigi2)]=(1β2)(E[(β2tigi2)])=(1β2)(β2tiE[gi2])  since β is constant=E[gt2](1β2)(β2ti)+ζ  since E[gi2] is same for all i=1:t\begin{aligned} \mathbb E[v_t]&=\mathbb E[(1−\beta_2)\sum(\beta ^{t−i}_2*g^2_i)]\\ &=(1−\beta_2)\mathbb E[\sum(\beta ^{t−i}_2*g^2_i)]\\ &=(1−β_2)\sum(\mathbb E[(\beta^{t−i}_2*g^2_i)])\\ &=(1-\beta_2)\sum(\beta_2^{t-i}\mathbb E[g_i^2])\ \text{ since}\ \beta\ \text{is constant}\\ &=\mathbb E[g_t^2]*(1-\beta_2)\sum(\beta_2^{t-i})+\zeta\ \text{ since}\ \mathbb E[g_i^2]\ \text{is same for all i=1:t} \end{aligned}

그림 2에 위 수식을 덧붙여 이해해나가면 결국, E[v]\mathbb{E}[v]1/(1βt)1/(1-\beta^t)를 곱하면 E[g2]\mathbb{E}[g^2]와 유사하게 되므로, 1(1βt)\frac{1}{(1-\beta^t)}를 곱해주어 bias 문제를 해결한다.

mm에 대해서도 같은 방법으로 접근하면 된다.

4개의 댓글

comment-user-thumbnail
2023년 6월 26일

정리가 너무 깔끔해요!👍

1개의 답글
comment-user-thumbnail
2023년 7월 2일

https://melonplaymods.com/2023/06/11/vintage-black-car-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/special-forcesnpc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/prehistoric-nature-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/seek-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/fighter-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/gangster-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/ww1-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/percys-predicament-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/crash-test-truck-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/seeks-hallway-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/tank-maus-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/scp-goi-chaos-insurgency-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/thomas-the-tank-engin-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/brawl-stars-pack-characters-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/naruto-mod-for-melon-playground-2/
https://melonplaymods.com/2023/06/11/skeletykvanpc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/stinger-flynn-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/tank-mod-for-melon-playground-3/
https://melonplaymods.com/2023/06/11/light-weapons-from-star-wars-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/pack-of-school-items-mod-for-melon-playground/

답글 달기
comment-user-thumbnail
2023년 7월 2일

https://melonplaymods.com/2023/06/10/reebro-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/octopus-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/fishing-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/bathroom-items-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/mutants-from-stalkernpc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/the-dollnpc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/low-fire-guns-and-shells-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/cartoon-cat-mod-for-melon-playground-3/
https://melonplaymods.com/2023/06/11/biodroid-biorobots-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/funky-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/s-t-a-l-k-e-r-npc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/bone-wubbox-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/deadpool-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/building-and-map-city-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/tang-three-character-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/lone-operative-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/devil-fruit-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/character-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/cake-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/bendy-ax-bendys-ax-mod-for-melon-playground/

답글 달기