← Playground← 놀이터

PRISM · Machine Learning PlaygroundPRISM · 머신러닝 놀이터

Gradient Descent & Optimizers경사 하강법과 최적화기
Roll down a loss landscape with SGD, Momentum, RMSProp, and Adam — feel how learning rate and curvature shape the pathSGD, 모멘텀, RMSProp, Adam으로 손실 지형을 굴러 내려가며 — 학습률과 곡률이 경로를 어떻게 결정하는지 느껴보기

SGD Momentum모멘텀 RMSProp Adam Optimum θ*최적점 θ*

Loss vs iteration — log scale where the loss stays positive, so convergence speeds are directly comparable.반복에 따른 손실 — 손실이 양수인 지형에서는 로그 스케일이라 수렴 속도를 직접 비교할 수 있습니다.

SGD
Current loss현재 손실

Plain step along the gradient.경사를 그대로 따라가는 기본 스텝.

Momentum모멘텀
Current loss현재 손실

Velocity damps oscillation, accelerates in valleys.속도가 진동을 억제하고 골짜기에서 가속합니다.

RMSProp
Current loss현재 손실

Per-coordinate adaptive scaling.좌표별 적응적 스케일링.

Adam
Current loss현재 손실

Momentum + adaptive scale + bias correction.모멘텀 + 적응 스케일 + 편향 보정.

Formulas공식

All methods start from the same point and follow the gradient g = ∇f(θ) of the loss, with learning rate η:모든 방법은 같은 점에서 출발해 손실의 경사 g = ∇f(θ)를 따르며, 학습률 η를 사용합니다:

$$\textbf{SGD:}\quad \theta \leftarrow \theta - \eta\,g$$

Momentum accumulates a velocity that damps zig-zag and accelerates along consistent directions:모멘텀은 속도를 누적하여 지그재그를 억제하고 일관된 방향으로 가속합니다:

$$\textbf{Momentum:}\quad v \leftarrow \beta v - \eta\,g,\qquad \theta \leftarrow \theta + v$$

RMSProp keeps a running average of squared gradients and rescales each coordinate:RMSProp는 제곱 경사의 이동평균을 유지하여 각 좌표를 재조정합니다:

$$\textbf{RMSProp:}\quad s \leftarrow \rho\,s + (1-\rho)\,g^2,\qquad \theta \leftarrow \theta - \frac{\eta\,g}{\sqrt{s}+\varepsilon}$$

Adam combines a bias-corrected first moment (momentum) with a bias-corrected second moment (adaptive scale):Adam은 편향 보정된 1차 모멘트(모멘텀)와 편향 보정된 2차 모멘트(적응 스케일)를 결합합니다:

$$m \leftarrow \beta_1 m + (1-\beta_1)g,\quad v \leftarrow \beta_2 v + (1-\beta_2)g^2$$ $$\hat m = \frac{m}{1-\beta_1^{\,t}},\quad \hat v = \frac{v}{1-\beta_2^{\,t}},\qquad \theta \leftarrow \theta - \frac{\eta\,\hat m}{\sqrt{\hat v}+\varepsilon}$$
What to watch관찰 포인트
  1. On the ill-conditioned quadratic, the ravine is steep across and shallow along. Plain SGD zig-zags across the ravine and crawls along it; Momentum damps the oscillation and accelerates down the valley; Adam / RMSProp rescale per-coordinate and head almost straight for the minimum.악조건 이차함수에서는 골짜기가 가로로 가파르고 세로로 완만합니다. 기본 SGD는 골짜기를 가로질러 지그재그하며 축을 따라서는 느리게 기어갑니다. 모멘텀은 진동을 억제하고 골짜기를 따라 가속하며, Adam / RMSProp는 좌표별로 재조정해 최소점을 향해 거의 직진합니다.
  2. Too large a learning rate overshoots and diverges (the path flies off and is clamped to the plot edge); too small and it crawls — the fundamental step-size tradeoff.학습률이 너무 크면 과도하게 넘어가 발산하고(경로가 튕겨 나가 그림 가장자리에 고정됨), 너무 작으면 기어갑니다 — 스텝 크기의 근본적인 절충입니다.
  3. On the saddle, the gradient magnitude vanishes near the saddle point, so SGD stalls; momentum and adaptive methods build up movement and break out of the flat region faster.안장점에서는 안장점 근처에서 경사 크기가 사라져 SGD가 정체됩니다. 모멘텀과 적응적 방법은 움직임을 쌓아 평평한 영역을 더 빨리 벗어납니다.
  4. Adam = Momentum (1st moment) + per-coordinate adaptive scaling (2nd moment) with bias correction — it usually wins on curved, ill-conditioned landscapes.Adam = 모멘텀(1차 모멘트) + 좌표별 적응 스케일링(2차 모멘트) + 편향 보정 — 휘어지고 악조건인 지형에서 대개 가장 앞섭니다.