Calibrating and Improving Graph Contrastive Learning

Ma Kaili, Garry Yang, Han Yang, Yongqiang Chen, James ChengTMLR 2023

Abstract

Graph contrastive learning algorithms have demonstrated remarkable success in various applications such as node classification, link prediction, and graph clustering. However, in unsupervised graph contrastive learning, some contrastive pairs may contradict the truths in downstream tasks and thus the decrease of losses on these pairs undesirably harms the performance in the downstream tasks. To assess the discrepancy between the prediction and the ground-truth in the downstream tasks for these contrastive pairs, we adapt expected calibration error (ECE) to graph contrastive learning. The analysis of ECE motivates us to propose a novel regularization method, Contrast-Reg, to ensure that decreasing the contrastive loss leads to better performance in the downstream tasks. As a plug-in regularizer, Contrast-Reg effectively improves the performance of existing graph contrastive learning algorithms. We provide both theoretical and empirical results to demonstrate the effectiveness of Contrast-Reg in enhancing the generalizability of the Graph Neural Network (GNN) model and improving the performance of graph contrastive algorithms with different similarity definitions and encoder backbones across various downstream tasks.

Introduction

Graph Contrastive Learning (GCL) has emerged as a powerful paradigm for unsupervised representation learning on graphs. By maximizing the similarity between different views of the same node (positive pairs) and minimizing it for different nodes (negative pairs), GCL models learn robust embeddings. However, a significant challenge persists: the "misalignment" between the unsupervised contrastive objective and downstream task performance.

The Misalignment Problem

In GCL, positive pairs are often selected based on graph structure (e.g., neighbors or augmented views). Without ground-truth labels, some of these pairs may actually belong to different classes. Minimizing the contrastive loss on such misleading pairs forces the model to learn spurious features, leading to overfitting. This phenomenon is characterized by a disconnect between the model's confidence and its actual accuracy on downstream tasks—a problem known as mis-calibration.

Figure 1(b): ECE and positive sampling accuracy $q^+$ over epochs, showing that as training progresses, calibration error increases while accuracy on genuine positive pairs decreases.

As shown in the figure above, while the training loss might decrease, the Expected Calibration Error (ECE) often rises, and the accuracy of identifying genuine positive pairs ($q^+$) declines. This suggests that the model becomes overconfident in its predictions while losing generalizability.

Proposed Methodology

To address this, the authors introduce two key innovations:

  1. Unsupervised ECE: An adaptation of the supervised ECE metric to the GCL setting, measuring the discrepancy between predicted similarity and ground-truth labels.
  2. Contrast-Reg: A plug-in regularizer that introduces a random anchor vector $r$. It encourages consistent similarity between node representations and this anchor while ensuring that noisy node versions (created via feature shuffling) remain dissimilar. This prevents embedding norms from "exploding" and stabilizes the learning process.

Empirical Evaluation

The effectiveness of Contrast-Reg was evaluated across various benchmarks, including citation networks (Cora, Citeseer, Pubmed) and large-scale graphs (ogbn-arxiv).

Figure 2: The influence of Contrast-Reg on ECE, positive sampling accuracy $q^+$, and embedding norms. Contrast-Reg stabilizes calibration and improves accuracy compared to the unregularized baseline.

The results demonstrate that Contrast-Reg significantly improves performance. For instance, on the Pubmed dataset, GCA with Contrast-Reg achieved 87.06% accuracy, outperforming even supervised GCNs (79.26%). Furthermore, the regularizer consistently reduced ECE across all datasets, confirming its ability to improve model calibration.

Conclusion

Contrast-Reg offers a simple yet effective solution to the calibration problem in graph contrastive learning. By preventing the model from overfitting to spurious features and stabilizing embedding norms, it enhances the generalizability of GNNs across diverse downstream tasks. Its backbone-agnostic nature makes it a versatile tool for improving existing and future GCL algorithms.

Summary updated

BibTeX
@article{kaili2023calibrating,
  author = {MA KAILI and Garry YANG and Han Yang and Yongqiang Chen and James Cheng},
  title = {{Calibrating and Improving Graph Contrastive Learning}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=LdSP6cvTS4},
}
Figure