On Kernel Regression with Data-Dependent Kernels

James B. SimonarXiv 2022

Abstract

The primary hyperparameter in kernel regression (KR) is the choice of kernel. In most theoretical studies of KR, one assumes the kernel is fixed before seeing the training data. Under this assumption, it is known that the optimal kernel is equal to the prior covariance of the target function. In this note, we consider KR in which the kernel may be updated after seeing the training data. We point out that an analogous choice of kernel using the posterior of the target function is optimal in this setting. Connections to the view of deep neural networks as data-dependent kernel learners are discussed.

Introduction

In Kernel Regression (KR), the kernel function defines the similarity between data points and dictates the model's inductive bias. Traditionally, the kernel is treated as a static hyperparameter chosen a priori. However, modern machine learning practice—particularly the use of deep neural networks—often involves learning or tuning representations based on the training data. This paper explores the theoretical limit of this adaptation: if we can modify the kernel after observing training labels, what is the best possible kernel we could pick?

The Optimal Posterior Kernel

The author, James B. Simon, contrasts two paradigms. In the classic setting where the kernel $K$ is fixed, the optimal kernel is the prior covariance of the target function. In the adaptive setting, where the kernel can be modified after seeing the dataset $\mathcal{D}$, the paper derives the Optimal Posterior Kernel ($K^*$). This kernel is defined as the expectation of the product of function values over the posterior distribution:

$$K^*(x, x') \equiv \mathbb{E}_{f \sim \mu_f | \mathcal{D}}[f(x)f(x')] $$

A key insight is that KR using $K^*$ is mathematically equivalent to calculating the posterior mean of the target function. This makes KR with an optimal data-dependent kernel the "Gold Standard" Bayesian predictor, achieving the minimum possible expected squared risk among all predictors, not just linear ones.

Empirical Evidence from Neural Networks

To bridge theory and practice, the study examines whether deep neural networks (DNNs) behave like learners of this optimal posterior kernel. Using a CNN trained on a binary "superclass" version of CIFAR-10 (distinguishing "rideable" vs. "non-rideable" objects), the author tracks the evolution of the network's internal representation over time.

Evolution of accuracy (A), kernel alignment (B, C), and effective rank (D) during CNN training.

As shown in the figure above, several key trends emerge during training that align with the theoretical properties of an optimal adaptive kernel:

  1. Kernel Alignment: The alignment between the kernel and the target labels ($a_{y, \kappa}$) increases as the model learns (Panel B). This indicates the network is successfully adapting its internal similarity metric to match the task.
  2. Effective Rank: The "Effective Rank" of the kernel matrix (erank(K)) drops significantly as test accuracy rises (Panel D). This suggests the network is shedding noise and compressing the representation into a lower-dimensional space highly relevant to the task, a behavior predicted for the optimal posterior kernel.
  3. Overfitting Signatures: Interestingly, the effective rank begins to increase again during the final stages of training (Panel D, after epoch 100). This coincides with the onset of overfitting, where training accuracy approaches 1.0 but test accuracy plateaus or slightly declines (Panel A).

Conclusion

This work provides a theoretical framework for understanding neural networks as adaptive kernel machines. The transition from a prior kernel (like the Neural Tangent Kernel) toward a posterior-like kernel explains the observed phenomena of increasing alignment and decreasing rank. While the optimal posterior kernel $K^*$ remains a theoretical benchmark due to the difficulty of knowing the true posterior, metrics like the normalized RKHS norm ($\tilde{a}_{\mathcal{Y},K}$) offer promising new ways to monitor and understand the learning dynamics of deep models.

Summary updated

Abstract

The primary hyperparameter in kernel regression (KR) is the choice of kernel. In most theoretical studies of KR, one assumes the kernel is fixed before seeing the training data. Under this assumption, it is known that the optimal kernel is equal to the prior covariance of the target function. In this note, we consider KR in which the kernel may be updated after seeing the training data. We point out that an analogous choice of kernel using the posterior of the target function is optimal in this setting. Connections to the view of deep neural networks as data-dependent kernel learners are discussed.
BibTeX
@misc{simon2022kernel,
  author = {James B. Simon},
  title = {{On Kernel Regression with Data-Dependent Kernels}},
  year = {2022},
  eprint = {2209.01691},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2209.01691},
}
Figure