↓ Luncat ka eusi utama
  1. Catetan Rékayasa & Artikel Téknis/

Generalization, Bias–Variance Tradeoff & The Double Descent Phenomenon

Daptar eusi
Dasar Machine Learning - Artikel ieu mangrupikeun bagian tina hiji séri.
Bagian 4: Artikel ieu

1. Masalah Inti: Naonkeun Nurunkeun Training Loss ka Nol Teu Cukup
#

Dina Part 3, urang ngarancang optimizers sapertos Momentum sareng AdamW pikeun nurunkeun empirical training loss $\hat{R}_n(w)$ kalayan cepet sareng reliable. Eta ngarengsekeun masalah optimization, sanajan ninggalkeun masalah generalization anu leuwih jero teu karengsekeun.

Anggap anjeun ngelatih dua model dina dataset anu sami persis:

  • Model A ngabogaan 5 parameters sareng nepi ka training MSE 0.15.
  • Model B ngabogaan 50 parameters sareng nepi ka training MSE 0.00.

Model mana anu kinerja langkung alus dina data can kakintun? Teori statistik klasik ngawantara Model B sigana ngahapal noise acak—ngalacak test error anu kalacak. Sanajan deep learning modern biasana ngelatih neural networks sareng miliaran parameters dina data training anu langkung saeutik, nurunkeun training loss near nol sambil ngahasilkeun generalization anu state-of-the-art.

Kumaha dua kanyataan ieu bisa leres babarengan?

Ngarengsekeun paradoks ieu peryogi mbedah anatomi matematis tina expected prediction error (Bias–Variance Decomposition), ngarti kumaha constraints eksplisit ngarobah parameter space ($L_1$ vs. $L_2$ Regularization), nga-estimasi out-of-sample risk kalayan reliable (Cross-Validation), sareng akhirna ngahijikeun teori klasik sareng regime Double Descent modern.


2. Intuisi Konsep: The Archer, The Sculptor, sareng The Overparameterized Bridge
#

The Archer (Bias vs. Variance)
#

Bayangkeun nguji opat pemanah ngaluarkeun panah ka target bullseye. Unggal panah ngagambarkeun model anu dilatih dina sampel acak anu beda $S$ anu ditarik tina dunya dasar anu sami:

  • High Bias, Low Variance (Underfitting): Panah ngumpul heureut babarengan, tapi jauh ka luhur-kenca ti bullseye. Model stubbornly consistent—hypothesis space-na kakenca kaku pikeun nepi ka target salaku.
  • Low Bias, High Variance (Overfitting): Posisi rata-rata panah nangtu bullseye, tapi panah individu nyebar lepat dina papan. Perturbasi leutik dina sampel latihan ngabalukarkeun fluktuasi anu dramatis dina fungsi anu diajar.

The Sculptor ($L_1$ vs. $L_2$ Regularization)
#

Regularization ngabatasan sabaraha kabebasan model pikeun ngalangkungan noise. Bayangkeun eta salaku nyetel budget dina norma parameter:

  • $L_2$ (Ridge) ngaluarkeun weight sacara mulus dina sadaya features anu pakait—kitu salaku ngaleungeun dingding curam supados teu aya parameter tunggal anu nangtu.
  • $L_1$ (Lasso) katingal salaku minimalist anu dasa—maksa feature anu lemah atawa redundan ka exact zero, ngalakukeun automatic feature selection sambil ngajaga ngan signal anu pangkuatna.

The Overparameterized Bridge (Double Descent)
#

Naonkeun model anu kompleks pisan kadangkala ngaliwatan model anu kompleks modest? Bayangkeun rek ngawangun jembatan smooth anu ngalangkungan 40 survey points anu noisy:

  • Sareng exactly 40 degrees of freedom, aya ngan hiji kurva anu nyepak unggal titik noisy—maksa jembatan ngalingcir kencang jadi peaks sareng valleys ekstrem ngan pikeun nyentuh unggal titik.
  • Sareng 1,000 degrees of freedom, aya tak hingga akeh kurva anu ngalangkungan 40 titik. Upami algoritma anjeun milih kurva pang-smooth (minimum-norm) diantara sadaya exact interpolators, degrees of freedom tambahan nyerep noise sacara lokal tanpa ngahasilkeun osilasi global anu ageung.

