← Playground← 놀이터

PRISM · Statistical-Mechanics PlaygroundPRISM · 통계역학 놀이터

Flat Minima & Generalization평평한 최솟값과 일반화
Flat minima, thermal noise, and free energy평평한 최솟값, 열적 잡음, 그리고 자유 에너지

For the same training loss, a wide valley generalizes better than a narrow one. Adjust the temperature (mini-batch noise), the test-distribution shift, and the optimizer (SGD · SAM) to see why the free energy F = ⟨E⟩ − T·S favors flat valleys.같은 학습 손실이라도 넓은 골짜기가 좁은 골짜기보다 일반화가 잘 된다. 온도(미니배치 잡음), 테스트 분포 이동, 옵티마이저(SGD · SAM)를 조절해 왜 자유 에너지 F = ⟨E⟩ − T·S가 평평한 골짜기를 선호하는지 보라.

Energy landscape에너지 지형 L_train (solid) · L_test (dashed, shift s)L_train (실선) · L_test (점선, 이동 s)
θ = −4parameter θ파라미터 θθ = +4
Boltzmann occupancy볼츠만 점유 분포 p(θ) ∝ e−L/T · time-avg ≈ ensemble-avg시간 평균 ≈ 앙상블 평균
sharp well좁은 골 0%
flat well넓은 골 0%
⟨E⟩ · S
F =
Controls조절기
Temperature T온도 T mini-batch noise미니배치 잡음 0.15
Test shift s테스트 이동 s covariate shift공변량 이동 0.50
Narrow-well sharpness좁은 골 뾰족함 width σₛ폭 σₛ 0.30
SAM radius ρSAM 반지름 ρ sharpness-aware objective뾰족함 인식 목적함수 0.35
The ball starts in the narrow well. Raise T to see thermal escape.공은 좁은 골에서 시작한다. T를 높여 열적 탈출을 관찰하라.
Measurements측정값 sharp well좁은 골
θ
curvature κ (sharpness)곡률 κ (뾰족함)
L_train
L_test
generalization gap일반화 격차
steps스텝 수
0
Things to try해볼 것들
  1. Trapped: at the start (low T) the ball is stuck in the narrow well.갇힘: 처음에는 (낮은 T) 공이 좁은 골에 갇혀 있다.
  2. Thermal escape: raise T to cross the barrier; over time the ball spends longer in the wide well (mass bars below).열적 탈출: T를 높여 장벽을 넘어라. 시간이 지나면 공은 넓은 골에 더 오래 머문다 (아래 질량 막대).
  3. Generalization: move s to see how the gap differs between the narrow and wide wells.일반화: s를 움직여 좁은 골과 넓은 골 사이에서 격차가 어떻게 달라지는지 보라.
  4. SAM objective: turn on SAM to see how shallow the narrow well becomes under the sharpness-aware loss.SAM 목적함수: SAM을 켜서 뾰족함 인식 손실에서 좁은 골이 얼마나 얕아지는지 보라.

Wide well = low curvature넓은 골 = 낮은 곡률

When the test distribution is offset by s (covariate shift), the narrow well climbs its steep walls and loss spikes, while the wide well barely changes. So low-curvature κ minima have a smaller generalization gap.테스트 분포가 s만큼 이동하면 (공변량 이동), 좁은 골은 가파른 벽을 타고 올라 손실이 급증하지만 넓은 골은 거의 변하지 않는다. 그래서 곡률 κ가 낮은 최솟값일수록 일반화 격차가 작다.

Temperature = Langevin noise온도 = 랑주뱅 잡음

SGD ≈ gradient descent + thermal noise, with stationary distribution p ∝ e^(−L/T). This minimizes the free energy F = ⟨E⟩ − T·S, favoring flat minima whose entropy S (basin volume) is large.SGD ≈ 경사 하강 + 열적 잡음이며, 정상 분포는 p ∝ e^(−L/T)이다. 이는 자유 에너지 F = ⟨E⟩ − T·S를 최소화하여, 엔트로피 S(골의 부피)가 큰 평평한 최솟값을 선호한다.

SAM: worst-neighbor lossSAM: 최악 이웃 손실

It minimizes the worst-case loss within a ρ-ball, W(θ)=max L(θ+δ). The narrow well is steep right next door so W spikes and it is avoided; the wide well barely moves and is selected.ρ-공 안에서 최악의 손실 W(θ)=max L(θ+δ)을 최소화한다. 좁은 골은 바로 옆이 가팔라 W가 급증하므로 회피되고, 넓은 골은 거의 변하지 않아 선택된다.