# 图自编码器

图自编码器（graph autoencoder, GAE）是一种神经网络，它将图结构数据编码为低维节点嵌入，并据此重构图的邻接矩阵（记录哪些节点对之间存在连接的表格），从而为节点聚类、链接预测等任务提供无监督学习目标。变分图自编码器（variational graph auto-encoder, VGAE）由托马斯·N·基普夫（Thomas N. Kipf）和[马克斯·韦林](https://www.edgepedia.org/zh/max-welling)（Max Welling）于2016年在一篇arXiv论文中提出，并在NIPS贝叶斯深度学习研讨会上作了报告，它是同一思想的概率形式；该论文摘要开篇写道：“我们提出变分图自编码器（VGAE），一个用于图结构数据无监督学习的框架”。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> 作者的代码仓库将GAE描述为“用于图上无监督学习、聚类和链接预测的端到端可训练神经网络模型”。<sup>[2](https://github.com/tkipf/gae/)</sup> 两种模型都产出节点嵌入和重构邻接矩阵；嵌入用于聚类，重构概率则用于给候选边打分。<sup>[2](https://github.com/tkipf/gae/)</sup>

| 关键事实 | 详情 |
|---|---|
| 输出 | 节点嵌入 \( Z \) 与重构邻接矩阵 \( \hat{A} = \sigma(Z \cdot Z^{T}) \) <sup>[1](https://arxiv.org/abs/1611.07308)</sup> |
| 编码器 | 两层图卷积网络（GCN）；VGAE输出高斯后验 \( q(z_i \mid X,A) = \mathcal{N}(z_i \mid \mu_i, \mathrm{diag}(\sigma_i^2)) \) <sup>[1](https://arxiv.org/abs/1611.07308)</sup> |
| 解码器 | 内积：\( p(A_{ij}=1 \mid z_i, z_j) = \sigma(z_i^{T} \cdot z_j) \) <sup>[1](https://arxiv.org/abs/1611.07308)</sup> |
| 损失 | 加权交叉熵重构（GAE）或变分下界（VGAE）<sup>[1](https://arxiv.org/abs/1611.07308)</sup><sup> • </sup><sup>[3](https://grlearning.github.io/papers/73.pdf)</sup> |
| 原始基准（AUC/AP） | VGAE 91.4/92.6（Cora）、90.8/92.0（Citeseer）、94.4/94.7（Pubmed）；GAE 91.0/92.0、89.5/89.9、96.4/96.5 <sup>[1](https://arxiv.org/abs/1611.07308)</sup> |
| 评估协议 | 5%的引用链接用于验证，10%用于测试，并加入等量的随机非边 <sup>[1](https://arxiv.org/abs/1611.07308)</sup> |
| 当前范式 | 掩码图建模（GraphMAE、MaskGAE及其后继）是原始邻接重构的一种替代方案 <sup>[4](https://ar5iv.labs.arxiv.org/html/2205.10803)</sup> |

## 工作原理

该模型将图视为待压缩和重构的数据。编码器将节点特征 \( X \) 和邻接矩阵 \( A \) 映射为嵌入，每个节点一个；解码器根据嵌入为每一对节点之间存在连接的可能性打分。在原始VGAE中，编码器是一个两层GCN，\( \mathrm{GCN}(X,A) = \tilde{A}\, \mathrm{ReLU}(\tilde{A} \cdot X \cdot W_0) \cdot W_1 \)，其中 \( \tilde{A} = D_{+}^{-1/2} \cdot (A+I) \cdot D_{+}^{-1/2} \)，\( D_{+} \) 是 \( A+I \) 的度矩阵，两个并行的GCN分别产生后验均值 \( \mu \) 和对数标准差 \( \log \sigma \)。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> 解码器是经逻辑Sigmoid函数的内积，\( p(A_{ij}=1 \mid z_i, z_j) = \sigma(z_i^{T} \cdot z_j) \)。<sup>[1](https://arxiv.org/abs/1611.07308)</sup>

非概率的GAE是确定性特例：\( Z = \mathrm{GCN}(X,A) \) 且 \( \hat{A} = \sigma(Z \cdot Z^{T}) \)。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> 训练采用交叉熵重构损失（原论文对正边项加权更重；下式展示的是未加权形式），

\[ \mathcal{L}^{\mathrm{AE}} = -\frac{1}{n^2} \sum_{(i,j)} \left[ A_{ij} \log \hat{A}_{ij} + (1-A_{ij}) \log (1-\hat{A}_{ij}) \right], \]

或者，对于VGAE，采用证据下界（ELBO），训练时最大化

\[ \mathcal{L} = \mathbb{E}_{q(Z \mid X,A)}[\log p(A \mid Z)] - \mathrm{KL}\left[ q(Z \mid X,A) \,\|\, p(Z) \right] \]

其先验为标准高斯 \( p(Z) = \prod_i \mathcal{N}(z_i \mid 0, I) \)。<sup>[1](https://arxiv.org/abs/1611.07308)</sup><sup> • </sup><sup>[3](https://grlearning.github.io/papers/73.pdf)</sup>

## 实现方式

在实践中，使用PyTorch Geometric实现时：构建一个GCN（或其他GNN）编码器，在未指定解码器时挂载默认的InnerProductDecoder，然后用提供的重构损失进行训练。<sup>[5](https://pytorch-geometric.readthedocs.io/en/stable/generated/torch_geometric.nn.models.GAE.html)</sup> 由于真实邻接矩阵极度稀疏，损失被零项主导；原论文对 \( A_{ij}=1 \) 的项重新加权，或者对 \( A_{ij}=0 \) 的项进行子采样。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> PyG的`recon_loss`在正边和负边上计算二元交叉熵，当未提供负样本时对正边索引调用`negative_sampling`。<sup>[6](https://pytorch-geometric.readthedocs.io/en/latest/_modules/torch_geometric/nn/models/autoencoder.html)</sup> 对于VGAE，重参数化为 \( z = \mu + \epsilon \cdot \exp(\mathrm{logstd}) \)，其中 \( \epsilon \sim \mathcal{N}(0,I) \)，对数标准差被截断在10。<sup>[6](https://pytorch-geometric.readthedocs.io/en/latest/_modules/torch_geometric/nn/models/autoencoder.html)</sup> 评估报告留出边上的AUC和平均精度。<sup>[5](https://pytorch-geometric.readthedocs.io/en/stable/generated/torch_geometric.nn.models.GAE.html)</sup>

## 起源

图自编码器由托马斯·N·基普夫（Thomas N. Kipf）和马克斯·韦林（Max Welling）于2016年在一篇arXiv论文中提出，该论文在NIPS贝叶斯深度学习研讨会上报告，引入了变分图自编码器（VGAE）。<sup>[7](https://doi.org/10.48550/arxiv.1611.07308)</sup> 它建立在变分自编码器一系列工作之上，特别是达尼洛·希门尼斯·雷森德（Danilo Jimenez Rezende）、沙基尔·穆罕默德（Shakir Mohamed）和达安·维尔斯塔（Daan Wierstra）关于深度生成模型随机反向传播的工作（2014年，arXiv）<sup>[8](https://doi.org/10.48550/arxiv.1401.4082)</sup>，以及作者自己的图卷积网络工作（2016年，arXiv）。<sup>[9](https://doi.org/10.48550/arxiv.1609.02907)</sup>

## 变体

潘世瑞（Shirui Pan）及其同事提出的对抗正则化图自编码器（ARGA/ARVGA，2018）针对的观察是：普通图自编码器对潜在分布不加任何限制，这可能导致嵌入质量不佳；一个判别器施加高斯先验。<sup>[10](https://doi.org/10.48550/arxiv.1802.04407)</sup><sup> • </sup><sup>[11](https://arxiv.org/pdf/1908.04003)</sup> SIG-VAE（阿尔曼·哈桑扎德（Arman Hasanzadeh）及其同事，2019）用半隐式非高斯后验替代高斯后验，以捕捉重尾、偏度和多峰性，并在解码器中采用伯努利-泊松链接函数。<sup>[12](https://doi.org/10.48550/arxiv.1908.07078)</sup><sup> • </sup><sup>[13](https://proceedings.neurips.cc/paper/2019/file/fd4771e85e1f916f239624486bff502d-Paper.pdf)</sup> GALA重构节点特征而非邻接矩阵，使用基于拉普拉斯锐化的解码器，这是编码器拉普拉斯平滑的对偶操作；这对抗了过平滑问题，并使解码器可学习，而重构邻接矩阵的VGAE和ARVGA无法做到这一点。<sup>[14](https://ar5iv.labs.arxiv.org/html/1908.02441)</sup> BGAE/BVGAE用Barlow-Twins风格的损失 \( \mathcal{L} = \mathcal{L}_{\mathrm{recon}} + \beta \cdot \mathcal{L}_{\mathrm{cov}} \) 最小化嵌入分量之间的冗余，但该方法仅限于高度同质性的网络，因为它依赖的图扩散仅在此类网络上表现良好。<sup>[15](https://arxiv.org/pdf/2110.15742)</sup> 线性图自编码器用一跳线性编码器 \( Z = \tilde{A} \cdot W \) 替代GCN。<sup>[3](https://grlearning.github.io/papers/73.pdf)</sup>

## 应用

作者记录的早期下游应用包括大规模关系数据中的链接预测（施利希特克鲁尔（Schlichtkrull）、基普夫及其同事，2017）和带辅助信息的推荐矩阵补全（伯格（Berg）等，2017）。<sup>[2](https://github.com/tkipf/gae/)</sup> 原始实验中使用的Cora、Citeseer和Pubmed引用图已成为图自编码器事实上的基准。<sup>[3](https://grlearning.github.io/papers/73.pdf)</sup> 在原始协议下，VGAE在Cora上达到AUC/AP 91.4/92.6，Citeseer上90.8/92.0，Pubmed上94.4/94.7；GAE分别达到91.0/92.0、89.5/89.9和96.4/96.5。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> 加入输入特征有显著帮助：不加特征时，VGAE在Cora上得分为84.0/87.7，与无特征谱聚类（84.6/88.5）和DeepWalk（83.1/85.0）处于同一区间。<sup>[1](https://arxiv.org/abs/1611.07308)</sup> 后续改进在可比协议下报告了增益：RWR-GAE加入随机游走正则化使潜在表示捕捉局部拓扑，在Cora上达到92.9/92.7，在Citeseer上达到92.1/91.5。<sup>[11](https://arxiv.org/pdf/1908.04003)</sup> 具体到链接预测，生成式（重构邻接矩阵的）模型往往优于对比方法，GraphMAE是个例外，因为图重构与下游任务对齐。<sup>[16](https://arxiv.org/html/2403.14340)</sup>

## 局限与替代方案

标准GAE过度强调邻近性信息而牺牲了结构性信息，这限制了在链接预测之外任务上的表现。由于大多数GAE以链接重构为目标，它们擅长链接预测和节点聚类，但在节点和图分类上不尽如人意。<sup>[4](https://ar5iv.labs.arxiv.org/html/2205.10803)</sup> 原始特征重构目标不包含均匀性正则化，因此允许平凡捷径，如常数映射作为最优解。<sup>[17](https://arxiv.org/html/2410.10241v1)</sup> 特征重构变体有其自身的失效模式：GraphMAE风格模型容易发生特征平滑，即相邻节点获得相似的重构特征，且它们缺失全局图信息，损害节点和图分类<sup>[18](https://ar5iv.labs.arxiv.org/html/2310.15523)</sup>；GraphMAE本身在链接预测上表现不佳，因为仅重构节点特征会降低链接级任务的性能。<sup>[18](https://ar5iv.labs.arxiv.org/html/2310.15523)</sup>

可扩展性受限于内积解码器，其 \( Z \) 与 \( Z^{T} \) 相乘导致二次 \( O(dn^2) \) 复杂度；一种补救方案是每次迭代重构10,000个节点的随机子图。<sup>[3](https://grlearning.github.io/papers/73.pdf)</sup> 基于GCN的GAE还因全批量训练而内存密集；LoNGAE风格的小批量训练可保持内存恒定。<sup>[19](https://ar5iv.labs.arxiv.org/html/1802.08352)</sup> 编码器的选择没有想象的那么重要：线性编码器可证明比非线性（ReLU/GCN）编码器对GAE具有更强的表示能力，且除相对稠密的图外，经验上也与之匹敌。<sup>[3](https://grlearning.github.io/papers/73.pdf)</sup><sup> • </sup><sup>[20](https://arxiv.org/html/2211.01858)</sup>

主要的替代方案是对比方法，如DGI、GRACE和GCA，它们使用Jensen-Shannon或InfoNCE风格的目标而非重构<sup>[21](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)</sup>，以及掩码图自编码器。GraphMAE用掩码令牌遮罩输入节点特征，编码损坏的图，重新掩码潜在编码，用GNN而非MLP解码，并用缩放余弦误差重构特征；需要大的掩码比例（约50%）以减少属性图中的冗余。<sup>[4](https://ar5iv.labs.arxiv.org/html/2205.10803)</sup> MaskGAE用边级和路径级策略遮罩一部分边并重构缺失结构；它还证明了图自编码器本质上是对比学习方法，冗余度几乎随重叠子图的大小线性增长。2024年一项通过对比学习视角对GAE的基准评估得出结论：掩码GAE在特征层面（GraphMAE）和结构层面（MaskGAE）都比原始GAE更强大，且基于结构的GAE在引用基准上通常表现最佳。<sup>[17](https://arxiv.org/html/2410.10241v1)</sup>

## References

1. [Variational Graph Auto-Encoders (Kipf & Welling, 2016)](https://arxiv.org/abs/1611.07308)
2. [tkipf/gae, Implementation of Graph Auto-Encoders in TensorFlow](https://github.com/tkipf/gae/)
3. [Keep It Simple: Graph Autoencoders Without Graph Convolutional Networks (Salha, Hennequin, Vazirgiannis)](https://grlearning.github.io/papers/73.pdf)
4. [GraphMAE: Self-Supervised Masked Graph Autoencoders (Hou et al., KDD 2022)](https://ar5iv.labs.arxiv.org/html/2205.10803)
5. [torch_geometric.nn.models.GAE documentation](https://pytorch-geometric.readthedocs.io/en/stable/generated/torch_geometric.nn.models.GAE.html)
6. [torch_geometric.nn.models.autoencoder source code](https://pytorch-geometric.readthedocs.io/en/latest/_modules/torch_geometric/nn/models/autoencoder.html)
7. [Kipf, Thomas N., Welling, Max (2016). Variational Graph Auto-Encoders. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1611.07308)
8. [Rezende, Danilo Jimenez, Mohamed, Shakir, Wierstra, Daan (2014). Stochastic Backpropagation and Approximate Inference in Deep Generative Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1401.4082)
9. [Kipf, Thomas N., Welling, Max (2016). Semi-Supervised Classification with Graph Convolutional Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1609.02907)
10. [Pan, Shirui and colleagues (2018). Adversarially Regularized Graph Autoencoder for Graph Embedding. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1802.04407)
11. [RWR-GAE: Random Walk Regularized Graph Auto Encoder](https://arxiv.org/pdf/1908.04003)
12. [Hasanzadeh, Arman and colleagues (2019). Semi-Implicit Graph Variational Auto-Encoders. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1908.07078)
13. [Semi-Implicit Graph Variational Auto-Encoders (SIG-VAE), NeurIPS 2019](https://proceedings.neurips.cc/paper/2019/file/fd4771e85e1f916f239624486bff502d-Paper.pdf)
14. [Symmetric Graph Convolutional Autoencoder for Unsupervised Graph Representation Learning (GALA, CIKM 2019)](https://ar5iv.labs.arxiv.org/html/1908.02441)
15. [Barlow Graph Auto-Encoder (BGAE/BVGAE)](https://arxiv.org/pdf/2110.15742)
16. [Exploring Task Unification in Graph Representation Learning via Generative Approach (GA²E, 2024)](https://arxiv.org/html/2403.14340)
17. [Revisiting and Benchmarking Graph Autoencoders: A Contrastive Learning Perspective (lrGAE, 2024)](https://arxiv.org/html/2410.10241v1)
18. [Generative and Contrastive Paradigms Are Complementary for Graph Self-Supervised Learning (GCMAE)](https://ar5iv.labs.arxiv.org/html/2310.15523)
19. [Learning to Make Predictions on Graphs with Autoencoders (LoNGAE / alphaLoNGAE)](https://ar5iv.labs.arxiv.org/html/1802.08352)
20. [Relating graph auto-encoders to linear models](https://arxiv.org/html/2211.01858)
21. [Self-Supervised Learning of Graph Neural Networks: A Unified Review (IEEE TKDE)](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)

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

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

Copyright 2026 Edgepedia

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

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

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