Similarity of Neural Architectures Based on Input Gradient Transferability

Jaehui Hwang, Dongyoon Han, Byeongho Heo, Song Park, Sanghyuk Chun, Jong-Seok Lee

Abstract

In this paper, we aim to design a quantitative similarity function between two neural architectures. Specifically, we define a model similarity using input gradient transferability. We generate adversarial samples of two networks and measure the average accuracy of the networks on adversarial samples of each other. If two networks are highly correlated, then the attack transferability will be high, resulting in high similarity. Using the similarity score, we investigate two topics: (1) Which network component contributes to the model diversity? (2) How does model diversity affect practical scenarios? We answer the first question by providing feature importance analysis and clustering analysis. The second question is validated by two different scenarios: model ensemble and knowledge distillation. Our findings show that model diversity takes a key role when interacting with different neural architectures. For example, we found that more diversity leads to better ensemble performance. We also observe that the relationship between teacher and student networks and distillation performance depends on the choice of the base architecture of the teacher and student networks. We expect our analysis tool helps a high-level understanding of differences between various neural architectures as well as practical guidance when using multiple architectures.

Introduction

The rapid evolution of deep learning has produced a vast library of neural architectures, from standard ResNets to Vision Transformers (ViT) and MLP-Mixers. However, the community lacks a robust, scalable way to measure how "different" these models actually are. While two models might achieve similar top-1 accuracy on ImageNet, their internal representations and decision boundaries may vary wildly. Understanding this diversity is crucial for tasks like model ensembling, where combining redundant models yields diminishing returns.

Previous methods for quantifying similarity, such as comparing internal representations or loss surfaces, are often computationally prohibitive or restricted to models with identical structures. This paper introduces Similarity by Attack Transferability (SAT), a model-agnostic, quantitative metric designed to measure architectural diversity at scale.

Methodology: Similarity by Attack Transferability (SAT)

The core intuition behind SAT is that if an adversarial attack designed to fool Model A also successfully fools Model B, the two models likely share similar input gradients and decision boundaries.

To calculate the SAT score, the authors generate adversarial samples using the Projected Gradient Descent (PGD) attack for both models. They then measure the "transfer success rate"—the frequency with which an attack on one model succeeds against the other. The final SAT score is defined as the logarithm of this average success rate. To ensure a fair comparison, the authors applied this metric to 69 state-of-the-art models from the timm library, all maintaining ImageNet top-1 accuracies between 79% and 83%.

What Drives Architectural Diversity?

By mapping 13 different architectural components to SAT scores using a gradient boosting regressor, the study identifies which design choices most significantly impact a model's behavior.

Permutation importance of architectural components in determining model similarity.

The results highlight a clear hierarchy: Macro over Micro. The "Base Architecture" (e.g., CNN vs. Transformer) and the "Stem Layer" (the initial layers that process raw pixels) are the dominant factors in model similarity. In contrast, "micro" tweaks such as the specific activation function (ReLU vs. GeLU) or the choice between standard and depthwise convolutions have a negligible impact on the model's fundamental vulnerabilities. Essentially, the way a model initially "patchifies" or downsamples an image sets a trajectory for its decision boundaries.

Mapping the Model Landscape

Using spectral clustering on SAT scores, the researchers grouped the 69 models into 10 distinct clusters. These clusters align closely with architectural families, such as non-hierarchical Transformers (ViT, DeiT), ResNets, and NAS-based models.

Visualization of architectural similarity clusters for 69 state-of-the-art models.

This taxonomy reveals that designing a new architecture is far more effective for achieving diversity than simply re-training an existing one with different hyper-parameters or random seeds. SAT serves as a reliable and computationally efficient proxy for measuring distances between decision boundaries, proving roughly 5x faster than previous direct measurement methods.

Practical Implications

Model Ensembling

The study found a strong negative correlation (-0.32) between SAT scores and ensemble gains. This confirms a practical rule of thumb: the more diverse (less similar) two models are according to the SAT metric, the better they perform when combined in an ensemble. Diversity allows models to compensate for each other's unique vulnerabilities.

Knowledge Distillation (KD)

The relationship between similarity and KD performance is more nuanced. When the teacher and student share the same base architecture (e.g., Transformer to Transformer), higher similarity generally leads to better performance. However, when they differ (e.g., a CNN teacher and a Transformer student), lower similarity—or higher diversity—actually benefits the student, likely because the structural discrepancy acts as a form of regularization.

Conclusion

SAT provides a scalable framework for understanding the landscape of modern neural architectures. By focusing on input gradient transferability, it reveals that high-level design choices like the stem layer define a model's identity more than specific layer-wise configurations. This metric offers practical guidance for practitioners looking to optimize ensembles or select effective teacher-student pairs for distillation.

Summary updated

Abstract

In this paper, we aim to design a quantitative similarity function between two neural architectures. Specifically, we define a model similarity using input gradient transferability. We generate adversarial samples of two networks and measure the average accuracy of the networks on adversarial samples of each other. If two networks are highly correlated, then the attack transferability will be high, resulting in high similarity. Using the similarity score, we investigate two topics: (1) Which network component contributes to the model diversity? (2) How does model diversity affect practical scenarios? We answer the first question by providing feature importance analysis and clustering analysis. The second question is validated by two different scenarios: model ensemble and knowledge distillation. Our findings show that model diversity takes a key role when interacting with different neural architectures. For example, we found that more diversity leads to better ensemble performance. We also observe that the relationship between teacher and student networks and distillation performance depends on the choice of the base architecture of the teacher and student networks. We expect our analysis tool helps a high-level understanding of differences between various neural architectures as well as practical guidance when using multiple architectures.
BibTeX
@inproceedings{hwang2024similarity,
  author = {Jaehui Hwang and Dongyoon Han and Byeongho Heo and Song Park and Sanghyuk Chun and Jong-Seok Lee},
  title = {{Similarity of Neural Architectures Based on Input Gradient Transferability}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  url = {https://openreview.net/forum?id=757eURYlAS},
}
Figure