CNN2GNN: How to Bridge CNN with GNN

Ziheng Jiao, Hongyuan Zhang, Xuelong Li

Abstract

CNN2GNN is a novel framework that bridges the gap between Convolutional Neural Networks (CNNs) and Graph Neural Networks (GNNs) through heterogeneous knowledge distillation. By using a deep CNN as a "teacher" and a lightweight 2-layer GNN as a "student," the framework enables GNNs to inherit intra-sample feature extraction capabilities while leveraging their inherent strength in capturing inter-sample topological relationships. Experimental results on benchmarks like Mini-ImageNet demonstrate that the distilled GNN student can outperform significantly deeper CNN teachers (e.g., ResNet-152) while maintaining high computational efficiency.

Bridging Intra-Sample and Inter-Sample Strengths

Deep learning currently relies heavily on two distinct architectures. CNNs are excellent at extracting "intra-sample" features—such as the texture of a cat's fur or the shape of a car—but require stacking dozens or hundreds of layers, which is computationally expensive. Conversely, GNNs excel at capturing "inter-sample" relationships (how different data points relate to each other) using very few layers. However, GNNs traditionally require a pre-defined graph structure, which images lack, and suffer from high latency during large-scale inference.

Conceptual comparison of CNN intra-sample representation and GNN topological relationship extraction.

CNN2GNN seeks to unify these strengths by answering a fundamental question: How can we bridge these two heterogeneous networks to enjoy the intra-sample strengths of CNNs and the topological strengths of GNNs simultaneously?

The CNN2GNN Framework

The framework consists of two primary components designed to facilitate this transfer of knowledge:

1. Differentiable Sparse Graph Head

Since images do not naturally possess a graph structure, the authors designed a "graph head" that learns one dynamically. This module uses a differentiable mechanism to learn an $s$-sparse graph, where each node connects only to its $s$ most relevant neighbors, preventing the graph from becoming a noisy collection of irrelevant connections. To handle unseen images during testing, the framework employs inductive learning mechanisms that either cascade test images with training batches or use similarity-based approximations to determine the graph structure.

2. Heterogeneous Distillation

The core of the approach is transferring knowledge from a heavy-duty CNN teacher (e.g., ResNet-152 or VGG-19) to a simple 2-layer GNN student. This is achieved through "response-based distillation," where the GNN is trained using a combination of standard cross-entropy and Kullback-Leibler (KL) divergence loss. This forces the GNN to mimic the output probability distributions of the CNN teacher, effectively inheriting its feature-extraction capabilities.

Key Insights and Results

The authors argue that GNNs are inherently more efficient than CNNs because they are "bilinear." While a CNN layer is a linear projection, a GNN layer utilizes both a projection matrix (for features) and a graph-related matrix (for relationships). This allows a 2-layer GNN to represent more complex information than a 2-layer CNN.

Experimental evaluations on datasets like CIFAR-100 and Mini-ImageNet yielded impressive results:

  • Superior Accuracy: On CIFAR-100, a GNN student distilled from a ResNet-34 teacher achieved 65.13% accuracy, outperforming the teacher's 62.19%.
  • Beating the Giants: On Mini-ImageNet, a 2-layer GNN student distilled from a ResNet-152 teacher achieved 60.64% accuracy, significantly higher than the teacher's 50.35%.
  • Efficiency: The GNN student achieves these results with significantly fewer FLOPs (Floating Point Operations) than the teacher models, offering a superior performance-to-efficiency trade-off.

Limitations and Future Work

While CNN2GNN shows great promise, challenges remain regarding inference latency in extremely large-scale scenarios and the computational cost of calculating similarity matrices for very large batches. Future work may extend this framework to other non-graph domains, potentially bridging GNNs with Transformers or other emerging architectures.

Summary updated

BibTeX
@article{jiao2025cnn,
  author = {Ziheng Jiao and Hongyuan Zhang and Xuelong Li},
  title = {{CNN2GNN: How to Bridge CNN with GNN}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2025},
  doi = {10.1109/tpami.2025.3583357},
}
Figure