# 图对比学习

图对比学习（Graph Contrastive Learning, GCL）是一种自监督方法，无需标签即可学习节点或整图的表示。它通过对每个输入创建两个增强视图，在嵌入空间中将匹配视图的表示拉近、将无关样本推远。学习到的嵌入可用于节点级任务（如节点分类）和图级任务（如图分类），该方法是图自监督学习的三大主要流派之一，与生成式和预测式方法并列。<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup><sup> • </sup><sup>[2](https://dl.acm.org/doi/10.1109/TKDE.2021.3131584)</sup>

| 关键事实 | 详情 |
|---|---|
| 输出 | 节点嵌入和/或图嵌入，用于节点分类、图分类、蛋白质功能预测和推荐<sup>[3](https://openreview.net/pdf?id=sq5uaqz6UD)</sup><sup> • </sup><sup>[4](https://arxiv.org/pdf/2109.01116)</sup> |
| 核心目标 | 对正负样本对的 NT-Xent 或 InfoNCE 风格损失；Jensen-Shannon 估计器也很常见<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup><sup> • </sup><sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)</sup> |
| 增强至关重要 | 不做任何增强时，图对比学习往往不如从头训练<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> |
| 典型增益 | GraphCL 使用单一最佳增强，在 NCI1 上比从头训练提升 1.62%，PROTEINS 上提升 3.15%，COLLAB 上提升 6.27%，RDT-B 上提升 1.66%<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> |
| 无负样本选项 | BGRL 完全去除负样本，内存成本降至先前对比方法的 1/2–1/10<sup>[6](https://ar5iv.labs.arxiv.org/html/2102.06514)</sup> |
| 近期理论 | 最小化 InfoNCE 可证明同时最小化与均值表示的相似度，因此负采样起到表示散射的作用<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2024/file/d0ffb35aaa7faa894afe5060c694d674-Paper-Conference.pdf)</sup> |

## 工作原理

GCL 框架为同一输入生成多个视图，\( w_{i} = \mathcal{T}_{i}(A, X) \)，其中 \( A \) 为邻接矩阵，\( X \) 为节点特征；对每个视图编码 \( h_{i} = f_{i}(w_{i}) \)，并最大化视图表示之间成对互信息 \( \mathcal{I}(h_{i}, h_{j}) \) 的加权和。<sup>[8](https://diveintographs.readthedocs.io/en/latest/tutorials/sslgraph.html)</sup> 同一图的两个视图构成正样本对；不同图的视图构成负样本对。实践中，互信息目标以三种下界之一实现：Donsker-Varadhan、Jensen-Shannon 或 InfoNCE 估计器，其中 Jensen-Shannon 和 InfoNCE 在图研究中最为常用。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)</sup>

GraphCL 使用归一化温度缩放交叉熵损失（NT-Xent），相对于负样本对最大化正样本对 \( z_{i}, z_{j} \) 之间的一致性。<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> 更早的 Deep Graph Infomax（DGI）确立了局部-全局模式：它最大化节点（补丁）表示与用图卷积网络架构计算的高层图摘要之间的互信息，无需随机游走，适用于直推式和归纳式任务。<sup>[9](https://research.google/pubs/deep-graph-infomax/)</sup>

## 实现方法

实践流程包含五个步骤。第一，选择增强方式；GraphCL 设计了四类图增强以编码不同的先验。<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> 第二，用图神经网络编码器对两个视图编码；例如 GCC 使用 [GIN](https://www.edgepedia.org/zh/graph-isomorphism-network)，并以归一化图拉普拉斯矩阵的前几个特征向量作为广义位置嵌入。<sup>[10](https://keg.cs.tsinghua.edu.cn/jietang/publications/KDD20-Qiu-et-al-GCC-GNN-pretrain.pdf)</sup> 第三，应用非线性投影头，通常为两层多层感知机，以余弦相似度作为判别器；预训练后移除投影头。<sup>[8](https://diveintographs.readthedocs.io/en/latest/tutorials/sslgraph.html)</sup><sup> • </sup><sup>[11](https://ar5iv.labs.arxiv.org/html/2006.04131)</sup> 第四，用温度参数和小批量中抽取的负样本计算对比损失：GraphCL 将包含 \( N \) 个图的小批量增强为 \( 2N \) 个视图，从其余 \( N - 1 \) 个增强图中取负样本。<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> 第五，冻结编码器训练下游分类器，或端到端微调；GCC 提供两种模式。<sup>[10](https://keg.cs.tsinghua.edu.cn/jietang/publications/KDD20-Qiu-et-al-GCC-GNN-pretrain.pdf)</sup>

超参数的选择通常较为宽松。GRACE 以概率 \( p_{r} \) 移除边、以概率 \( p_{m} \) 掩蔽特征来损坏视图，只要图未被过度损坏（如 \( p_{r} \le 0.8 \) 且 \( p_{m} \le 0.8 \)），性能就不敏感。<sup>[11](https://ar5iv.labs.arxiv.org/html/2006.04131)</sup> 提高温度 \( \tau \) 先提升性能后降低性能，中间波动有限。<sup>[4](https://arxiv.org/pdf/2109.01116)</sup>

标准规则增强池为 NodeDrop、Subgraph、EdgePert、AttrMask 和 Identical。<sup>[12](https://pmc.ncbi.nlm.nih.gov/articles/PMC9130056/)</sup> 一项受控实证研究将 GCL 分解为增强、对比模式、目标和负样本挖掘，发现产生更稀疏图视图的拓扑增强（边移除、节点丢弃、个性化 PageRank、随机游走采样）优于边添加。<sup>[4](https://arxiv.org/pdf/2109.01116)</sup> 节点丢弃和子图采样通常有益，子图强制局部-全局一致性。<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup> MVGRL 的最佳结果来自将邻接矩阵变换为扩散矩阵，而特征空间增强则降低了性能。<sup>[13](https://doi.org/10.48550/arxiv.2006.05582)</sup>

## 起源

视觉领域的先驱是 Deep InfoMax，它通过互信息估计与最大化来学习表示（R Devon Hjelm 及同事，2018，arXiv）。<sup>[14](https://doi.org/10.48550/arxiv.1808.06670)</sup> Deep Graph Infomax 将这一思想迁移到图（Petar Veličković 及同事，2018，arXiv，发表于 ICLR 2019）。<sup>[9](https://research.google/pubs/deep-graph-infomax/)</sup> 2020 年，基于增强的现代浪潮同时从多个团队涌现：GraphCL（Yuning You 及同事，Neural Information Processing Systems 2020）<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup>、GRACE（Yanqiao Zhu 及同事，2020，arXiv）<sup>[15](https://doi.org/10.48550/arxiv.2006.04131)</sup>、MVGRL（Kaveh Hassani 与 Amir Hosein Khasahmadi，2020，arXiv）<sup>[13](https://doi.org/10.48550/arxiv.2006.05582)</sup> 和 GCC（Jiezhong Qiu 及同事，2020，arXiv）。<sup>[16](https://doi.org/10.48550/arxiv.2006.09963)</sup> 随后是 2021–2023 年的变体浪潮。

## 变体

各方法的主要区别在于视图的构造方式和对比的样本对。一篇综述按增强策略、对比模式（尺度内对比与尺度间对比）和目标对该领域进行了组织。<sup>[3](https://openreview.net/pdf?id=sq5uaqz6UD)</sup>

- **GraphCL** 在增强池上用 NT-Xent 对比整图（全局-全局）嵌入。<sup>[3](https://openreview.net/pdf?id=sq5uaqz6UD)</sup>
- **GRACE** 在两个损坏视图间对比节点级嵌入，同时使用视图间和视图内负样本，且不像 DGI 那样对读出函数做单射性假设。<sup>[11](https://ar5iv.labs.arxiv.org/html/2006.04131)</sup>
- **GCA**（Yanqiao Zhu 及同事，2020，arXiv）加入由拓扑和语义先验驱动的自适应增强。<sup>[17](https://doi.org/10.48550/arxiv.2010.14945)</sup>
- **MVGRL** 用两个图神经网络编码器和一个点积判别器对比一阶邻居视图和图扩散结构视图。<sup>[13](https://doi.org/10.48550/arxiv.2006.05582)</sup>
- **SimGRACE**（Jun Xia 及同事，2022，arXiv）将原始图输入图神经网络和同一编码器的扰动副本，无需数据增强即获得两个视图。<sup>[18](https://doi.org/10.48550/arxiv.2202.03104)</sup><sup> • </sup><sup>[19](https://dl.acm.org/doi/10.1145/3485447.3512156)</sup>
- **BGRL**（Shantanu Thakoor 及同事，2021，arXiv）是自举式而非对比式：在线编码器预测由目标编码器（以指数移动平均更新）产生的替代增强的表示，不使用负样本。<sup>[6](https://ar5iv.labs.arxiv.org/html/2102.06514)</sup>
- **JOAO**（Yuning You 及同事，2021，arXiv）通过双层优化选择增强；其后续工作在图生成器的参数空间中以可学习连续先验替代离散增强先验，并以 InfoMin 和 InfoBN 原则正则化。<sup>[20](https://doi.org/10.48550/arxiv.2106.07594)</sup><sup> • </sup><sup>[12](https://pmc.ncbi.nlm.nih.gov/articles/PMC9130056/)</sup>
- 无负样本和特征空间设计包括 Graph Barlow Twins（Piotr Bielak、Tomasz Kajdanowicz 与 Nitesh V. Chawla，2022，Knowledge-Based Systems）<sup>[21](https://doi.org/10.1016/j.knosys.2022.109631)</sup>、COSTA 的协方差保持特征增强（Yifei Zhang 及同事，2022，arXiv）<sup>[22](https://doi.org/10.48550/arxiv.2206.04726)</sup> 和 GraphACL 的无增强非对称方案（Teng Xiao 及同事，2023，arXiv）。<sup>[23](https://doi.org/10.48550/arxiv.2310.18884)</sup>

## 应用

已报告的数据及其条件：GRACE 在蛋白质功能预测上报告约 10 个百分点的绝对提升，其无监督表示在直推式任务上超过有监督对应方法。<sup>[11](https://ar5iv.labs.arxiv.org/html/2006.04131)</sup> MVGRL 在 8 个节点和图分类基准上报告了最先进的线性评估结果。<sup>[13](https://doi.org/10.48550/arxiv.2006.05582)</sup> GraphCL-Automated 学习到的增强先验在 ogbg-ppa 上比手动调优增强提升 +1.33%，在 ogbg-code 上提升 +1.16%。<sup>[12](https://pmc.ncbi.nlm.nih.gov/articles/PMC9130056/)</sup>

应用涵盖药物发现、基因组分析和推荐系统。<sup>[3](https://openreview.net/pdf?id=sq5uaqz6UD)</sup> 在推荐领域，2025 年的一篇综述将视图构造分类为结构、特征和模态生成，并编录了近期变体，包括 LightGCL（Xuheng Cai 及同事，2023，arXiv）、PF-GCL++ 和 XSimGCL。<sup>[24](https://doi.org/10.48550/arxiv.2302.08191)</sup><sup> • </sup><sup>[25](https://link.springer.com/article/10.1007/s11704-025-50044-5)</sup>

## 局限与替代方案

已记录的失败模式包括：领域无关增强导致的假阳性，可能破坏任务相关信息并产生无效样本；在小型基准上，图神经网络的归纳偏置可弥补这种弱判别性，而在基于图的[文档分类](https://www.edgepedia.org/zh/document-classification)中，任务相关增强将准确率提升高达 20%。<sup>[26](https://arxiv.org/pdf/2111.03220)</sup> 其他失败模式包括基于相似度的难负样本挖掘导致的假阴性（被选为难负样本的嵌入可能实际上是正样本）<sup>[4](https://arxiv.org/pdf/2109.01116)</sup>、不使用增强时的坍缩<sup>[1](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)</sup>，以及按数据集通过试错、昂贵搜索或领域知识选择增强的负担，这正是 SimGRACE 的动机。<sup>[19](https://dl.acm.org/doi/10.1145/3485447.3512156)</sup>

可扩展性是结构性约束：视觉对比学习通常每批使用 1K–8K 样本提供负样本，而图框架使用的批次小几个数量级。<sup>[26](https://arxiv.org/pdf/2111.03220)</sup> 存在两条出路。GraphECL 表明，其广义损失只需少量负样本（如 \( M = 5 \)）。<sup>[27](https://par.nsf.gov/servlets/purl/10549103)</sup> BGRL 去除负样本，将内存用量降至原来的 1/2–1/10，可扩展到数亿节点的图，并且是 KDD Cup 2021 开放图基准大规模挑战赛获胜方案的一部分。<sup>[6](https://ar5iv.labs.arxiv.org/html/2102.06514)</sup> 内存仍可能成为瓶颈：GRACE 在 24GB RTX 3090 上对 Co.Physics 运行时内存不足。<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2024/file/d0ffb35aaa7faa894afe5060c694d674-Paper-Conference.pdf)</sup>

最接近的替代方案是[图自编码器](https://www.edgepedia.org/zh/graph-autoencoder)，如 VGAE（Thomas N. Kipf 与 [Max Welling](https://www.edgepedia.org/zh/max-welling)，2016，arXiv）<sup>[28](https://doi.org/10.48550/arxiv.1611.07308)</sup>，以及更广泛的图自监督学习生成式和预测式流派。<sup>[2](https://dl.acm.org/doi/10.1109/TKDE.2021.3131584)</sup> 在对比学习本身内部，自举损失（BYOL 式和 Barlow Twins 式）达到与基于负样本目标相当的性能<sup>[4](https://arxiv.org/pdf/2109.01116)</sup>，BGRL、CCA-SSG 和 LaGraph 推导出带不变性正则化的目标，无需负样本对。<sup>[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)</sup> 一项比较仍未解决：GRACE 自身带视图内负样本的目标在其全部四个数据集上均优于其 InfoNCE 变体<sup>[11](https://ar5iv.labs.arxiv.org/html/2006.04131)</sup>，而受控基准研究发现 InfoNCE 在基于负样本的目标中最佳<sup>[4](https://arxiv.org/pdf/2109.01116)</sup>；已发表结果未能解决这一分歧。关于对比模式，基准研究发现局部-局部对比最适合节点分类，全局-全局对比最适合图级任务<sup>[4](https://arxiv.org/pdf/2109.01116)</sup>，MVGRL 独立发现节点-图跨视图对比强于图-图对比。<sup>[13](https://doi.org/10.48550/arxiv.2006.05582)</sup>

理论也有进展：SGRL 证明下界 \( \mathcal{L}_{\mathrm{InfoNCE}}(h_{i}) \ge \mathrm{sim}(h_{i}, \bar{h}) + \ln(2n) \)，表明最小化 InfoNCE 同时最小化与均值节点表示的相似度，因此负采样等价于表示散射。<sup>[7](https://proceedings.neurips.cc/paper_files/paper/2024/file/d0ffb35aaa7faa894afe5060c694d674-Paper-Conference.pdf)</sup>

## References

1. [Graph Contrastive Learning with Augmentations (GraphCL), NeurIPS 2020](https://proceedings.nips.cc/paper/2020/file/3fe230348e9a12c13120749e3f9fa4cd-Paper.pdf)
2. [Self-Supervised Learning on Graphs: Contrastive, Generative, or Predictive (IEEE TKDE survey)](https://dl.acm.org/doi/10.1109/TKDE.2021.3131584)
3. [A dedicated survey on Graph Contrastive Learning (GCL)](https://openreview.net/pdf?id=sq5uaqz6UD)
4. [An Empirical Study of Graph Contrastive Learning (NeurIPS 2021 Datasets and Benchmarks)](https://arxiv.org/pdf/2109.01116)
5. [Self-Supervised Learning of Graph Neural Networks: A Unified Review](https://pmc.ncbi.nlm.nih.gov/articles/PMC9902037/)
6. [Large-Scale Representation Learning on Graphs via Bootstrapping (BGRL)](https://ar5iv.labs.arxiv.org/html/2102.06514)
7. [Exploitation of a Latent Mechanism in Graph Contrastive Learning: Representation Scattering (SGRL, NeurIPS 2024)](https://proceedings.neurips.cc/paper_files/paper/2024/file/d0ffb35aaa7faa894afe5060c694d674-Paper-Conference.pdf)
8. [Tutorial for Self-Supervised GNNs, DIG documentation](https://diveintographs.readthedocs.io/en/latest/tutorials/sslgraph.html)
9. [Deep Graph Infomax (DGI), publisher page (Google Research / DeepMind, ICLR 2019)](https://research.google/pubs/deep-graph-infomax/)
10. [GCC: Graph Contrastive Coding for Graph Neural Network Pre-Training (KDD 2020)](https://keg.cs.tsinghua.edu.cn/jietang/publications/KDD20-Qiu-et-al-GCC-GNN-pretrain.pdf)
11. [Deep Graph Contrastive Representation Learning (GRACE), 2020 (ICML 2020 version)](https://ar5iv.labs.arxiv.org/html/2006.04131)
12. [Bringing Your Own View: Graph Contrastive Learning without Prefabricated Data Augmentations (GraphCL-Automated / JOAO lineage)](https://pmc.ncbi.nlm.nih.gov/articles/PMC9130056/)
13. [Hassani, Kaveh, Khasahmadi, Amir Hosein (2020). Contrastive Multi-View Representation Learning on Graphs. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2006.05582)
14. [Hjelm, R Devon and colleagues (2018). Learning deep representations by mutual information estimation and maximization. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1808.06670)
15. [Zhu, Yanqiao and colleagues (2020). Deep Graph Contrastive Representation Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2006.04131)
16. [Qiu, Jiezhong and colleagues (2020). GCC: Graph Contrastive Coding for Graph Neural Network Pre-Training. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2006.09963)
17. [Zhu, Yanqiao and colleagues (2020). Graph Contrastive Learning with Adaptive Augmentation. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2010.14945)
18. [Xia, Jun and colleagues (2022). SimGRACE: A Simple Framework for Graph Contrastive Learning without Data Augmentation. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2202.03104)
19. [SimGRACE: A Simple Framework for Graph Contrastive Learning without Data Augmentation (WWW 2022)](https://dl.acm.org/doi/10.1145/3485447.3512156)
20. [You, Yuning and colleagues (2021). Graph Contrastive Learning Automated. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2106.07594)
21. [Piotr Bielak, Tomasz Kajdanowicz, Nitesh V. Chawla (2022). Graph Barlow Twins: A self-supervised representation learning framework for graphs. Knowledge-Based Systems.](https://doi.org/10.1016/j.knosys.2022.109631)
22. [Zhang, Yifei and colleagues (2022). COSTA: Covariance-Preserving Feature Augmentation for Graph Contrastive Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2206.04726)
23. [Xiao, Teng and colleagues (2023). Simple and Asymmetric Graph Contrastive Learning without Augmentations. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2310.18884)
24. [Cai, Xuheng and colleagues (2023). LightGCL: Simple Yet Effective Graph Contrastive Learning for Recommendation. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2302.08191)
25. [Graph contrastive learning view construction methods in recommender systems: a survey (Frontiers of Computer Science, 2025)](https://link.springer.com/article/10.1007/s11704-025-50044-5)
26. [Augmentations in Graph Contrastive Learning: Current Methodological Flaws & Towards Better Practices](https://arxiv.org/pdf/2111.03220)
27. [Efficient Contrastive Learning for Fast and Accurate Inference on Graphs (GraphECL)](https://par.nsf.gov/servlets/purl/10549103)
28. [Kipf, Thomas N., Welling, Max (2016). Variational Graph Auto-Encoders. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1611.07308)

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

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/graph-contrastive-learning

English original: https://www.edgepedia.org/graph-contrastive-learning
