Does Preprocessing Help Training Over-parameterized Neural Networks?
Zhao Song, Shuo Yang, Ruizhe Zhang
Introduction
Over the last decade, deep learning has achieved dominating performance over many areas, e.g., computer vision [LBBH98, KSH12, SLJ+15, HZRS16], natural language processing [CWB+11, DCLT18], game playing [SHM+16, SSS+17] and beyond. The computational resource requirement for deep neural network training grows very quickly. Designing a fast and provable training method for neural networks is, therefore, a fundamental and demanding challenge.
Almost all deep learning models are optimized by gradient descent (or its variants). The total training time can be split into two components, the first one is the number of iterations and the second one is the cost per spent per iteration. Nearly all the iterative algorithms for acceleration can be viewed as two separate lines of research correspondingly, the first line is aiming for an algorithm that has as small as possible number of iterations, the second line is focusing on designing as efficient as possible data structures to improve the cost spent per iteration of the algorithm [Vai89, CLS19, LSZ19, JLSW20, JKL+20, JSWZ21]. In this paper, our major focus is on the second line.
Is it possible to improve the cost per iteration of training neural network algorithm? E.g., is possible?
We provide a new theoretical framework for speeding up neural network training by: 1) adopting the shifted neural tangent kernel; 2) showing that only a small fraction () of neurons are activated for each input data in each training iteration; 3) identifying the sparsely activated neurons via geometric search; 4) proving that the algorithm can minimize the training loss to zero in a linear convergence rate.
We provide two theoretical results 1) our first result (Theorem 6.1) builds a dynamic half-space report data structure for the weights of a neural network, to train neural networks in sublinear cost per iteration; 2) our second result (Theorem 6.2) builds a static half-space report data-structure for the input data points of the training data set for training a neural network in sublinear time.
The goal of our paper is to theoretically characterize the acceleration brought by the high-dimensional geometric data structure. Specifically, our algorithm and analysis are built upon the HSR data structures [AEM92] which can find all the points that have large inner products and support efficient data update. Note that HSR comes with a stronger recovery guarantee than LSH, in the sense that HSR, whereas LSH is guaranteed to find some of those points.
Convergence via over-parameterization.
Over the last few years, there has been a tremendous work studying the convergence result of deep neural network explicilty or implicitly based on neural tangent kernel (NTK) [JGH18], e.g. [LL18, DZPS19, AZLS19a, AZLS19b, DLL+19, ADH+19a, ADH+19b, SY19, CGH+19, ZMG19, CG19, ZG19, OS20, LSS+20, JT20, ZPD+20, HLSY21, BPSW21]. It has been shown that (S)GD can train a sufficiently wide NN with random initialization will converge to a small training error in polynomial steps.
Challenges and Techniques
Empirical works combine high-dimensional search data structures (e.g., LSH) with neural network training, however, they do not work theoretically due to the following reasons:
Without shifting, the number of activated (and therefore updated) neurons is . There is no hope to theoretically prove complexity (See Challenge 1).
Approximate high-dimensional search data structures might miss some important neurons, which can potentially prevent the training from converging (see Challenge 2).
We propose a shifted ReLU activation that is guaranteed to have number of activated neurons. Along with the shifted ReLU, we also propose a shifted NTK to rigorously provide a convergence guarantee (see Solution 1).
We adopt an exact high-dimensional search data structure that better couples with the shifted NTK. It takes time to identify the activated neurons and fits well with the convergence analysis as it avoids missing important neurons (see Solution 2).
Solution 1
The problem actually comes from the activation function. In practice, people use a shifted ReLU function to train neural networks. The main observation of our work is that threshold implies sparsity. We consider the setting where all neurons have a unified threshold parameter . Then, by the concentration of Gaussian distribution, there will be activated neurons after the initialization.
The next step is to show that the number of activated neurons will not blow up too much in the following training iterations. In [DZPS19, SY19], they showed that the weights vectors are changing slowly during the training process. In our work, we open the black box of their proof and show a similar phenomenon for the shifted ReLU function. More specifically, a key component is to prove that for each training data, a large fraction of neurons will not change their status (from non-activated to activated and vice versa) in the next iteration with high probability. To achieve this, they showed that this is equivalent to the event that a standard Gaussian random variable in a small centered interval , and applied the anti-concentration inequality to upper-bound the probability. In our setting, we need to upper-bound the probability of in a shifted interval . On the one hand, we can still apply the anti-concentration inequality by showing that the probability is at most . On the other hand, this probability is also upper-bounded by , and for small , we can apply the concentration inequality for a more accurate estimation. In the end, by some finer analysis of the probability, we can show that with high probability, the number of activated neurons in each iteration is also for each training data. If we take , we only need to deal with truly sublinear in of activated neurons in the forward evaluation.
Challenge 2: How to find the small subset of activated neurons?
A linear scan of the neurons will lead to a time complexity linear in , which we hope to avoid. Randomly sampling or using LSH for searching can potentially miss important neurons which are important for a rigorous convergence analysis.
Solution 2
Preliminaries
This section is organized as follows. Section 3.1 introduces the neural network and present problem formulation. Section 3.2 presents the half-space report data-structure, Section 3.3 proposes our new sparsity-based Characterizations.
1 Problem Formulation
We say function is for simplicity.
For each , we sample
For each , we sample from uniformly at random
To update the weights from iteration to iteration , we follow the standard update rule of the GD algorithm,
The ODE of the gradient flow is defined as
2 Data Structure for Half-Space Reporting
The half-space range reporting problem is an important problem in computational geometry, which is formally defined as following:
Let denote the pre-processing time to build the data structure, denote the time per query and time per update.
We use the data-structure proposed in [AEM92] to solve the half-space range reporting problem, which admits the interface summarized in Algorithm 1. Intuitively, the data-structure recursively partitions the set and organizes the points in a tree data-structure. Then for a given query , all points of with are reported quickly. Note that the query here defines the half-space in Definition 3.5.
Adapted from [AEM92], the algorithm comes with the following complexity:
Part 1. , amortized .
Part 2. , amortized .
We remark that Part 1 will be used in Theorem 6.1 and Part 2 will be used in Theorem 6.2.
3 Sparsity-based Characterizations
In this section, we consider the ReLU function with a nonzero threshold: , which is commonly seen in practise, and also has been considered in theoretical work [ZPD+20].
We first define the set of neurons that are firing at time .
We propose a new “sparsity” lemma in this work. It shows that gives the desired sparsity.
Let be a tunable parameter. If we use the as the activation function, then after the initialization, with probability at least , it holds that for each input data , the number of activated neurons is at most , where is the total number of neurons.
By the concentration of Gaussian distribution, the initial fire probability of a single neuron is
Hence, for the indicator variable , we have
By standard concentration inequality (Lemma B.1),
where . If we choose , then we have:
Then, by union bound over all , we have that with high probability
the number of initial fire neurons for the sample is bounded by . ∎
The following remark gives an example of setting the threshold , and will be useful for showing the sublinear complexity in the next section.
If we choose then . For , Eq. (5) implies that
Training Neural Network with Half-Space Reporting Data Structure
In this section, we present two sublinear time algorithms for training over-parameterized neural networks. The first algorithm (Section 4.1) relies on building a high-dimensional search data-structure for the weights of neural network. The second algorithm (Section 4.2) is based on building a data structure for the input data points of the training set. Both of the algorithms use the HSR to quickly identify the fired neurons to avoid unnecessary calculation. The time complexity and the sketch of the proof are provided after each of the algorithms.
We first introduce the algorithm that preprocesses the weights for , which is commonly used in practice [CLP+21, CMF+20, KKL20]. Recall is . By constructing a HSR data-structure for ’s, we can quickly find the set of active neurons for each of the training sample . See pseudo-code in Algorithm 2.
In the remaining part of this section, we focus on the time complexity analysis of Algorithm 2. The convergence proof will be given in Section 5.
Given data points in -dimensional space. Running gradient descent algorithm (Algorithm 2) on (Definition 3.1) the expected cost per-iteration of the gradient descent algorithm is
The first term corresponds to the running time of querying the active neuron set for all training samples . With the first result in Corollary 3.6, the complexity is bounded by .
The second term corresponds to updating in the high-dimensional search data-structure (Lines 9 and 10). Again with the first result in Corollary 3.6, we have . Combining with the fact that , the second term is bounded by .
The third term is the time complexity of gradient calculation restricted to the set . With the bound on (Lemma C.10), we have .
Putting them together completes the proof. ∎
2 Data Preprocessing
While the weights preprcessing algorithm is inspired by the common practise, the dual relationship between the input and model weights inspires us to preprocess the dataset before training (i.e., building HSR data-structure for ). This largely improves the per-iteration complexity and avoids the frequent updates of the data structure since the training data is fixed. More importantly, once the training dataset is preprocessed, it can be reused for different models or tasks, thus one does not need to perform the expensive preprocessing for each training.
The corresponding pseudocode is presented in Algorithm 3. With preprocessed, we can query HSR with weights and the result is the set of training samples for which fires for. Given for , we can easily reconstruct the set , which is the set of neurons fired for sample . The forward and backward pass can then proceed similar to Algorithm 2.
At the end of each iteration, we will update based on the new estimation and update accordingly. For Algorithm 3, the HSR data-structure is static for the entire training process. This is the main difference from Algorithm 2, where the HSR needs to be updated every time step to account for the changing weights .
We defer the convergence analysis to Section 5 and focus on the time complexity analysis of Algorithm 2 in the rest of this section. We consider being a constant for the rest of this subsection.
Given data points in -dimensional space. Running gradient descent algorithm (Algorithm 2) on (Definition 3.1), the expected per-iteration running time of initializing for is The cost per iteration of the training algorithm is
We analyze the initialization and training parts separately.
In Lines 4 and 5, the sets for are initialized. For each , we need to query the data structure the set of data points ’s such that . Hence, the running time of this step is
where the second step follows from .
Training
Consider training the neural network for steps. For each step, first notice that the forward and backward computation parts (Line 7 - 9) are the same as previous algorithm. The time complexity is .
We next show that maintaining and (Line 10 - 14) takes time. For each fired neuron , we first remove the indices of data in the sets , which takes time
Then, we find the new set of ’s such that by querying the half-space reporting data structure. The total running time for all fired neurons is
Then, we update the index sets in time . Therefore, each training step takes time, which completes the proof. ∎
Convergence of Our Algorithm
We state the result of our training neural network algorithms (Lemma 5.2) can converge in certain steps. An important component in our proof is to find out a lower bound on minimum eigenvalue of the continuous Hessian matrix . It turns out to be an anti-concentration problem of the Gaussian random matrix. In [OS20], they gave a lower bound on for ReLU function with , assuming the input data are separable. One of our major technical contribution is generalizing it to arbitrary .
With proposition 5.1, we are ready to show the convergence rate of training an over-parameterized neural network with shifted ReLU function.
Suppose input data-points are -separable, i.e., . Let and . Let . Then
Note that the randomness is over initialization. Eventually, we choose where is the final accuracy.
This result shows that despite the shifted ReLU and sparsely activated neurons, we can still retain the linear convergence. Combined with the results on per-step complexity in the previous section, it gives our main theoretical results of training deep learning models with sublinear time complexity (Theorem 6.1 and Theorem 6.2).
Main Classical Results
We present two theorems (under classical computation model) of our work, showing the sublinear running time and linear convergence rate of our two algorithms. We leave the quantum application into Appendix G. The first algorithm is relying on building a high-dimensional geometric search data-structure for the weights of a neural network.
Given data points in -dimensional space. We preprocess the initialization weights of the neural network. Running gradient descent algorithm (Algorithm 2) on a two-layer, -width, over-parameterized ReLU neural network will minimize the training loss to zero, and the expected running time of gradient descent algorithm (per iteration) is
The second algorithm is based on building a data structure for the input data points of the training set. Our second algorithm can further reduce the cost per iteration from to truly sublinear in , e.g. .
Given data points in -dimensional space. We preprocess all the data points. Running gradient descent algorithm (Algorithm 3) on a two-layer, -width, over-parameterized ReLU neural network will minimize the training loss to zero, and the expected running time of gradient descent algorithm (per iteration) is
Discussion and Limitations
In this paper, we propose two sublinear algorithms to train neural networks. By preprocessing the weights of the neuron networks or preprocessing the training data, we rigorously prove that it is possible to train a neuron network with sublinear complexity, which overcomes the barrier in classical training methods. Our results also offer theoretical insights for many previously established fast training methods.
Our algorithm is intuitively related to the lottery tickets hypothesis [FC18]. However, our theoretical results can not be applied to explain lottery tickets immediately for two reasons: 1) the lottery ticket hypothesis focuses on pruning weights; while our results identify the important neurons. 2) the lottery ticket hypothesis identifies the weights that need to be pruned after training (by examining their magnitude), while our algorithms accelerate the training via preprocessing. It would be interesting to see how our theory can be extended to the lottery ticket hypothesis.
One limitation of our work is that the current analysis framework does not provide a convergence guarantee for combining LSH with gradient descent, which is commonly seen in many empirical works. Our proof breaks as LSH might miss important neurons which potentially ruins the convergence analysis. Instead, we refer to the HSR data structure, which provides a stronger theoretical guarantee of successfully finding all fired neurons.
References
Roadmap.
In Section A, we present our main algorithms. In Section B, we provide some preliminaries. In Section C, we provide sparsity analysis. We show convergence analysis in Section D. In Section E, we show how to combine the sparsity, convergence, running time all together. In Section F, we show correlation between sparsity and spectral gap of Hessian in neural tangent kernel. In Section G, we discuss how to generalize our result to quantum setting.
Appendix A Complete Algorithms
In this section, we present three algorithms (Alg. 4, Alg. 5 and Alg. 6) which are the complete version of Alg. 1, Alg. 2 and Alg. 3.
Appendix B Preliminaries
B.1 Probabilities
Let . Then, for ,
B.2 Half-space reporting data structures
The time complexity of HSR data structure is:
Let be a fixed constant. Let be a parameter between and . There is a dynamic data structure for half-space reporting that uses space and pre-processing time, time per query where is the output size and is any fixed constant, and amortized update time.
Part 1., , amortized .
Part 2., , amortized .
B.3 Basic algebras
Appendix C Sparsity Analysis
In [DZPS19, SY19], they proved the following lemma for . Here, we provide a more general statement for any .
For any shift parameter , we define continuous version of shifted NTK and discrete version of shifted NTK as:
We define .
Let be number of samples of , then
We will use the matrix Chernoff bound (Theorem B.4) to provide a lower bound on the least eigenvalue of discrete version of shifted NTK .
Hence, . We need to upper-bound . Naively, we have
since for each entry at ,
Hence, by matrix Chernoff bound (Theorem B.4) and choosing choose , we can show
C.2 Handling Hessian if perturbing weight
We present a tool which is inspired by a list of previous work [DZPS19, SY19].
Part 1, holds with probability at least .
Part 2, holds with probability at least .
where the first step follows from definition of Frobenius norm, the last third step follows from by defining
For simplicity, we use to (note that we fixed and ).
Note that event happens iff happens.
Prior work [DZPS19, SY19] only one way to bound . We present two ways of arguing the upper bound on . One is anti-concentration, and the other is concentration.
where the last step follows from and is a constant.
If the event happens and the event happens, then we have
If the event happens or the event happens, then we obtain
Define . Thus, we are able to use Lemma B.1,
Define . Thus, it gives
where are some constants.
Define . By Lemma B.1,
For the second part, by Lemma C.2, . Hence,
which happens with probability by the union bound. ∎
C.3 Total movement of weights
For , let be an matrix with -th entry:
We follow the standard notation in Lemma 3.5 in [SY19].
We state a tool from previous work [DZPS19, SY19] (more specifically, Lemma 3.4 in [DZPS19], Lemma 3.6 in [SY19]). Since adding the shift parameter to NTK doesn’t affect the proof of the following lemma, thus we don’t provide a proof and refer the readers to prior work.
,
C.4 Bounded gradient
The proof of Lemma 3.6 in [SY19] implicitly implies the following basic property of gradient.
C.5 Upper bound on the movement of weights per iteration
The following Claim is quite standard in the literature, we omitt the details.
C.6 Bounding the number of fired neuron per iteration
We define the set of neurons that are flipping at time :
Over all the iterations of training algorithm, there are some neurons that never flip states. We provide a mathematical formulation of that set,
For each , let denote the set of neurons that are never flipped during the entire training process,
In Lemma 3.8, we already show that for all with high probability. We can show that it also holds for .
Let be a parameter, and let be the activation function. For each , is the number of activated neurons at the -th iteration. For , with probability at least , is at most for all .
The base case of is shown by Lemma 3.8 that for all with probability at least .
Assume that the statement holds for . By Claim C.7, we know ,
If we take , we have that
By a union bound for , we obtain with probability
the number of activated neurons for at the -th iteration of the algorithm is
where the last step follows from by Lemma 3.8.
The Lemma is then proved for all . ∎
Let . For , let be the set defined by Eq. (6). Part 1. For , if and only if . Part 2. If , then
Part 1. We first note that is equivalent to the event that
Assume that . Then, we can write with and .
Now, suppose there exists a such that .
Since and , we can see that the above conditions hold if and only if
In other words, if and only if .
where the last step follows from . ∎
Appendix D Convergence Analysis
The following Claim provides an upper bound for initialization. Prior work only shows it for , we generalize it to . The modification to the proof of previous Claim 3.10 in [SY19] is quite straightforward, thus we omit the details here.
Let denote the NTK shifted parameter. Let parameter denote the failure probability. Then
D.2 Bounding progress per iteration
In previous work, [SY19] define and only for . In this section, we generalize it to . Let us define two shifted matrices and
Following the same proof as Claim 3.9 [SY19], we can show that the following Claim. The major difference between our claim and Claim 3.9 in [SY19] is, they only proved it for the case . We generalize it to . The proof is several basic algebra computations, we omit the details here.
The nontrivial parts in our analysis is how to bound and for the shifted cases (We will provide a proof later). Once we can bound all these terms, we can show the following result for one iteration of the algorithm:
D.3 Upper bound on the norm of dual Hessian
The proof of the following fact is similar to Fact C.1 in [SY19]. We generalize the to . The same bound will hold as Fact C.1 in [SY19] if we replace by . Thus, we omit the details here.
Let . Let shifted matrix be defined as Eq. (8). For all , we have
D.4 Bounding the gradient improvement term
By Lemma C.2, there exists constants such that
If we have or , then
D.5 Bounding the blowup by the dual Hessian term
Using Fact D.4, we have .
By Lemma C.10, , it has
Hence, with probability at least
D.6 Bounding the blowup by the flip-neurons term
D.7 Bounding the blowup by the prediction movement term
The proof of the following Claim is quite standard and simple in literature, see Claim 3.14 in [SY19]. We omit the details here.
D.8 Putting it all together
The goal of this section to combine all the convergence analysis together.
Let , , let , and
We know with probability ,
Claim C.7 requires the following relationship between and ,
By Claim D.1, we can upper bound the prediction error at the initialization,
Claim D.5 (where is a constant) requires an upper bound on ,Due to the relationship between and , we are not allowed to choose in an arbitrary function of . Thus, we should only expect to use to fix the problem.
Combing the lower bound and upper bound of , it implies the lower bound on in our Lemma statement.
which is dominated by the lower bound on in our lemma statement, thus we can ignore it.
However, by Theorem F.1, it will always hold for any .
where it follows from taking and .
Therefore, we can take the choice of the parameters and Eqs. (11), (12) imply
Appendix E Combine
Let denote the number of points. Let denote the dimension of points. Let denote the failure probability. Let be the separability of data points. For any parameter , we choose , if
If we preprocess the initial weights of the neural network, then we choose to get the desired running time.
If we preprocess the training data points, then we choose to be an arbitrarily small constant to get the desired running time.
Since we know the upper bound of , thus we need to choose
Let us choose , for any .
Given data points in -dimensional space. Running gradient descent algorithm on a two-layer ReLU (over-parameterized) neural network with neurons in the hidden layers is able to minimize the training loss to zero, let denote the preprocessing time and denote the cost per iteration of gradient descent algorithm.
If we preprocess the initial weights of the neural network (Algorithm 2), then
If we preprocess the training data points (Algorithm 3), then
Appendix F Bounds for the Spectral Gap with Data Separation
Let . Recall the continuous Hessian matrix is defined by
Let . Then, we have
Then, can be written as
where denotes the Hadamard product between and .
By Claim B.7, and since for all , we only need to show:
where the first step follows from Jensen’s inequality, the second step follows from Markov’s inequality, the last step follows from .
Since this is true for all , we find Eq. (17) with by choosing as described later.
For , Gaussian small ball guarantees
Then, by Theorem 3.1 in [LS01] (Claim B.2), we have
Next, we argue that is small for all . For a fixed , observe that
Let .
Then, from Gaussian anti-concentration bound (Lemma B.3) and variance bound on , we have
Define to be the following event:
where the last step follows from choosing .
where the third step follows from .
On the event , by Claim F.2, we have that .
Furthermore, conditioned on , are independent as ’s are function of alone. Hence, can be split into two equally likely events that are symmetric with respect to i.e. and .
Now, using , we find
where , and the sixth step follows from , the last step follows from the concentration of Gaussian distribution. In Line 5 and 6 of the above proof, is sampled from . ∎
If , then implies that .
If , then implies that .
That is, if , then we have .
Case 1. We can assume . By assumption, we know that .
According to the range of , it implies .
If , then by the range of , we have .
Case 2. The case can be proved in a similar way. ∎
Appendix G Quantum Algorithm for Training Neural Network
In this section, we provide a quantum-classical hybrid approach to train neural networks with truly sub-quadratic time per iteration. The main observation is that the classical HSR data structure can be replaced with the Grover’s search algorithm in quantum.
We first state our main result in below, showing the running time of our quantum training algorithm:
Given data points in -dimensional space. Running gradient descent algorithm on a two-layer, -with, over-parameterized, and ReLU neural network will minimize the training loss to zero, let denote the cost per iteration of gradient descent algorithm. Then, we have
by applying Grover’s search algorithm for the neurons (Algorithm 7) or the input data points (Algorithm 8).
We remark that previous works ([KLP19, AHKZ20]) on training classical neural networks use the quantum linear algebra approach, which achieves quantum speedup in the linear algebra operations in the training process. For example, [KLP19] used the block encoding technique to speedup the matrix multiplication in training convolutional neural network (CNN). [AHKZ20] used the quantum inner-product estimation to reduce each neuron’s computational cost. One drawback of this approach is that the quantum linear algebra computation incurs some non-negligible errors. Hence, extra efforts of error analysis are needed to guarantee that the intermediate errors will not affect the convergence of their algorithms.
Compared with the previous works, the only quantum component of our algorithm is Grover’s search. So, we do not need to worry about the quantum algorithm’s error in the training process. And we are able to use our fast training framework to exploit a sparse structure, which makes the Grover’s search algorithm run very fast, and further leads to a truly sub-quadratic training algorithm.
We also remark the difference between two algorithms in this quantum section the first algorithm runs Grover’s search for each data point to find the activated neurons, while the second one runs Grover’s search for each neuron to find the data points that make it activated. The advantage of Algorithm 8 is it uses less quantum resources, since its search space is of size and the first algorithm’s search space is of size .
We first state a famous result about the quadratic quantum speedup for the unstructured search problem using Grover’s search algorithm.
Given access to the evaluation oracle for an unknown function such that for some unknown number , we can find all ’s in in -time quantumly.
For , the time complexity of the -th iteration in Algorithm 7 is
Since for all , the running time per iteration of Algorithm 7 is , which completes the proof of the lemma. ∎
The following lemma proves the running time of Algorithm 8.
For , the time complexity of the -th iteration in Algorithm 8 is
The classical part is quite similar to Algorithm 6, which takes -time per iteration.
Therefore, the cost per iteration is , and the lemma is then proved. ∎
Combining Lemma G.5 and Lemma G.6 proves the main result of this section:
In Section E, we prove that with high probability for all if we take . Hence, by Lemma G.5, each iteration in Algorithm 7 takes
time in quantum. On the other hand, by Lemma G.6, each iteration in Algorithm 8 takes quantum time
where the second step is by , which completes the proof of the corollary. ∎