3. Rumusan Matematis: The Bias–Variance Decomposition
#

Anu dirumuskeun pikeun neural networks sareng statistical estimators ku Geman, Bienenstock, sareng Doursat (1992), Bias–Variance Decomposition misahkeun sumber persis tina expected squared prediction error.

Asumsikeun data dihasilkeun ku fungsi deterministik anu teu terang $f(x)$ ditambah noise independent zero-mean:

$$y = f(x) + \epsilon, \qquad \mathbb{E}[\epsilon] = 0, \qquad \operatorname{Var}(\epsilon) = \sigma^2$$

Biar $\hat{f}_S(x)$ nandakeun model anu dilatih dina dataset acak $S \sim P^n$. Sabab $S$ sorangan acak, $\hat{f}_S(x)$ mangrupikeun variabel acak dina unggal test point $x$ anu tetep. Harti rata-rata prediksi dina sadaya possible training sets ukuran $n$ salaku:

$$\bar{f}(x) = \mathbb{E}_S\big[\hat{f}_S(x)\big]$$

Ayeuna itung expected squared test error dina titik $x$ ku nambahan sareng ngurangan $\bar{f}(x)$ di jero kuadrat:

$$\mathbb{E}_{S, \epsilon}\Big[\big(y - \hat{f}_S(x)\big)^2\Big] = \mathbb{E}_{S, \epsilon}\Big[\big((f(x) - \bar{f}(x)) + (\bar{f}(x) - \hat{f}_S(x)) + \epsilon\big)^2\Big]$$

Ngabuka trinomial square ngahasilkeun tilu squared terms sareng tilu cross terms. Unggal cross term leungit sacara identitas:

  1. Sabab $\epsilon$ ngabogaan zero mean sareng independent tina $S$, dua cross terms anu ngalibatkeun $\epsilon$ sarua ka nol.
  2. Sabab $f(x) - \bar{f}(x)$ deterministik dina $S$, eta kaluar tina ekspektasi:
$$2\big(f(x) - \bar{f}(x)\big) \cdot \mathbb{E}_S\big[\bar{f}(x) - \hat{f}_S(x)\big] = 2\big(f(x) - \bar{f}(x)\big) \cdot \big(\bar{f}(x) - \bar{f}(x)\big) = 0$$

Anu meser nyaeta hiji identitas anu paling dasar dina statistical learning:

$$\mathbb{E}_{S, \epsilon}\Big[\big(y - \hat{f}_S(x)\big)^2\Big] = \underbrace{\big(f(x) - \mathbb{E}_S[\hat{f}_S(x)]\big)^2}_{\text{Bias}^2[\hat{f}_S(x)]} + \underbrace{\mathbb{E}_S\Big[\big(\hat{f}_S(x) - \mathbb{E}_S[\hat{f}_S(x)]\big)^2\Big]}_{\text{Variance}[\hat{f}_S(x)]} + \underbrace{\sigma^2}_{\text{Irreducible Noise}}$$
  • $\text{Bias}^2$: Kasalahan sistematis anu diakibatkeun asumsi struktural anu kolot banar dina $\mathcal{H}$.
  • $\text{Variance}$: Sensitivitas tina predictor anu diajar ka fluktuasi acak dina sampel latihan $S$ anu spesifik.
  • $\sigma^2$: Bayes error floor—noise acak intrinsik pangukuran atawa lingkungan anu teu aya algoritma anu bisa ngeleungitkeun.

The Classical U-Shaped Tradeoff
#

Dina statistik klasik dimensi-lila (dimana jumlah parameter $p$ kirang ti jumlah sampel $n$), naekan kompleksitas model nyumputkeun $\text{Bias}^2$ sambing ngaronjatkeun $\text{Variance}$ dina rate anu naek. Ngahijikeun dua kurva ngahasilkeun kurva test error U-shaped klasik, nunjukkeun hiji “sweet spot” kompleksitas anu sedeng.


