Algorithmic Regularization in Learning Deep Homogeneous Models: Layers are Automatically Balanced
Simon S. Du, Wei Hu, Jason D. Lee
Introduction
Modern machine learning models often consist of multiple layers. For example, consider a feed-forward deep neural network that defines a prediction function
where are weight matrices in layers, and is a point-wise homogeneous activation function such as Rectified Linear Unit (ReLU) . A simple observation is that this model is homogeneous: if we multiply a layer by a positive scalar and divide another layer by , the prediction function remains the same, e.g. .
A direct consequence of homogeneity is that a solution can produce small function value while being unbounded, because one can always multiply one layer by a huge number and divide another layer by that number. Theoretically, this possible unbalancedness poses significant difficulty in analyzing first order optimization methods like gradient descent/stochastic gradient descent (GD/SGD), because when parameters are not a priori constrained to a compact set via either coercivenessA function is coercive if implies . of the loss or an explicit constraint, GD and SGD are not even guaranteed to converge (Lee et al., 2016, Proposition 4.11). In the context of deep learning, Shamir (2018) determined that the primary barrier to providing algorithmic results is in that the sequence of parameter iterates is possibly unbounded.
Now we take a closer look at asymmetric matrix factorization, which is a simple two-layer homogeneous model. Consider the following formulation for factorizing a low-rank matrix:
Notice that the gradient of is not homogeneous anymore. Further, consider a globally optimal solution such that is of order and is of order ( being very small). A small perturbation on can lead to dramatic change to the gradient of . This phenomenon can happen for all homogeneous functions when the layers are unbalanced. The lack of nice geometric properties of homogeneous functions due to unbalancedness makes first-order optimization methods difficult to analyze.
A common theoretical workaround is to artificially modify the natural objective function as in (1) in order to prove convergence. In (Tu et al., 2015; Ge et al., 2017a), a regularization term for balancing the two layers is added to (1):
For problem (3), the regularizer removes the homogeneity issue and the optimal solution becomes unique (up to rotation). Ge et al. (2017a) showed that the modified objective (3) satisfies (i) every local minimum is a global minimum, (ii) all saddle points are strictA saddle point of a function is strict if the Hessian at that point has a negative eigenvalue., and (iii) the objective is smooth. These imply that (noisy) GD finds a global minimum (Ge et al., 2015; Lee et al., 2016; Panageas and Piliouras, 2016).
On the other hand, empirically, removing the homogeneity is not necessary. We use GD with random initialization to solve the optimization problem (1). Figure 1(a) shows that even without regularization term like in the modified objective (3) GD with random initialization converges to a global minimum and the convergence rate is also competitive. A more interesting phenomenon is shown in Figure 1(b) in which we track the Frobenius norms of and in all iterations. The plot shows that the ratio between norms remains a constant in all iterations. Thus the unbalancedness does not occur at all! In many practical applications, many models also admit the homogeneous property (like deep neural networks) and first order methods often converge to a balanced solution. A natural question arises:
Why does GD balance multiple layers and converge in learning homogeneous functions?
In this paper, we take an important step towards answering this question. Our key finding is that the gradient descent algorithm provides an implicit regularization on the target homogeneous function. First, we show that on the gradient flow (gradient descent with infinitesimal step size) trajectory induced by any differentiable loss function, for a large class of homogeneous models, including fully connected and convolutional neural networks with linear, ReLU and Leaky ReLU activations, the differences between squared norms across layers remain invariant. Thus, as long as at the beginning the differences are small, they remain small at all time. Note that small differences arise in commonly used initialization schemes such as Gaussian initialization or Xavier/Kaiming initialization schemes (Glorot and Bengio, 2010; He et al., 2016). Our result thus explains why using ReLU activation is a better choice than sigmoid from the optimization point view. For linear activation, we prove an even stronger invariance for gradient flow: we show that stays invariant over time, where and are weight matrices in consecutive layers with linear activation in between.
Next, we go beyond gradient flow and consider gradient descent with positive step size. We focus on the asymmetric matrix factorization problem (1). Our invariance result for linear activation indicates that stays unchanged for gradient flow. For gradient descent, can change over iterations. Nevertheless we show that if the step size decreases like (), will remain small in all iterations. In the set where is small, the loss is coercive, and gradient descent thus ensures that all the iterates are bounded. Using these properties, we then show that gradient descent converges to a globally optimal solution. Furthermore, for rank- asymmetric matrix factorization, we give a finer analysis and show that randomly initialized gradient descent with constant step size converges to the global minimum at a globally linear rate.
The homogeneity issue has been previously discussed by Neyshabur et al. (2015a, b). The authors proposed a variant of stochastic gradient descent that regularizes paths in a neural network, which is related to the max-norm. The algorithm outperforms gradient descent and AdaGrad on several classification tasks.
A line of research focused on analyzing gradient descent dynamics for (convolutional) neural networks with one or two unknown layers (Tian, 2017; Brutzkus and Globerson, 2017; Du et al., 2017a, b; Zhong et al., 2017; Li and Yuan, 2017; Ma et al., 2017; Brutzkus et al., 2017). For one unknown layer, there is no homogeneity issue. While for two unknown layers, existing work either requires learning two layers separately (Zhong et al., 2017; Ge et al., 2017b) or uses re-parametrization like weight normalization to remove the homogeneity issue (Du et al., 2017b). To our knowledge, there is no rigorous analysis for optimizing multi-layer homogeneous functions.
For a general (non-convex) optimization problem, it is known that if the objective function satisfies (i) gradient changes smoothly if the parameters are perturbed, (ii) all saddle points and local maxima are strict (i.e., there exists a direction with negative curvature), and (iii) all local minima are global (no spurious local minimum), then gradient descent (Lee et al., 2016; Panageas and Piliouras, 2016) converges to a global minimum. There have been many studies on the optimization landscapes of neural networks (Kawaguchi, 2016; Choromanska et al., 2015; Du and Lee, 2018; Hardt and Ma, 2016; Bartlett et al., 2018; Haeffele and Vidal, 2015; Freeman and Bruna, 2016; Vidal et al., 2017; Safran and Shamir, 2016; Zhou and Feng, 2017; Nguyen and Hein, 2017a, b; Zhou and Feng, 2017; Safran and Shamir, 2017), showing that the objective functions have properties (ii) and (iii). Nevertheless, the objective function is in general not smooth as we discussed before. Our paper complements these results by showing that the magnitudes of all layers are balanced and in many cases, this implies smoothness.
2 Paper Organization
The rest of the paper is organized as follows. In Section 2, we present our main theoretical result on the implicit regularization property of gradient flow for optimizing neural networks. In Section 3, we analyze the dynamics of randomly initialized gradient descent for asymmetric matrix factorization problem with unregularized objective function (1). In Section 4, we empirically verify the theoretical result in Section 2. We conclude and list future directions in Section 5. Some technical proofs are deferred to the appendix.
3 Notation
We use bold-faced letters for vectors and matrices. For a vector , denote by its -th coordinate. For a matrix , we use to denote its -th entry, and use and to denote its -th row and -th column, respectively (both as column vectors). We use or to denote the Euclidean norm of a vector, and use to denote the Frobenius norm of a matrix. We use to denote the standard Euclidean inner product between two vectors or two matrices. Let .
The Auto-Balancing Properties in Deep Neural Networks
In this section we study the implicit regularization imposed by gradient descent with infinitesimal step size (gradient flow) in training deep neural networks. In Section 2.1 we consider fully connected neural networks, and our main result (Theorem 2.1) shows that gradient flow automatically balances the incoming and outgoing weights at every neuron. This directly implies that the weights between different layers are balanced (Corollary 2.1). For linear activation, we derive a stronger auto-balancing property (Theorem 2.2). In Section 2.2 we generalize our result from fully connected neural networks to convolutional neural networks. In Section 2.3 we present the proof of Theorem 2.1. The proofs of other theorems in this section follow similar ideas and are deferred to Appendix A.
We consider gradient descent with infinitesimal step size (also known as gradient flow) applied on , which is captured by the differential inclusion:
where is a continuous time index, and is the Clarke sub-differential (Clarke et al., 2008). If curves () evolve with time according to (5) they are said to be a solution of the gradient flow differential inclusion.
Our main result in this section is the following invariance imposed by gradient flow.
For any and , we have
Taking sum of (6) over , we obtain the following corollary which says gradient flow preserves the difference between the squares of Frobenius norms of weight matrices.
Corollary 2.1 explains why in practice, trained multi-layer models usually have similar magnitudes on all the layers: if we use a small initialization, is very small at the beginning, and Corollary 2.1 implies this difference remains small at all time. This finding also partially explains why gradient descent converges. Although the objective function like (4) may not be smooth over the entire parameter space, given that is small for all , the objective function may have smoothness. Under this condition, standard theory shows that gradient descent converges. We believe this finding serves as a key building block for understanding first order methods for training deep neural networks.
For linear activation, we have the following stronger invariance than Theorem 2.1:
If for some we have , then
This result was known for linear networks (Arora et al., 2018), but the proof there relies on the entire network being linear while Theorem 2.2 only needs two consecutive layers to have no nonlinear activations in between.
While Theorem 2.1 shows the invariance in a node-wise manner, Theorem 2.2 shows for linear activation, we can derive a layer-wise invariance. Inspired by this strong invariance, in Section 3 we prove gradient descent with positive step sizes preserves this invariance approximately for matrix factorization.
2 Convolutional Neural Networks
Now we show that the conservation property in Corollary 2.1 can be generalized to convolutional neural networks. In fact, we can allow arbitrary sparsity pattern and weight sharing structure within a layer; convolutional layers are a special case.
Denote by the collection of all the parameters in this network, and we consider gradient flow to learn the parameters:
The following theorem generalizes Corollary 2.1 to neural networks with sparse connections and shared weights:
Therefore, for a neural network with arbitrary sparsity pattern and weight sharing structure, gradient flow still balances the magnitudes of all layers.
3 Proof of Theorem 2.1
The proofs of all theorems in this section are similar. They are based on the use of the chain rule (i.e. back-propagation) and the property of homogeneous activations. Below we provide the proof of Theorem 2.1 and defer the proofs of other theorems to Appendix A.
Now we prove (6). Since () can only affect through , we have for ,
On the other hand, only affects through . Using the chain rule, we get
where is interpreted as a set-valued mapping whenever it is applied at a non-differentiable point.More precisely, the equalities should be an inclusion whenever there is a sub-differential, but as we see in the next display the ambiguity in the choice of sub-differential does not affect later calculations.
It follows thatThis holds for any choice of element of the sub-differential, since holds at for any choice of sub-differential.
Comparing the above expression to (7), we finish the proof. ∎
Gradient Descent Converges to Global Minimum for Asymmetric Matrix Factorization
In this section we constrain ourselves to the asymmetric matrix factorization problem and analyze the gradient descent algorithm with random initialization. Our analysis is inspired by the auto-balancing properties presented in Section 2. We extend these properties from gradient flow to gradient descent with positive step size.
Formally, we study the following non-convex optimization problem:
First we consider the general case of . Our main theorem below says that if we use a random small initialization , and set step sizes to be appropriately small, then gradient descent (9) will converge to a solution close to the global minimum of (8). To our knowledge, this is the first result showing that gradient descent with random initialization directly solves the un-regularized asymmetric matrix factorization problem (8).
Now we are using positive step sizes , so we no longer have the invariance of . Nevertheless, by a careful analysis of the updates, we can still prove that is small, the objective decreases, and and stay bounded. Formally, we have the following lemma:
With high probability over the initialization , for all we have:
Balancedness: ;
Decreasing objective: ;
Boundedness: .
Now that we know the GD algorithm automatically constrains in a bounded region, we can use the smoothness of in this region and a standard analysis of GD to show that converges to a stationary point of (Lemma B.2). Furthermore, using the results of (Lee et al., 2016; Panageas and Piliouras, 2016) we know that is almost surely not a strict saddle point. Then the following lemma implies that has to be close to a global optimum since we know from Lemma 3.1 (i). This would complete the proof of Theorem 3.1.
Suppose is a stationary point of such that . Then either , or is a strict saddle point of .
The full proof of Theorem 3.1 and the proofs of Lemmas 3.1 and 3.2 are given in Appendix B.
2 The Rank-111 Case
We have shown in Theorem 3.1 that GD with small and diminishing step sizes converges to a global minimum for matrix factorization. Empirically, it is observed that a constant step size is enough for GD to converge quickly to global minimum. Therefore, some natural questions are how to prove convergence of GD with a constant step size, how fast it converges, and how the discretization affects the invariance we derived in Section 2.
While these questions remain challenging for the general rank- matrix factorization, we resolve them for the case of . Our main finding is that with constant step size, the norms of two layers are always within a constant factor of each other (although we may no longer have the stronger balancedness property as in Lemma 3.1), and we utilize this property to prove the linear convergence of GD to a global minimum.
When , the asymmetric matrix factorization problem and its GD dynamics become
Here we assume has rank , i.e., it can be factorized as where and are unit vectors and .
Our main theoretical result is the following.
Suppose , with () for some sufficiently small constant , and for some sufficiently small constant . Then with constant probability over the initialization, for all we have for some universal constants . Furthermore, for any , after iterations, we have .
Theorem 3.2 shows for and , their strengths in the signal space, and , are of the same order. This approximate balancedness helps us prove the linear convergence of GD. We refer readers to Appendix C for the proof of Theorem 3.2.
Empirical Verification
We perform experiments to verify the auto-balancing properties of gradient descent in neural networks with ReLU activation. Our results below show that for GD with small step size and small initialization: (1) the difference between the squared Frobenius norms of any two layers remains small in all iterations, and (2) the ratio between the squared Frobenius norms of any two layers becomes close to . Notice that our theorems in Section 2 hold for gradient flow (step size ) but in practice we can only choose a (small) positive step size, so we cannot hope the difference between the squared Frobenius norms to remain exactly the same but can only hope to observe that the differences remain small.
Conclusion and Future Work
In this paper we take a step towards characterizing the invariance imposed by first order algorithms. We show that gradient flow automatically balances the magnitudes of all layers in a deep neural network with homogeneous activations. For the concrete model of asymmetric matrix factorization, we further use the balancedness property to show that gradient descent converges to global minimum. We believe our findings on the invariance in deep models could serve as a fundamental building block for understanding optimization in deep learning. Below we list some future directions.
In this paper we focus on the invariance induced by gradient descent. In practice, different acceleration and adaptive methods are also used. A natural future direction is how to characterize the invariance properties of these algorithms.
From gradient flow to gradient descent: a generic analysis?
As discussed in Section 3, while strong invariance properties hold for gradient flow, in practice one uses gradient descent with positive step sizes and the invariance may only hold approximately because positive step sizes discretize the dynamics. We use specialized techniques for analyzing asymmetric matrix factorization. It would be very interesting to develop a generic approach to analyze the discretization. Recent findings on the connection between optimization and ordinary differential equations (Su et al., 2014; Zhang et al., 2018) might be useful for this purpose.
Acknowledgements
We thank Phil Long for his helpful comments on an earlier draft of this paper. JDL acknowledges support from ARO W911NF-11-1-0303.
References
Appendix
Appendix A Proofs for Section 2
Now we suppose for some . Denote . Then we have . Using the chain rule, we can directly compute
The proof is finished by combining (10) and (11). ∎
Appendix B Proof for Rank-r𝑟r Matrix Factorization (Theorem 3.1)
In this section we give the full proof of Theorem 3.1.
First we recall the gradient of our objective function :
With this notation, we can express the Hessian as follows:
Now we use the expression of the Hessian to prove that is locally smooth when both arguments and are bounded.
We prove smoothness by giving an upper bound on for any .
This implies . ∎
Recall the following three properties we want to prove in Lemma 3.1, which we call , and , respectively:
We use induction to prove these statements. For , we can make the Gaussian variance in the initialization sufficiently small such that with high probability we have
From now on we assume they are all satisfied. Then is already satisfied, is satisfied because , and can be verified by .
To prove , and for all , we prove the following three claims. Since we have , and , if the following claims are all true, the proof will be completed by induction.
;
;
.
.
Using the update rule (9) we can calculate
where . Then we have
where the last line is due to and .
Since we have and for all , (13) is still true when substituting with any . Summing all of them and noting , we get
Therefore we have proved . ∎
.
Note that we only need to show . We prove this using the standard analysis of gradient descent, for which we need the smoothness of the objective function (Lemma B.1). We first need to bound , , and . We know from that and . We can also bound and easily from the GD update rule:
Let . From Lemma B.1, is -smooth over . Also note that by our choice. Then using smoothness we have
Therefore we have shown . ∎
.
From we know which implies . Therefore it suffices to prove
Then by the Cauchy-Schwarz inequality we have
Similarly, we also have . Therefore we have proved (15). ∎
B.2 Convergence to a Stationary Point
With the balancedness and boundedness properties in Lemma 3.1, it is then standard to show that converges to a stationary point of .
Under the setting of Theorem 3.1, with high probability exists, and is a stationary point of . Furthermore, satisfies .
We assume the three properties in Lemma 3.1 hold, which happens with high probability. Then from (14) we have
Under the above descent condition, the result of Absil et al. says that the iterates either diverge to infinity or converge to a fixed point. According to Lemma 3.1, { are all bounded, so they have to converge to a fixed point as .
Next, from (16) we know that is bounded. Notice that scales like . So we must have . Then according to the smoothness of in a bounded region (Lemma B.1) we conclude , i.e., is a stationary point.
The second part of the lemma is evident according to Lemma 3.1 (i). ∎
B.3 Proof of Lemma 3.2
The main idea in the proof is similar to Ge et al. [2017a]. We want to find a direction such that either is negative or is close to a global minimum. We show that this is possible when .
Let , and . Define
We will show that is the desired direction. Recall (12):
.
Since is a stationary point of , we have the first-order optimality condition:
Note that and . We have
where we have used the following consequences of (18):
The second term in (17) has the following upper bound:
.
We make use of the following identities, all of which can be directly verified by plugging in definitions:
We also need the following inequality, which is [Ge et al., 2017a, Lemma 6]:
Now we can prove the desired bound as follows:
where in the last line we have used and . ∎
Using Claims B.4 and B.5, we obtain an upper bound on (17):
Therefore, we have either or . In the latter case, is a strict saddle point of . This completes the proof of Lemma 3.2.
B.4 Finishing the Proof of Theorem 3.1
Theorem 3.1 is a direct corollary of Lemma B.2, Lemma 3.2, and the fact that gradient descent does not converge to a strict saddle point almost surely [Lee et al., 2016, Panageas and Piliouras, 2016].
Appendix C Proof for Rank-111 Matrix Factorization (Theorem 3.2)
We define the following four key quantities:
where and are the projection matrices onto the orthogonal complement spaces of and , respectively. Notice that and . It turns out that we can write down the explicit formulas for the dynamics of these quantities:
To facilitate the analysis, we also define:
Then our goal is to show and as . We calculate the dynamics of and :
According to our initialization scheme, with high probability we have and We assume that these conditions are satisfied. We also assume that the signal at the beginning is positive: , which holds with probability . Without loss of generality we assume .If , we can simply flip the signs of and .
Positive signal strengths: ;
Small magnitudes in complement space: ;
Growth of magnitude in signal space: ;
Bounded ratio between two layers: .
In this stage, the strengths in the complement spaces remain small () and the strength in the signal space is growing exponentially (). Furthermore, implies , which means the signal strengths in the two layers are of the same order.
Then we enter stage 2, which is essentially a local convergence phase. The following lemma characterizes the behaviors of the strengths in the signal and noise spaces in this stage.
Let be as defined in Lemma C.1. Then there exists a universal constant such that the followings hold for all :
Non-vanishing signal strengths in both layers: ;
Bounded signal strengths: , i.e., ;
Shrinking magnitudes in complement spaces: ;
Convergence in signal space: .
Note that properties (a) and (b) in Lemma C.2 imply for all , where are universal constants. Property (c) implies that for all where , we have . Then property (d) tells us that after another iterations, we can ensure for all . These imply after iterations, completing the proof of Theorem 3.2. ∎
We use induction to prove the following statements for :
We know that , and hold from our assumptions on the initialization.
().
where in the second inequality we have used the definition of , and the last inequality is true when is sufficiently small.
().
().
Similarly we have . Note that is chosen to be sufficiently small.
().
Since and , we have
().
From we know . Thus
Lastly we upper bound . Note that for all we have . From we know that is increasing exponentially. Therefore, we must have . ∎
By the definition of we know . In the proof of Lemma C.1, we have shown and . These imply for some small universal constant .
We use induction to prove the following statements for all :
is obvious. We know that is true by the definition of . can be shown as follows:
reduces to , which was shown in the proof of Lemma C.1.
().
Notice that we have since and are sufficiently small. Then we have
Similarly we have .
().
Similarly we have .
().
where we have used . Since and , we have . Furthermore, we can choose and small enough such that which implies
where the last step is true when is sufficiently small.
().
From and we have . Also we have . Thus we can make sure and . Then from (24) we have
We have shown and for all . Now we use them to prove for all :
Here we have used , which is clearly true when is small enough.
Therefore, we have finished the proof of Lemma C.2. ∎