# 归一化

**归一化**（Normalization）在统计学和机器学习中，是指将数据或模型激活值调整到共同的尺度、范围或分布，使任何变量都不会仅仅因为其单位而占据主导地位。这个词涵盖了几种不同的操作：重新缩放特征值（最小-最大缩放、z 分数标准化、稳健缩放）、将分布变换为接近正态分布（Box-Cox 变换、分位数变换）、对神经网络内部的激活值进行归一化（批归一化、层归一化和 RMS 归一化），以及一个不相关的用法——将数据库规范化为各种范式。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup><sup> • </sup><sup>[2](https://aiwiki.ai/wiki/normalization)</sup>

| 关键事实 | 详情 |
|---|---|
| Z 分数 | z 分数是一个值偏离均值多少个标准差，\( x' = (x - \mu)/\sigma \)；一个高于均值 2 个标准差的值，其 z 分数为 +2.0<sup>[3](https://developers.google.com/machine-learning/crash-course/numerical-data/normalization)</sup> |
| 最小-最大缩放 | \( x' = (x - x_{\min})/(x_{\max} - x_{\min}) \) 将值映射到 [0, 1]；适用于边界稳定、离群点很少或不极端的情形<sup>[3](https://developers.google.com/machine-learning/crash-course/numerical-data/normalization)</sup> |
| 量化收益 | PCA 测试准确率从原始数据的 35.19% 升至使用 StandardScaler 后的 96.30%；对数损失从 1.18 降至 0.0739<sup>[4](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html)</sup> |
| k-means | 在混合单位数据集上，原始数据 k-means 的平均准确率为 0.6621，而 z 分数缩放后为 0.9142<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11623793/)</sup> |
| 批归一化 | 仅用原来十四分之一的训练步数达到相同准确率，集成模型在 ImageNet 上达到 4.82% 的 top-5 测试误差<sup>[6](https://proceedings.mlr.press/v37/ioffe15.html)</sup> |
| RMSNorm | 性能与层归一化相当，同时将运行时间减少 7%–64%，已在 LLaMA、Mistral 和 Gemma 中取代层归一化<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf)</sup><sup> • </sup><sup>[8](https://dl.acm.org/doi/full/10.1145/3787109.3815212)</sup> |
| 泄漏规则 | 先划分数据，仅在训练子集上拟合缩放器，再用拟合得到的参数变换测试子集<sup>[9](https://sklearn.org/1.4/common_pitfalls.html)</sup> |

## 重新缩放方法

**最小-最大缩放**使用 \( x' = (x - x_{\min})/(x_{\max} - x_{\min}) \) 将浮点值从其自然范围转换为标准范围，通常为 0 到 1 或 -1 到 +1。谷歌的机器学习指南建议在以下情况下使用它：数据的上下界随时间变化不大，特征包含很少或没有极端离群点，且特征大致呈平坦形状（均匀分布）。<sup>[3](https://developers.google.com/machine-learning/crash-course/numerical-data/normalization)</sup>

**Z 分数标准化**将每个值表示为偏离均值的标准差数量，\( x' = (x - \mu)/\sigma \)。该指南建议对钟形（正态分布）特征使用 z 分数缩放，对数缩放则作为针对其他形状的第三种技术。<sup>[3](https://developers.google.com/machine-learning/crash-course/numerical-data/normalization)</sup>

**稳健缩放**使用百分位数——中位数和四分位距——进行中心化和缩放，因此统计量不受少量极大边缘离群点的影响。在 scikit-learn 带离群点的示例中，两个特征的大多数变换值都落在 [-2, 3] 范围内；而 StandardScaler 在存在离群点时无法保证特征尺度均衡，因为离群点会影响经验均值和标准差；MinMaxScaler 则将所有内点压缩到一个狭窄的带内，在加州房价的一个特征中窄至 [0, 0.005]。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup>

第四种操作的命名有时容易引起混淆，它是逐样本而非逐特征的：scikit-learn 的 Normalizer 将每个样本的向量重新缩放为单位范数，与样本的分布无关。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup>

## 使分布正态化

重新缩放改变位置和散布，但不改变分布的形状。有两类变换可以改变形状。PowerTransformer 提供非线性变换，将数据变换为接近正态分布，以稳定方差并最小化偏度，使用 Yeo-Johnson 或 Box-Cox 变换，缩放因子由最大似然估计确定；Box-Cox 只能应用于严格为正的数据，因此当存在负值时优先使用 Yeo-Johnson。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup> QuantileTransformer 应用非线性变换，使每个特征的概率密度函数映射为均匀分布或高斯分布；离群点会坍缩到范围边界 0 和 1，这可能导致饱和伪影。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup>

## 为什么算法需要归一化输入

未缩放的数据可能减慢甚至阻止许多基于梯度的估计器的收敛，而基于度量和基于梯度的估计器通常假设数据大致标准化。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup>

这种敏感性因算法而异。即使基于树的模型几乎不受缩放影响，许多其他算法仍要求特征归一化；k 近邻和基于 PCA 的模型变化显著。<sup>[4](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html)</sup> 在一项 2025 年的系统性基准测试中，评估了 12 种缩放技术——包括较少见的 VAST 和 Pareto 方法——在 14 种机器学习算法和 16 个数据集上的表现，结果表明集成方法（随机森林、XGBoost、CatBoost 以及 LightGBM 等同类方法）无论应用哪种缩放器都能保持稳健性能，而逻辑回归、SVM、TabNet 和 MLP 对所选缩放器高度敏感。<sup>[10](https://arxiv.org/abs/2506.08274)</sup>

## 数据说话

**k-means。** 在一项 2024 年针对特征单位不同的数据集的研究中，原始数据上的 k-means 平均准确率、精确率、召回率和 F 分数分别为 0.6621、0.6112、0.7104 和 0.6559，而即使是所测试的缩放器中最弱的一种（最小-最大归一化）也达到 0.8855、0.8859、0.8850 和 0.8851。Z 分数标准化给出了最佳整体结果：0.9142、0.9149、0.9115 和 0.9128。在一个数据集上，原始数据 k-means 的准确率为 0.5614，而 z 分数缩放将其提升至 0.9620，RobustScaler 提升至 0.9327。当所有特征共享相同单位时，缩放结果与原始数据相似，最大绝对值缩放略优，准确率为 0.8076。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11623793/)</sup>

**分类。** 对于 KNN 分类，z 分数标准化将准确率从 92.1% 的未缩放基线提升至 96.5%，绝对提升 4.4 个百分点，F1 分数为 0.956，并将交叉验证标准差从 0.018 减半至 0.009。<sup>[11](https://ijiemr.org/public/uploads/paper/461251779128587.pdf)</sup> 对于基于 PCA 的分类，准确率从 35.19% 升至 96.30%，对数损失从 1.18 降至 0.0739。<sup>[4](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html)</sup>

**深度学习。** 批归一化仅用原来十四分之一的训练步数达到相同准确率，批归一化网络的集成在 ImageNet 上达到 4.82% 的 top-5 测试误差，超过人类评分者的准确率。<sup>[6](https://proceedings.mlr.press/v37/ioffe15.html)</sup> RMSNorm 在机器翻译质量上与层归一化相当（在 newstest2014/2017 上 SacreBLEU 分别为 22.4/23.7 对 22.6/23.6），同时节省 24.7% 的训练时间，每 1000 个训练步为 501 秒对 665 秒。<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf)</sup> 同一基准研究还发现了缩放器之间的成本差异：RobustScaler、StandardScaler、Tanh Transformer 和 Hyperbolic Tangent 最为内存密集，而 MaxAbsScaler、MinMaxScaler 和 Decimal Scaler 始终记录到最低的内存消耗。<sup>[10](https://arxiv.org/abs/2506.08274)</sup>

## 神经网络内部的归一化

**批归一化**（Ioffe 和 Szegedy，ICML 2015）通过归一化层输入来解决内部协变量偏移问题，即训练过程中前层参数变化导致每层输入分布的变化。它允许使用更高的学习率，降低对初始化的敏感性，并在某些情况下消除了对 Dropout 的需求。<sup>[6](https://proceedings.mlr.press/v37/ioffe15.html)</sup> 从机制上看，批归一化计算一个通道内所有激活值在小批量样本和空间位置上的均值，除以标准差，并应用由 \( \gamma_c, \beta_c \) 参数化的可学习通道仿射变换；在测试时，使用均值和方差的运行平均值代替批统计量。<sup>[12](https://papers.neurips.cc/paper/7996-understanding-batch-normalization.pdf)</sup> 小批量引入的噪声可能额外起到一种正则化作用，但这是实践中观察到的现象，并非该层的定义性组成部分。<sup>[13](https://d2l.smola.org/chapter_convolutional-modern/batch-norm.html)</sup>

批归一化为何有效存在争议。原始论文将收益归因于减少内部协变量偏移，<sup>[6](https://proceedings.mlr.press/v37/ioffe15.html)</sup> 而一项跨 ResNet18/34/50/101 的经验分析得出结论，其成功可能主要源于改进的权重初始化而非归一化步骤本身，并指出改进的原因尚不清楚。<sup>[14](https://www.sciencedirect.com/science/article/pii/S0020025523005200)</sup>

**层归一化**对批归一化进行了改造：它不使用整个批次的统计量，而是从单个训练样本馈入一层中每个神经元的总输入中推导归一化均值和方差。与批归一化不同，它在训练和测试时执行完全相同的计算，对小批量大小没有约束，可用于批大小为 1 的纯在线场景；通过在每个时间步分别计算统计量，它可以直接应用于循环神经网络，并稳定隐藏状态动态。<sup>[15](https://arxiv.org/abs/1607.06450)</sup> 后来的分析发现，去掉偏置和增益的简化版本（LayerNorm-simple）在四个数据集上优于层归一化，在英越机器翻译上取得了最先进的性能。<sup>[16](https://papers.neurips.cc/paper/8689-understanding-and-improving-layer-normalization.pdf)</sup>

**RMSNorm** 假设层归一化中的重中心化不变性并非必要，转而通过均方根对求和输入进行正则化，提供重缩放不变性和隐式学习率自适应。<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf)</sup> 它在不同模型上达到与层归一化相当的性能，同时将运行时间减少 7%–64%。<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf)</sup>

## 最新进展

**RMSNorm 的采用。** 现代大语言模型，包括 LLaMA、Mistral 和 Gemma，已采用 RMSNorm 替代层归一化，这一转变推动了用于 RMSNorm 推理的专用硬件加速器。<sup>[8](https://dl.acm.org/doi/full/10.1145/3787109.3815212)</sup> RMSNorm 也已被 Qwen 和 DeepSeek 采用，PyTorch 在 2.4 版本中将其作为 torch.nn.RMSNorm 添加了原生支持。<sup>[2](https://aiwiki.ai/wiki/normalization)</sup> RMSNorm 被描述为提供稳定的训练和具有竞争力的性能，尤其是在大规模 Transformer 模型中。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2026/file/c017e92288b5056c578bb6b0b69d9e76-Paper-Conference.pdf)</sup>

**为什么均值中心化是冗余的。** 一种几何分解表明，层归一化的标准化步骤去除了向量沿均匀向量的分量，对剩余部分进行归一化，并按维度的平方根进行缩放。经验上，使用层归一化或 RMSNorm 训练的大语言模型在训练和推理期间平均而言与均匀向量正交，意味着它们不携带沿该向量的分量；该分析主张使用 RMSNorm 而非层归一化，前者在计算上也更高效。<sup>[18](https://aclanthology.org/2026.findings-eacl.20/)</sup>

**新变体。** 动态 Tanh（DyT）变换已被证明可以通过将通道特定项提升为全局可学习参数而从 RMSNorm 数学地导出，为 DyT 与层归一化的相似性提供了理论基础；RMSNorm 的精确逐元素对应物是一种称为 Dynamic Inverse Square 的变换。<sup>[19](https://aclanthology.org/2026.eacl-short.48.pdf)</sup> HybridNorm 将多头注意力中的 QKV 归一化与前馈网络中的 Post-Norm 相结合，以权衡 Pre-Norm 的稳定性与 Post-Norm 的表达能力；QKV-Norm 在缩放点积注意力之前分别对查询、键和值矩阵进行归一化，增强训练稳定性。<sup>[20](https://proceedings.neurips.cc/paper_files/paper/2025/file/23a1e7765b22c7e2ffdabf2e6b5dbc44-Paper-Conference.pdf)</sup>

**批归一化在语言模型中的局限。** 批归一化在大语言模型中很少被采用，因为它不适合序列建模任务，并可能在一个批次内跨样本泄漏上下文信息。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2026/file/c017e92288b5056c578bb6b0b69d9e76-Paper-Conference.pdf)</sup> 归一化方法的一个共同局限是，稳定性是通过牺牲输入尺度的信息来获得的，这可能限制表达能力。<sup>[17](https://proceedings.iclr.cc/paper_files/paper/2026/file/c017e92288b5056c578bb6b0b69d9e76-Paper-Conference.pdf)</sup>

## 实践指导与陷阱

**避免泄漏。** 当构建模型时使用了预测时不可用的信息，就会发生数据泄漏，导致过于乐观的性能估计，例如来自交叉验证的估计。缩放的规则是始终先将数据划分为训练和测试子集，尤其是在任何预处理步骤之前，并且在使用 fit 和 fit_transform 方法时绝不要包含测试数据；在所有数据上拟合可能产生过于乐观的分数。scikit-learn 管道是防止数据泄漏的一种方法，因为它确保在正确的数据子集上执行适当的方法，包括在交叉验证和超参数调优期间。<sup>[9](https://sklearn.org/1.4/common_pitfalls.html)</sup>

**离群点。** 三种主要缩放器在离群点下差异显著。StandardScaler 的均值和标准差被离群点拉动，无法保证特征尺度均衡；MinMaxScaler 映射到 [0, 1] 但将内点压缩到狭窄的带内；RobustScaler 基于百分位数的统计量不受少量极大边缘离群点的影响。<sup>[1](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)</sup>

**选择方法。** 将缩放器与分布和算法相匹配：最小-最大缩放适用于边界已知的数据和神经网络输入，z 分数标准化适用于与线性模型、SVM 和 PCA 配合使用的大致高斯数据。<sup>[2](https://aiwiki.ai/wiki/normalization)</sup> 缩放并不总是有益的：如果低尺度变量不具有预测性，缩放可能通过放大噪声特征而增加过拟合，<sup>[4](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html)</sup> 而当所有特征共享相同单位时，缩放可能给出与原始数据相似的结果。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC11623793/)</sup>

**关于名称的说明。** 数据库规范化是将表组织为 1NF、2NF、3NF、BCNF 及更高范式，这与机器学习中的归一化是完全不同的概念，尽管两者都涉及施加结构和一致性。<sup>[2](https://aiwiki.ai/wiki/normalization)</sup>

## References

1. [Compare the effect of different scalers on data with outliers, scikit-learn documentation](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html)
2. [Normalization, AI Wiki](https://aiwiki.ai/wiki/normalization)
3. [Numerical data: Normalization, Google Machine Learning Crash Course](https://developers.google.com/machine-learning/crash-course/numerical-data/normalization)
4. [Importance of Feature Scaling, scikit-learn documentation](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html)
5. [The impact of neglecting feature scaling in k-means clustering (2024), PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC11623793/)
6. [Ioffe & Szegedy (2015). Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift, ICML](https://proceedings.mlr.press/v37/ioffe15.html)
7. [Zhang & Sennrich (2019). Root Mean Square Layer Normalization, NeurIPS](https://proceedings.neurips.cc/paper_files/paper/2019/file/1e8a19426224ca89e83cef47f1e7f53b-Paper.pdf)
8. [LightningRMS: A High-Throughput Mixed-Precision RMSNorm Accelerator, GLSVLSI](https://dl.acm.org/doi/full/10.1145/3787109.3815212)
9. [Common pitfalls and recommended practices, scikit-learn 1.4.2 documentation](https://sklearn.org/1.4/common_pitfalls.html)
10. [The Impact of Feature Scaling In Machine Learning, arXiv:2506.08274](https://arxiv.org/abs/2506.08274)
11. [The choice of scaling technique matters for classification performance, IJIEMR](https://ijiemr.org/public/uploads/paper/461251779128587.pdf)
12. [Understanding Batch Normalization, NeurIPS 2018](https://papers.neurips.cc/paper/7996-understanding-batch-normalization.pdf)
13. [Normalization Layers, Dive into Deep Learning](https://d2l.smola.org/chapter_convolutional-modern/batch-norm.html)
14. [An empirical analysis of the shift and scale parameters in BatchNorm, Information Sciences](https://www.sciencedirect.com/science/article/pii/S0020025523005200)
15. [Ba, Kiros & Hinton (2016). Layer Normalization, arXiv:1607.06450](https://arxiv.org/abs/1607.06450)
16. [Understanding and Improving Layer Normalization, NeurIPS 2019](https://papers.neurips.cc/paper/8689-understanding-and-improving-layer-normalization.pdf)
17. [SEEDNORM, ICLR](https://proceedings.iclr.cc/paper_files/paper/2026/file/c017e92288b5056c578bb6b0b69d9e76-Paper-Conference.pdf)
18. [Geometric Interpretation of Layer Normalization and a Comparative Analysis with RMSNorm, EACL 2026 Findings](https://aclanthology.org/2026.findings-eacl.20/)
19. [On the Mathematical Relationship Between Layer Normalization and Dynamic Activation Functions, EACL 2026](https://aclanthology.org/2026.eacl-short.48.pdf)
20. [HybridNorm: Towards Stable and Efficient Transformer Training, NeurIPS 2025](https://proceedings.neurips.cc/paper_files/paper/2025/file/23a1e7765b22c7e2ffdabf2e6b5dbc44-Paper-Conference.pdf)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Applied, official, and domain statistics › Applied, official, and domain statistics

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/normalization

English original: https://www.edgepedia.org/normalization