4. Ngadalikeun Variance Sacara Eksplisit: $L_1$ (Lasso) vs. $L_2$ (Ridge) Regularization
#

Pikeun nyegah variance muges tanpa ngeleungitkeun features anu mungkin mangpaat, urang sengaja nyuntik kuantitas bias anu dikadalikeun ngalangkungan norm-based regularization.

Dina Part 2, urang nurunkeun penalties $L_2$ sareng $L_1$ salaku MAP priors Bayesian (Gaussian vs. Laplace). Di dieu, urang ningali optimization geometry sareng exact shrinkage behavior.

Constrained vs. Penalized Formulation
#

Ku Lagrange duality, ngaminimalkeun penalized objective sarua sareng ngaminimalkeun unpenalized empirical risk di jero norma ball anu dibatasi radius $t$:

  • Ridge Regression ($L_2$, Hoerl & Kennard, 1970):
$$\hat{w}_{\text{Ridge}} = \arg\min_{w} \left( \frac{1}{2n}\Vert{}Xw - y\Vert{}_2^2 + \frac{\lambda}{2}\Vert{}w\Vert{}_2^2 \right) \iff \min_{w} \Vert{}Xw - y\Vert{}_2^2 \quad \text{s.t.} \quad \Vert{}w\Vert{}_2^2 \le t$$
  • Lasso Regression ($L_1$, Tibshirani, 1996):
$$\hat{w}_{\text{Lasso}} = \arg\min_{w} \left( \frac{1}{2n}\Vert{}Xw - y\Vert{}_2^2 + \lambda\Vert{}w\Vert{}_1 \right) \iff \min_{w} \Vert{}Xw - y\Vert{}_2^2 \quad \text{s.t.} \quad \Vert{}w\Vert{}_1 \le t$$

Naonkeun $L_1$ Ngahasilkeun Exact Sparsity Sambing $L_2$ Teu
#

Bedana katingal kalayan tegas ti dua sudut—geometry sareng subgradient algebra:

  1. Geometric Intersection: Level sets tina squared loss $\Vert{}Xw - y\Vert{}_2^2$ mangrupikeun ellipsoids concentric anu puseurna di unregularized OLS solution $\hat{w}_{\text{OLS}}$. Solusi regularized kajadian dina titik mungkin kahiji dimana ellipsoid anu mekar nyentuh constraint region:
  • Constraint $L_2$ $\Vert{}w\Vert{}_2^2 \le t$ mangrupikeun hypersphere smooth (circle dina 2D). Sabab eta teu mibanda corner, ellipsoid hampir teu kalaulaweun nyentuh mungkin langsung dina coordinate axis. Weights nyumput ka nol, sanajan jarang jadi exact zero.
  • Constraint $L_1$ $\Vert{}w\Vert{}_1 \le t$ mangrupikeun cross-polytope (rotated diamond dina 2D) sareng sharp vertices anu ngalangkungan unggal coordinate axis. Salaku ellipsoid mekar, eta sacara disproportionate nyentuh corner atawa edge dimana salah sahiji atawa langkung coordinates sarua ka $w_j = 0$ sacara identitas.
  1. Exact Algebraic Mechanism (Orthonormal Design): Pertimbangkeun kasus bersih dimana kolom tina $X$ orthonormal ($\frac{1}{n}X^\top X = I_d$), supados unregularized estimate ngan $\hat{w}_{\text{OLS}} = \frac{1}{n}X^\top y$. Duanana estimators ngadekomposisi per-coordinate jadi exact closed forms:
  • Ridge (Proportional Shrinkage): $$\hat{w}_j^{\text{Ridge}} = \frac{\hat{w}_j^{\text{OLS}}}{1 + \lambda}$$

Unggal coordinate di-scale-down ku fraksi konstan $1 / (1 + \lambda)$. Sanajan noisy weight leutik 0.001 nyumput ka 0.0005—teu kalaulaweun exact zero.

  • Lasso (Soft-Thresholding): Sabab $\vert{}w_j\vert{}$ non-differentiable dina $w_j = 0$, urang nerapkeun subgradient optimality $0 \in w_j - \hat{w}_j^{\text{OLS}} + \lambda\,\partial\vert{}w_j\vert{}$, ngahasilkeun soft-thresholding operator: $$\hat{w}_j^{\text{Lasso}} = \operatorname{sign}(\hat{w}_j^{\text{OLS}}) \max\big(0,\, \vert{}\hat{w}_j^{\text{OLS}}\vert{} - \lambda\big)$$

