Adam Induces Implicit Weight Sparsity in Rectifier Neural Networks
Atsushi Yaguchi, Taiji Suzuki, Wataru Asano, Shuhei Nitta, Yukinobu, Sakata, Akiyuki Tanizawa

TL;DR
This paper reveals that training deep neural networks with ReLU, L2 regularization, and Adam optimizer naturally induces weight sparsity, enabling effective model reduction without additional regularizers.
Contribution
The study identifies conditions under which Adam training induces implicit weight sparsity and proposes a simple method to reduce model size by removing zero weights.
Findings
Adam training induces group sparsity in weights.
The proposed reduction method maintains performance.
Effective size reduction demonstrated on MNIST and CIFAR-10.
Abstract
In recent years, deep neural networks (DNNs) have been applied to various machine leaning tasks, including image recognition, speech recognition, and machine translation. However, large DNN models are needed to achieve state-of-the-art performance, exceeding the capabilities of edge devices. Model reduction is thus needed for practical use. In this paper, we point out that deep learning automatically induces group sparsity of weights, in which all weights connected to an output channel (node) are zero, when training DNNs under the following three conditions: (1) rectified-linear-unit (ReLU) activations, (2) an -regularized objective function, and (3) the Adam optimizer. Next, we analyze this behavior both theoretically and experimentally, and propose a simple model reduction method: eliminate the zero weights after training the DNN. In experiments on MNIST and CIFAR-10 datasets, we…
| Preprocess | divide each pixel value by 255 |
|---|---|
| Data augmentation | No |
| Batch size / #epochs | 64 / 100 |
| Learning rate schedule | multiplied by 0.5 every 25 epochs |
| -norm threshold | |
| regularization | Yes () |
| # hidden layers | 1 |
| # nodes per layer | 1000 |
| Activation function | ReLU |
| Batch normalization | Yes (before activation) |
| Initializer | Xavier [27] for weights, 0 for biases |
| Optimizer | Adam |
| () |
| Optimizer | Adam (baseline) | mSGD | adagrad | RMSprop |
|---|---|---|---|---|
| Acc. [%] | 98.43 | 98.35 | 98.31 | 98.31 |
| Sparsity [%] | 70.00 | 0.00 | 0.00 | 65.20 |
| Activation | ReLU (baseline) | ELU | ||
| Acc. [%] | 98.43 | 98.39 | 98.27 | 98.42 |
| Sparsity [%] | 70.00 | 1.70 | 77.00 | 0.00 |
| Others | baseline | He init. | w/o BN | w/o reg. |
| Acc. [%] | 98.43 | 98.42 | 98.26 | 98.45 |
| Sparsity [%] | 70.00 | 68.70 | 82.10 | 0.00 |
| # of nodes | 10 | 50 | 100 | 500 | 1000 (baseline) | 2000 |
|---|---|---|---|---|---|---|
| Acc. [%] | 93.92 | 97.46 | 98.17 | 98.48 | 98.43 | 98.45 |
| # of remaining weights | 10 | 50 | 100 | 291 | 300 | 288 |
| # of hidden layers | 1 (baseline) | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Acc. [%] | 98.43 | 98.73 | 98.78 | 98.88 | 98.68 |
| # of remaining weights in each hidden layer | 300 | 128-227 | 153-75-186 | 177-78-76-160 | 168-87-73-75-160 |
| Optimizer | Acc. [%] | Reduced [%] |
|---|---|---|
| mSGD (as in [31]) | 92.45 | - |
| mSGD (our implementation) | 93.13 | 0.00 |
| AMSGRAD | 92.64 | 0.00 |
| AdamW | 91.97 | 0.00 |
| Adam | 92.61 | 53.23 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Neural Network Applications · Domain Adaptation and Few-Shot Learning · Stochastic Gradient Optimization Techniques
Adam Induces Implicit Weight Sparsity in Rectifier Neural Networks
Atsushi Yaguchi1, Taiji Suzuki23, Wataru Asano1, Shuhei Nitta1, Yukinobu Sakata1, Akiyuki Tanizawa1
1{atsushi.yaguchi, wataru.asano, shuhei.nitta, yuki.sakata, akiyuki.tanizawa}@toshiba.co.jp
1Corporate Research and Development Center, Toshiba Corporation, Kawasaki, Japan
2Graduate School of Information Science and Technology, The University of Tokyo, Japan
3Center for Advanced Integrated Intelligence Research, RIKEN, Tokyo, Japan
Abstract
In recent years, deep neural networks (DNNs) have been applied to various machine leaning tasks, including image recognition, speech recognition, and machine translation. However, large DNN models are needed to achieve state-of-the-art performance, exceeding the capabilities of edge devices. Model reduction is thus needed for practical use. In this paper, we point out that deep learning automatically induces group sparsity of weights, in which all weights connected to an output channel (node) are zero, when training DNNs under the following three conditions: (1) rectified-linear-unit (ReLU) activations, (2) an -regularized objective function, and (3) the Adam optimizer. Next, we analyze this behavior both theoretically and experimentally, and propose a simple model reduction method: eliminate the zero weights after training the DNN. In experiments on MNIST and CIFAR-10 datasets, we demonstrate the sparsity with various training setups. Finally, we show that our method can efficiently reduce the model size and performs well relative to methods that use a sparsity-inducing regularizer.
Index Terms:
deep neural networks, model reduction, group sparse, Adam
I Introduction
Recently, deep learning has been successfully applied in various machine learning tasks [1]. For example, it surpassed human performance at an image recognition task on the ImageNet dataset [2]. These successes are supported by the development of activation functions such as ReLU [3], regularization and normalization methods such as dropout [4] and batch normalization (BN) [5], and network architectures such as ResNet [6]. Recent successes are also enabled by the growth of training datasets and increases in computing power. Because wider or deeper network models have become necessary to achieve high performance, hardware with limited memory and computational power are unable to match this performance. Reducing model size is necessary if applications, such as video recognition for automated driving systems and surveillance systems, are to run on edge devices, but this reduction of model size lowers accuracy.
Various methods have been proposed for model reduction [7, 8, 9, 10, 11, 12, 13]. Shi et al. [7] and Han et al. [8] reduced the amount of computation and data without changing the original network architecture. Shi et al. [7] did this by exploiting the sparsity of ReLU activations to reduce the computational load of convolution. Han et al. [8], in contrast, compressed the amount of data by quantizing weight coefficients. Other model reduction methods that slim the network architecture have been proposed [9, 10, 11, 12]. After training redundant models, less-important channels or nodes are pruned based on the norm [9] or statistics of the activations [10]. These methods require training redundant models before pruning. To address this, Wen et al. [11], Scardapane et al. [12], and Yoon et al. [13] proposed methods to directly train compact models. Their methods regularize the weights so that only some weights have nonzero coefficients, and eliminate zero weights after training to produce a sparse model. They reported that group sparse regularization, which induces all weights connected to an output channel (node) to be zero, greatly reduces the size of models because it can directly eliminate channels or nodes.
In this paper, first we point out there appears group sparsity of weights during training of DNNs under the following three conditions: (1) ReLU activations, (2) an -regularized objective function, and (3) the Adam optimizer [14]. As shown in Fig. 1, though regularization of weights does not intrinsically induce sparsity, some weight vectors converge toward the origin (i.e., zero) if these three conditions are met. Interestingly, this behavior does not appear with the momentum-SGD (mSGD) optimizer [15], as shown in Fig. 2. Next, we analyze this behavior both theoretically and experimentally, and propose a simple model reduction method: eliminate the zero weights after training the DNN. Our method is easy to optimize since it does not rely on sparsity-inducing (non-smooth) regularizers such as norm, and can efficiently control the model size by calibrating the parameter of regularization. In experiments, we demonstrate the sparsity on the MNIST and CIFAR-10 datasets with various training setups, and show our method can effectively reduce the model size relative to methods that use a sparsity-inducing regularizer.
In the following, we first give our problem setting and propose a method for model reduction (Section II), then describe its theoretical analysis (Section III). After we briefly review related works (Section IV), we give some experimental results (Section V) and conclude the paper (Section VI).
II Proposed Method
II-A Problem Setting
We consider an -layer network with parameters , where is the weight matrix between layer and layer whose columns are the per-channel weight vectors. The corresponding bias is . The kernel width is , the kernel height is , and the numbers of input and output channels are and , respectively. Fig. 3 illustrates the weight vectors in fully connected and convolution layers. Note that the number of channels equals the number of nodes in the fully connected layer, which corresponds to the case of .
Let be an activation function. An input vector to a layer is then computed as for the fully connected layer. should be defined at each spatial location for the convolution layer, but we use the notation of the fully connected layer for simplicity. The parameters are learned by the optimization problem
[TABLE]
where and represent a loss function and a regularization function, respectively. and are an input and a target vector, respectively, for the network, and is the number of samples in the training set. Instead of using all samples in each timestep of the optimization, we utilize a mini-batch of size , in which samples are drawn independently and uniformly from the training set.
II-B Model Reduction
To reduce the model size, we utilize group sparsity by pruning weights under a threshold, that is, we prune column vectors in , satisfying for a small positive constant . We induce sparsity by imposing the regularization on each weight vector. We therefore define the regularization function as
[TABLE]
where is a regularization parameter, and indicates the Frobenius norm. We use ReLU [3], given as , as the activation function for each non-output layer, and optimize the objective function by using Adam [14]. Its update rule for a parameter is given by
[TABLE]
where is the gradient at timestep ; , , and are positive constants.
The flow of our method is shown in Algorithm 1 as pseudocode. After training the network, the size is reduced by eliminating all weight vectors having norm smaller than a threshold . Since the weights converge to near the origin, it is easy to select the threshold. Our method can also effectively reduce the model size by directly eliminating channels or nodes.
III Theoretical Analysis
In this section, we mathematically describe the mechanism of the sparsity and analyze convergence under certain conditions.
III-A Preliminaries
The gradient with respect to , the th weight vector in layer , is given by
[TABLE]
If the activation function is ReLU,
[TABLE]
then the gradient becomes
[TABLE]
Thus, if there are only a few samples satisfying (i.e., activated samples), , and the vanilla-SGD is used as the optimizer with a step size , then the weight is updated as , which means the weight decays to zero if . From the observation that 50 – 90% of ReLUs are not activated [3][7], we assume the gradient of the regularization should be dominant for weights connected to such less-activated ReLUs, which induces the convergence to zero. As shown in Fig. 2, however, this behavior does not appear with mSGD. We believe this is due to the difference in convergence rate between the optimizers.
We conducted a preliminary experiment with the Adam optimizer under the condition that , and found that after the weight decays to a certain level, it oscillates near the origin, as shown in Fig. 4. For example, a weight decreased from an initial value of 0.2 and then began to oscillate around . This oscillation is not observed with mSGD. In Theorem III.2 in the following subsection, we give the decay rate for Adam under the pre-oscillation condition.
III-B Convergence Analysis
Here, for simplicity of notation, we omit the indices and and use the subscript to indicate the timestep, then use a scalar weight denoted by . We suppose a non-activation situation in which the gradient of the loss is zero; thus, . Detailed proofs of the following theorems are given in the appendices.
Proposition III.1**.**
*Let for . Under conditions and , decays at rate for mSGD.
Therefore, if , then we obtain a convergence rate faster than the given by SGD. In particular, we obtain a convergence rate similar to Nesterov’s acceleration [16].
Theorem III.2**.**
Without loss of generality, we may suppose . Then, as long as satisfies that for , decays as for Adam.
The above convergence rate is doubly exponential. Therefore, to achieve we require only steps. We recall that SGD and mSGD require steps to achieve . Thus, the solution with Adam becomes smaller than sufficiently small more rapidly than with SGD and mSGD. We believe this rapid decay before oscillation contributes to the sparsity with Adam.
Although our theorem for Adam does not guarantee convergence to the origin, we have the following proposition.
Proposition III.3**.**
*If converges to as , then the limit point must satisfy .
Substituting a condition: into Eq. (6), the step size of Adam for a sufficiently large can be represented as
[TABLE]
If converges to , then as , for , it holds that letting , the step size becomes
[TABLE]
The above must be a Cauchy sequence if it converges; that is, the step size must be 0, which is satisfied with .
IV Related Work
In this section, we briefly review related works, including analyses on training DNNs from the viewpoints of activation functions and optimizers, and methods of model reduction. Group sparsity as discussed in this paper relates to the vanishing gradient problem [17], which is generally caused by saturation nonlinearities such as and . These functions have certain regimes in which the gradient vanishes, and ReLU also possesses such a regime (specifically, ). Li et al. [18] showed that unsupervised pretraining encourages sparse activations with and ReLU in the resulting DNNs. Though it has been known that some units never activate across the entire training dataset, the so-called dying-ReLU [19], detailed analysis of this has not been reported. The remedy for this problem is leaky-ReLU [20] given by
[TABLE]
which parameterizes the negative slope to prevent its gradients from vanishing in the negative regime. In the next section, we compare various activation functions, including leaky-ReLU and saturation nonlinearities, in terms of sparsity.
SGD is a common optimizer for training DNNs. It is a simple method but achieves good generalization performance by careful tuning of step-size and acceleration via the momentum term [15]. In contrast, adaptive gradient methods, including Adagrad [21], RMSprop [22], Adam [14], and AdaDelta [23], commonly attain faster convergence than the SGD by automatically adjusting the step size. Compared with the SGD, however, their generalization performances are worse in many cases. Theoretical analysis has been conducted, and improvements have been reported [24, 25, 26]. Wilson et al. [24] proved that the adaptive methods do not converge to an optimum in a simple convex optimization problem. Reddi et al. [25] proved that the non-convergence of Adam is due to the step-size scaling according to the moving average of the squared gradient, and proposed an improved method, AMSGRAD. Loshchilov et al. [26] proposed AdamW, which decouples the weight-decay term from the update rule of Adam, and showed it achieves performance similar to that of mSGD. Despite these analyses of Adam, it has not been reported that Adam induces implicit weight sparsity in training DNNs. In the next section, we compare Adam against various optimizers including mSGD, adaptive gradient methods, and the improved methods of Adam [25, 26].
There are two broad approaches to model reduction: pruning redundant weights after learning and learning with sparsity-inducing regularizers on weights. In an example of the former approach, Li et al. [9] exploit the norm of weight vectors to prune less important channels after learning the DNN, and Polyak et al. [10] do the same based on the statistics of ReLU activations. However, selecting the pruning threshold is difficult, and fine-tuning after pruning is necessary for recovering the accuracy. In our method, since the weights converge to near the origin, it is easy to select the threshold, which only need to be smalls, such as , and the fine-tuning is optional. In the latter approach, Wen et al. [11], Scardapane et al. [12], and Yoon et al. [13] minimize the norm of weight vectors with the objective function so that channel-level group sparsity is obtained. Our method yields sparsity based on the norm, which is a smooth function, making it easy to optimize. We show the effectiveness of our method relative to the other methods [11][12] below.
V Experiments
In this section, we demonstrate the sparsity under various training setups and compare our model reduction method with others that use sparsity-inducing regularizers. The experiments were on image classification tasks using MNIST [28] and CIFAR-10 datasets [29]. In all experiments on both datasets, we used softmax function in output layer and cross-entropy loss for training networks.
V-A Demonstration of Sparsity
On the MNIST dataset, we used fully connected networks with the experimental setup summarized in Table I as the baseline, and evaluated different activation functions, optimizers, and other components. Table II shows the validation accuracy and sparsity of the weight vectors produced by the different setups. There is not much difference in terms of accuracy, but the sparsity varies for each component. Near the top of Table II, RMSprop yields sparsity as well as that of Adam. RMSprop is basically a special case of Adam by setting , and we see it has similar convergence. The middle of Table II shows the results for different activation functions. Sparsity is obtained by ReLU and by exponential linear units (ELU) [30]. Since its gradients mostly vanish in the negative regime except near the origin, we see it behaves like ReLU, that is, the gradient of the objective function is dominated by that of regularization, and it yields similar sparsity. While obtains only limited sparsity, it indicates that saturation nonlinearities have the potential for sparsity. We also investigated the behavior of leaky-ReLU [20]. We plotted the distributions of norm with changing its negative slope as shown in Fig. 5. In the case of = 0, which corresponds to ReLU, we can see there are two modes: the lower mode for (near-) zero weights and the other mode for active weights. Observing that the lower mode shifts as the negative slope increases, we see that leaky-ReLU can alleviate the decay of weights by propagating gradients for negative inputs.
Additionally, we evaluated the behavior with an initializer proposed by He et al. [2] and with or without BN layer and regularization. The bottom of Table II shows that the initializer and BN layer make no appreciable difference, but regularization is needed for sparsity, as expected. Next, we investigated the effects of the number of nodes in the hidden layer and the number of layers in the network. Table III shows the validation accuracy and number of retained weight vectors (i.e., nodes) after training for the different number of nodes. It can be observed that networks having a small number of nodes results in low accuracy and the weights of those are fully retained. We attribute this to such networks not being redundant, meaning that each node in the networks contributes to decreasing the loss (i.e., each node is well activated). In contrast, the numbers of retained weights (and accuracies) in networks with more than 500 nodes were almost identical. This result indicate that wide networks can be reduced to a certain narrow model without sacrificing accuracy. The results with different number of layers are shown in Table IV, where each network was trained with 1000 nodes in each layer. The results indicate that the number of retained weights becomes small in the deeper layers (except for the last hidden layer).
On the CIFAR-10 dataset, we trained a VGG-style covolutional neural network with almost the same setup as in [31]. During a preprocessing step, each image was normalized to have mean 0 and standard deviation 1 over three channels, and horizontal flipping was applied as data augmentation. We again used the initializer proposed by He et al. [2] for weights and applied dropout [4] to convolution and fully connected layers, as in [31]. With the same parameter of , we compared against other optimizers: mSGD, AMSGRAD [25], and AdamW [26]. An initial learning rate of 0.1 was used for mSGD and 0.0005 for the others. The batch size, learning rate scheduling, and -norm threshold for model reduction are shown in Table I. The maximum validation accuracy during the training for 400 epochs and the ratio of reduced parameters at that time are reported in Table V. We can see that parameters are not reduced by AMSGRAD and AdamW, that is, these optimizers do not induce sparsity. Instead of using the moving average of the squared gradient, AMSGRAD uses its maximum until each timestep. Thus, AMSGRAD does not induce sparsity because the step-size tends to decrease as the training progresses, and so weights decay more slowly. For AdamW, the lack of sparsity is because the rate of decay in the weights is similar to that of SGD since the weight-decay term is decoupled from the step-size computation of Adam. We can see that Adam achieves accuracy similar to that of AMSGRAD but reduces more than 50% of parameters. However, there is still a gap in accuracy between Adam and mSGD. We suspect that this gap may result from the implicit weight sparsity of Adam.
Next, we observed relationships between activation rate of channels (ReLUs) and norm of their weight vectors during the training. We again trained a VGG-style network by Adam and mSGD with the same setups as above. We picked up 23 of 64 filters in first convolution layer, which resulted in convergence to zero with Adam. The progress of their activation rate and norm with both optimizers is illustrated in Fig. 6, respectively. Activation rate of a filter was computed as follows: counted nonzero pixels in a feature map after the ReLU layer; divided it by the feature map size; and computed it for all training images, then averaged it. In Fig. 6, we can see that norm and activation rate with Adam jointly decrease to zero while those with mSGD converge to some nonzero values as the training progress. This observation indicates that activation rate of ReLU decreases in conjunction with norm of its input weight vector. Thus, we see that the weight decays rapidly with Adam even when ReLU is not completely inactive (i.e., a condition: is not exactly satisfied).
V-B Comparisons on Model Reduction
We conducted comparisons with other model reduction methods in which the group sparsity of weights is explicitly induced by the regularizer. On the MNIST dataset, we compared with a method proposed by Wen et al. [11]. We used the same network model as in [11], namely, a 4-layer fully connected network without BN layer, having 500 and 300 nodes in its hidden layers. We trained it with He’s initializer [2] and the same setup as in Table I. Our method is slightly better than [11] in accuracy while comparable in reduction rate, as shown in Table VI.
Moreover, we compared with a method proposed by Scardapane et al. [12] on the CIFAR-10 dataset, using the same model and setup as the experiment in a previous subsection. We implemented their method, in which the model was trained by mSGD with initial learning rate of 0.1. The threshold of model reduction was set as for the other method. For investigating the trade-off between accuracy and reduction rate, we used several parameters of the regularization . The network was trained 5 times for each with different initial weights, and the accuracy and ratio of reduced parameters were plotted in Fig. 7. It can be seen that our method basically outperforms the other method in accuracy while achieving the same reduction rate. The other method sometimes achieved low accuracy, and ours was more stable. Therefore, our method can efficiently control the model size by calibrating a parameter of regularization.
VI Conclusions
In this paper, we have analyzed the implicit weight sparsity induced by Adam, ReLU, and regularization in both theoretical and experimental aspects. Assuming that weight decay by regularization becomes dominant under the existence of less-activated ReLUs, we have mathmatically described that Adam requires steps to achieve a sufficiently small weight of , which is faster than the of mSGD. We believe this difference leads to sparsity of weights with Adam. Additionally, we proposed a method for model reduction by simply eliminating the zero weights after training the DNN. In experiments on MNIST and CIFAR-10 datasets, we demonstrated the sparsity with various training setups and found that other activation functions and optimizers having properties similar to ReLU and Adam, respectively, also achieve sparsity. Finally, we confirmed that our method can efficiently reduce the model size and exhibits favorable performance relative to that of other methods that use a sparsity-inducing regularizer.
Acknowledgment
TS was partially supported by MEXT Kakenhi (25730013, 25120012, 26280009, 15H05707 and 18H03201), Japan Digital Design, JST-PRESTO and JST-CREST.
Appendices
VI-A Convergence of mSGD (Proposition III.1)
The update rule of mSGD for a weight is given by
[TABLE]
The condition implies that
[TABLE]
Since , must satisfy under the assumption . Here, letting for and defining and , we have that
[TABLE]
The right-hand side can be evaluated as
[TABLE]
VI-B Convergence of Adam (Theorem III.2)
Let . Then, by the update rule, is recursively given by
[TABLE]
for and .
First, notice that if , then the difference between and is bounded by
[TABLE]
Hence, we see that, as long as , positivity of is ensured: .
Suppose that and is an integer such that, for , . In this setting,
[TABLE]
Therefore, we have , and
[TABLE]
Here, letting , we have . From this observation, we again evaluate as
[TABLE]
Now, let be the smallest such that . By this definition, if , then
[TABLE]
Therefore, for ,
[TABLE]
Now, supposing that satisfies (otherwise, we have ), the above inequality yields
[TABLE]
which is doubly exponential. Therefore, to achieve we require only
[TABLE]
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Y. Le Cun, Y. Bengio, and G. Hinton, “Deep learning,” Nature , vol. 521, pp. 436–444, 2015.
- 2[2] K. He, X. Zhang, S. Ren, and J. Sun, “Delving deep into rectifiers: Surpassing human-level performance on imagenet classification,” in Proc. IEEE International Conference on Computer Vision (ICCV) , 2015.
- 3[3] X. Glorot, A. Bordes, and Y. Bengio, “Deep sparse rectifier neural networks,” in Proc. International Conference on Artificial Intelligence and Statistics (AISTATS) , 2011, pp. 315–323.
- 4[4] N. Srivastava, G. Hinton, A. Krizhevsky, I. Sutskever, and R. Salakhutdinov, “Dropout: A simple way to prevent neural networks from overfitting,” Journal of Machine Learning Research , vol. 15, pp. 1929–1958, 2014.
- 5[5] S. Ioffe and C. Szegedy, “Batch normalization: Accelerating deep network training by reducing internal covariate shift,” in Proc. International Conference on Machine Learning (ICML) , 2015, pp. 448–456.
- 6[6] K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” in Proc. IEEE International Conference on Computer Vision and Pattern Recognition (CVPR) , 2016.
- 7[7] S. Shi and X. Chu, “Speeding up convolutional neural networks by exploiting the sparsity of rectifier units,” ar Xiv preprint ar Xiv:1704.07724 , 2017.
- 8[8] S. Han, H. Mao, and W. J. Dally, “Deep compression: Compressing deep neural network with pruning, trained quantization and huffman coding,” in Proc. International Conference on Learning Representations (ICLR) , 2016.
