Personalized Layer Selection for Graph Neural Networks

Kartik Sharma, Vineeth Rakesh, Yingtong Dou, Srijan Kumar, Mahashweta Das · DOI

Introduction

Graph Neural Networks (GNNs) have become the standard for learning on graph-structured data. However, a fundamental limitation of traditional GNN architectures is their reliance on a fixed number of message-passing layers for all nodes in a graph. This "one-size-fits-all" approach assumes that the optimal neighborhood size (the number of "hops") is uniform across the entire dataset. In reality, nodes exhibit significant diversity in their local topology. For instance, a node in a highly homophilic cluster may benefit from deep neighborhood aggregation, while a "bridge" node connecting disparate communities may suffer from "oversmoothing" or noise if forced to aggregate information from too many hops.

This paper introduces MetSelect (Metric Selection), a plug-and-play algorithm designed to adaptively select the optimal representation layer for each individual node. By allowing nodes to choose their own "granularity," MetSelect addresses the dual challenges of oversmoothing in deep networks and performance degradation in heterophilic graphs.

Methodology: The MetSelect Framework

MetSelect operates by evaluating the embeddings produced at every layer of a GNN, from the initial feature projection (Layer 0) to the final output (Layer $L$). The selection process is governed by a metric learning approach that identifies which layer provides the most discriminative representation for a given node.

1. Class Prototypes and Metric Learning

For each layer $l \in \{0, \dots, L\}$, the algorithm computes a "class prototype"—the mean embedding of all training nodes belonging to a specific class. To classify a target node, MetSelect calculates the distance between the node's embedding at a given layer and these prototypes.

2. Mahalanobis Distance for Layer Normalization

Comparing embeddings across different layers is non-trivial because the scale and variance of representations change as information propagates. MetSelect utilizes the Mahalanobis distance, which normalizes the distance by the variance of the embeddings at that specific layer. This ensures that the "confidence" of a classification at Layer 2 can be fairly compared to the confidence at Layer 20, despite differences in their embedding spaces.

3. Adaptive Layer Selection

A node is assigned the label of the class prototype to which it is closest across all available layers. This allows the model to "stop" early for nodes where local features are sufficient or to "go deep" for nodes requiring extensive context.

4. Training Objective

The model is trained using a composite loss function that minimizes both the standard cross-entropy loss (using the selected personalized layers) and a distance-based loss that encourages node embeddings to cluster tightly around their respective class prototypes.

Experimental Evaluation

The authors evaluated MetSelect across 10 benchmark datasets, categorized by their homophily levels:

  • Homophilic Graphs: Cora, Citeseer, Pubmed, and ogbn-arxiv (where neighbors tend to share labels).
  • Heterophilic Graphs: Actor, Chameleon, Squirrel, Cornell, Wisconsin, and Texas (where neighbors often have different labels).

MetSelect was integrated into standard architectures, including Graph Convolutional Networks (GCN), Graph Attention Networks (GAT), and Graph Isomorphism Networks (GIN).

Key Insights

Overcoming Heterophily

In heterophilic datasets like Texas or Cornell, standard GNNs often perform poorly because the graph structure introduces noise through dissimilar neighbors. MetSelect naturally mitigates this by frequently selecting Layer 0 (the node's own attributes) for nodes in these graphs, effectively learning when to ignore the graph structure in favor of raw node features.

Enabling Deep GNNs

Traditional GCNs typically experience a sharp decline in performance beyond 2-3 layers due to oversmoothing, where node representations become indistinguishable. MetSelect allows GNNs to scale up to 128 layers without performance degradation. Because each node can select a shallower layer if deep representations become noisy, the network remains stable regardless of total depth.

Structural Robustness

MetSelect provides an inherent defense against adversarial "poisoning" attacks (e.g., Mettack), where edges are added to mislead the classifier. By providing the flexibility to bypass corrupted neighborhood information, GCN+MetSelect maintained a 30-point accuracy lead over vanilla GCNs under heavy attack scenarios.

Results and Conclusion

MetSelect demonstrated significant performance gains, particularly on heterophilic datasets where it improved accuracy by up to 20%. Furthermore, it consistently outperformed other adaptive baselines like NDLSelect and AttnSelect across all tested environments.

While MetSelect introduces some computational overhead (approximately 2.5x training time per epoch), its ability to stabilize deep GNNs and provide robustness against structural noise makes it a powerful tool for complex, real-world graph tasks. Future work may explore more granular selection mechanisms, such as choosing specific motifs or subgraphs, to further refine node representations.

Summary updated

BibTeX
@article{sharma2025personalized,
  author = {Kartik Sharma and Vineeth Rakesh and Yingtong Dou and Srijan Kumar and Mahashweta Das},
  title = {{Personalized Layer Selection for Graph Neural Networks}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2025},
}
Figure