Unggal feature anu magnitude signalna handap ti threshold ($\vert{}\hat{w}_j^{\text{OLS}}\vert{} \le \lambda$) ka-set ka exact zero, ngeleungitkeun features anu teu relevan sacara otomatis.

Property $L_2$ Regularization (Ridge) $L_1$ Regularization (Lasso) Elastic Net ($L_1 + L_2$)
Bayesian Prior Isotropic Gaussian $\mathcal{N}(0, \tau^2 I)$ Independent Laplace $\operatorname{Laplace}(0, b)$ Mixture of Gaussian & Laplace
Constraint Geometry Smooth hypersphere ($\Vert{}w\Vert{}_2^2 \le t$) Sharp cross-polytope ($\Vert{}w\Vert{}_1 \le t$) Rounded diamond (strictly convex with corners)
Effect on Weights Proportional shrinkage; dense solutions Soft-thresholding; exact sparsity ($w_j = 0$) Sparse solutions with grouped shrinkage
Correlated Features Shares weight evenly across correlated predictors Arbitrarily picks one feature and zeroes the rest Selects or drops correlated groups together
Optimization Smooth & strictly convex; closed-form $(X^\top X + \lambda I)^{-1}X^\top y$ Convex but non-smooth at 0; solved via coordinate descent / proximal GD Solved efficiently via coordinate descent

5. Nga-estimasi True Risk dina Praktek: $k$-Fold Cross-Validation
#

Milih hyperparameters sapertos polynomial degree atawa regularization strength $\lambda$ peryogi nga-estimasi out-of-sample risk tanpa nyentuh final held-out test set.

Ngabagi dataset anu terbatas jadi hiji train/validation split ngahasilkeun high estimation noise—pilihan $\lambda$ anjeun bisa ngan overfit validation slice anu hiji. $k$-Fold Cross-Validation (Stone, 1974; Kohavi, 1995) ngabagi training set $S$ jadi $k$ disjoint, equal-sized folds $S_1, \dots, S_k$. Pikeun unggal fold $j$:

  1. Latih model $\hat{f}^{(-j)}$ dina sisa $k - 1$ folds ($S \setminus S_j$).
  2. Evaluasi loss-na dina held-out fold $S_j$.

Cross-validation risk estimate ngarata-ratakeun dina sadaya $n$ sampel:

$$\widehat{\text{CV}}_k = \frac{1}{k} \sum_{j=1}^{k} \frac{1}{\vert{}S_j\vert{}} \sum_{i \in S_j} L\big(\hat{f}^{(-j)}(x_i), y_i\big)$$

The Hidden Bias–Variance Tradeoff of $k$ Itself
#

Milih $k$ teu ngan pilihan compute—eta ngadatangan tradeoff statistikna sorangan:

  • Small $k$ (e.g., $k = 2$): Unggal model ngelatih dina ngan 50% data. Sabab learning curves naekan sareng sample size, $\widehat{\text{CV}}_2$ sacara sistematis overestimates true risk tina model full-data akhir (high pessimistic bias).
  • Leave-One-Out CV ($k = n$): Unggal model ngelatih dina $n - 1$ titik, ngahasilkeun risk estimate near unbiased. Tapi, dua training folds mana wae babagi $n - 2$ identical samples, supados $n$ models kuat pakait positip—anu bisa ngaronjatkeun variance tina CV estimate di samping biaya computational $n\times$.
  • The Practical Sweet Spot ($k = 5$ or $k = 10$): Anu dipalidasi ku Kohavi (1995), 5-fold sareng 10-fold CV ngabalancekeun bias handap, variance anu dikadalikeun, sareng compute anu reksa dina sadaya tabular sareng scientific workloads.

6. The Modern Paradox: The Double Descent Phenomenon
#

