On the Similarity between the Laplace and Neural Tangent Kernels
Amnon Geifman, Abhay Yadav, Yoni Kasten, Meirav Galun, David Jacobs, Ronen Basri
Introduction
Neural networks with significantly more parameters than training examples have been successfully applied to a variety of tasks. Somewhat contrary to common wisdom, these models typically generalize well to unseen data. It has been shown that in the limit of infinite model size, these neural networks are equivalent to kernel regression using a family of novel Neural Tangent Kernels (NTK) . NTK methods can be analyzed to explain many properties of neural networks in this limit, including their convergence in training and ability to generalize . Recent experimental work has shown that in practice, kernel methods using NTK perform similarly, and in some cases better, than neural networks , and that NTK can be used to accurately predict the dynamics of neural networks . This suggests that a better understanding of NTK can lead to new ways to analyze neural networks.
These results raise an important question: Is NTK significantly different from standard kernels? For the case of fully connected (FC) networks, provides experimental evidence that NTK is especially effective, showing that it outperforms the Gaussian kernel on a large suite of machine learning problems. Consequently, they argue that NTK should be added to the standard machine learning toolbox. has shown empirically that the dynamics of neural networks on randomly labeled data more closely resembles the dynamics of learning through stochastic gradient descent with the Laplace kernel than with the Gaussian kernel. In this paper we show theoretically and experimentally that NTK does closely resemble the Laplace kernel, already a standard tool of machine learning.
Related Works
The connection between neural networks and kernel methods has been investigated for over two decades. Early works have noted the equivalence between neural networks with single hidden layers of infinite width and Gaussian Processes (GP) , where GP prior can be used to achieve exact Bayesian inference. Recently have extended the results to deep fully-connected neural networks in which all but the last layer retain their initial values. In this context, introduced the Arc-cosine kernel, while showed a duality between neural networks and compositional kernels.
More recent work introduced the family of neural tangent kernels (NTK) . This work showed that for massively overparameterized and fully trained networks, their training dynamics closely follows the path of kernel gradient descent, and that training converges to the solution of kernel regression with NTK. Follow-up work defined analogous kernels for residual and convolutional networks . Recent work also showed empirically that classification with NTK achieves performance similar to deep neural networks with the corresponding architecture .
The equivalence between kernels and overparameterized neural networks opened the door to studying inductive bias in neural networks. For two layer, FC networks, investigated the spectral property of the NTK when the data is distributed uniformly on the hypersphere, showing in particular that with GD low frequencies are learned before higher ones. extended these results to non-uniform distributions. analyzed the eigenvalues of NTK over the Boolean cube, and analyzed its spectrum under approximate pairwise orthogonality. further leveraged the spectral properties of the kernels to investigate their RKHS in the case of bias-free two layer networks. Our results apply to deep networks with bias. studied approximation bounds for two layer neural networks, and studied generalization properties of kernel methods in the context of neural networks.
Recent work compares the performance of NTK to that of common kernels. Specifically, ’s experiments suggest that NTK is superior to the Gaussian and low degree polynomial kernels. compares the learning speed of GD for randomly mislabeled data, showing that NTK learns such data as fast as the Laplace kernel and much faster than the Gaussian kernel. Our analysis provides a theoretical justification of this result.
NTK vs. the Exponential Kernels
Our aim is to compare NTK to common kernels. In comparing kernels we need to consider two main properties: first, what functions are included in their respective RKHS and secondly, how their respective norms behave. (These concepts are reviewed below in Sec. 3.1.) The answer to the former question determines the set of functions considered for regression, while the answer to the latter determines the result of regression. Together, these will determine how a kernel generalizes to unseen data points. Below we see that on the hypersphere both NTK and exponential kernels (e.g., Gaussian and Laplace) give rise to the same set of eigenfunctions. Therefore, the answers to the questions above are determined fully by the corresponding eigenvalues. Moreover, the asymptotic decay rate of the eigenvalues of each kernel determines their RKHS.
For all we have that the .
Reproducing property: for all and for all it holds that .
Moreover, RKHSs and positive definite kernels are uniquely paired.
According to Mercer’s theorem can be written as
where are the eigenvalues and eigenfunctions of with respect to the measure , i.e.,
The RKHS is the space of functions of the form whose RKHS norm is finite, i.e., . The latter condition restricts the set of functions in an RKHS, allowing only functions that are sufficiently smooth in accordance with the asymptotic decay of .
Neural Tangent Kernel. Let denote a neural network function with ReLU activation and trainable parameters . Then the corresponding NTK is defined as
When this problem is called minimum norm interpolant, and the solution satisfies
Deriving the eigenvalues for NTK for deep networks is complicated, due to its recursive definition. For a two-layer network without bias, proved that the eigenvalues decay at a rate of . With no bias, however, two-layer networks are nonuniversal, and in particular for odd . To avoid this issue Theorem 1 establishes that with bias NTK is universal for any number of layers , and its eigenvalues decay at a rate no faster than . Moreover, with the eigenvalues decay exactly at the rate of .
and constants that depend on the dimension such that
if , and
if .
The proof of this theorem for borrows techniques from . The proof for relies mainly on showing that the algebraic operations in the recursive definition of NTK (including addition, product and composition) do not increase the rate of decay. The consequence of Theorem 1 is that NTK for FC networks gives rise to an infinite size feature space and that its eigenvalues decay no faster than . While our proofs only establish a bound for the case that , empirical results suggest that the eigenvalues for these kernels decay exactly as , as can be seen in Figure 1.
shows that the Gaussian kernel restricted to the hypersphere yields eigenvalues that decay exponentially fast. In contrast we next prove that the eigenvalues of the Laplace kernel restricted to the hypersphere decay polynomially as , the same decay rate shown for NTK in Theorem 1 and in Figure 1.
where are constants that depend on the dimension and the parameter .
Likewise, with training points and , derived the following lower bound
where are the eigenvalues of . Both of these bounds are equivalent asymptotically up to a constant for NTK (with bias) and the Laplace kernel.
While theoretical discussions of NTK largely assume the input data is normalized to lie on the sphere, such normalization is not the common practice in neural network applications. Instead, most often each feature is normalized separately by setting its mean to zero and variance to 1. Other normalizations are also common. It is therefore important to examine how NTK behaves outside of the hypersphere, compared to common kernels.
Below we derive the eigenfunctions of NTK for deep FC networks with ReLU activation with and without bias. We note that derived the eigenfunctions of NTK for two-layer FC networks with no bias. We will show that the same eigenfunctions are obtained with deep, bias-free networks, and that additional eigenfunctions appear when bias is added. We begin with a definition.
A kernel is homogeneous of order if .
Let + so that as in 1 and is homogeneous of order 0. Then the eigenfunctions of are of the form .
In contrast to NTK, the Laplace kernel is shift invariant, and therefore its eigenfunctions are the Fourier transform. The two kernels hence cannot be compared merely by their eigenvalues. Figure 2 shows the eigenfunctions of NTK along with their correlation to the eigenfunctions of the Laplace kernel. While these differences are large, they seem to make only little difference in experiments, see Section 4 below. It is possible to produce a homogeneous version of the Laplace kernel as follows
Following Thm. 5 the eigenfunctions of this kernel are the scaled spherical harmonics and, following Thm. 2, its eigenvalues decay at the rate of , much like the NTK.
Experiments
We compare the performance of NTK with Laplace, Gaussian, and -exponential kernels on both small and large scale real datasets. Our goal is to demonstrate: a) Results with the Laplace kernel are quite similar to those obtained by NTK, and b) The -exponential kernel can achieve slightly better results than NTK. Experimental details are provided in the supplementary material.
We compare methods using the same set of 90 small scale UCI datasets (with less than 5000 data points) as in . The results are provided in Table 4 for the exponential kernels and their homogeneous versions, denoted by the "H-" prefix, as well as for NTK. For completeness, we also cite the results for Random forest (RF), the top classifier identified in , and neural networks from . Further comparison of the accuracies obtained with NTK vs. the H-Laplace kernel on each of the 90 datasets is shown in Figure 4.
We report the same metrics as used in : Friedman Ranking, Average Accuracy, P90/P95, and PMA. A superior classifier is expected to have lower Friedman rank and higher P90, P95, and PMA. Friedman Ranking reports the average ranking of a given classifier compared to other classifiers. P90/P95 denotes the fraction of datasets on which a classifier achieves more than of the maximum achievable accuracy (i.e., maximum accuracy among all the classifiers ). PMA represents the percentage of maximum accuracy.
From Table 4, one can observe that the H-Laplace kernel results are the closest to NTK on all the metrics. In fact, as seen in Figure 4, these methods seem to achieve highly similar accuracies in each of the 90 datasets. Furthermore, the H--exponential outperforms all the classifiers including NTK on all metrics. Moreover, the homogeneous versions slightly outperform the standard kernels. All these methods have hyperparameters that can be optimized. In , they search hyperparameters for NTK. For a fair comparison, we search for the same number for the -exponential and fewer (70) for the Laplace kernels. We note finally that deeper networks yield NTK shapes that are more sharply peaked, corresponding to Laplace kernels with higher values of . This is shown in Fig. 5 below.
2 Large scale datasets
We leverage FALKON , an efficient approximate kernel method to conduct large scale regression and classification tasks following the setup of . The results and datasets details are reported in Table 1. We searched for hyperparameters based on a small validation dataset for all the methods and used the standard train/test partition provided on the UCI repository. From Table 1, one can notice that NTK and H-Laplace perform similarly. For each dataset, either the -exponential or Gaussian kernels slightly outperforms these two kernels.
3 Hierarchical convolutional kernels
Convolutional NTKs (CNTK) were shown to express the limit of convolutional neural networks when the number of channels tends to infinity, and recent empirical results showed that the two achieve similar accuracy on test data . CNTK is defined roughly by recursively applying NTK to image patches. For our final experiment we constructed alternative hierarchical kernels, in the spirit of , by recursively applying exponential kernels in a manner similar to CNTK. The new kernel, denoted C-Exp, is applied first to pairs of image patches, then to patches of kernel values, and so forth. A detailed algorithm is provided in the supplementary material. We applied the kernel (using the homogeneous versions of the Laplace, Gaussian and -exponential kernels) to the Cifar-10 dataset and compared it to CNTK. Our experimental conditions and results for CNTK are identical to those of . (Note that these do not include global average pooling.) Consistent with our previous experiments, Table 2 shows that these kernels are on par with the CNTK with small advantage to the -exponential kernel. This demonstrates that the four kernels maintain similar performance even after repeated application.
Conclusions
Our paper has considered the relationship between NTK and the classic Laplace kernel. Our main result is to show that for data normalized on the unit hypersphere, these two kernels have the same RKHS. Experiments show that the two kernels perform almost identically on a wide range of real-world applications. Coupled with prior results that show that kernel methods using NTK mimic the behavior of FC neural networks, our results suggest that much insight about neural networks can be obtained from analysis of the well-known Laplace kernel, which has a simple closed form.
Neural networks do offer great flexibility not easily translated to kernel methods. They can naturally be applied to large data sets, and researchers have developed many techniques for training them, such as dropout and batch normalization, that improve performance but do not directly translate to kernel methods. Furthermore, while we study feed-forward fully connected networks, analyzing more complex architectures, such as CNNs, GANs, autoencoders and recurrent networks, or the effect of other activation functions, remains a significant challenge for future work. Comparing the eigenfunctions of NTK with those of classical kernels under non-uniform distribution is yet a further challenge.
Broader impact
This work explains the success of deep, fully connected networks through their similarity to exponential kernels. Such an analysis may allow for a better interpretability of deep network models.
Acknowledgements
The authors thank the U.S.- Israel Binational Science Foundation, grant number 2018680, the National Science Foundation, grant no. IIS-1910132, the Quantifying Ensemble Diversity for Robust Machine Learning (QED for RML) program from DARPA and the Guaranteeing AI Robustness Against Deception (GARD) program from DARPA for their support of this project.
References
Appendix A Formulas for NTK
We begin by providing the recursive definition of NTK for fully connected (FC) networks with bias initialized at zero. The formulation includes a parameter that when set to zero the recursive formula coincides with the formula given in for bias-free networks.
The recursive formula for NTK.
The recursive formula in assumes the bias is initialized with a normal distribution. Here we assume the bias is initialized at zero, yielding a sightly different formulation, which can be readily derived from ’s formulation.
By definition , and for ReLU activation we have and
To prove the next theorem, we recall several results on the the arithmetics of RKHS, following .
Aronszajn’s kernel sum theorem. The RKHS for is given by
This yields the kernel sum inclusion.
Norm addition inequality.
Norm product inequality.
Aronszajn’s inclusion theorem. if and only if , such that , where the latter notation means that is a positive definite kernel over .
B.2 The decay rate of the eigenvalues of NTK
and constants that depend on the dimension such that
if , and
if .
We split the theorem into the next two lemmas. The first lemma handles NTK of two-layer FC networks with bias, and the second lemma handles NTK for deep networks.
where are constants that depend on the dimension .
Furthermore, according to Proposition 5 in
To conclude, this implies that and , such that for all it holds that
and also, unless , for all
such that it holds that in which depends on the dimension
Now, following Lemma 17 in all of the eigenvalues of are positive, including . This implies that the constant function .
and for it holds that
where is a tuning parameter. We next prove an asymptotic bound on its eigenvalues.
where are constants that depend on the dimension and the parameter .
Our proof relies on several supporting lemmas.
( Thm 1.14 page 6) For all it holds that
where
To calculate the Fourier transform we need to calculate the following integral
According to the Lemma 5, plugging and into (15) yields
Then, the eigenvalues in the spherical harmonic expansion are related to the Fourier coefficients of , , as follows
where is the usual Bessel function of the first kind of order .
Having, these supporting Lemmas, we can now prove Theorem 7.
First, is a positive zonal kernel and hence can be written as
Next, to derive the bounds we plug the Fourier coefficients, , computed in Lemma 6, into the expression for the harmonic coefficients, (16), obtaining
Applying a change of variables we get
We next bound this integral from both above and below. To get an upper bound we observe that for , implying that , and consequently
The above integral was computed in (Sec. 13.41 page 402 with , , and ) which gives
Using Stirling’s formula as . Consequently, for sufficiently large
where depends on , and the dimension .
We use again the relation (17) to derive a lower bound for . First, note that since are all non-negative for and therefore
Applying Stirling’s formula we obtain , which implies that as grows, . Therefore, asymptotically for large
from which we conclude that , where the constant depends on , , and . We have therefore shown that there exists such that
Finally, to show that for all we use again (16) in Lemma 7 which states that
Note that in the interval it holds that and due to Lemma 6. Therefore implies that is identically 0 on , contradicting the properties of the Bessel function of the first kind. Hence, for all . ∎
In this section we denote , and by , . We first prove Theorem 9 and as a consequence Lemma 8 is proved.
To that end, we first prove the following supporting Lemma.
Assuming the induction hypothesis holds for , i.e.,
we prove that those equalities are also true for .
By the definition of (7) and the induction hypothesis for we have that
Plugging this result in the definitions of (8) and (9), using the induction hypothesis we obtain
Finally, using the recursion formula (6) () and the induction hypothesis for , we obtain
Let + so that as in 1 and is homogeneous of order 0. Then the eigenfunctions of are of the form .
Since is zonal, its Mercer’s representation reads
where the spherical harmonics are the eigenfunctions of . Consequently, as noted also in ,
where the rightmost equality is due to the orthogonality of the spherical harmonics and by setting
Clearly this integral is positive, and the conditions of the theorem guarantee that it is finite.
By the conditions of the theorem we can write
where denote the zonal spherical harmonics. We next show that the space spanned by the functions and is fixed under the following integral transform
We use (21) and (22) to substitute for the inner integral, obtaining
Together with (23), this can be written as
Appendix E Experimental Details
In this section, we provide experimental details for the UCI dataset. We use precisely the same pre-processed datasets, and follow the same performance comparison protocol as in .
We reproduced the results of using the publicly available codehttps://github.com/LeoYu/neural-tangent-kernel-UCI, and followed the same protocol as in . The total number of kernels evaluated in are and the SVM cost value parameter is tuned from to by powers of . Hence, the total number of hyper-parameter combinations searched using cross-validation is .
Exponential Kernels Specifications
For the Laplace and Gaussian kernels, we searched for kernel width values () from to in the log space with base , where is chosen heuristically as the median of pairwise distances between data points (known as the median trick ). So, the total number of kernel evaluations is . For -exponential, we searched through 5 equally spaced values of from to . Since we wanted to keep the number of the kernel evaluations the same as for NTK in , we searched through only three kernel bandwidth values () which are , and #features (default value in the sklearn packagehttps://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.rbf_kernel.html). So, the total number of kernel evaluations is .
For a fair comparison with , we swept the same range of SVM cost value parameter as in , i.e., from to by powers of . Hence, the total number of hyper-parameter search using cross-validation is for Laplace and for -exponential which is the same as for NTK in .
E.2 Large scale datasets
We used the experimental setup mentioned in and the publicly available code https://github.com/LCSL/FALKON_paper. solves kernel ridge regression (KRR ) using the FALKON algorithm, which solves the following linear system
where is an kernel matrix defined by , , and is the regularization parameter. Refer to for more details.
In Table 3, we provide the hyper parameters chosen with cross validation.
E.3 C-Exp: Convolutional Exponential Kernels
Let and denote two vectorized images. Let denote a window function (we used windows). Our hierarchical exponential kernels are defined by as follows:
where denotes the bias and the last step is analogous to a fully connected layer in networks, and we set
where can be any kernel defined on the sphere. In the experiments we applied this scheme to the three exponential kernels, Laplace, Gaussian and -exponential.
C-Exp Laplace. , with .
C-Exp exponential. , with .
C-Exp Gaussian. , with .
For the training phase we used 1-hot vectors from which we subtracted 0.1, as in . For the classification phase, as in , we normalized the kernel matrices such that all the diagonal elements are ones. To avoid ill conditioned kernel matrices we applied ridge regression with a regularization factor of . Finally, to reduce overall running times, we parallelized the kernel computations on NVIDIA Tesla V100 GPUs.