Scaling Neural Tangent Kernels via Sketching and Random Features
Amir Zandieh, Insu Han, Haim Avron, Neta Shoham, Chaewon Kim, Jinwoo Shin
Introduction
Recent results have shown that over-parameterized Deep Neural Networks (DNNs), generalize surprisingly well. In an effort to understand this phenomena, researchers have studied ultra-wide DNNs and shown that in the infinite width limit, a fully connected DNN trained by gradient descent under least-squares loss is equivalent to kernel regression with respect to the Neural Tangent Kernel (NTK) . This connection has shed light on DNNs’ ability to generalize and optimize (train) their parameters efficiently . More recently, Arora et al. proved an analogous equivalence between convolutional DNNs with infinite number of channels and Convolutional NTK (CNTK). Beyond the aforementioned theoretical purposes, several papers have explored the algorithmic use of this kernel. Arora et al. and Geifman et al. showed that NTK based kernel models can outperform trained DNNs (of finite width). Additionally, CNTK kernel regression sets an impressive performance record on CIFAR-10 for kernel methods without trainable kernels . The NTK has also been used in experimental design and predicting training time .
There is a rich literature on kernel approximations for large-scale learning. One of the most popular approaches is the random features method which works by randomly sampling the feature space of the kernel function, originally due to the seminal work of Rahimi and Recht . Another popular approach which is developed in linear sketching literature , works by designing sketches that can be efficiently applied to the feature space of a kernel without needing to explicitly form the high dimensional feature space. This approach has been successful at designing efficient subspace embeddings for the polynomial kernel . In this paper, we propose solutions for scaling the NTK and CNTK by building on both of these kernel approximations techniques and designing efficient feature maps that approximate the NTK/CNTK evaluation. Consequently, we can simply transform the input dataset to these feature spaces, and then apply fast linear learning methods to approximate the answer of the corresponding nonlinear kernel method efficiently. The performance of such approximate methods is similar or sometimes better than the exact kernel methods due to implicit regularization effects of the approximation algorithms .
One of our results is an efficient random features construction for the NTK. Our starting point is the explicit NTK feature map suggested by Bietti and Mairal based on tensor product of the feature maps of arc-cosine kernels. We obtain our random features, by sampling the feature space of arc-cosine kernels . However, the naïve construction of the features would incur an exponential cost in the depth of the NTK, due to the tensor product of features generated in consecutive layers. We remedy this issue, by utilizing an efficient sketching algorithm for tensor products known as TensorSRHT which can effectively approximate the tensor products of vectors while preserving their inner products. We provide a rigorous error analysis of the proposed scheme in Theorem 2.
Our next results are sketching methods for both NTK and CNTK using a runtime that is linearly proportional to the sparsity of the input dataset (or number of pixels of images). Our methods rely on the arc-cosine kernels’ feature space defined by their Taylor expansion. By careful truncation of their Taylor series, we approximate the arc-cosine kernels with bounded-degree polynomial kernels. Because the feature space of a polynomial kernel is the tensor product of its input space, its dimensionality is exponential in the degree of the kernel. Fortunately, Ahle et al. have developed a linear sketch known as PolySketch that can reduce the dimensionality of high-degree tensor products very efficiently, therefore, we can sketch the resulting polynomial kernels using this technique. We then combine the transformed features from consecutive layers by further sketching their tensor products. In case of CNTK, we have an extra operation which sketches the direct sum of the features of neighbouring pixels at each layer that precisely corresponds to the convolution operation in CNNs. We carefully analyze the errors introduced by polynomial approximations and various sketching steps in our algorithms and also bound their runtimes in Theorems 1 and 4.
Furthermore, we improve the arc-cosine random features to spectrally approximate the entire kernel matrix, which is advocated in recent literature for ensuring high approximation quality in downstream tasks . Our construction is based on leverage score sampling, which entertains better convergence bounds . However, computing this distribution is as expensive as solving the kernel methods exactly. We propose a simple distribution that tightly upper bounds the leverage scores of arc-cosine kernels and for further efficiency, use Gibbs sampling to generate random features from our proposed distribution. We provide our spectral approximation guarantee in Theorem 3.
Finally, we empirically benchmark our proposed methods on various classification/regression tasks and demonstrate that our methods perform similar to or better than exact kernel method with NTK and CNTK while running extremely faster. In particular, we classify CIFAR-10 dataset 150 faster than exact CNTK and at the same time achieve higher test accuracy.
2 Related Works
There has been a long line of work on the correspondence between DNN and kernel machines . Furthermore, there has been many efforts in understanding a variety of NTK properties including optimization , generalization , loss surface , etc.
A popular line of work on kernel approximation problem is based on the Fourier features method , which works well for shift-invariant kernels and with some modifications can embed the Gaussian kernel near optimally . Other random feature constructions have been suggested for a variety of kernels, e.g., arc-cosine kernels , polynomial kernels . In linear sketching literature, Avron et al. proposed a subspace embedding for the polynomial kernel which was recently extended to general dot product kernels . The runtime of this method, while nearly linear in sparsity of the input dataset, scales exponentially in kernel’s degree. Recently, Ahle et al. improved this exponential dependence to polynomial which enabled them to sketch high-degree polynomial kernels and led to near-optimal embeddings for Gaussian kernel. In fact, this sketching technology constitutes one of the main ingredients of our proposed methods. Additionally, combining sketching with leverage score sampling can improve the runtime of the polynomial kernel embeddings .
3 Preliminaries: PolySketch and TensorSRHT Transforms
ReLU Neural Tangent Kernel
Let and be and order arc-cosine kernels defined as follows,
The connection between ReLU-NTK function and the NTK kernel is formalized bellow,
Sketching and Random Features for NTK
The main results of this section are efficient oblivious sketching as well as random features for the fully-connected NTK. As shown in ?? and ??, the NTK , is constructed by recursive composition of arc-cosine kernels and . So, to design efficient sketches for the NTK we crucially need efficient methods for approximating these functions. Generally, there are two main approaches to approximating these functions; one is random features sampling and the other is truncated Taylor series expansion coupled with fast sketching. We design algorithms by exploiting both of these techniques.
Our main tool is approximating the arc-cosine kernels with low-degree polynomials, and then applying PolySketch to the resulting polynomial kernels. The features for multi-layer NTK are the recursive tensor product of arc-cosine sketches at consecutive layers, which in turn can be sketched efficiently using PolySketch. We present our oblivious sketch in ??.
Now we present our main theorem on NTKSketch algorithm as follows.
For a proof, see ??. One can observe that the runtime of our NTKSketch is faster than the gradient features of an ultra-wide random DNN, studied by Arora et al. , by a factor of .
2 NTK Random Features
The proof of ?? is provided in ??. Arora et al. proved that the gradient of randomly initialized ReLU network with finite width can approximate the NTK, but their feature dimension should be which is larger than ours by a factor of . In ??, we also empirically show that ?? requires far fewer features than random gradients.
3 Spectral Approximation for NTK via Leverage Scores Sampling
Although the above NTK approximations can estimate the kernel function itself, it is still questionable how it affects the performance of downstream tasks. Several works on kernel approximation adopt spectral approximation bound with regularization and approximation factor , that is,
where and . The spectral bound can provide rigorous guarantees for downstream applications including kernel ridge regression , clustering and PCA . We first provide spectral bounds for arc-cosine kernels, then we present our spectral approximation bound for two-layer ReLU networks, which is the first in the literature.
To guarantee that the arc-cosine random features in ?? provide spectral approximation, we will use the leverage score sampling framework of . We reduce the variance of random features by performing importance sampling. The challenge is to find a proper modified distribution that certainly reduces the variance. It turns out that the original order arc-cosine random features has a small enough variance. More precisely, let be the order arc-cosine kernel matrix, i.e., , and , where is defined in ??. If the number of features , then
The details are provided in ?? and ??. We are now ready to state our spectral approximation bound for our modified random features.
For a proof see ??. To generalize the current proof technique to deeper networks, one needs a monotone property of arc-cosine kernels, i.e., for . However, this property does not hold in general and we leave the extension to deeper networks to future work.
Sketching Convolutional Neural Tangent Kernel
Similar to NTKSketch our method relies on approximating the arc-cosine kernels with low-degree polynomials via Taylor expansion, and then applying PolySketch to the resulting polynomial kernels. Our sketch computes the features for each pixel of the input image, by tensor product of arc-cosine sketches at consecutive layers, which in turn can be sketched efficiently using PolySketch . Additionally, the features of pixels that lie in the same patch get locally combined at each layer via direct sum operation. This precisely corresponds to the convolution operation in neural networks. We present our CNTKSketch algorithm in ?? and give its performance guarantee in the following theorem.
The proof is in ??. Runtime of our CNTKSketch is only linear in the number of image pixels , which is in stark contrast to quadratic scaling of the exact CNTK computation .
Experiments
In this section, we empirically show that running least squares regression on the features generated by our methods is extremely fast and effective for learning with NTK and CNTK kernel machines. We run experiments on a system with an Intel E5-2630 CPU with 256 GB RAM and a single GeForce RTX 2080 GPUs with 12 GB RAM. Codes are available at https://github.com/insuhan/ntk-sketch-rf.
We first benchmark our proposed NTK approximation algorithms on MNIST dataset and compare against gradient-based NTK random features (GradRF) as a baseline method. To apply our methods and GradRF into classification task, we encode class labels into one-hot vectors with zero-mean and solve the ridge regression problem. We search the ridge parameter with a random subset of training set and choose the one that achieves the best validation accuracy. We use the ReLU network with depth . In ??, we observe that our random features (NTKRF ) achieves the best test accuracy. The NTKSketch narrowly follows the performance of NTKRF and the Grad-RF is the worst method which confirms the observations of Arora et al. , i.e., gradient of a finite width network degrades practical performances.
As shown in ??, the NTK is a normalized dot-product kernel characterized by the function . This function can be easily computed using operations at any desired , therefore, we can efficiently fit a polynomial to this function using numerical methods (for instance, it is shown in ?? that a degree- polynomial can tightly approximate the depth- ReLU-NTK function ). Then, we can efficiently sketch the resulting polynomial kernel using PolySketch , as was previously done for Gaussian and general dot-product kernels . Therefore, we can accelerate our NTKSketch for deeper networks (), using this heuristic.
2 CNTK Classification on CIFAR-10
Next we test our CNTKSketch on CIFAR-10 dataset . We choose a convolutional network of depth and compare CNTKSketch and GradRF for various feature dimensions. We borrow results of both CNTK and CNN from Arora et al. . The results are provided in ?? and ??. Somewhat surprisingly, CNTKSketch even performs better than the exact CNTK regression by achieving when feature dimension is set to . The likely explanation is that CNTKSketch takes advantages of implicit regularization effects of approximate feature map and powerful expressiveness of the CNTK. Moreover, computing the CNTK matrix takes over 250 hours (12 days) under our setting which is at least slower than our CNTKSketch.
3 Regression on Large-scale UCI Datasets
Discussion and Conclusion
In this work, we propose efficient low-rank feature maps for the NTK and CNTK kernel matrices based on both sketching and random features. Computing NTK have been raised severe computational problems when they apply to practical applications. Our methods runs remarkably faster than the NTK with performance improvement.
Potential negative societal impact. This is a technical work proposing provable algorithms which stand alone independently of data, e.g., do not learn any private information of input data. We think there is no particular potential negative societal impact due to our work.
Limitations. This paper only considers fully-connected and convolutional neural networks, and our ideas are not directly applicable to scale up NTK of other deep networks, e.g., transformers .
Acknowledgments and Disclosure of Funding
Amir Zandieh was partially supported by the Swiss NSF grant No. P2ELP2_195140. Haim Avron and Neta Shoham were partially supported by BSF grant 2017698 and ISF grant 1272/17. Jinwoo Shin was partially supported by the Engineering Research Center Program through the National Research Foundation of Korea (NRF) funded by the Korean Government MSIT (NRF_2018R1A5A1059921) and Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government (MSIT) (No.2019_0_00075, Artificial Intelligence Graduate School Program (KAIST)).
References
Appendix A ReLU-NTK Expression
For , define the derivative covariance as,
Let and for every integer , the depth- NTK expression is defined recursively as:
First note that the main component of the DP given in ??, ??, and ?? is the Activation Covariances:
Proof of ??: Consider the NTK expression given in ??, ??, and ??. We first prove by induction on that the covariance function defined in ?? satisfies:
The base of induction is trivial for due to .
To prove the inductive step, suppose that the inductive hypothesis holds for , i.e.,
Using a similar argument we have . Therefore, by ??, we can write
Since we assumed that , we have . By inductive hypothesis along with ??, we find that
which completes the induction and proves that for every ,
Since we assumed that , . Therefore, by ??, for every ,
Now we prove by induction on integer that the NTK with layers and ReLU activation given in ?? satisfies
The base of induction, trivially holds because, by ??:
To prove the inductive step, suppose that the inducive hypothesis holds for , that is . Now using the recursive definition of given in ?? along with ?? and ?? we can write,
Appendix B Sketching Preliminaries: PolySketch and SRHT
Our sketching algorithms use the Subsampled Randomized Hadamard Transform (SRHT) to reduce the dimensionality of the intermediate vectors that arise in our computations. Next lemma gives the performance of SRHT sketches which is proved, for instance, in Theorem 9 of ,
Now we restate the ?? and present the proof,
This immediately proves the first statement of the lemma.
As shown in , the sketch can be applied to tensor product vectors of the form by recursive application of independent instances of OSNAP transform and a novel variant of the SRHT , proposed in called TensorSRHT, on vectors and their sketched versions. The sketch , as shown in ??, can be represented by a binary tree with leaves where the leaves are OSNAP sketches and the internal nodes are the TensorSRHT. The use of OSNAP in the leaves of this sketch structure ensures excellent runtime for sketching sparse input vectors. However, note that if the input vectors are not sparse, i.e., for input vectors , then we can simply remove the OSNAP transforms from the leaves of this structure and achieve improved runtime, without hurting the approximation guarantee. Therefore, the sketch that satisfies the statement of the lemma is exactly the one introduced in for sparse input vectors and for non-sparse inputs is obtained by removing the OSNAP transforms from the leaves of the sketch structure given in ??.
Furthermore, the sketch can be applied to tensor product of any collection of vectors. The time to apply to the tensor product consists of time of applying OSNAP to each of the vectors and time of applying instances of TensorSRHT to intermediate vectors which are of size . This runtime can be upper bounded by , which proves the third statement of the ??. ∎
Appendix C NTK Sketch: Claims and Invariants
We start by proving that the polynomials and defined in ?? of ?? closely approximate the arc-cosine functions and on the interval $$.
Remark. Observe that .
If we let and be defined as in ?? of ??, then for any integer , the polynomial defined in ?? of ?? satisfies,
Moreover, for any integer , the polynomial defined as in ?? of ??, satisfies,
Proof of ??: We start by Taylor series expansion of around , . Therefore, we have
To prove the second part of the lemma, we consider the Taylor expansion of at . Since , the Taylor series of can be obtained from the Taylor series of as follows,
Therefore, it is possible to approximate the function up to error using a polynomial of degree . Also if we want to approximate using a polynomial up to error on the interval $\mathcal{O}\left(\frac{1}{\varepsilon^{2/3}}\right)\kappa_{1}\kappa_{0}P_{\tt relu}^{(p)}\dot{P}_{\tt relu}^{(p^{\prime})}$ given in ?? of ?? are positive definite functions.
In order to prove ??, we also need the following lemma on the error sensitivity of polynomials and ,
For any integer , any , and any such that , if we let the polynomials and be defined as in ?? of ??, then
Proof of ??: Note that an that satisfies the preconditions of the lemm, is in the range . Now we bound the derivative of the polynomial on the interval ,
therefore, the second statement of lemma holds.
To prove the first statement of lemma, we bound the derivative of the polynomial on the interval as follows,
therefore, the second statement of the lemma follows. This completes the proof of ??. ∎
For the rest of this section, we need two basic properties of tensor products and direct sums:
for vectors with conforming sizes.
Now we are in a position to analyze the invariants that are maintained throughout the execution of NTKSketch (??):
The mapping computed by NTKSketch in line 4 and ?? of ?? satisfy
The mapping computed by NTKSketch in line 5 and ?? of ?? satisfy
Proof of ??: The proof is by induction on the value of . More formally, consider the following statements for every :
Additionally, by induction, we prove that for every ,
(1) Base of induction (): By line 4 of ??, and , thus, ?? implies the following
By using the above together with ?? and union bound as well as triangle inequality, we have
Using union bound, this proves the base of induction for statement , i.e.,
Moreover, by line 5 of ??, and , thus, ?? implies that,
By conditioning on and using the above together with triangle inequality it follows that,
Similarly we can prove that with probability we have and , which proves the base of induction for the second statement, i.e., . This completes the base of induction.
(2) Inductive step: Assume that the inductive hypothesis holds for . First, note that by ?? and using ?? we have the following,
where and the collection of vectors and and coefficients are defined as per ?? and ??, respectively.
By ?? together with union bound, the following inequalities simultaneously hold for all , with probability at least :
Therefore, by plugging ?? to ?? and using union bound, triangle inequality and Cauchy–Schwarz inequality we find that,
where and is the polynomial defined in ??. Using the inductive hypothesis , we have that
Therefore, by ?? we have and . Consequently, since , we obtain that By plugging this into ?? we have,
Furthermore, the inductive hypothesis implies that
By incorporating the above inequality into ?? using triangle inequality we find that,
Now, by invoking ?? and using the fact that we have,
By combining the above inequality with ?? using triangle inequality and using the fact that (by ??), we get the following bound,
This is sufficient to prove the inductive step by union bound, i.e., .
Now we prove the inductive step for statement , that is, we prove that conditioned on , statement holds with probability at least . First, note that by ?? and using ?? we have,
where and the collection of vectors and and coefficients are defined as per ?? and ??, respectively. By invoking ?? along with union bound, with probability at least , the following inequalities hold true simultaneously for all
Therefore, by plugging ?? into ?? and using union bound, triangle inequality and Cauchy–Schwarz inequality we find that,
where and is the polynomial defined in ??. By inductive hypothesis we have and . Therefore, using the fact that and ??, and . Consequently, since , we find that By plugging this into ?? we have,
Furthermore, inductive hypothesis implies , hence, by invoking ?? we find that,
By plugging the above inequality into ?? using triangle inequality, we find that,
Now, by invoking ?? and using the fact that we have,
By combining the above inequality with ?? using triangle inequality and using the fact that (by ??), we get the following bound,
Now let and . Then by ?? and using ?? we have the following,
where . By the fact that we conditioned on ,
By ??, we can further obtain an upper bound:
Now note that because we conditioned on and using ??, with probability at least the following holds:
Similarly, with probability at least , thus, by union bound:
Therefore, by combining the above with ?? via union bound we find that,
Now note that . We proceed by bounding the term using ??, as follows,
We proved that conditioned on and , and with probability at least . Hence, by union bound we find that,
Note that , thus by conditioning on inductive hypothesis and ?? we have,
By combining the above inequality with ??, , and ?? using triangle inequality and union bound we get the following inequality,
By noting that (see ??) we have proved that
Similarly we can prove the following inequalities hold with probability at least ,
This proves the inductive step for the statement follows, i.e.,
Therefore, by union bounding over all , it follows that the statements of the lemma hold simultaneously for all with probability at least . This completes the proof of ??. ∎
We now analyze the runtime of the NTKSketch algorithm:
Proof of ??: There are three main components to the runtime of this procedure that we have to account for. The first is the time to apply the sketch to in line 4 of ??. By ??, the runtime of computing is . The second heavy operation corresponds to computing vectors for and in ??. By ??, the time to compute for a fixed and all is bounded by,
The total time to compute vectors for all and all is thus . Finally, the last computationally expensive operation is computing vectors for and in ??. By ??, the runtime of computing for a fixed and all is bounded by,
Hence, the total time to compute vectors for all and all is . The total runtime of the NTK Sketch is obtained by summing up these three contributions. This completes the proof of ??. ∎
Now we are ready to prove the main theorem on NTKSketch. See 1
Because is a matrix of i.i.d normal entries with rows, for a large enough constant , is a JL transform and hence satisfies the following,
where . By ?? and using the fact that , the following bounds hold with probability at least :
Additionally, by ??, the following holds with probability at least :
Hence by union bound and triangle inequality we have,
Now note that by ??, , and also note that for every and any , , therefore,
Remark on the fact that for every and any . Note that from the definition of in ??, we have that for any : , , , and for every because is a monotonically increasing function on the interval $\dot{\Sigma}_{\tt relu}^{(h)}\alpha\in\dot{\Sigma}_{\tt relu}^{(1)}(\alpha)\geq 0\dot{\Sigma}_{\tt relu}^{(2)}(\alpha)\geq\frac{1}{2}\dot{\Sigma}_{\tt relu}^{(h)}(\alpha)\geq\frac{3}{5}h\geq 3\kappa_{0}(\cdot)K_{\tt relu}^{(L)}K_{\tt relu}^{(L)}\left(\alpha\right)\geq(L+1)/9L\geq 2\alpha\in$
Runtime analysis: By ??, runtime to compute the NTKSketch is
Appendix D NTK Random Features: Claims and Proofs
In this section we prove ??. We first restate the theorem: See 2
In the proof of this theorem we use the following results from the literature,
and note that . Recall that, by ?? and ??:
We use the recursive relation to approximate:
For notational simplicity, we define the following events:
Our proof is based on the following claims:
First we claim that, there exists a constant such that for any :
which directly follows by invoking ?? with and setting and and applying union bound over choices of .
Our second claim is that there exists a constant such that if then
The above statement is a direct consequence of invoking ?? with and union bounding over choices of . In ??, we choose and for to obtain ?? by union bound.
If the events in ??, ?? and ?? hold, then
When , we showed in the proof of ?? that , therefore,
Since and , this implies that,
D.2 Proof of Auxiliary Claims
See 1 Proof of ??: The proof is based on ?? that provides an upper bound on variance of the PolySketch. By using the definition of and ??, with probability at least , we have
Union bounding over the choices of completes the proof of ??. ∎
Furthermore, the assumption that ?? holds, implies that,
For the third part in ??, we observe that
Appendix E Spectral Approximation via Leverage Scores Sampling
The proofs here rely on Theorem 3.3 in which states spectral approximation bounds of random features for general kernels equipped with the leverage score sampling. This result is a generalization of on the Random Fourier Features.
If then
holds with probability at least .
We now ready to provide spectral approximation guarantee for arc-cosine kernels of order zero.
In order to utilize ??, we need an upper bound of as below:
E.2 First Order Arc-Cosine Kernels
Now note that by definition of , we have . Therefore, using the Taylor expansion of the function and the fact that its Taylor coefficients are all non-negative, we have,
Using the above inequality along with ??, we can write,
To obtain an upper bound of the third term in ??, we consider the singular value decomposition of . And we have
Therefore, plugging this into ?? and ?? gives,
and recall that the modified random features are defined as
Putting all together into ??, we derive the result. This completes the proof of ??. ∎
E.3 Proof of ??
Our proof relies on spectral approximation bounds of PolySketch given in the fourth part of ??.
Proof of ??: Note that the NTK of two-layer ReLU network can be formulated as
where and are the arc-cosine kernel matrices of order and with dataset , respectively.
Let and be the random features of and , defined as per ?? and ??, respectively. Also let be the feature matrix that ?? outputs, that is each column of this matrix is obtained by applying this algorithm on the dataset . By basic properties of tensor products we have,
Our proof is a combination of spectral analysis of and which are stated in ??, ?? and ??, respectively.
From ??, if then with probability at least it holds that,
Now we bound the trace of :
To guarantee spectral approximation of , we will use the result of ??. Using ?? along with ?? and the fact that for some constant , and union bound, with probability at least , we have
where the inequality in second line follows from ?? and the fourth line follows from the assumption for all which leads that . The last inequality holds since .
Similarly, we can obtain the following lower bound:
Furthermore, by taking a union bound over all events, ?? holds with probability at least . This completes the proof of ??. ∎
E.4 Auxiliary Lemmas
If are positive semi-definite matrices of conforming sizes such that , then,
Proof of ??: We want to show that for any vector , . Because the matrices are PSD, there exist matrices of appropriate sizes such that we can decompose these matrices as follows,
Using this and basic properties of tensor products, we have the following for any vector ,
Appendix F ReLU-CNTK: Expression and Main Properties
The final CNTK expressions is defined as:
Now we show how to recursively compute the ReLU-CNTK as follows,
For every positive integers , the -layer CNTK for ReLU activation function and convolutional filter size of is defined as follows
The final CNTK expressions for ReLU activation is:
In what follows we prove that the procedure in ?? precisely computes the CNTK kernel function corresponding to ReLU activation and additionally, we present useful corollaries and consequences of this fact.
To prove the inductive step, suppose that the inductive hypothesis holds for some . Now we show that conditioned on the inductive hypothesis, the inductive claim holds. By ??, we have,
Therefore, this proves that for every and every integer .
where the third line follows from ?? and fourth line follows because we have . The fifth line above follows from ??. This proves the equivalence between the tensor covariance defined in ?? and the one defined in ?? of ??. Similarly, by using ??, we can prove the statement of the lemma about as follows,
We describe some of the basic properties of the function defined in ?? in the following lemma,
Cauchy–Schwarz inequality: .
Norm value: .
Proof of ??: We prove the lemma by induction on . The base of induction corresponds to . In the base case, by ?? and ?? and Cauchy–Schwarz inequality, we have
This proves the base for the first statement. Additionally we have, which proves the base for the second statement of the lemma. Now, in order to prove the inductive step, suppose that statements of the lemma hold for , where . Then, conditioned on this, we prove that the lemma holds for . First note that by conditioning on the inductive hypothesis, applying Cauchy–Schwarz inequality, and using the definition of in ??, we can write
where the second line above follows because of the fact that is a monotonically increasing function. This completes the inductive step for the first statement of lemma. Now we prove the inductive step for the second statement as follows,
where we used ?? to conclude that and then used the fact that is non-negative. This completes the inductive proof of the lemma. This completes the proof of ??. ∎
We also describe some of the main properties of the function defined in ?? in the following lemma,
Cauchy–Schwarz inequality: .
Norm value: .
Proof of ??: First, note that by ?? and the definition of in ?? we have,
We also need to use some properties of defined in ?? and ??. We present these propertied in the next lemma,
Cauchy–Schwarz inequality: .
Norm value: .
Proof of ??: The proof is by induction on . The base of induction corresponds to . By definition of in ??, the base of induction for both statements of the lemma follow immediately.
Now we prove the inductive hypothesis. Suppose that the lemma statement holds for . We prove that conditioned on this, the statements of the lemma hold for . There are two cases. The first case corresponds to . In this case, by definition of in ?? and using ?? and ?? we can write,
where the second line above follows from inductive hypothesis along with ?? and ??. The third and fourth lines above follow by Cauchy–Schwarz inequality. The second case corresponds to . In this case, by definition of in ?? and using ?? and ?? along with the inductive hypothesis we can write,
where the second line above follows from inductive hypothesis along with ??. This completes the inductive step and in turn proves the first statement of the lemma.
To prove the inductive step for the second statement of lemma we consider two cases again. The first case is . In this case, note that by using inductive hypothesis together with ?? and ?? we can write,
where the last line above follows from definition of in ??. The second case corresponds to . In this case, by inductive hypothesis together with ?? and ?? we can write,
This completes the inductive step for the second statement and in turn proves the second statement of the lemma. This completes the proof of ??. ∎
Appendix G CNTK Sketch: Algorithm, Claims and Invariants
In this section we give our sketching algorithm for the CNTK kernel and prove our main theorem for this algorithm, i.e., ??. We start by introducing our CNTKSketch algorithm in the following definition:
Let , , , , and and and be the polynomials defined in ??.
For every , , and compute as per ?? of ??.
In the following lemma, we analyze the correctness of the CNTKSketch algorithm by giving the invariants that the algorithm maintains at all times,
The mapping computed by the CNTK Sketch algorithm in ?? and ?? of ?? satisfy the following,
The mapping computed by the CNTK Sketch algorithm in ?? and ?? of ?? satisfy the following,
Proof of ??: The proof is by induction on the value of . More formally, consider the following statements for every :
Simultaneously for all and :
Simultaneously for all and :
We prove that probabilities and are both greater than . Additionally, for every , we prove that the conditional probabilities and are greater than .
The base of induction corresponds to . By ??, and , thus, ?? implies the following
Similarly, we can prove that with probability at least , the following hold
By union bounding over all and , this proves the base of induction for statement , i.e., .
Moreover, by ??, we have that and , thus, by ??, it trivially holds that . This completes the base of induction.
Now, we proceed to prove the inductive step. That is, by assuming the inductive hypothesis for , we prove that statements and hold. More precisely, first we condition on the statement being true for some , and then prove that holds with probability at least . Next we show that conditioned on statements being true, holds with probability at least . This will complete the induction.
First, note that by ??, union bound, and using ??, the following holds simultaneously for all and all , with probability at least ,
where and the collection of vectors and and coefficients are defined as per ?? and ??, respectively. Additionally, by ?? and union bound, the following inequalities hold, with probability at least , simultaneously for all , all and all :
Therefore, by plugging ?? back to ?? and using union bound and triangle inequality as well as Cauchy–Schwarz inequality, we find that with probability at least , the following holds simultaneously for all and
where and is the polynomial defined in ??. By using the definition of in ?? we have,
Hence, by conditioning on the inductive hypothesis and using ?? and ?? we have,
Therefore, by invoking ??, it follows that and . Consequently, because , we find that
For shorthand we use the notation . By plugging this into ?? and using the notation , we find that the following holds simultaneously for all and all , with probability at least ,
Furthermore, by conditioning on the inductive hypothesis and combining it with ?? and applying Cauchy–Schwarz inequality and invoking ?? we find that,
For shorthand, we use the notation . Note that by ?? and ??, . Hence, we can invoke ?? and use ?? to find that,
By incorporating the above inequality into ?? using triangle inequality we find that, with probability at least , the following holds simultaneously for all and all :
Additionally, since , we can invoke ?? and use the fact that to conclude,
By combining the above inequality with ?? via triangle inequality and using the fact that, by ??, we get the following inequality, with probability at least ,
Similarly, we can prove that with probability at least the following hold, simultaneously for all and ,
This is sufficient to prove the inductive step for statement , i.e., .
Now we prove the inductive step for statement . That is, we prove that conditioned on , and , holds with probability at least . First, note that by ?? and using ?? and union bound, we have the following simultaneously for all and all , with probability at least ,
where and the collection of vectors and and coefficients are defined as per ?? and ??, respectively. By ?? and union bound, with probability at least , the following inequalities hold true simultaneously for all , all and all ,
Therefore, by plugging ?? into ?? and using union bound and triangle inequality as well as Cauchy–Schwarz inequality, we find that with probability at least , the following holds simultaneously for all and
where and is the polynomial defined in ??. By conditioning on the inductive hypothesis and using ?? and ?? we have and . Therefore, using the fact that and by invoking ??, it follows that and . Consequently, because , we find that
By plugging this into ?? we get the following, with probability at least ,
Furthermore, recall the notation and note that by ?? and ??, . Hence, we can invoke ?? and use the fact that to find that ?? implies the following,
By incorporating the above inequality into ?? using triangle inequality, we find that, with probability at least , the following holds simultaneously for all and all :
Since , we can invoke ?? and use the fact that to conclude,
By combining above inequality with ?? via triangle inequality and using the fact that, by ??, we get the following bound simultaneously for all and all , with probability at least :
Similarly we can prove that with probability at least , the following hold simultaneously for all and all ,
We will use ?? and ?? to prove the inductive step for .
Next, we consider two cases for the value of . When , the vectors are defined in ?? and when , these vectors are defined differently in ??. First we consider the case of . Note that in this case, if we let and be the vectors defined in ??, then by ?? and union bound, the following holds simultaneously for all and all , with probability at least :
where . Now, if we let and , then by ??, and . Thus by ?? and union bound, with probability at least , we have the following inequalities simultaneously for all and :
Therefore, if we condition on inductive hypotheses and , then by using ??, ??, the inequality ?? and ?? along with the fact that , we have:
where the fourth line above follows from the inductive hypothesis along with ?? and ?? and ??. The last line above follows from ?? and ??. Similarly we can prove, , thus conditioned on , with probability at least :
By incorporating this into ?? it follows that if we condition on , then, with probability at least , the following holds simultaneously for all and all ,
Now we bound the term using ??, ??, and ?? along with inductive hypotheses and ??. With probability at least the following holds simultaneously for all and all :
where the last line above follows from ?? together with the fact that .
By combining the above with inductive hypotheses and ?? via triangle inequality and invoking ?? we get that the following holds simultaneously for all and all , with probability at least ,
By plugging the above bound into ?? using triangle inequality and using ?? we get the following, with probability at least :
Similarly, we can prove that with probability at least the following hold simultaneously for all and all ,
This is sufficient to prove the inductive step for statement , in the case of , i.e., .
Now we prove the inductive step for in the case of . Similar to before, if we let and , then by ??, we have and . Thus by ?? and union bound, we find that, with probability at least , the following inequality holds simultaneously for all and :
Therefore, using ?? and ?? along with inductive hypotheses and ??, with probability at least , the following holds simultaneously for all and ,
By combining the above with inductive hypotheses and ?? via triangle inequality and invoking ?? and also using the definition of given in ??, we get that the following holds, simultaneously for all and , with probability at least ,
This proves the inductive step for statement , in the case of , i.e., . The induction is complete and hence the statements of lemma are proved by union bounding over all . This completes the proof of ??. ∎
In the following lemma we analyze the runtime of the CNTK Sketch algorithm,
Proof of ??: First note that the total time to compute for all and and as per ?? is bounded by . Besides the time to compute , there are two other main components to the runtime of this procedure. The first heavy operation corresponds to computing vectors for and and all indices and , in ??. By ??, the time to compute for a fixed , fixed and , and all is bounded by,
The total time to compute vectors for all and all and all indices and is thus bounded by . The next computationally expensive operation is computing vectors for and , and all indices and , in ??. By ??, the runtime of computing for a fixed , fixed and , and all is bounded by,
Hence, the total time to compute vectors for all and and all indices and is . The total runtime bound is obtained by summing up these three contributions. This completes the proof of ??. ∎
The matrix is defined in ?? to be a matrix of i.i.d. normal entries with rows for large enough constant . shows that is a JL transform and hence satisfies the following,
where . By triangle inequality together with ?? and ??, the following bounds hold with probability at least :
Therefore, by union bound we find that, with probability at least :
Be combining the above with ?? using triangle inequality and union bound and also using ??, the following holds with probability at least :
Furthermore, it follows from ?? that for any because the function is non-negative everywhere on $\dot{\Gamma}_{i,j,i^{\prime},j^{\prime}}^{(2)}(y,z)\geq\frac{1}{2q^{2}}\kappa_{0}(\alpha)\geq\frac{1}{2}\alpha\in\Gamma_{i,j,i^{\prime},j^{\prime}}^{(h)}(y,z)\geq\frac{\sqrt{N^{(h)}_{i,j}(y)\cdot N^{(h)}_{i^{\prime},j^{\prime}}(z)}}{q^{2}}\cdot\Sigma_{\tt relu}^{(h)}(-1)\kappa_{0}(\cdot)h\geq 1\dot{\Gamma}_{i,j,i^{\prime},j^{\prime}}^{(h)}(y,z)\geq\frac{1}{q^{2}}\cdot\dot{\Sigma}_{\tt relu}^{(h)}(-1)$.
By using these inequalities and Definition of in ?? together with ??, recursively, it follows that, for every and :
Therefore, using this inequality and ?? we have that for every :
Now using this inequality and ??, the following holds for every :
Therefore, by incorporating the above into ?? we get that,
Runtime analysis: By ??, time to compute the CNTK Sketch is .