Salila sabaraha dekade, kurva U-shaped Bias–Variance klasik diajar salaku hukum salaku: teu kalaulaweun ngajaga model capacity ngalangkungan jumlah training samples ($p \gt n$), atanapi variance bakal muges sareng ngaruksak generalization.

Deep learning modern ngahancurkeun aturan eta. ResNets, Vision Transformers, sareng Large Language Models biasana ngandung ordo magnitude langkung ageung parameters tibatan data points latihan, interpolate data latihan ka loss near-nol, sanajan tetep generalize sacara luar bias.

Belkin et al. (2019) ngahijikeun statistik klasik sareng deep learning modern dina hiji kurva: Double Descent.

Anatomi Dua Regime
#

Alih-alih hiji U-curve tunggal, ngempilkeun test risk salaku fungsi model capacity $p$ (ngajaga sample size $n$ tetep) nembongkeun tilu phase anu beda:

  1. Classical Underparameterized Regime ($p \lt n$): Kurva U-shaped Bias–Variance klasik tetep utuh. Salaku $p$ naek, bias turun sareng test error turun—nepi ka $p$ ndeukeut ka $n$, dimana variance mimitian naek.
  2. The Interpolation Threshold ($p \approx n$): Dina wates persis dimana model nampi parameter anu cukup pikeun ngahasilkeun zero training error ($\hat{R}_n = 0$), test error muges kencang jadi sharp peak.
  3. Modern Overparameterized (Interpolating) Regime ($p \gg n$): Sanggeus threshold, training error tetep pinned dina nol, sanajan test error turun kadua—sering turun handap ti model underparameterized pangalusna.

Naonkeun Peak Spike Lajeng Runtuh? (The Singular Value Mechanism)
#

Kiarana ieu teu misterius “deep learning magic”—eta katingal bersih dina ordinary ridgeless linear regression anu dieusikeun ngalangkungan minimum-norm Moore–Penrose pseudoinverse (Hastie et al., 2022):

$$\hat{w}_{\text{min-norm}} = \arg\min_{w} \Vert{}w\Vert{}_2 \quad \text{subject to} \quad Xw = y \implies \hat{w} = X^+ y$$

Pertimbangkeun target noisy $y = X w^* + \epsilon$ sareng $\operatorname{Cov}(\epsilon) = \sigma^2 I_n$. Teu gumantung naonkeun $p \lt n$ atawa $p \gt n$, komponen variance tina parameter error anu diakibatkeun ku label noise $\epsilon$ scales langsung sareng inverse squared nonzero singular values tina feature matrix $X \in \mathbb{R}^{n \times p}$:

$$\mathbb{E}_\epsilon\Big[\Vert{}\hat{w} - \mathbb{E}[\hat{w}]\Vert{}_2^2\Big] = \sigma^2 \operatorname{tr}\big((X^\top X)^+\big) = \sigma^2 \sum_{i=1}^{\min(n, p)} \frac{1}{s_i^2}$$

Ku Marchenko–Pastur Law ti random matrix theory, smallest nonzero singular value $s_{\min}(X)$ kalakuanna sacara dramatis beda dina aspect ratio $\gamma = p / n$:

$$s_{\min}(X) \propto \big\vert{}\sqrt{p} - \sqrt{n}\big\vert{}$$

Tingali ekspresi eta langsung:

  • Right at $p = n$ ($\gamma = 1$): $\sqrt{p} - \sqrt{n} = 0$. Matrix $X$ jadi nearly singular, $s_{\min}(X) \to 0$, sareng $1 / s_{\min}^2 \to \infty$. Pikeun maksa exact interpolation ngalangkungan noisy labels make ngan cukup parameters, model kedah nembongkeun weights anu ageung, anu kalimutan positip sareng negatip—exploding variance.
  • Far beyond $p \gg n$ ($\gamma \gg 1$): $\vert{}\sqrt{p} - \sqrt{n}\vert{}$ naek ageung deui. Smallest nonzero singular value kaluar aman ti nol, sareng $1 / s_{\min}^2$ nyumput deui. Samentara, sabab tak hingga akeh interpolating solutions aya, milih solusi minimum-norm nyebar nyerep label noise sacara harmonis dina ratusan dimensi tambahan, ngahasilkeun fungsi anu langkung smooth sareng test error anu leuwih handap.

