← Playground← 놀이터

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

Batch Normalization배치 정규화
Re-center and re-scale activations layer by layer — see how BN keeps signals alive through a deep network and smooths training층마다 활성화를 다시 중심화하고 다시 스케일링 — BN이 깊은 신경망에서 신호를 살아있게 유지하고 학습을 매끄럽게 하는 과정 보기

Raw batch x원본 배치 x BN output y = γx̂ + βBN 출력 y = γx̂ + β μ_B (raw mean)μ_B (원본 평균)
without BNBN 없음 with BNBN 적용 std = 1std = 1

Per-layer activation std (log scale) as signal propagates through depth.신호가 깊이를 따라 전파될 때의 층별 활성 표준편차 (로그 스케일).

μ_B
Batch mean (raw)배치 평균 (원본)

Mean of x before BN; subtracted to re-center.BN 이전 x의 평균; 중심화를 위해 빼줍니다.

σ_B
Batch std (raw)배치 표준편차 (원본)

Std of x before BN; divides to re-scale.BN 이전 x의 표준편차; 재스케일을 위해 나눕니다.

out μ
Mean of yy의 평균

Mean of BN output ≈ β (x̂ has mean 0).BN 출력의 평균 ≈ β (x̂의 평균은 0).

out σ
Std of yy의 표준편차

Std of BN output ≈ |γ| (x̂ has std 1).BN 출력의 표준편차 ≈ |γ| (x̂의 표준편차는 1).

Formulas공식

Batch normalization standardizes each feature over the mini-batch of size m, then restores freedom with learnable γ, β:배치 정규화는 크기 m의 미니배치에 대해 각 특성을 표준화한 뒤, 학습 가능한 γ, β로 표현의 자유도를 복원합니다:

$$\mu_B=\frac1m\sum_{i=1}^m x_i,\qquad \sigma_B^2=\frac1m\sum_{i=1}^m (x_i-\mu_B)^2$$

Normalize to zero mean / unit variance (ε guards against dividing by zero), then apply the affine transform:평균 0 / 분산 1로 정규화한 뒤(ε는 0으로 나눔을 방지), 아핀 변환을 적용합니다:

$$\hat x_i=\frac{x_i-\mu_B}{\sqrt{\sigma_B^2+\epsilon}},\qquad y_i=\gamma\,\hat x_i+\beta$$

So the output mean is exactly β and its std is |γ|·σ_B/√(σ_B²+ε) ≈ |γ| — normalization removes the input's mean and scale, and γ, β put back whatever the network needs.따라서 출력 평균은 정확히 β이고 표준편차는 |γ|·σ_B/√(σ_B²+ε) ≈ |γ| 입니다 — 정규화가 입력의 평균과 스케일을 제거하면, γ, β가 신경망에 필요한 값을 다시 부여합니다.

What to watch관찰 포인트
  1. BN standardizes each feature over the batch to mean 0 / var 1, then γ, β let the network re-learn any mean and scale it needs — so it never loses representational power. Watch out μ track β and out σ track |γ| in the cards.BN은 배치에 대해 각 특성을 평균 0 / 분산 1로 표준화하고, 이어서 γ, β가 필요한 어떤 평균과 스케일도 다시 학습하게 해줍니다 — 따라서 표현력을 결코 잃지 않습니다. 카드에서 out μ가 β를, out σ가 |γ|를 따라가는 것을 확인하세요.
  2. Without BN, activation std compounds multiplicatively with depth: gain > 1 → exploding, gain < 1 → vanishing (a straight line in log scale). With BN every layer is renormalized, so the std curve stays flat near 1 and gradients stay healthy.BN이 없으면 활성 표준편차가 깊이에 따라 곱셈적으로 누적됩니다: 이득 > 1 → 폭발, 이득 < 1 → 소실 (로그 스케일에서 직선). BN이 있으면 매 층이 재정규화되므로 표준편차 곡선이 1 근처에서 평평하게 유지되고 그래디언트가 건강하게 유지됩니다.
  3. Intuition: BN smooths the loss landscape and reduces sensitivity to weight initialization and learning rate — the modern view of why BN helps optimization, beyond the original "internal covariate shift" story.직관: BN은 손실 지형을 매끄럽게 만들고 가중치 초기화와 학습률에 대한 민감도를 낮춥니다 — 원래의 "내부 공변량 이동" 설명을 넘어, BN이 최적화에 도움이 되는 이유에 대한 현대적 관점입니다.