# 自编码器

自编码器是一种被训练来重构自身输入的神经网络，由一个编码器和一个解码器组成，编码器将输入映射为潜在表示，解码器将该表示映射回原始数据。网络的训练通过最小化输入 \( x \) 与其重构 \( g(f(x)) \) 之间的损失函数 \( \mathcal{L}(x, g(f(x))) \)（如均方误差）来实现<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。解码器的输出通常并非目标所在；这种复制任务的意义在于，中间编码 \( h = f(x) \) 获得了有用的性质，可用于降维、特征学习、生成或异常检测<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。

| 关键事实 | 详情 |
|---|---|
| 结构 | 编码器 \( f_\phi : \mathbb{R}^d \to \mathcal{Z} \) 将输入映射为潜在变量 \( z \)；解码器 \( g_\theta : \mathcal{Z} \to \mathbb{R}^d \) 从 \( z \) 重构输入，二者之间存在重构损失<sup>[2](https://www.zhb.uni-luebeck.de/epubs/ediss2661.pdf)</sup> |
| 欠完备形式 | 编码维度小于输入维度，迫使模型捕捉训练数据中最显著的特征<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup> |
| 线性情形 | 在线性解码器和均方误差下，欠完备自编码器学习张成与主成分分析（PCA）相同的子空间<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup> |
| 深度突破 | 辛顿（Hinton）与萨拉赫丁诺夫（Salakhutdinov）（《科学》，2006）展示了一种初始化方案，使深度自编码器能够学习低维编码，效果远优于PCA<sup>[3](https://pubmed.ncbi.nlm.nih.gov/16873662/)</sup> |
| 去噪变体 | 樊尚（Vincent）等人于2008年提出去噪自编码器，训练网络从损坏版本中恢复干净输入<sup>[4](https://www.sciencedirect.com/topics/computer-science/autoencoder)</sup><sup> • </sup><sup>[5](https://mlanthology.org/icml/2008/vincent2008icml-extracting/)</sup> |
| 变分变体 | 金马（Kingma）与韦林（Welling）于2013年提出变分自编码器，一种用于含连续潜在变量的有向概率模型的随机变分推断算法<sup>[6](https://arxiv.org/abs/1312.6114)</sup> |
| 掩码变体 | 掩码自编码器（MAE，CVPR 2022）遮蔽约75%的图像块并重构缺失像素，训练加速3倍以上<sup>[7](https://openaccess.thecvf.com/content/CVPR2022/papers/He_Masked_Autoencoders_Are_Scalable_Vision_Learners_CVPR_2022_paper.pdf)</sup> |

## 工作原理

训练目标刻意保持简单：让输出接近输入。防止模型退化为恒等映射的，是对容量或损失的约束。最直接的约束是欠完备设计，即编码维度小于输入维度，因此编码器必须压缩，解码器必须从该压缩中重构<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。

仅靠容量约束并不足够。如果编码器和解码器被赋予过大的容量，自编码器可以学会直接复制输入，而不提取关于数据分布的任何有用信息；当编码维度等于或超过输入维度时，即便是线性编码器和解码器也能将输入复制到输出<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。正则化自编码器以不同方式解决这一问题：它们不是通过保持编码器和解码器的浅层结构以及较小的编码维度，而是通过使用鼓励其他性质的损失函数，如表示的稀疏性、表示导数较小，或对噪声或缺失输入的鲁棒性。正则化自编码器可以是非线性的、过完备的，同时仍能学到关于数据分布的有用信息<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。

线性情形使与经典方法的联系变得精确。当解码器为线性且损失为均方误差时，欠完备自编码器作为复制任务的副产品，学习训练数据的主成分子空间；非线性编码器和解码器则产生更强大的PCA非线性推广<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。对损失景观的分析表明，\( L_2 \) 正则化线性自编码器在所有临界点处都学习解码器左奇异向量方向上的主方向<sup>[8](https://proceedings.mlr.press/v97/kunin19a/kunin19a.pdf)</sup>。

## 主要变体

**稀疏自编码器。** 稀疏自编码器在重构误差上对编码层添加稀疏惩罚 \( \Omega(h) \)，目标为 \( \mathcal{L}(x, g(f(x))) + \Omega(h) \)。以这种方式正则化的模型必须对其训练数据的独特统计特征做出响应，而非充当恒等函数，稀疏自编码器通常用于为分类等其他任务学习特征<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。

**去噪自编码器。** 去噪自编码器由樊尚等人于2008年提出，训练其从损坏版本中恢复干净输入，堆叠去噪自编码器可用于初始化深度架构<sup>[4](https://www.sciencedirect.com/topics/computer-science/autoencoder)</sup><sup> • </sup><sup>[5](https://mlanthology.org/icml/2008/vincent2008icml-extracting/)</sup>。这一思想具有概率解释：樊尚于2011年证明，简单的去噪自编码器训练准则等价于将特定基于能量的模型的得分与数据的非参数Parzen密度估计器的得分相匹配，这也为绑定编码器和解码器权重提供了依据<sup>[9](https://direct.mit.edu/neco/article-abstract/23/7/1661/7677)</sup>。

**变分自编码器。** 变分自编码器（VAE）由机器学习和统计推断领域的研究者迪德里克·P·金马（Diederik P. Kingma）与[阿姆斯特丹大学](https://www.edgepedia.org/zh/university-of-amsterdam)机器学习教授[马克斯·韦林](https://www.edgepedia.org/zh/max-welling)（Max Welling）提出，将自编码重新表述为含连续潜在变量的有向概率模型中的近似推断。他们2013年的论文引入了一种随机变分推断与学习算法，可扩展至大规模数据集，即使后验难以处理也能工作，其使用了可用标准随机梯度方法优化的变分下界的重参数化<sup>[6](https://arxiv.org/abs/1312.6114)</sup>。VAE优化一个由重构损失（失真）和KL项（率）组成的目标，其中率是互信息的上界，通常被解释为控制压缩程度的正则化项<sup>[10](https://proceedings.mlr.press/v130/bozkurt21a.html)</sup>。

**掩码自编码器。** 掩码自编码器是一种适配视觉变换器的去噪自编码器形式：随机选取的一大部分图像块（约75%）被遮蔽，编码器仅处理可见图像块，轻量解码器从潜在表示和掩码标记重构原始图像。这种非对称设计使训练加速3倍以上，以这种方式预训练的普通ViT-Huge模型在仅使用ImageNet-1K数据的方法中达到了87.8%的准确率<sup>[7](https://openaccess.thecvf.com/content/CVPR2022/papers/He_Masked_Autoencoders_Are_Scalable_Vision_Learners_CVPR_2022_paper.pdf)</sup>。

## 应用

**异常检测。** 无监督异常检测中自编码器的主流方案是在正常数据上训练模型，并以重构误差对测试样本评分：正常输入重构良好，异常输入则不然。在脑部MRI中，这一原理使得通过压缩和恢复健康数据学习到的正常解剖模型能够从错误恢复中标记异常结构，避免了对大量人工分割训练数据的需求，理论上还能检测监督方法可能遗漏的罕见病变<sup>[11](https://www.sciencedirect.com/science/article/pii/S1361841520303169)</sup>。同样的思想被用于检测医学影像中的域偏移，将源训练数据视为正常，将域偏移的测试数据视为异常<sup>[12](https://www.sciencedirect.com/science/article/abs/pii/S1361841521001821)</sup>。

该方案存在已知的弱点。基于 \( \ell_p \) 距离的重构损失不能衡量图像间的感知相似性，使得难以检测语义不同的离群点，而大的 \( \ell_p \) 重构损失可能源于生成建模不佳，而非图像本身是离群点<sup>[13](https://proceedings.mlr.press/v161/somepalli21a/somepalli21a.pdf)</sup>。一项对基于自编码器的脑部MRI方法的比较研究还发现，已发表工作之间的实验设计各异，数据集、分辨率和架构不同，阻碍了有效的比较，并考察了跨扫描仪和站点的域偏移敏感性<sup>[11](https://www.sciencedirect.com/science/article/pii/S1361841520303169)</sup>。

**医学影像。** 一项遵循PRISMA指南的系统综述综合了通过[Web of Science](https://www.edgepedia.org/zh/web-of-science)检索到的118项关于变分自编码器在结构性医学影像中应用的研究。VAE在神经影像学中应用最为广泛，尤其是基于MRI的合成和异常检测，心脏、眼科和肺部影像等其他领域则展现出不同的建模优先方向。所识别的关键挑战包括泛化性有限、训练规格、异构的评估实践以及隐私相关约束<sup>[14](https://www.sciencedirect.com/science/article/pii/S1568494626003613)</sup>。

**其他领域。** 综述文献将自编码器置于机器视觉、自然语言处理、复杂网络、推荐系统、语音处理和异常检测等领域之中<sup>[15](https://link.springer.com/article/10.1007/s10462-023-10662-6)</sup>。在高光谱成像中，自编码器模型被应用于分类、高光谱解混和异常检测<sup>[16](https://www.sciencedirect.com/science/article/pii/S1574013723000515)</sup>。

## 局限与替代方案

核心张力在于重构保真度与表示有用性之间。容量过大的解码器可以忠实地重构输入，而潜在编码几乎不携带有意义的结构<sup>[1](https://www.deeplearningbook.org/contents/autoencoders.html)</sup>。在变分自编码器中，率项的行为有悖直觉：降低其强度在大多数设置下反而改善泛化，而减少互信息通常导致欠拟合，这表明标准球面高斯先验并非通常能改善泛化的归纳偏置<sup>[10](https://proceedings.mlr.press/v130/bozkurt21a.html)</sup>。

表示质量还取决于下游任务。一项从率失真理论视角审视基于自编码器的表示学习的综述指出，关于下游任务的先验知识的多少与所学表示对这些任务的有用程度之间存在明显的权衡<sup>[17](https://arxiv.org/abs/1812.05069)</sup>。在理论上，线性表示设置下，对比学习在特征恢复和域内下游任务两方面均可证明优于标准自编码器和生成对抗网络<sup>[18](https://jmlr.org/beta/papers/v24/21-1501.html)</sup>。

## References

1. [Chapter 14, Autoencoders, Deep Learning (Goodfellow, Bengio, Courville)](https://www.deeplearningbook.org/contents/autoencoders.html)
2. [Autoencoders section, dissertation, Universität zu Lübeck](https://www.zhb.uni-luebeck.de/epubs/ediss2661.pdf)
3. [Hinton, G. E., and Salakhutdinov, R. R. (2006). Reducing the dimensionality of data with neural networks. Science 313(5786):504–507. PubMed](https://pubmed.ncbi.nlm.nih.gov/16873662/)
4. [Autoencoder overview, ScienceDirect Topics](https://www.sciencedirect.com/topics/computer-science/autoencoder)
5. [Vincent, P. et al. (2008). Extracting and Composing Robust Features with Denoising Autoencoders. ICML 2008](https://mlanthology.org/icml/2008/vincent2008icml-extracting/)
6. [Kingma, D. P., and Welling, M. (2013). Auto-Encoding Variational Bayes. arXiv:1312.6114](https://arxiv.org/abs/1312.6114)
7. [He, K. et al. (2022). Masked Autoencoders Are Scalable Vision Learners. CVPR 2022](https://openaccess.thecvf.com/content/CVPR2022/papers/He_Masked_Autoencoders_Are_Scalable_Vision_Learners_CVPR_2022_paper.pdf)
8. [Kunin, D. et al. (2019). Loss Landscapes of Regularized Linear Autoencoders. PMLR 97](https://proceedings.mlr.press/v97/kunin19a/kunin19a.pdf)
9. [Vincent, P. (2011). A Connection Between Score Matching and Denoising Autoencoders. Neural Computation 23(7):1661–1674](https://direct.mit.edu/neco/article-abstract/23/7/1661/7677)
10. [Bozkurt, A. et al. (2021). Rate-Regularization and Generalization in Variational Autoencoders. PMLR 130:3880–3888](https://proceedings.mlr.press/v130/bozkurt21a.html)
11. [Baur, C. et al. (2021). Autoencoders for unsupervised anomaly segmentation in brain MR images: A comparative study. Medical Image Analysis 69](https://www.sciencedirect.com/science/article/pii/S1361841520303169)
12. [Autoencoder based self-supervised test-time adaptation for medical image analysis. Medical Image Analysis](https://www.sciencedirect.com/science/article/abs/pii/S1361841521001821)
13. [Somepalli, G. et al. (2021). Anomaly detection with adversarial mirroring autoencoders (AMA). PMLR 161](https://proceedings.mlr.press/v161/somepalli21a/somepalli21a.pdf)
14. [Variational autoencoders for anatomy-specific insights in medical imaging: A systematic review. Applied Soft Computing 194 (2026)](https://www.sciencedirect.com/science/article/pii/S1568494626003613)
15. [Berahmand, K. et al. (2024). Autoencoders and their applications in machine learning: a survey. Artificial Intelligence Review 57:28](https://link.springer.com/article/10.1007/s10462-023-10662-6)
16. [Integration of hyperspectral imaging and autoencoders: Benefits, applications, hyperparameter tunning and challenges. Computer Science Review](https://www.sciencedirect.com/science/article/pii/S1574013723000515)
17. [Tschannen, M. et al. (2018). Recent Advances in Autoencoder-Based Representation Learning. arXiv:1812.05069](https://arxiv.org/abs/1812.05069)
18. [Ji, W. et al. (2023). The Power of Contrast for Feature Learning: A Theoretical Analysis. JMLR 24(330)](https://jmlr.org/beta/papers/v24/21-1501.html)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Neural networks and deep learning › Neural network architectures › Autoencoder and self-supervised representation architectures

Copyright 2026 Edgepedia

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

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

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