Deep Double Descent & The Role of Explicit Regularization
#

Nakkiran et al. (2020) ngajelaskeun phenomenon ieu kajadian dina ResNets, CNNs, sareng Transformers modern teu ngan salaku fungsi model width, tapi oge dina training epochs (epoch-wise double descent) sareng sanajan dataset size—ngahartikeun unified Effective Model Complexity (EMC) relative ka dataset size.

Sami penting mangrupikeun nuance kritis anu dibuktikeun ku Hastie et al. (2022) sareng Nakkiran et al. (2021): optimal $L_2$ regularization ($\lambda \gt 0$) sampurna ngeleungitkeun interpolation peak. Nambahan $\lambda I$ mindahkeun unggal denominator ti $s_i^2$ ka $(s_i^2 + \lambda)^2 / s_i^2$, nyegah $s_{\min} \to 0$ kalaulaweun ngabagi ku nol. The double descent spike hususna signature tina model unregularized atawa under-regularized anu ngalintasi exact interpolation boundary.


L1 vs. L2 regularization geometry and the double descent curve

Figure 4. Kenca: diamond L1 nyentuh axis (sparse solution) sambing circle L2 nyumputkeun sadaya weights. Katuhu: test risk ngadeukeut puncak dina interpolation threshold lajeng turun deui dina regime overparameterized.

7. Minimal Implementation: Ngaverifikasi Bias–Variance & Double Descent dina NumPy
#

Script di handap ngajelaskeun dua hasil dasar ti nol:

  1. Part A (Monte Carlo Bias–Variance Audit): Ngaverifikasi identitas persis $\text{MSE} = \text{Bias}^2 + \text{Variance} + \sigma^2$ dina polynomial degrees 1, 3, sareng 7.
  2. Part B (Double Descent in Random ReLU Features): Sweeping feature width $p$ dina interpolation threshold $p = n = 40$ make exact minimum-norm interpolation (np.linalg.pinv), ngabandingkeun Ridgeless Interpolation unregularized ($\lambda = 0$) sareng Ridge Regularization ($\lambda = 0.05$).
import numpy as np

# =====================================================================
# PART A: Monte Carlo Verification of MSE = Bias^2 + Variance + Noise
# =====================================================================
rng = np.random.default_rng(42)

def f_true(x: np.ndarray) -> np.ndarray:
    return np.sin(np.pi * x)

sigma = 0.30
n_train = 25
n_trials = 600
x_test = np.linspace(-0.85, 0.85, 50)
y_clean_test = f_true(x_test)

print("=== PART A: Exact Bias-Variance Decomposition (600 Monte Carlo trials) ===")
print(f"True Irreducible Noise Floor (sigma^2): {sigma**2:.4f}\n")
print(f"{'Deg':<4} | {'Bias^2':<8} | {'Variance':<8} | {'Sum+Noise':<9} | {'Empirical MSE'}")
print("-" * 55)

for deg in [1, 3, 7]:
    preds = np.zeros((n_trials, len(x_test)))
    noisy_targets = np.zeros((n_trials, len(x_test)))

    Phi_test = np.vander(x_test, N=deg + 1, increasing=True)

    for trial in range(n_trials):
        x_tr = rng.uniform(-1.0, 1.0, size=n_train)
        y_tr = f_true(x_tr) + rng.normal(0.0, sigma, size=n_train)

        Phi_tr = np.vander(x_tr, N=deg + 1, increasing=True)
        w_hat, *_ = np.linalg.lstsq(Phi_tr, y_tr, rcond=None)

        preds[trial] = Phi_test @ w_hat
        noisy_targets[trial] = y_clean_test + rng.normal(0.0, sigma, size=len(x_test))

    mean_pred = preds.mean(axis=0)
    bias_sq = float(np.mean((mean_pred - y_clean_test) ** 2))
    variance = float(np.mean(np.var(preds, axis=0)))
    emp_mse = float(np.mean((preds - noisy_targets) ** 2))
    theoretical_sum = bias_sq + variance + sigma ** 2

    print(
        f"{deg:<4} | {bias_sq:<8.4f} | {variance:<8.4f} | "
        f"{theoretical_sum:<9.4f} | {emp_mse:.4f}"
    )

