Identity Matters in Deep Learning
Moritz Hardt, Tengyu Ma
Introduction
Traditional convolutional neural networks for image classification, such as AlexNet (), are parameterized in such a way that when all trainable weights are , a convolutional layer represents the -mapping. Moreover, the weights are initialized symmetrically around This standard parameterization makes it non-trivial for a convolutional layer trained with stochastic gradient methods to preserve features that were already good. Put differently, such convolutional layers cannot easily converge to the identity transformation at training time.
This shortcoming was observed and partially addressed by through batch normalization, i.e., layer-wise whitening of the input with a learned mean and covariance. But the idea remained somewhat implicit until residual networks (; ) explicitly introduced a reparameterization of the convolutional layers such that when all trainable weights are the layer represents the identity function. Formally, for an input each residual layer has the form rather than This simple reparameterization allows for much deeper architectures largely avoiding the problem of vanishing (or exploding) gradients. Residual networks, and subsequent architectures that use the same parameterization, have since then consistently achieved state-of-the-art results on various computer vision benchmarks such as CIFAR10 and ImageNet.
In this work, we consider identity parameterizations from a theoretical perspective, while translating some of our theoretical insight back into experiments. Loosely speaking, our first result underlines how identity parameterizations make optimization easier, while our second result shows the same is true for representation.
In analogy with residual networks, we will instead parameterize the objective function as
Here, denotes the spectral norm of The constant factor depends on the conditioning of We give the formal statement in Theorem 2.1. The theorem has the interesting consequence that as the depth increases, smaller norm solutions exist and hence regularization may offset the increase in parameters.
Universal finite sample expressivity.
Going back to non-linear residual networks with ReLU activations, we can ask: How expressive are deep neural networks that are solely based on residual layers with ReLU activations? To answer this question, we give a very simple construction showing that such residual networks have perfect finite sample expressivity. In other words, a residual network with ReLU activations can easily express any functions of a sample of size provided that it has sufficiently more than parameters. Note that this requirement is easily met in practice. On CIFAR 10 (), for example, successful residual networks often have more than parameters. More formally, for a data set of size with classes, our construction requires parameters. Theorem 3.2 gives the formal statement.
The power of all-convolutional residual networks.
2 Related Work
Since the advent of residual networks (; ), most state-of-the-art networks for image classification have adopted a residual parameterization of the convolutional layers. Further impressive improvements were reported by with a variant of residual networks, called dense nets. Rather than adding the original input to the output of a convolutional layer, these networks preserve the original features directly by concatenation. In doing so, dense nets are also able to easily encode an identity embedding in a higher-dimensional space. It would be interesting to see if our theoretical results also apply to this variant of residual networks.
There has been recent progress on understanding the optimization landscape of neural networks, though a comprehensive answer remains elusive. Experiments in and suggest that the training objectives have a limited number of bad local minima with large function values. Work by draws an analogy between the optimization landscape of neural nets and that of the spin glass model in physics (). showed that -layer neural networks have no bad differentiable local minima, but they didn’t prove that a good differentiable local minimum does exist. and show that linear neural networks have no bad local minima. In contrast, we show that the optimization landscape of deep linear residual networks has no bad critical point, which is a stronger and more desirable property. Our proof is also notably simpler illustrating the power of re-parametrization for optimization. Our results also indicate that deeper networks may have more desirable optimization landscapes compared with shallower ones.
Optimization landscape of linear residual networks
We will analyze the landscape of the population risk, defined as,
Recall that is the spectral norm of . We define the norm for the tensor as the maximum of the spectral norms of its slices,
We first note that the condition is without loss of generality in the following sense. Given any linear transformation with negative determinant, we can effectively flip the determinant by augmenting the data and the label with an additional dimension: let and , where is an independent random variable (say, from standard normal distribution), and let . Then, we have that and .When the dimension is odd, there is an easier way to see this – flipping the label corresponds to flipping , and we have .
Second, we note that here should be thought of as a constant since if is too large (or too small), we can scale the data properly so that . Concretely, if , then we can scaling for the outputs properly so that and . In this case, we have , which will remain a small constant for fairly large condition number . We also point out that we made no attempt to optimize the constant factors here in the analysis. The proof of Theorem 2.1 is rather involved and is deferred to Section A.
Given the observation of Theorem 2.1, we restrict our attention to analyzing the landscape of in the set of with -norm less than ,
For any , we have that any critical point of the objective function inside the domain must also be a global minimum.
Theorem 2.2 suggests that it is sufficient for the optimizer to converge to critical points of the population risk, since all the critical points are also global minima.
Moreover, in addition to Theorem 2.2, we also have that any inside the domain satisfies that
Equation (2.3) says that the gradient has fairly large norm compared to the error, which guarantees convergence of the gradient descent to a global minimum () if the iterates stay inside the domain which is not guaranteed by Theorem 2.2 by itself.
Towards proving Theorem 2.2, we start off with a simple claim that simplifies the population risk. We use to denote the Frobenius norm of a matrix, and denotes the inner product of and in the standard basis (that is, where denotes the trace of a matrix.)
Here is a constant that doesn’t depend on , and denote the square root of , that is, the unique symmetric matrix that satisfies .
Next we compute the gradients of the objective function from straightforward matrix calculus. We defer the full proof to Section A.
The gradients of can be written as,
Now we are ready to prove Theorem 2.2. The key observation is that each matric has small norm and cannot cancel the identity matrix. Therefore, the gradients in equation (2.5) is a product of non-zero matrices, except for the error matrix . Therefore, if the gradient vanishes, then the only possibility is that the matrix vanishes, which in turns implies is an optimal solution.
Therefore we complete the proof of equation (2.3). Finally, if is a critical point, namely, , then by equation (2.3) we have that . That is, is a global minimum. ∎
Representational Power of the Residual Networks
A residual network is composed of a sequence of such residual blocks. In comparison with the full pre-activation architecture in , we remove two batch normalization layers and one ReLU layer in each building block.
We assume that for every , we have for some absolute constant
Images, for example, can always be imperceptibly perturbed in pixel space so as to satisfy this assumption for a small but constant
Under this mild assumption, we prove that residual networks have the power to express any possible labeling of the data as long as the number of parameters is a logarithmic factor larger than .
Suppose the training examples satisfy Assumption 3.1. Then, there exists a residual network (specified below) with parameters that perfectly expresses the training data, i.e., for all the network maps to
It is common in practice that as is for example the case for the Imagenet data set where and
We briefly sketch the proof of the Lemma to provide intuitions, and defer the full proof to Section B. The operation that each residual block applies to the hidden variable can be abstractly written as,
where corresponds to the hidden variable before the block and corresponds to that after. We claim that for an (almost) arbitrary sequence of vectors , there exists such that operation (3.5) transforms vectors of ’s to an arbitrary set of other vectors that we can freely choose, and maintain the value of the rest of vectors. Concretely, for any subset of size , and any desired vector , there exist such that
Power of all-convolutional residual networks
Inspired by our theory, we experimented with all-convolutional residual networks on standard image classification benchmarks.
We trained our models with the Tensorflow framework, using a momentum optimizer with momentum and batch size is . All convolutional weights are trained with weight decay The initial learning rate is which drops by a factor and and steps. The model reaches peak performance at around steps, which takes about on a single NVIDIA Tesla K40 GPU. Our code can be easily derived from an open source implementationhttps://github.com/tensorflow/models/tree/master/resnet by removing batch normalization, adjusting the residual components and model architecture. An important departure from the code is that we initialize a residual convolutional layer of kernel size and output channels using a random normal initializer of standard deviation rather than used for standard convolutional layers. This substantially smaller weight initialization helped training, while not affecting representation.
A notable difference from standard models is that the last layer is not trained, but simply a fixed random projection. On the one hand, this slightly improved test error (perhaps due to a regularizing effect). On the other hand, it means that the only trainable weights in our model are those of the convolutions, making our architecture “all-convolutional”.
An interesting aspect of our model is that despite its massive size of million trainable parameters, the model does not seem to overfit too quickly even though the data set size is In contrast, we found it difficult to train a model with batch normalization of this size without significant overfitting on CIFAR10.
Table 2 summarizes the top- classification error of our models compared with a non-exhaustive list of previous works, restricted to the best previous all-convolutional result by , the first residual results , and state-of-the-art results on CIFAR by . All results are with standard data augmentation.
2 ImageNet
The ImageNet ILSVRC 2012 data set has data points with classes. Each image is resized to pixels with channels. We experimented with an all-convolutional variant of the -layer network in . The original model achieved classification error. Our derived model has trainable parameters. We trained the model with a momentum optimizer (with momentum ) and a learning rate schedule that decays by a factor of every two epochs, starting from the initial learning rate Training was distributed across machines updating asynchronously. Each machine was equipped with GPUs (NVIDIA Tesla K40) and used batch size split across the GPUs so that each GPU updated with batches of size
In contrast to the situation with CIFAR10 and CIFAR100, on ImageNet our all-convolutional model performed significantly worse than its original counterpart. Specifically, we experienced a significant amount of underfitting suggesting that a larger model would likely perform better.
Despite this issue, our model still reached top- classification error on the test set ( data points), and top- test error after steps (about one week of training). While no longer state-of-the-art, this performance is significantly better than the reported by , as well as the best all-convolutional architecture by . We believe it is quite likely that a better learning rate schedule and hyperparameter settings of our model could substantially improve on the preliminary performance reported here.
Conclusion
Our theory underlines the importance of identity parameterizations when training deep artificial neural networks. An outstanding open problem is to extend our optimization result to the non-linear case where each residual has a single ReLU activiation as in our expressivity result. We conjecture that a result analogous to Theorem 2.2 is true for the general non-linear case. Unlike with the standard parameterization, we see no fundamental obstacle for such a result.
We hope our theory and experiments together help simplify the state of deep learning by aiming to explain its success with a few fundamental principles, rather than a multitude of tricks that need to be delicately combined. We believe that much of the advances in image recognition can be achieved with residual convolutional layers and ReLU activations alone. This could lead to extremely simple (albeit deep) architectures that match the state-of-the-art on all image classification benchmarks.
Acknowledgment: We thank Jason D. Lee, Qixing Huang, and Jonathan Shewchuk for helpful discussions and kindly pointing out errors in earlier versions of the paper. We also thank Jonathan Shewchuk for suggesting an improvement of equation (2.3) that is incorporated into the current version. Tengyu Ma would like to thank the support by Dodds Fellowship and Siebel Scholarship.
References
Appendix A Missing Proofs in Section 2
In this section, we give the complete proofs for Theorem 2.1 and Lemma 2.4, which are omitted in Section 2.
We see that the network defined by reconstruct the transformation , and therefore it’s a global minimum of the population risk (formally see Claim 2.3 below). Next, we verify that each of the has small spectral norm:
Towards fully proving the Theorem 2.1, we start with the following Claim:
We first consider the case when is a rotation. Each rotation matrix can be written as . Suppose . Then we can take and . We can verify that
Next, we consider the case when is a reflection. Then we have that can be written as , where is the reflection with respect to the -axis. Then we can take and and complete the proof. ∎
Next we give the formal full proof of Theorem 2.1. The main idea is to reduce to the block diagonal situation and to apply the Claim above.
Let be the singular value decomposition of , where , are two orthonormal matrices and is a diagonal matrix with nonnegative entries on the diagonal. Since and , we can flip properly so that . Since is a normal matrix (that is, satisfies that ), by Claim C.1, we have that can be block-diagonalized by orthonormal matrix into , where is a real block diagonal matrix with each block being of size at most . Using Claim A.1, we have that for any , there exists such that
and . Let and . We can rewrite equation (A.2) as
Moreover, we have that is a diagonal matrix with on the diagonal. Since ’s are orthonormal matrix with determinant 1, we have . That is, has an even number of ’s on the diagonal. Then we can group the ’s into blocks. Note that is the rotation matrix . Thus we can write as a concatenation of ’s on the diagonal and block . Then applying Claim A.1 (on each of the block ), we obtain that there are such that
where . Thus using equation (A.3) and (2.3), we obtain that
Moreover, we have that for every , , because is an orthonormal matrix. The same can be proved for . Thus let for and , and we can rewrite,
We can deal with similarly by decomposing into matrices that are close to identity matrix,
Last, we deal with the diagonal matrix . Let . We have . Then, we can write where and is an integer to be chosen later. We have that . When , we have that
A.2 Proof of Lemma 2.4
Appendix B Missing Proofs in Section 3
In this section, we provide the full proof of Theorem 3.2. We start with the following Lemma that constructs a building block that transform vectors of an arbitrary sequence of vectors to any arbitrary set of vectors, and main the value of the others. For better abstraction we use , to denote the sequence of vectors.
which is a different way of writing equation (3.6).
Without loss of generality, suppose . We construct as follows. Let the -th row of be for , and let where denotes the all 1’s vector. Let the -column of be for .
Next we verify that the correctness of the construction. We first consider . We have that is a a vector with -th coordinate equal to . The -th coordinate of is equal to , which can be upperbounded using the assumption of the Lemma by
Therefore, this means contains a single positive entry (with value at least ), and all other entries being non-positive. This means that where is the -th natural basis vector. It follows that .
Finally, consider . Then similarly to the computation in equation (B.1), is a vector with all coordinates less than . Therefore is a vector with negative entries. Hence we have , which implies . ∎
Now we are ready to state the formal version of Lemma 3.3.
We will use Lemma B.1 repeatedly to construct building blocks , and thus prove Lemma B.2. Each building block takes a subset of vectors among and convert them to ’s, while maintaining all other vectors as fixed. Since they are totally layers, we finally maps all the ’s to the target vectors ’s.
We use Lemma B.1 repeatedly. Let . Then using Lemma B.1 with and for , we obtain that there exists such that for , it holds that , and for , it holds that .
Now we construct the other layers inductively. We will construct the layers such that the hidden variable at layer satisfies for every , and for every . Assume that we have constructed the first layer and next we use Lemma B.1 to construct the layer. Then we argue that the choice of , , and satisfies the assumption of Lemma B.1. Indeed, because ’s are chosen uniformly randomly, we have w.h.p for every and , . Thus, since , we have that also doesn’t correlate with any of the . Then we apply Lemma B.1 and conclude that there exists such that for , for , and for . These imply that
Now we ready to prove Theorem 3.2, following the general plan sketched in Section 3.
Appendix C Toolbox
In this section, we state two folklore linear algebra statements. The following Claim should be known, but we can’t find it in the literature. We provide the proof here for completeness.
where is a real block diagonal matrix that consists of blocks with size at most .
The following Claim is used in the proof of Theorem 2.2. We provide a proof here for completeness.
Since is the smallest eigenvalue of , we have that
Taking square root of both sides completes the proof. ∎