Input Similarity from the Neural Network Perspective

Guillaume Charpiat, Nicolas Girard, Loris Felardos, Yuliya TarabalkaNeurIPS 2019

Introduction: The Problem with Standard Similarity

How do we define if two images are "similar" to a neural network? Standard metrics like the $L^2$ (pixel-wise) distance are notoriously unreliable; a simple one-pixel shift can result in a massive $L^2$ difference, even if the images look identical to a human observer. To bypass this, researchers often use "perceptual losses"—comparing the internal activations of a pre-trained network like VGG. However, this approach is somewhat arbitrary. Why should we use VGG's learned features to explain an entirely different model's behavior?

This paper argues that similarity should be intrinsic to the specific model being analyzed. Instead of relying on black-box interpretations or external models, the authors quantify exactly how a network's internal parameters link two different inputs. This intrinsic perspective is crucial for understanding complex model behaviors, such as why networks can sometimes learn perfectly even when trained on highly noisy or corrupted datasets.

Methods: Defining Similarity Through Influence

The authors define similarity through the lens of influence. The core question is: If you were to nudge the network's parameters $\theta$ to change the output for input $A$, how much would the output for input $B$ move?

Conceptual illustration of gradient-based similarity, showing how parameter updates for one data point influence others.

To formalize this, they introduce several key concepts:

  1. The Gradient Kernel: They define a kernel $k^I_\theta(x, x')$ as the inner product of the gradients: $\nabla_\theta f_\theta(x) \cdot \nabla_\theta f_\theta(x')$. This measures how aligned the parameter updates are for two different inputs.
  2. Correlation Similarity: To make this metric intuitive and scale-invariant, they normalize the gradient kernel into a correlation measure (the cosine similarity of gradients), bounding the value between -1 and 1.
  3. Higher Dimensions: For multi-output models (like 2D image registration), they extend this concept to a $d \times d$ matrix. This matrix is closely related to the Neural Tangent Kernel (NTK) and describes how movements in different output directions are coupled.
  4. Fast Density Estimation: Computing this across a whole dataset is traditionally expensive. The authors provide a clever mathematical trick to compute the "number of neighbors" for every point in a dataset in just two passes (an $O(|D|p)$ complexity), making large-scale analysis feasible.

Key Insights: The "Aha" Moment on Denoising

One of the most compelling applications of this similarity measure is explaining the "self-denoising" phenomenon—why networks can outperform their own noisy training labels.

Because the network perceives many points as "similar" (according to its gradient kernel), it effectively averages the noisy labels over those local neighborhoods during training. If the label noise is zero-mean, this averaging process cancels out the noise, allowing the model to converge on the true underlying signal.

Furthermore, the authors observe fascinating training dynamics. As training progresses, the network's perceived "neighborhoods" evolve. In later epochs, the network becomes better at distinguishing fine-grained features, effectively shrinking the similarity radius between distinct but visually similar patches.

Key Results

The intrinsic similarity measure yields impressive practical results across several domains:

  • Self-Denoising in Action: In a multimodal image registration task (aligning satellite images to maps using OpenStreetMap data), the model started with noisy ground truth labels having a median error of 18 pixels. By iteratively training and using its own "perceived similarity" to average out noise, the error plummeted to just 3.5 pixels—essentially reaching human-level accuracy despite the flawed initial data.
  • Superior Retrieval: The proposed similarity measure significantly outperformed standard VGG-based perceptual loss in retrieving semantically similar images. For example, it successfully grouped similar residential areas that traditional perceptual losses failed to connect.
Examples of image retrieval using the proposed similarity measure, successfully grouping semantically similar residential areas based on the network's intrinsic perspective.
  • Quantifiable Uncertainty: The norm of the gradient kernel serves as a reliable proxy for prediction uncertainty. If a data point has very few "neighbors" in the gradient space, the model is highly likely to overfit that specific point, signaling low confidence in its generalization.

Limitations and Future Work

While powerful, the approach has limitations. For classification tasks with thousands of classes, computing the $d \times d$ matrix becomes computationally prohibitive. The authors suggest "binarizing" the task (comparing the correct class versus all others) as a temporary workaround, but finding a native solution for high-dimensional outputs remains an open challenge.

Additionally, the raw influence kernel is not perfectly symmetric (input A might influence B more than B influences A). While symmetric versions are provided, the implications of this asymmetry for model fairness and bias require further exploration. Finally, the authors hypothesize that explicitly encouraging the network to view certain samples as similar during training could improve adversarial robustness, paving the way for exciting future research.

Summary updated

BibTeX
@inproceedings{charpiat2019input,
  author = {Guillaume Charpiat and Nicolas Girard and Loris Felardos and Yuliya Tarabalka},
  title = {{Input Similarity from the Neural Network Perspective}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
}
Figure