Towards Robust Graph Contrastive Learning

Nikola Jovanovic, Zhao Meng, Lukas Faber, Roger WattenhoferarXiv 2021

Abstract

We study the problem of adversarially robust self-supervised learning on graphs. In the contrastive learning framework, we introduce a new method that increases the adversarial robustness of the learned representations through i) adversarial transformations and ii) transformations that not only remove but also insert edges. We evaluate the learned representations in a preliminary set of experiments, obtaining promising results. We believe this work takes an important step towards incorporating robustness as a viable auxiliary task in graph contrastive learning.

Introduction

Graph Neural Networks (GNNs) have demonstrated remarkable performance across various domains, yet they remain notoriously fragile to adversarial perturbations. Small, often imperceptible changes to a graph's structure—such as the strategic addition or removal of edges—can lead to significant degradation in model performance. This vulnerability is a critical barrier to deploying GNNs in safety-critical applications like fraud detection or autonomous systems.

While self-supervised Contrastive Learning has emerged as a powerful paradigm for learning graph representations without labels, most existing methods (e.g., GRACE, GCA) rely on random perturbations like stochastic edge dropping. These "easy" perturbations fail to prepare models for the targeted, malicious attacks encountered in real-world scenarios. To address this, we propose GROC (Graph Robust Contrastive Learning), a framework that integrates adversarial transformations directly into the self-supervised loop.

Methodology: The GROC Framework

GROC moves beyond random noise by using gradient signals to identify and manipulate structural vulnerabilities during training. The process for each training batch follows three primary steps:

  1. Stochastic Masking: The process begins with standard random feature masking to generate two initial views of the graph.
  2. Gradient-Based Search: A preliminary forward-backward pass is performed to calculate the "gradient intensity" of edges. This identifies which structural changes would most significantly increase the contrastive loss.
  3. Adversarial Transformation:
    • Adversarial Removal: Instead of random dropping, GROC removes edges with the minimal gradient values—those that most strongly support the current representation.
  4. Adversarial Insertion: Crucially, GROC also adds edges that maximize the loss. To maintain computational efficiency, potential edges are only considered between "anchor nodes" and their multi-hop neighbors.
Overview of the GROC framework illustrating stochastic and adversarial transformations to generate difficult views for contrastive learning.

By forcing the model to maintain consistent representations even under these "hard" structural changes, the resulting embeddings become significantly more resilient to adversarial manipulation.

Experimental Evaluation

We evaluated GROC on five standard transductive node classification benchmarks: Cora, Citeseer, Pubmed (citation networks), AmazonPhoto (co-purchase graph), and WikiCS (hyperlink graph). We utilized the Nettack threat model—a common targeted gray-box attack—to test the "robust accuracy" of the models under varying perturbation budgets (ranging from 1 to 5 changes per node).

Key Results

GROC consistently outperformed both supervised GCNs and state-of-the-art self-supervised baselines in robust accuracy across all datasets.

Robust accuracy comparison on Cora, Citeseer, and Pubmed datasets under varying perturbation budgets.
  • Superior Robustness: On the Cora dataset, under a perturbation budget of 5, GROC achieved 37.5% robust accuracy, significantly higher than standard contrastive methods like GRACE (23.5%) and even supervised GCNs (26.0%).
  • The Importance of Insertion: Ablation studies showed that the "GRACE-ADV" variant (adversarial removal only) performed better than random methods but worse than the full GROC model, confirming that adversarial edge insertion is a vital component of structural robustness.
  • Stability: While GROC occasionally exhibits a slight trade-off in standard accuracy, it provides a much flatter decay curve as attack intensity increases, demonstrating superior stability.

Conclusion and Future Work

GROC demonstrates that adversarial robustness can be effectively treated as a self-supervised pre-training task. By leveraging the gradient of the contrastive loss, we can identify and harden structural weaknesses without requiring labeled data.

Future research will focus on reducing the computational overhead associated with the extra forward-backward passes and extending the evaluation to inductive settings and a broader range of attack strategies, such as RL-S2V or Meta-Attack. This work represents a significant step toward developing GNNs that are both data-efficient and secure against adversarial threats.

Summary updated

BibTeX
@misc{jovanovic2021towards,
  author = {Nikola Jovanovic and Zhao Meng and Lukas Faber and Roger Wattenhofer},
  title = {{Towards Robust Graph Contrastive Learning}},
  year = {2021},
  eprint = {2102.13085},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.13085},
}
Figure