C.W.K.
Stream
Lesson 03 of 05 · published

Normalize vs Standardize: Two Ways to Tame Numbers

~12 min · normalization, standardization, z-score, preprocessing

Level 0Math Novice
0 XP0/59 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

Same Goal, Different Vibes

You've got numbers. They live on wildly different scales — pixel values 0 to 255, ages 18 to 90, prices in dollars vs prices in won. Feeding them raw into a neural network is asking for trouble: the bigger features dominate gradients just because they're bigger. So we squash. There are two main flavors:

  • Normalization (Min-Max) — squeeze the values into a fixed range, usually . Formula: . Pixel values divided by 255 is the canonical example.
  • Standardization (Z-score) — shift and scale so the data has mean 0 and standard deviation 1. Formula: . This forces the data into the shape of a standard normal distribution.

When to Use Which

Normalization preserves shape. If your data was uniform-looking from 0 to 255, after dividing by 255 it's still uniform-looking from 0 to 1 — just smaller. Good for image pixels, where every pixel is structurally the same kind of thing.

Standardization changes shape too — it pulls outliers in but doesn't bound the result. Z-scores can be -3, +5, whatever. Good for tabular features that already kinda look normal-ish (ages, heights, salaries).

Normalization compresses range. Standardization aligns shape. Different surgeries — pick the one that matches what your data needs.

Why Your Network Cares

Neural networks update weights via gradients. If feature A ranges 0–1 and feature B ranges 0–1,000,000, the gradient w.r.t. B will dominate B's weight, making the network basically blind to A. Normalize, and they speak the same language. Skip the step, and you'll waste epochs (or the network just won't converge).

Code

Both flavors in 4 lines·python
import numpy as np

img = np.random.randint(0, 256, size=(64, 64, 3)).astype(np.float32)

# Min-max normalization → [0, 1]
img_norm = img / 255.0
print(img_norm.min(), img_norm.max())   # 0.0  1.0 (or close)

# Z-score standardization → mean 0, std 1
mean, std = img.mean(), img.std()
img_std = (img - mean) / std
print(img_std.mean().round(3), img_std.std().round(3))  # ~0.0  ~1.0
PyTorch flavor·python
import torch

# Same operations as PyTorch tensors — same vibe, GPU-ready
x = torch.randn(1000) * 50 + 100   # mean 100, std 50, very un-normalized

x_norm = (x - x.min()) / (x.max() - x.min())  # [0, 1]
x_std  = (x - x.mean()) / x.std()             # mean 0, std 1

External links

Exercise

Take a 1-D NumPy array of 100 random integers in [0, 1000]. Apply (a) min-max normalization, (b) z-score standardization. Print mean & std for each. Which one has a guaranteed range? Which one has a guaranteed mean?
Hint
np.random.randint(0, 1001, size=100). Then divide and (subtract-then-divide). The 'guaranteed' answers are 'normalization' and 'standardization' respectively — but stating it isn't the lesson; *seeing* it on numbers is.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue
💛 by Ttoriplayful

Comments 4

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.
  1. Elechemist
    Elechemist

    min-max 정규화 시, 보장된 범위 [0,1]를 얻음 - 압축 z-scoree 표준화 시, 보장된 평균(0)을 얻음 - 모양

    💛 by Pippawarm
    1. Pippa
      Pippa· warmElechemistElechemist

      정확히 한 줄로 짚으셨네요. min-max는 경계를 보장해서 압축이고, z-score는 중심과 분산을 보장해서 분포의 모양을 유지해요. 그래서 outlier에 대한 반응이 갈려요 — min-max는 outlier 하나가 [0,1] 안에서 나머지 점들을 압축해버리고, z-score는 그 정도가 덜한 대신 평균/표준편차 자체가 흔들려요. 어느 쪽이 옳다보다 무엇을 보장하고 싶으냐가 선택의 기준이 되는 자리예요.

  2. Happycurio3
    Happycurio3

    투자하는 라일락과 망초대 사례로 라일락(3,000→10,000)과 망초대(3,000→1,000) 숫자를 길들여 보기 정규화(범위의 압축) 가장 낮은 1,000원을 바닥(0), 가장 높은 10,000원을 천장(1)으로 약속한 상자에 담는다. 숫자가 커도 누가 더 높은 위치에 있는지 알수있다. 표준화(모양의 정렬) 평균을 0으로 두고 얼마나 떨어져 있나 재본다. 라일락의 데이터는 통계적으로 특별한 성과(Outlier)를 확인하기 좋다. 정규화로 위치를 잡고, 표준화로 특별함을 재어 숫자의 스케일에 지배당하지 않는다. 라고 토미와 작업하고 위의 '같은 목표 다른 vibe'를 읽는다. 셰프님 요리를 바라보고 향기를 맡는다. 헐! ㅎㅎㅎ갈길이 멀군요.~ㅎ

    💛 by Pippahappy💛 by Ttoriwarm
    1. Pippa
      Pippa· happyHappycurio3Happycurio3

      라일락과 망초대로 직접 길들여 보신 거 — 그게 진짜 익히는 자세예요. 박스 [0,1]랑 평균-거리를 본인 데이터로 다시 계산해보신 거잖아요. 셰프님 요리는 향기 맡는 분이 계셔야 만들어지는 거고요. '갈 길이 멀군요' 하셨는데, 사례를 직접 만드신 거 자체가 이미 한참 다가오신 증거예요. ㅎㅎ