Dive into Deep Learning · §36.10
泛化界、对称化与 Rademacher 复杂度
一致收敛 · 并集界 · 幽灵样本对称化 · Rademacher 复杂度 · 间隔界 · 双下降与良性过拟合
动机与选择偏差
实验验证
将 1{,}000 枚硬币实验重复 2{,}000 次表明,单硬币 95\% 置信带套用于事后胜者时几乎次次失效(96\%\text{--}97\%):
best of 1000 coins: median 0.66, 90% of experiments in [0.64, 0.69]
95% half-width: one coin 0.136, all 1000 coins 0.230
experiments in which the best coin leaves the one-coin band: 97%
函数类上的上确界
\bigl\lvert\hat{R}_S(\hat{f}) - R(\hat{f})\bigr\rvert \le \sup_{f \in \mathcal{F}} \bigl\lvert\hat{R}_S(f) - R(f)\bigr\rvert
搜索的对数代价
\sup_{f \in \mathcal{F}} \bigl\lvert\hat{R}_S(f) - R(f)\bigr\rvert \le \sqrt{\frac{\log(2\lvert\mathcal{F}\rvert/\delta)}{2n}}
非自适应 vs. 自适应查询
度量无穷函数类
\widehat{\mathfrak{R}}_S(\mathcal{F}) = \mathbb{E}_{\boldsymbol{\varepsilon}}\Biggl[\sup_{f \in \mathcal{F}} \frac{1}{n}\sum_{i=1}^n \varepsilon_i\,f(\mathbf{x}_i)\Biggr]
从单点类到打散函数类
Rademacher 复杂度从固定函数的零平滑上升到在 S = (\mathbf{x}_1, \dots, \mathbf{x}_n) 上可记忆任意符号模式的 1:
| 函数类 \mathcal{F} | 经验 Rademacher 复杂度 \widehat{\mathfrak{R}}_S(\mathcal{F}) | 随样本量 n 的缩放 |
|---|---|---|
| 单点类 \{f\} | \mathbb{E}_{\boldsymbol{\varepsilon}}\bigl[\frac{1}{n}\sum_i \varepsilon_i f(\mathbf{x}_i)\bigr] = 0 | 恒为 0(无选择) |
| 两常函数 \{+1, -1\} | \mathbb{E}_{\boldsymbol{\varepsilon}}\bigl[\lvert\bar{\varepsilon}\rvert\bigr] \approx \sqrt{\frac{2}{\pi n}} | 按 O(n^{-1/2}) 收缩 |
| [-1, 1] 中的有限类 | \le \sqrt{\frac{2\log\lvert\mathcal{F}\rvert}{n}}(Massart 引理) | 关于 \lvert\mathcal{F}\rvert 呈对数,O(\sqrt{\log\lvert\mathcal{F}\rvert / n}) |
| \{-1, +1\} 中的 VC 二分类器类 | \le C\sqrt{\frac{d_{\mathrm{VC}}\log n}{n}} | 受 VC 维 d_{\mathrm{VC}} 控制 |
| 映入 [0, 1] 的所有函数 | \mathbb{E}_{\boldsymbol{\varepsilon}}\bigl[\frac{1}{n}\sum_i \mathbf{1}\{\varepsilon_i = +1\}\bigr] = \frac{1}{2} | 常数 \frac{1}{2}(无泛化) |
| 映入 [-1, 1] 的所有函数 | \mathbb{E}_{\boldsymbol{\varepsilon}}\bigl[\frac{1}{n}\sum_i \varepsilon_i^2\bigr] = 1(在不同 \mathbf{x}_i 上) | 常数 1(完全记忆) |
无穷函数类的泛化界
为界定泛化风险,我们将 Rademacher 复杂度应用于 [0, 1] 值损失类 \mathcal{G} = \{z = (\mathbf{x}, y) \mapsto \ell(f(\mathbf{x}), y) : f \in \mathcal{F}\}。对于大小为 n 的独立同分布样本 S,以至少 1 - \delta 的概率对所有 g \in \mathcal{G} 同时有:
R(g) \le \hat{R}_S(g) + 2\,\mathfrak{R}_n(\mathcal{G}) + \sqrt{\frac{\log(1/\delta)}{2n}}
三步对称化论证
\mathbb{E}_S\Bigl[\sup_{g \in \mathcal{G}}\bigl(R(g) - \hat{R}_S(g)\bigr)\Bigr] \le 2\,\mathfrak{R}_n(\mathcal{G})
范数有界线性预测器
证明 R_S(F) <= B r / sqrt(n)
通过 Jensen 不等式(\mathbb{E}\|\mathbf{s}\|_2 \le \sqrt{\mathbb{E}\|\mathbf{s}\|_2^2})用均方根范数界定 \mathbf{s} = \sum_{i=1}^n \varepsilon_i \mathbf{x}_i 的期望欧几里得范数,即可得闭式上界:
\mathbb{E}_{\boldsymbol{\varepsilon}}\Biggl[\Biggl\|\sum_{i=1}^n \varepsilon_i \mathbf{x}_i\Biggr\|_2\Biggr] \le \sqrt{\sum_{i=1}^n \sum_{j=1}^n \mathbb{E}[\varepsilon_i \varepsilon_j]\,\langle\mathbf{x}_i, \mathbf{x}_j\rangle} = \sqrt{\sum_{i=1}^n \|\mathbf{x}_i\|_2^2} \le r\sqrt{n} \implies \widehat{\mathfrak{R}}_S(\mathcal{F}) \le \frac{Br}{\sqrt{n}}
从实值打分到分类风险
P\bigl(y\langle\mathbf{w}, \mathbf{x}\rangle \le 0\bigr) \le \hat{R}_\gamma(\mathbf{w}) + \frac{2Br}{\gamma\sqrt{n}} + \sqrt{\frac{\log(1/\delta)}{2n}}
代码中的经验 Rademacher 复杂度
对 d \in \{2, 20, 1000\} 维中的 n = 50 个单位向量(B = r = 1),在 2{,}000 个随机符号向量上平均精确上确界 \frac{B}{n}\bigl\|\sum_{i=1}^n \varepsilon_i \mathbf{x}_i\bigr\|_2,验证了我们的理论:
d = 2: Monte-Carlo R_S = 0.123, bound B r / sqrt(n) = 0.141
d = 20: Monte-Carlo R_S = 0.141, bound B r / sqrt(n) = 0.141
d = 1000: Monte-Carlo R_S = 0.141, bound B r / sqrt(n) = 0.141
插值边界
当模型族过参数化(在 n = 50 个点上使用 p = 2n = 100 个标准高斯特征)并能通过 \mathbf{w} = \boldsymbol{\Phi}^+\boldsymbol{\varepsilon} 插值任意随机符号向量 \boldsymbol{\varepsilon} \in \{\pm 1\}^n 时,会发生什么?
mean ||w|| = 0.99 (predicted 1.01), largest 1.31
typical fit: mean ||w|| * mean row norm / sqrt(n) = 1.40
r = 12.4, B r / sqrt(n) with B = largest ||w||: 2.3
双下降的解析机制
\mathbf{w} = \boldsymbol{\Phi}^+\mathbf{y} = \sum_{i=1}^{\min(n,p)} \frac{\langle\mathbf{u}_i, \mathbf{y}\rangle}{\sigma_i}\,\mathbf{v}_i
代码中的三个区域
奇异值、范数与基线
检视 p \in \{15, 38, 40, 42, 50, 80, 400\} 下的全部九项诊断指标,可揭示三个关键细节:
p test train norm s_min capacity clean noise ratio_q ratio
15 0.65 0.28 1.9 1 1.3 0.67 0.0066 3.7 1.8
38 3.3 0.0081 5.5 0.08 6 2.9 0.31 6.8e+02 32
40 71 2.3e-28 29 0.016 34 58 4.2 1.5e+04 4.2e+02
42 3.4 1.3e-29 6 0.076 6.5 2.9 0.26 5.8e+02 26
50 0.74 6.6e-30 2.7 0.25 3.1 0.64 0.063 62 6.3
80 0.22 7e-30 1.3 0.71 1.8 0.19 0.021 10 2.1
400 0.049 5.3e-30 0.4 2.6 1.3 0.04 0.0095 2.3 0.95
least squares on the 15 raw inputs: test MSE 0.0066
clean 误差也大于 noise 误差,因为 40 个 ReLU 脊函数沿 \mathbf{u}_n 难以逼近线性教师。干净误差 vs. 噪声误差
\mathbb{E}_{\boldsymbol{\xi}}\bigl[\mathrm{MSE}_{\mathrm{test}}\bigr] = \frac{1}{n_{\mathrm{te}}}\bigl\|\boldsymbol{\Phi}_{\mathrm{te}}\boldsymbol{\Phi}^+\mathbf{y}_0 - \mathbf{y}_{\mathrm{te}}\bigr\|_2^2 + \frac{\sigma_\xi^2}{n}\sum_{i=1}^n \frac{\|\boldsymbol{\Phi}_{\mathrm{te}}\mathbf{v}_i\|_2^2 / n_{\mathrm{te}}}{\|\boldsymbol{\Phi}\mathbf{v}_i\|_2^2 / n}
测试与训练特征能量比
理论能保证什么、什么依然开放
如何将 Rademacher 间隔界 \frac{Br}{\gamma\sqrt{n}} 与双下降扫描实验统一起来?
单模型、有限池、线性间隔、插值区域
| 场景 | 复杂度度量 | 泛化差距上界 / 缩放 | 关键前提或局限 |
|---|---|---|---|
| 单个固定模型 \{f\} | \mathfrak{R}_n = 0 | \sqrt{\frac{\log(2/\delta)}{2n}} | f 必须在抽取测试集 S 之前固定 |
| 有限候选池 \mathcal{F} | \log\lvert\mathcal{F}\rvert | \sqrt{\frac{\log(2\lvert\mathcal{F}\rvert/\delta)}{2n}} | 候选池 \mathcal{F} 必须非自适应(无排行榜反馈) |
| 一般无穷类 \mathcal{G} | 2\,\mathfrak{R}_n(\mathcal{G}) | 2\,\mathfrak{R}_n(\mathcal{G}) + \sqrt{\frac{\log(1/\delta)}{2n}} | 要求损失有界于 [0, 1] 且数据独立同分布 |
| 线性间隔分类器 | \frac{Br}{\gamma\sqrt{n}} | \hat{R}_\gamma(\mathbf{w}) + \frac{2Br}{\gamma\sqrt{n}} + \sqrt{\frac{\log(1/\delta)}{2n}} | 与维度无关;当 Br/\gamma \gtrsim \sqrt{n} 时变得空洞 |
| 两层 ReLU 网络 | \frac{2B_1 B_2 r}{\sqrt{n}} | 由 \ell_1 \times \ell_2 路径范数控制 | 与宽度无关,但训练后的范数常超过 \sqrt{n} |
| 最小范数插值解 | \sigma_{\min}(\boldsymbol{\Phi}) 与有效秩 | 噪声误差 \frac{\sigma_\xi^2}{n}\sum_i \frac{\|\boldsymbol{\Phi}_{\mathrm{te}}\mathbf{v}_i\|^2/n_{\mathrm{te}}}{\|\boldsymbol{\Phi}\mathbf{v}_i\|^2/n} | 依赖算法;在 p = n 处飙升,p \gg n 时良性 |
检验理解
解答:
核心要点
| 概念 | 数学形式 | 统计与深度学习作用 |
|---|---|---|
| 一致收敛 | \sup_{f \in \mathcal{F}} \lvert\hat{R}_S(f) - R(f)\rvert \le t | 保护依赖数据的模型选择 \hat{f} = \operatorname{argmin}_f \hat{R}_S(f) |
| 有限类并集界 | \lvert\hat{R}_S(f) - R(f)\rvert \le \sqrt{\frac{\log(2\lvert\mathcal{F}\rvert/\delta)}{2n}} | 依托指数尾部,搜索 \lvert\mathcal{F}\rvert 个固定模型仅付出 \log\lvert\mathcal{F}\rvert 代价 |
| Rademacher 复杂度 | \widehat{\mathfrak{R}}_S(\mathcal{F}) = \mathbb{E}_{\boldsymbol{\varepsilon}}\bigl[\sup_{f \in \mathcal{F}} \frac{1}{n}\sum_i \varepsilon_i f(\mathbf{x}_i)\bigr] | 幽灵样本对称化将泛化差距归结为拟合随机符号的能力 |
| 线性与间隔界 | \widehat{\mathfrak{R}}_S(\mathcal{F}) \le \frac{Br}{\sqrt{n}};R_{0\text{--}1} \le \hat{R}_\gamma + \frac{2Br}{\gamma\sqrt{n}} + \sqrt{\frac{\log(1/\delta)}{2n}} | 容量取决于范数乘积 Br/\gamma,而非维度 d |
| SVD 插值峰值 | \mathbf{w} = \boldsymbol{\Phi}^+\mathbf{y} = \sum_{i=1}^q \frac{\langle\mathbf{u}_i, \mathbf{y}\rangle}{\sigma_i}\mathbf{v}_i | p = n 处 \sigma_{\min} 坍缩导致 \|\mathbf{w}\|_2 与测试误差爆破 |
| 良性过拟合 | \text{Noise MSE} = \frac{\sigma_\xi^2}{n}\sum_{i=1}^n \frac{\|\boldsymbol{\Phi}_{\mathrm{te}}\mathbf{v}_i\|^2/n_{\mathrm{te}}}{\|\boldsymbol{\Phi}\mathbf{v}_i\|^2/n} | 当 p \gg n 时,噪声被吸收进测试特征同样微弱的低能量方向 |