# =====================================================================
# PART B: Double Descent via Minimum-Norm Random ReLU Features
# Fixed n_train = 40, sweeping hidden feature count p from 4 to 500
# =====================================================================
def ridge_fit(Z: np.ndarray, y: np.ndarray, lam: float) -> np.ndarray:
    n, p = Z.shape
    if lam == 0.0:
        # Exact minimum-norm interpolator / OLS via SVD pseudoinverse
        return np.linalg.pinv(Z, rcond=1e-12) @ y
    # Use primal form when p <= n, dual (Woodbury) form when p > n
    if p <= n:
        return np.linalg.solve(Z.T @ Z + lam * np.eye(p), Z.T @ y)
    return Z.T @ np.linalg.solve(Z @ Z.T + lam * np.eye(n), y)

d_in = 10
n_tr_dd = 40
n_te_dd = 400
noise_dd = 0.30
widths = [4, 12, 24, 36, 40, 44, 60, 100, 250, 500]
n_seeds = 35

print("\n=== PART B: Double Descent across Interpolation Threshold (n = 40) ===")
print(
    f"{'Width p':<8} | {'Train MSE (lam=0)':<17} | "
    f"{'Test MSE (lam=0)':<17} | {'Test MSE (lam=0.05)'}"
)
print("-" * 70)

for p in widths:
    tr_mses_0, te_mses_0, te_mses_reg = [], [], []

    for seed in range(n_seeds):
        r = np.random.default_rng(1000 + seed)
        w_true = r.normal(0.0, 1.0, size=d_in)
        w_true = 1.5 * w_true / np.linalg.norm(w_true)

        X_tr = r.normal(0.0, 1.0, size=(n_tr_dd, d_in))
        y_tr = X_tr @ w_true + r.normal(0.0, noise_dd, size=n_tr_dd)

        X_te = r.normal(0.0, 1.0, size=(n_te_dd, d_in))
        y_te = X_te @ w_true + r.normal(0.0, noise_dd, size=n_te_dd)

        # Random ReLU feature projection scaled by 1/sqrt(p) so Z Z^T stays O(1)
        W_rand = r.normal(0.0, 1.0, size=(p, d_in)) / np.sqrt(d_in)
        Z_tr = np.maximum(0.0, X_tr @ W_rand.T) / np.sqrt(p)
        Z_te = np.maximum(0.0, X_te @ W_rand.T) / np.sqrt(p)

        # 1. Unregularized minimum-norm solution (lam = 0)
        a_0 = ridge_fit(Z_tr, y_tr, lam=0.0)
        tr_mses_0.append(np.mean((Z_tr @ a_0 - y_tr) ** 2))
        te_mses_0.append(np.mean((Z_te @ a_0 - y_te) ** 2))

        # 2. Ridge-regularized solution (lam = 0.05)
        a_reg = ridge_fit(Z_tr, y_tr, lam=0.05)
        te_mses_reg.append(np.mean((Z_te @ a_reg - y_te) ** 2))

    marker = " <-- p = n (threshold)" if p == n_tr_dd else ""
    print(
        f"{p:<8} | {np.mean(tr_mses_0):<17.4f} | "
        f"{np.mean(te_mses_0):<17.4f} | {np.mean(te_mses_reg):.4f}{marker}"
    )

Ngajelaskeun Kiarana
#

