# 泛化误差

**泛化误差**是在特定数据集上训练的模型的总体风险与该模型在同一数据集上的经验风险之差；它衡量学习器在未见数据上的表现与其测得的训练表现之间偏离多少。<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC9498125/)</sup> 在统计学习理论中，总体（或真实）风险是在完整数据分布上的期望损失，而经验风险是在训练样本上的平均损失，后者是唯一可以直接计算的量。<sup>[2](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)</sup> 界定这一差距是泛化理论的核心问题：它告诉实践者，一个拟合了训练数据的模型是否也能在来自同一分布的新数据上表现良好。

| 关键事实 | 详情 |
|---|---|
| 定义 | 泛化误差 = 学习算法在给定数据集上产生的模型的总体风险减去经验风险<sup>[1](https://pmc.ncbi.nlm.nih.gov/articles/PMC9498125/)</sup> |
| 有限类界 | 若有 \( m \) 个假设且损失在 [0, 1] 内，则 \( N > \frac{2}{\varepsilon^2} \ln \frac{2m}{\delta} \) 个样本以至少 \( 1-\delta \) 的概率给出 \( L(h_{\mathrm{ERM}}) \le \varepsilon + L(h^{*}) \)<sup>[2](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)</sup> |
| VC 维 | 若一个概念类的 Vapnik-Chervonenkis 维有限，则该概念类是可学习的；样本复杂度随该维数缩放<sup>[3](https://www.sciencedirect.com/science/article/pii/0166218X9390179R)</sup> |
| 稳定性路径 | 布斯凯和埃利塞夫从算法稳定性获得了 PAC 风格的界，这些界取决于算法如何搜索假设空间，即使 VC 维无限也适用<sup>[4](https://papers.neurips.cc/paper/1854-algorithmic-stability-and-generalization-performance)</sup> |
| PAC-贝叶斯路径 | 麦卡莱斯特定理用 \( \frac{1}{n}\left(\mathrm{D}[Q\|P] + \log\frac{n+1}{\delta}\right) \) 界定后验 \( Q \) 的泛化差距<sup>[5](https://www.jmlr.org/papers/volume3/seeger02a/seeger02a.pdf)</sup> |
| 信息论路径 | 自 Russo 和 Zou（2016, 2019）以及 Xu 和 Raginsky（2017）以来，在损失具有次高斯尾部的条件下，差距可由训练数据与学习到的假设之间的互信息来界定<sup>[6](https://proceedings.mlr.press/v178/lugosi22a.html)</sup> |
| 现代警示 | 在深度学习中，随着容量增长越过插值阈值，误差可能再次下降（双下降），因此经典容量度量无法追踪观察到的行为<sup>[7](https://doi.org/10.1073/pnas.1903070116)</sup> |

## 形式化设定

假设选择模型使这些量精确化。学习器观察到一个由独立随机变量 \( Z_1, \ldots, Z_N \) 组成的训练集，它们与某个随机变量 \( Z \) 同分布，并且必须从集合 \( \mathcal{H} = \{h_1, \ldots, h_m\} \) 中选择一个假设 \( h \)。损失函数 \( L : \mathcal{H} \times \mathcal{Z} \to [0,1] \) 衡量 \( h \) 对数据点的拟合有多差。总体损失 \( L(h) = \mathrm{E}[L(h, Z)] \) 在真实分布上评估 \( h \)，包括训练中未出现的点，而经验损失 \( \frac{1}{N} \sum_{i=1}^{N} L(h, Z_i) \) 仅从样本即可计算。<sup>[2](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)</sup> [经验风险最小化](https://www.edgepedia.org/zh/empirical-risk-minimization)（ERM）选择使经验损失最小的假设 \( h_{\mathrm{ERM}} \)；希望在于，如果训练集代表了分布，那么 \( h_{\mathrm{ERM}} \) 在总体损失下也表现接近最优。<sup>[2](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)</sup>

## 经典界：一致收敛与 VC 维

获得泛化界的最古老路径是经验量向其均值的一致收敛。<sup>[8](https://jmlr.csail.mit.edu/papers/volume2/bousquet02a/bousquet02a.pdf)</sup> 对于在数据抽取之前选定的固定假设，Hoeffding 不等式表明其训练误差很可能接近其泛化误差；对整个类取联合界可将此扩展到学习器所选择的假设。<sup>[9](https://haroldsoh.com/cs3264/notes/lecture-06.html)</sup> 对于由 \( m \) 个假设组成的有限类，所得的样本复杂度陈述是明确的：若 \( N > \frac{2}{\varepsilon^2} \ln \frac{2m}{\delta} \)，则以至少 \( 1-\delta \) 的概率有 \( L(h_{\mathrm{ERM}}) \le \varepsilon + L(h^{*}) \)，其中 \( h^{*} \) 使总体损失最小。<sup>[2](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)</sup>

无限类由 Vapnik-Chervonenkis（VC）维处理，即概念类能够以所有可能方式标记的最大点集的规模。<sup>[10](https://jmlr.csail.mit.edu/papers/volume20/18-549/18-549.pdf)</sup> 若一个概念类的 [VC 维](https://www.edgepedia.org/zh/vc-dimension)有限，则该概念类是可学习的，并且通过两个额外参数，所得的样本规模界比早期证明改进了约 \( 4 \log_2(e) \) 倍。<sup>[3](https://www.sciencedirect.com/science/article/pii/0166218X9390179R)</sup> 经典结果表明，假设的总体误差与其在足够大样本上的经验误差相似，样本复杂度上界为 \( O(\mathrm{VC}(\mathcal{C})) \)。<sup>[10](https://jmlr.csail.mit.edu/papers/volume20/18-549/18-549.pdf)</sup> VC 理论也被应用于神经网络：基于 VC 理论的界与奇偶机的统计力学结果进行了比较，奇偶机是一个两层网络。<sup>[11](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.72.2113)</sup>

## 算法稳定性

另一条路径完全放弃容量度量，转而询问算法对其数据的敏感程度。稳定学习器是指其学习到的解在训练集发生小变化时不会发生太大变化的学习器。布斯凯和埃利塞夫表明，泛化误差的 PAC 风格界可以从稳定性显式推导出来；这些界取决于算法如何搜索假设空间，而非其复杂度的任何度量，因此即使 VC 维无限也适用。他们证明了正则化网络具有所需的稳定性。<sup>[4](https://papers.neurips.cc/paper/1854-algorithmic-stability-and-generalization-performance)</sup> 他们后来在《机器学习研究杂志》（JMLR）发表的论文定义了几种稳定性概念，并利用它们推导基于经验误差和留一误差的界，涵盖回归和阈值分类，并应用于回归和分类的支持向量机以及 希尔伯特空间和 Kullback-Leibler 正则化。<sup>[8](https://jmlr.csail.mit.edu/papers/volume2/bousquet02a/bousquet02a.pdf)</sup>

## PAC-贝叶斯界

PAC-贝叶斯框架界定随机化分类器的泛化误差，即参数向量上的后验分布 \( Q \) 而非单个假设的泛化误差。麦卡莱斯特定理（1999）指出，对于任意数据分布，以至少 \( 1-\delta \) 的概率在大小为 \( n \) 的独立同分布样本上，泛化误差 \( \mathrm{gen}(Q) \) 与经验误差 \( \mathrm{emp}(S,Q) \) 之间的差距由 \( \epsilon(\delta, n, P, Q) = \frac{1}{n}\left(\mathrm{D}[Q\|P] + \log\frac{n+1}{\delta}\right) \) 控制，其中 \( \mathrm{D}[Q\|P] \) 是后验 \( Q \) 与在看到数据之前固定的先验 \( P \) 之间的 Kullback-Leibler 散度。<sup>[5](https://www.jmlr.org/papers/volume3/seeger02a/seeger02a.pdf)</sup> Matthias Seeger 应用该定理，证明了近似贝叶斯高斯过程分类的不依赖分布的泛化误差界，对于中等训练样本量，这些界可以非常紧。<sup>[12](https://www.jmlr.org/papers/v3/seeger02a.html)</sup> PAC-贝叶斯界此后被扩展到非独立同分布数据<sup>[13](https://jmlr.org/papers/volume11/ralaivola10a/ralaivola10a.pdf)</sup>，并在时间一致、任意时刻有效的表述下统一，这些表述在所有停止时间成立，并允许非平稳损失和非独立同分布数据。<sup>[14](https://jmlr.org/papers/v24/23-0401.html)</sup> 该框架也有实际应用：学习到的优化器可以通过直接最小化 PAC-贝叶斯上界来训练，从而产生数据驱动的性能保证。<sup>[15](https://www.jmlr.org/papers/v26/24-0755.html)</sup>

## 信息论界

在 Daniel Russo 和 [James Zou](https://www.edgepedia.org/zh/james-zou)（2016, 2019）以及 Xu 和 Raginsky（2017）的研究基础上，现已确立：当任何固定假设的损失具有次高斯尾部时，监督学习算法的泛化误差可以通过连接其输入（训练样本）与输出（学习到的假设）的互信息来界定。<sup>[6](https://proceedings.mlr.press/v178/lugosi22a.html)</sup> 现在存在一大类改进，包括来自 Steinke 和 Zakynthinou（2020）的超样本设置的条件互信息界<sup>[16](https://proceedings.mlr.press/v202/wang23w.html)</sup>，以及基于假设可压缩性的率失真概念的界。<sup>[17](https://proceedings.mlr.press/v178/sefidgaran22a.html)</sup> 这些工具也超越了监督学习，为量子数据<sup>[18](https://proceedings.mlr.press/v247/caro24a.html)</sup>和变分自编码器<sup>[19](https://proceedings.mlr.press/v306/futami26a.html)</sup>推导了界。

该框架有其局限。对于随机凸优化中的梯度下降，尚未证明任何信息论框架——包括输入-输出互信息、条件互信息及其变体、PAC-贝叶斯界以及最近的条件变体——能够为期望泛化误差建立极小极大速率。<sup>[20](https://proceedings.mlr.press/v201/haghifam23a.html)</sup>

## 神经网络与双下降之谜

经典的基于容量的理论预测误差应随模型复杂度增长，但现代深度网络通常近乎完美地拟合训练数据，同时仍能很好地泛化。[俄亥俄州立大学](https://www.edgepedia.org/zh/ohio-state-university)的 Mikhail Belkin 与 Daniel Hsu、Siyuan Ma 和 Soumik Mandal 描述了一条双下降曲线，它包含了教科书中的 U 形偏差-方差权衡：将模型容量增加到超过插值点会带来测试性能的改善。<sup>[7](https://doi.org/10.1073/pnas.1903070116)</sup> 在从样本侧观察的同一现象中，当训练样本数 \( N \) 与参数数 \( P \) 处于同一量级时，神经网络的泛化误差达到峰值，即插值阈值；相关的三重下降分析区分了两种过拟合，其峰值与该阈值重合。<sup>[21](https://proceedings.neurips.cc/paper_files/paper/2020/hash/1fd09c5f59a8ff35d499c0ee25a1d47e-Abstract.html)</sup>

针对神经网络的定制界也随之出现。Peter Bartlett、Dylan Foster 和 Martin Wainwright 的基于间隔的多类界随网络的间隔归一化谱复杂度缩放，其 Lipschitz 常数由权重矩阵的谱范数乘积乘以一个修正因子给出。在 MNIST 和 CIFAR-10 上用 SGD（随机梯度下降）训练的 AlexNet 上，使用原始标签和随机标签，该界、Lipschitz 常数和超额风险均直接相关，表明 SGD 选择的预测器其复杂度随任务难度缩放。<sup>[22](https://arxiv.org/abs/1706.08498)</sup> 其他工作根据深度、宽度和网络的 Jacobian 推导了数据依赖的间隔界。<sup>[23](https://arxiv.org/abs/1806.05159)</sup>

## 相关量

同样的差距也出现在模型训练之外。在自适应数据分析中，每次分析依赖于对同一数据的先前分析结果，Russo 和 Zou 使用互信息来界定自适应引入的偏差，这是科学中虚假发现背后的一个机制。<sup>[24](https://proceedings.mlr.press/v51/russo16.html)</sup> 在分布偏移下，训练分布和测试分布不同，分布外泛化要求相对于未知偏移分布的界；大偏差结果在该设定下产生显式界。<sup>[25](https://arxiv.org/abs/2106.04443)</sup>

## References

1. [Information-Theoretic Generalization Bounds for Distributed, Federated, and Iterative Learning, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC9498125/)
2. [1.4.2 Generalization error of empirical risk minimization, Cornell CS4850 lecture notes](https://www.cs.cornell.edu/courses/cs4850/2025sp/handouts/randalgs.pdf)
3. [Bounding sample size with the Vapnik-Chervonenkis dimension, Discrete Applied Mathematics (1993)](https://www.sciencedirect.com/science/article/pii/0166218X9390179R)
4. [Algorithmic Stability and Generalization Performance, Bousquet & Elisseeff, NIPS 2000](https://papers.neurips.cc/paper/1854-algorithmic-stability-and-generalization-performance)
5. [PAC-Bayesian Generalisation Error Bounds for Gaussian Process Classification (PDF), Seeger, JMLR 2002](https://www.jmlr.org/papers/volume3/seeger02a/seeger02a.pdf)
6. [Generalization Bounds via Convex Analysis, Lugosi & Neu, COLT 2022](https://proceedings.mlr.press/v178/lugosi22a.html)
7. [Reconciling modern machine-learning practice and the classical bias-variance trade-off, Belkin et al., PNAS 2019](https://doi.org/10.1073/pnas.1903070116)
8. [Stability and Generalization, Bousquet & Elisseeff, JMLR 2(Mar):499-526, 2002](https://jmlr.csail.mit.edu/papers/volume2/bousquet02a/bousquet02a.pdf)
9. [CS3264 Lecture 6 notes, Computational Learning Theory](https://haroldsoh.com/cs3264/notes/lecture-06.html)
10. [Simultaneous Private Learning of Multiple Concepts, JMLR 20 (2019)](https://jmlr.csail.mit.edu/papers/volume20/18-549/18-549.pdf)
11. [Learning and generalization in a two-layer neural network: The role of the VC dimension, Phys. Rev. Lett. 72, 2113](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.72.2113)
12. [PAC-Bayesian Generalisation Error Bounds for Gaussian Process Classification, Seeger, JMLR 3(Oct):233-269, 2002](https://www.jmlr.org/papers/v3/seeger02a.html)
13. [PAC-Bayes bounds for classifiers trained on non-IID data, Ralaivola et al., JMLR 11 (2010)](https://jmlr.org/papers/volume11/ralaivola10a/ralaivola10a.pdf)
14. [A Unified Recipe for Deriving (Time-Uniform) PAC-Bayes Bounds, Chugg, Wang & Ramdas, JMLR 24 (2023)](https://jmlr.org/papers/v24/23-0401.html)
15. [Data-Driven Performance Guarantees for Classical and Learned Optimizers, Sambharya & Stellato, JMLR 26 (2025)](https://www.jmlr.org/papers/v26/24-0755.html)
16. [Tighter Information-Theoretic Generalization Bounds from Supersamples, Wang & Mao, ICML 2023](https://proceedings.mlr.press/v202/wang23w.html)
17. [Rate-Distortion Theoretic Generalization Bounds for Stochastic Learning Algorithms, Sefidgaran et al., COLT 2022](https://proceedings.mlr.press/v178/sefidgaran22a.html)
18. [Information-theoretic generalization bounds for learning from quantum data, Caro et al., COLT 2024](https://proceedings.mlr.press/v247/caro24a.html)
19. [Information-Theoretic Generalization Bounds for VAEs, Futami & Fujisawa, ICML 2026](https://proceedings.mlr.press/v306/futami26a.html)
20. [Limitations of Information-Theoretic Generalization Bounds for Gradient Descent Methods in Stochastic Convex Optimization, Haghifam et al., COLT 2023](https://proceedings.mlr.press/v201/haghifam23a.html)
21. [Triple descent and the two kinds of overfitting: where & why do they appear?, NeurIPS 2020](https://proceedings.neurips.cc/paper_files/paper/2020/hash/1fd09c5f59a8ff35d499c0ee25a1d47e-Abstract.html)
22. [Spectrally-normalized margin bounds for neural networks, Bartlett, Foster & Wainwright, arXiv 2017](https://arxiv.org/abs/1706.08498)
23. [On Tighter Generalization Bound for Deep Neural Networks: CNNs, ResNets, and Beyond, arXiv 2018](https://arxiv.org/abs/1806.05159)
24. [Controlling Bias in Adaptive Data Analysis Using Information Theory, Russo & Zou, AISTATS 2016](https://proceedings.mlr.press/v51/russo16.html)
25. [Robust Generalization despite Distribution Shift via Minimum Discriminating Information, arXiv 2021](https://arxiv.org/abs/2106.04443)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 19, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 19, 2026; Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Learning theory and generalization › Generalization bounds

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/generalization-error

English original: https://www.edgepedia.org/generalization-error