Dua hasil teoretis jero katon langsung dina terminal output:

  1. Exact Additive Identity (Part A): Dina unggal polynomial degree, Bias^2 + Variance + sigma^2 cocog sareng Empirical MSE anu diukur mandiri dina presisi Monte Carlo sampling. Degree 1 dikadalikeun ku Bias^2, degree 3 ngaminimalkeun total error near 0.09 noise floor, sareng degree 7 nurunkeun Bias^2 near nol sambing Variance naek kencang.
  2. The Double Descent Spike & Ridge Smoothing (Part B):
  • Pikeun unregularized interpolation (lam=0), test MSE mimiti turun ti $p = 4$ ka $p = 12$, lajeng naek curam sareng muges langsung dina $p = 40 = n$ sacara persis salaku Train MSE nepi ka 0.0000. Ngalangkungan threshold ($p = 100 \to 500$), Train MSE tetep exact 0.0000 sambing Test MSE turun kalayan bersih ka second descent, ngaliwatan model underparameterized pangalusna!
  • Pikeun Ridge (lam=0.05), interpolation spike leungit sampurna—test MSE turun monotonic salaku feature width naek, ngajelaskeun sacara empiris naonkeun regularization ngahijikeun regime klasik sareng overparameterized.

8. Wates & Jembatan ka Part 5
#

Tingali sakitar hiji baris anu sneaky di jero ridge_fit() di luhur:

return Z.T @ np.linalg.solve(Z @ Z.T + lam * np.eye(n), y)

Lamun feature dimension $p$ jadi langkung ageung tibatan sample count $n$, urang ngabypass matrix $Z^\top Z$ anu ageung $p \times p$ sampurna sareng ngarengsekeun masalah ngan make matrix anu leutik $n \times n$ tina inner products $Z Z^\top$.

Trick aljabar eta ngabuka patarosan anu luar bias: naonkeun upami urang nyorong $p$ sampurna nepi ka tak hingga—ngalakukeun dina infinite-dimensional nonlinear feature space—tanpa kalaulaweun ngitung feature vectors $Z$ sacara eksplisit?

Dina Part 5: The Geometry of Decision Boundaries — Support Vector Machines & The Kernel Trick, urang bakal ngalangkungan kumaha ngamaksimalkeun geometric margins ngalangkungan Lagrangian duality ngarah langsung ka Kernel Methods—ngamungkinkeun algoritma linier nyieun arbitrarily complex nonlinear boundaries dina infinite-dimensional Hilbert spaces dina biaya computational anu lega.


Rujukan
#

  1. Hoerl, A. E., & Kennard, R. W. (1970). “Ridge Regression: Biased Estimation for Nonorthogonal Problems.” Technometrics, 12(1), 55–67. (Original formulation of $L_2$ regularization).
  2. Stone, M. (1974). “Cross-Validatory Choice and Assessment of Statistical Predictions.” Journal of the Royal Statistical Society: Series B (Methodological), 36(2), 111–147. (Statistical foundations of cross-validation).
  3. Geman, S., Bienenstock, E., & Doursat, R. (1992). “Neural Networks and the Bias/Variance Dilemma.” Neural Computation, 4(1), 1–58. (Bias–variance decomposition in machine learning).
  4. Kohavi, R. (1995). “A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection.” Proceedings of the 14th International Joint Conference on Artificial Intelligence (IJCAI 1995), 1137–1143.
  5. Tibshirani, R. (1996). “Regression Shrinkage and Selection via the Lasso.” Journal of the Royal Statistical Society: Series B (Methodological), 58(1), 267–288. (Original formulation of $L_1$ regularization and sparsity).
  6. Belkin, M., Hsu, D., Ma, S., & Mandal, S. (2019). “Reconciling Modern Machine-Learning Practice and the Classical Bias–Variance Trade-Off.” Proceedings of the National Academy of Sciences (PNAS), 116(32), 15849–15854. (Introduction of the Double Descent risk curve).
  7. Nakkiran, P., Kaplun, G., Bansal, Y., Yang, T., Barak, B., & Sutskever, I. (2020). “Deep Double Descent: Where Bigger Models and More Data Hurt.” International Conference on Learning Representations (ICLR 2020). arXiv:1912.02292.
  8. Hastie, T., Montanari, A., Rosset, S., & Tibshirani, R. J. (2022). “Surprises in High-Dimensional Ridgeless Least Squares Interpolation.” The Annals of Statistics, 50(2), 949–986. arXiv:1903.08560. (Random matrix theory proof of the interpolation peak and minimum-norm overparameterized descent).
Dasar Machine Learning - Artikel ieu mangrupikeun bagian tina hiji séri.
Bagian 4: Artikel ieu