b

DiscoverSearch
About
My stuff
Automatic and Simultaneous Adjustment of Learning Rate and Momentum for Stochastic Gradient Descent
2019·arXiv
Abstract
Abstract

Stochastic Gradient Descent (SGD) methods are prominent for training machine learning and deep learning models. The performance of these techniques depends on their hyperparameter tuning over time and varies for different models and problems. Manual adjustment of hyperparameters is very costly and time-consuming, and even if done correctly, it lacks theoretical justification which inevitably leads to “rule of thumb” settings. In this paper, we propose a generic approach that utilizes the statistics of an unbiased gradient estimator to automatically and simultaneously adjust two paramount hyperparameters: the learning rate and momentum. We deploy the proposed general technique for various SGD methods to train Convolutional Neural Networks (CNN’s). The results match the performance of the best settings obtained through an exhaustive search and therefore, removes the need for a tedious manual tuning.

Machine learning has intimate ties to optimization, considering that many learning problems are formulated as the minimization of a loss function that depends on a training set. An optimization problem that frequently appears in machine learning is the minimization of the average of loss functions over a finite training set, i.e.,

image

where  ¯xi ∈ Rd is the i-th observation in the training set  {¯xi}Mi=1 of size M, the function  f (w; ¯xi) :Rd → Ris the loss corresponding to  ¯xi, and  w ∈ Rpis the weight vector. Starting with an initial guess for the weight vector w, stochastic gradient descent (SGD) methods [1] attempt to minimize the loss function ¯F (w) (1)by iteratively updating the values of w. Each iteration utilizes a sample {xi}Ni=1 of size N, commonly called a “mini-batch”, which is taken randomly from the training set {¯xi}Mi=1. The update from  wtto  wt+1at the t-th iteration relies on a gradient estimator, which in turn depends on the current mini-batch. The typical unbiased gradient estimator of the unknown true gradient is defined by

image

where  g(i)tis the gradient produced by the i-th observation within the current mini-batch of size N. The gradient estimator  gt (2)entails variance, since it depends on a random set of observations. If the variance of  gt (2)is large, the SGD method may have difficulty converging and perform poorly. Indeed, the variance may be reduced by increasing the mini-batch size N. However, this increases the computational cost of each iteration. Some recent methods in the literature that attempt

image

Figure 1: The proposed method, dubbed as AutoOpt, provides a general approach to an automatic and simultaneous adjustment of the learning rate and momentum hyperparameters. We deploy and examine the generic technique for the SGD, Adam, and AdaGrad optimizers, for the sake of training CNN based classifiers.

to reduce the variance of the gradient estimator include [2, 3, 4, 5, 6], to mention a few. While these methods provide unbiased gradient estimators, they are not necessarily optimal in the sense of meansquared error (MSE) which allows reducing the variance with the cost of bias. Momentum-based methods (see [7] and other references within) trade-off between variance and bias by constructing the gradient estimator as a combination of the current unbiased gradient estimator and previous gradient estimators. Other state-of-the-art methods use biased estimators by scaling the gradient with square roots of exponential moving averages of past squared gradients [8]. These methods include, for example, AdaGrad [9], Adam [10], AdaDelta [11], NAdam [12], etc. The main drawback for these methods is their reliance on one or more hyperparameters, i.e., parameters which must be tuned in advance to obtain adequate performance. Unfortunately, manual hyperparameter tuning is very costly, as every hyperparameter configuration is typically tested over many iterations. Previous attempts to automatically tune the learning rate alone were proposed in [13, 14] and examined for simple architectures, such as logistic regression and fully-connected neural networks (FCNN’s). The technique presented in [13], for example, proposes an automatic adjustment of the learning rate, limited by the assumption of a diagonal Hessian matrix, and disregarding the off-diagonal elements of the observations’ covariance matrix. The approach proposed in [14] set the learning rate by utilizing the Barzilai-Borwein method [15] which in turn relies on an approximation of the Hessian, ignoring gradient estimators as suggested in [13]. To the best of our knowledge, there is no method to adjust the momentum hyperparameter automatically; neither in solitary nor simultaneously with the learning rate.

In this paper, we present a novel and generic method to automatically and simultaneously adjust the learning rate and the momentum hyperparameters, to minimize (or maximally decrease) the expected loss after the next update. The general method, dubbed as AutoOpt, is deployed for three popular optimizers: SGD, Adam and AdaGrad, schematically described in Figure 1. The technique is practical for modern deep learning architectures and is successfully examined for convolutional neural networks (CNN’s) [16]. The rest of the paper is organized as follows. In Section 2, we provide background and motivation for the proposed method. In Section 3, we derive the general formulation and the theoretical properties of the optimal learning rate and momentum. The optimal values depend on the unknown true gradient, thus unattainable and annunciate as the “oracle” solution. Nevertheless, we show in Section 4 that the oracle solution can be estimated, hence makes it feasible for a practical use. We deploy the proposed technique in SGD, Adam [10], and AdaGrad [9] for the sake of training CNN based classifiers. Our experimental results which appear in Section 5, show that the method automatically achieves the lowest or comparable classification errors, obtained through a tedious systematic search of the learning rate and momentum. We conclude the paper with a discussion on some future work. Notations: We depict vectors in lowercase boldface letters and matrices in uppercase boldface. The transpose operator and the diagonal operator are denoted by  (·)Tand  diag (·), respectively. The column vector of p ones is denoted by  1p = [1, 1, . . . , 1]Tand the expectation operator is denoted by  E {·}.

We outset our discussion from the theoretical (and ideal) scenario of an unlimited training set. Suppose that the observations within the training set  {¯xi}Mi=1are independent identically distributed (i.i.d), drawn from a probability density function P (x). In the ideal case of an unlimited amount of training examples, the loss function ¯F (w)(1) approaches the real unknown loss function, defined as

image

The loss function J (w) (3) is deterministic, and assumed to be continuously differentiable with respect to the weight vector w. Starting with an initial guess  w0, we would like to generate a sequence of weights  wt, t = 1, . . . , Tsuch that the loss function J (w) (3) is reduced at each iteration of the algorithm, i.e.,

image

The loss function J (w) (3) can be approximated by a second-order (i.e., quadratic) Taylor series expansion around  wt , i.e.,

image

where

image

and

image

are the gradient vector and the Hessian matrix of the loss function J (w) (3), evaluated at  wt. By deriving ˆJ (w) (5)with respect to w and setting the result to zero, we find that the next weight vector wt+1which minimizes ˆJ (w)(5) is given by

image

The iterative equation (8) is also known as the Newton-Raphson method [17]. In practice, at time t, only a finite sample (the current mini-batch) of size N is available. As a result, neither the gradient vector  ¯gt (6), nor the Hessian matrix ¯Ht (7)(and its inverse) required in (8), are known. To practically apply the update rule (8) for  wt+1, both quantities  ¯gtand ¯Ht, must be replaced by their estimators, denoted as  ˆgt and ˆHt, respectively. The use of the estimators  ˆgt and ˆHt(instead of  ¯gt and ¯Ht) leadsto the general update rule of SGD methods given by

image

We confine our discussion regarding the gradient estimator  ˆgtin (9), to the frequently used model

image

where  gt (2)is the unbiased estimator of the unknown true gradient  ¯gt (6) (i.e., E {gt} = ¯gt), β is themomentum parameter which is a scalar between 0 and 1, and  αis the learning rate, a positive scalar which ensures that the update rule (9) do not produce a weight vector  wt+1with an implausible large norm [18]. The inverse of the estimated Hessian matrix ˆH−1t in (9)is not easy to compute. There are various methods to estimate the inverse of the Hessian matrix, such as Broyden-Fletcher-Goldfarb-Shanno (BFGS) quasi-Newton based methods [19, 20]. However, if computational simplicity is of paramount importance, then it is common to assume that ˆH−1tis equal to the identity matrix I. In this paper we refer to that case as the classic SGD. The Adam optimizer [10], a popular SGD algorithm which is vastly used these days, assumes a diagonal Hessian matrix estimator of the form

image

Table 1: SGD methods that follow the general update rule (9) along with their gradient and Hessian estimators. These optimizers share the same gradient estimator model  ˆgt (10), with or without momentum, while utilizing different Hessian estimators.

image

The AdaGrad method [9], which corresponds to a version of Adam, utilizes the gradient estimator  ˆgt(10) with momentum  β = 0, and a diagonal Hessian matrix estimator of the form

image

These methods propose different gradient and Hessian estimators, to be plugged into the update rule (9), and are summarized in Table 1.

Our objective in this paper is to find the optimal values of  αand  βat time t, which minimize the expected value of the loss function ˆJ (w)(5) when using the update rule (9), i.e.,

image

We provide the solution for (13) in the following section. Recall that (13) is solved for the general update rule (9). Thus, the proposed solution can be deployed in any SGD method that utilizes the gradient estimator  ˆgt (10). As previously mentioned, the optimizers which appear in Table 1 are examined in the experiments section.

In this section, we derive the optimal learning rate and momentum as defined in (13). By changing variables such that  α = 1 − γ1 and β = γ21−γ1 , we can rewrite the gradient estimator  ˆgt (10) as

image

where  Gt is a p × 2matrix defined as

image

and  γ = [γ1, γ2]T is a 2 × 1vector. Then, by substituting the update rule  wt+1 (9) for w in (5) whileusing the gradient estimator  ˆgt(14), we can rewrite the expected value of the loss function (5) as

image

where

image

The matrix  At (17)and the vector  bt (18), are of size  2 × 2and  2 × 1, respectively. The optimal vector  γ at time t, which we denote by  γOt = [γ1Ot, γ2Ot]T , is the solution that minimizes the loss function  E�ˆJ (wt+1; γ)�(16), i.e.,

image

Since  γOt (19)depends on the true gradient  ¯gt (6), which is unknown in practice, we refer to it as the oracle solution. In the following section we propose an estimator for the oracle solution  γOt (19).

The oracle vector  γOt (19)minimizes the loss function  E�ˆJ (wt+1; γ)�(16), but unfortunately depends on the unknown quantities  At (17)and  bt (18). Consider first the perplexing vector  bt(18) which depends on the unknown gradient  ¯gt (6)and the Hessian matrix ¯Ht (7). With the aim of proceeding toward a practical method, we unfold the tangled equation by assuming that the Hessian is known, i.e., ˆHt = ¯Ht, and provided by the optimizer currently in use (see Table 1). As a result, the vector  bt(18) can be simplified (after a few mathematical manipulations) to

image

where

image

The scalar  V�gt| ˆHt�(21)still depends on the unknown true gradient  ¯gt(6), however, can be

estimated. The derivation of an unbiased estimator of  V�gt| ˆHt�(21)appears in Appendix A, and is equal to

image

where  g(i)tis the gradient produced by the i-th observation within the current mini-batch of size N. The estimator of  bt(18) is therefore

image

The estimator of  At (17)is calculated by replacing all expectations in  At (17)by their sample counterparts, i.e.,

image

Finally, by incorporating the estimators ˆbt (23) and ˆAt (24), the oracle solution  γOt (19)is estimated by

image

Consider that the values of  ˆγOtvaries based on the current mini-batch at time t, we mitigates this effect by using an exponentially weighted moving average model  ˆγEt, defined as

image

We summarize the proposed method for an automatic and simultaneous adjustment of the learning rate and momentum in Algorithm 1. The vector  ˆγEt (26)is computed in each step with a time-complexity that is equal or better than the time-complexity of the back-propagation algorithm [21] (see Appendix B), therefore make the method feasible for a practical use in deep learning architectures. In the next section, we examine the proposed method for classification purposes using CNN’s, and show that the technique attains the lowest or comparable classification errors as expected from theory.

We utilize the proposed method to train CNN classifiers for the MNIST [22] and CIFAR10 [23] data sets. The neural network architecture for MNIST has two convolution layers (10 and 20 channels with a kernel size 5), max pooling (kernel size 2), ReLU non-linearity and drop-out, which produces 320 features, followed by two fully connected layers (50 and 10 output features). The output layer is a log softmax layer, and the loss function is the negative log likelihood (NLL) loss. The architecture for CIFAR10 (3 input channels) has two convolution layers (6 and 16 channels with a kernel size 5), max pooling (kernel size 2) and ReLU non-linearity, which produces 400 features followed by three fully connected layers (120, 84, and 10 output features). The output layer is again a log softmax layer and the loss function is the NLL loss. We run thousands of configurations with different learning rate, momentum and random initial weights that were generated from 10 different seeds. For the SGD optimizer we run exhaustive hyperparameter search with

image

Figure 2: Automatic learning rate and momentum for SGD as a function of step for the first convolutional layer of the MNIST classifier. As expected, the learning rate increases as the mini-batch size increases. Whereas the learning rate starts to decay automatically, the previous gradient shifts to be less biased. As a result, the method utilizes the benefits of the previous gradient by gradually increasing the momentum value.

learning rate  ∈ L = {10−4, 10−3.5, 10−3, 10−2.5, 10−2, 10−1.5, 10−1, 10−0.5, 1}, momentum  ∈M = {0, 0.3, 0.8, 0.9, 0.95, 0.99} and batch size  ∈ N = {8, 16, 32, 64, 128, 256}values. This yields  |L| ∗ |M| ∗ |N| = 324different settings for each data set. Every setting is run with 10 different seeds. Thus, a total of 3,240 different configurations have been tested for the SGD optimizer. For the Adam and AdaGrad optimizers, best parameter search is carried out among the same learning rate and batch size values as in SGD. In Adam, we use  β1 = 0.9and  β2 = 0.99as suggested in the original Adam paper. The parameter tuning for Adam and AdaGrad optimizers each yield a total of 54 different settings and 540 results due to the use of 10 different seeds. The proposed method produces for each layer its own learning rate and momentum. To get further insights and intuition regarding the approach’s behavior; we present in Figure 2 the learning rate and momentum, generated by SGD, for the first convolutional layer of the MNIST classifier as a function of the mini-batch size N. As expected, the learning rate, provided in Figure 2(a), increases as the mini-batch size increases. Since a larger mini-batch result with less variance of the gradient estimator, the proposed method increases the learning rate. Once the learning rate reaches its peak, we can observe a learning rate decay. The learning rate decay is another hyperparameter that should be set in advance. In our case, however, the learning rate decay emerges automatically based on the data. The momentum values are provided in Figure 2(b). Initially, since the learning rate is relatively large, the previous gradient ˆgt−1is too biased to be combined with the current gradient  ˆgt, which results with low values of momentum. As the learning rate decay (and step size become smaller), the previous gradient  ˆgt−1 isless biased and therefore gain a greater presence when combined with the current unbiased gradient estimator  gt (2). The latter is reflected by increasing values of momentum as can be seen in Figure 2(b). In Figure 3, we present the scatter plots of test errors vs. train errors, achieved by the CNN

image

Figure 3: Train and test errors for the MNIST CNN classifier, after 10 epochs with SGD, as a function of the mini-batch size. The proposed method (denoted in black dots) achieves comparable, or the lowest error, which otherwise would be attained by an exhaustive manual tuning.

Table 2: Lowest train and test errors (mean and std across 10 seeds), for SGD, Adam, and AdaGrad, obtained by a tedious manual tuning. The optimal learning rate and momentum are provided by the first and second configuration values, respectively. The automatic tuning counterparts of these optimizers achieve comparable, or better results.

image

architecture for MNIST after 10 epochs. It can be seen how the optimal learning rate changes as a function of the mini-batch size while the method adapts and achieves the lowest error rates. For N = 32, we observe that the optimal learning rate is  α = 0.031, denoted by blue diamonds. It can be seen that the proposed method (denoted in the figure as AutoOpt), achieves the same error rates by automatically adapt to the optimal learning rate. For N = 64, the learning rate  α = 0.031becomes sub-optimal and the new optimal learning rate increases to  α = 0.1. Still, the proposed method adapts and achieves comparable test and train errors. Finally, when the mini-batch size increases to N = 256, the optimal learning rate increases to  α = 0.31, and the previous learning rate of  α = 0.1become sub-optimal. The optimal learning rate for  N = 32 (α = 0.031) is almost off the plot for the case of N = 256. Likewise, the proposed method performs similarly, or better, in the case of Adam and AdaGrad, as observed in Figure 4. For completeness, the lowest train and test errors (mean and std from 10 different seeds) obtained by the best performing configuration are summarized in Table 2. The first row in Table 2 lists the total number of parameter settings per data set for each optimizer. It can be observed that by conducting a tedious manual tuning, SGD, Adam and AdaGrad achieve comparable results. The deployment of the proposed method for these optimizers (AutoSGD, AutoAdam and AutoAdaGrad), avoids the tedious manual tuning while still achieving comparable train and test errors as shown in the table. The case of AutoAdam with CIFAR10 have a relatively large gap of more than 10%. The reason for that gap is a discrepancy between the unknown Hessian and the Hessian estimator provided by Adam (See the method’s assumption regarding the Hessian in Section 4, and Table 1 for different Hessian estimators). Nevertheless, as observed in Figure 4(e), the automatically tuned version attains a near-optimal solution in comparison to other configurations that were examined, and therefore, saves a substantial amount of time and efforts. Moreover, since SGD, Adam, and AdaGrad perform relatively the same after carefully tuned, it is straightforward to switch between their automatically tuned counterparts and reveal the best performing optimizer. An examination of three different automatic optimizers is still easily managed, in comparison to an intensive manual adjustment of each optimizer alone. The difference between the number of settings

image

Figure 4: Train and test errors for N = 128 after 10 epochs, for MNIST and CIFAR10, achieved by different optimizers. The MNIST classification errors, obtained by SGD, Adam, and AdaGrad, are presented in Figure (a), Figure (b), and Figure (c), respectively. The CIFAR10 errors, obtained by SGD, Adam, and AdaGrad, are presented in Figure (d), Figure (e), and Figure (f), respectively. The proposed method (denoted in black dots) automatically achieves comparable, or the lowest errors, and therefore avoids the exhaustive manual tuning.

for the original (manually tuned) optimizers and their automatic counterparts show the huge gain of the approach. To conclude, in all cases the proposed method automatically attains the lowest, or comparable test and train errors that otherwise would be achieved by an exhaustive manual tuning.

We tackle the manual tuning problem of two imperative hyperparameters: the learning rate and momentum. In Section 3, we derive a general method to compute the optimal learning rate and momentum that minimize the expected loss (13) after the next update. The technique relies on the unbiased gradient estimator  gt (2)which depends on the current mini-batch of size N at time t, and is summarized in Algorithm 1. The method is generic and can easily be deployed for different optimizers. Specifically, we examined the method for three well-known optimizers: SGD, Adam, and AdaGrad. The experimental results in Section 5 confirm the theoretical expectations where the learning rate and momentum automatically tuned to maximally decrease the expected loss by utilizing the mini-batch statistics, thus eliminating the need for an exhaustive manual tuning. We show that the method either outperform or comparable to the manual tuning by comparing classification errors of CNN based classifiers. Given the successful validation and the method’s generality, we intend to expand the proposed method into other deep learning architectures, and deploy it into more state-of-the-art optimizers previously mentioned. Also, as the optimal values of learning rate and momentum can freely increase or decrease based on the available data, we intend to examine the proposed approach for on-line training scenarios with non-stationary data. In these cases, the learning rate and momentum automatically adapt to the evolving data, and may stabilize to more appropriate settings based on the new distribution.

[1] James C Spall. Introduction to stochastic search and optimization: estimation, simulation, and control, volume 65. John Wiley & Sons, 2005.

[2] Chong Wang, Xi Chen, Alexander J Smola, and Eric P Xing. Variance reduction for stochastic gradient optimization. In C. J. C. Burges, L. Bottou, M. Welling, Z. Ghahramani, and K. Q. Weinberger, editors, Advances in Neural Information Processing Systems 26, pages 181–189. Curran Associates, Inc., 2013.

[3] Rie Johnson and Tong Zhang. Accelerating stochastic gradient descent using predictive variance reduction. In Advances in neural information processing systems, pages 315–323, 2013.

[4] Sashank J Reddi, Ahmed Hefny, Suvrit Sra, Barnabas Poczos, and Alexander J Smola. On variance reduction in stochastic gradient descent and its asynchronous variants. In Advances in Neural Information Processing Systems, pages 2647–2655, 2015.

[5] Hiroyuki Kasai. Stochastic variance reduced multiplicative update for nonnegative matrix factorization. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 6338–6342. IEEE, 2018.

[6] Bicheng Ying, Kun Yuan, and Ali H Sayed. Convergence of variance-reduced learning under random reshuffling. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 2286–2290. IEEE, 2018.

[7] Ilya Sutskever, James Martens, George Dahl, and Geoffrey Hinton. On the importance of initialization and momentum in deep learning. In International conference on machine learning, pages 1139–1147, 2013.

[8] Sashank J. Reddi, Satyen Kale, and Sanjiv Kumar. On the convergence of adam and beyond. In International Conference on Learning Representations, 2018.

[9] John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12(Jul):2121–2159, 2011.

[10] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.

[11] Matthew D Zeiler. Adadelta: an adaptive learning rate method. arXiv preprint arXiv:1212.5701, 2012.

[12] Timothy Dozat. Incorporating nesterov momentum into adam. In International Conference on Learning Representations, Workshop Track, 2016.

[13] Tom Schaul, Sixin Zhang, and Yann LeCun. No more pesky learning rates. In International Conference on Machine Learning, pages 343–351, 2013.

[14] Conghui Tan, Shiqian Ma, Yu-Hong Dai, and Yuqiu Qian. Barzilai-borwein step size for stochastic gradient descent. In Advances in Neural Information Processing Systems, pages 685–693, 2016.

[15] Jonathan Barzilai and Jonathan M Borwein. Two-point step size gradient methods. IMA journal of numerical analysis, 8(1):141–148, 1988.

[16] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger, editors, Advances in Neural Information Processing Systems 25, pages 1097–1105. Curran Associates, Inc., 2012.

[17] C. M. Bishop. Pattern recognition and machine learning, volume 4. Springer, New York, 2006.

[18] Antoine Bordes, Léon Bottou, and Patrick Gallinari. Sgd-qn: Careful quasi-newton stochastic gradient descent. Journal of Machine Learning Research, 10(Jul):1737–1754, 2009.

[19] Aryan Mokhtari and Alejandro Ribeiro. Res: Regularized stochastic bfgs algorithm. IEEE Transactions on Signal Processing, 62(23):6089–6104, 2014.

[20] Xunying Liu, Shansong Liu, Jinze Sha, Jianwei Yu, Zhiyuan Xu, Xie Chen, and Helen Meng. Limited-memory bfgs optimization of recurrent neural network language models for speech recognition. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 6114–6118. IEEE, 2018.

[21] David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning representations by back-propagating errors. nature, 323(6088):533, 1986.

[22] Yann Lecun and Corinna Cortes. The MNIST database of handwritten digits. 2009.

[23] Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.

[24] Ian Goodfellow, Yoshua Bengio, Aaron Courville, and Yoshua Bengio. Deep learning, volume 1. MIT press Cambridge, 2016.

[25] Vinod Nair and Geoffrey E Hinton. Rectified linear units improve restricted boltzmann machines. In Proceedings of the 27th international conference on machine learning (ICML-10), pages 807–814, 2010.

The expression  V�gt| ˆHt�(21) can be written as

image

and finally

image

The expression in the expectation is therefore the unbiased estimator of  V�gt| ˆHt�(21), provided in

ˆV�gt| ˆHt�(22). When the Hessian estimator ˆHtis diagonal, as in SGD, Adam, and AdaGrad (see

Table 1), the estimator ˆV�gt| ˆHt�(22) have a time-complexity of O (pN).

The proposed method for an automatic adjustment of learning rate and momentum (see Algorithm 1) can be utilized in fully-connected neural networks (FCNN’s) and convolution neural networks (CNN’s). Practically, when the Hessian estimator is a diagonal matrix, as in SGD, Adam, and AdaGrad (see Table 1) , the time complexity of the proposed algorithm remains the same as for the back-propagation phase [21], thus doesn’t increase the time complexity of the training. Consider the case of a FCNN with L layers [24]. The L layers, l = 1, . . . , L, are connected to each other by the following relation:

image

where f(.) is the activation function (for example, sigmoid() or rectified linear unit ReLU(.)[25]). The weight matrices  W[l] and the bias vectors  b[l], are of size  p[l] × p[l−1], and p[l] × 1, respectively. The activation matrix  A[l] (as well as  Z[l]) is of size  p[l] × N, where Nis the mini-batch size. Note that  A[0] is the forwarded mini-batch of size  p[0] × N.

The gradients of a loss function J with respect to the parameters�W[l], b[l]�, l = 1, . . . , Lare calculated using the back-propagation algorithm [21], i.e., we can compute the gradients�G[l], db[l]�,l = 1, . . . , L by the following procedure:

For l = L, . . . , 1 calculate:

image

The time complexities for (28), (29), (30), (31) are  O�p[l]N�, O�p[l]p[l−1]N�, O�p[l]N�, and O�p[l]p[l−1]N�, respectively. Recall the computation of the gradient  G[l] (29), the individual gradients  G[l](i), i = 1, 2, ..., Nare calculated by

image

where  G[l](i)have a time complexity of  O�p[l]p[l−1]�. Therefore, the time complexity for all individual gradients is  O�p[l]p[l−1]N�. The time complexity for ˆV�G[l]| ˆHt�(22)when the Hessian estimator ˆHtis diagonal is also the same as computing  G[l] (29), i.e., O�p[l]p[l−1]N�(see Appendix A). Therefore, the time complexity of Algorithm 1, when deployed for a fully-connected layer, have the same time complexity as its back-propagation, which is  O�p[l]p[l−1]N�for the l-th layer.

Similarly, assume that the l-th layer is a convolutional layer having the filter  W[l]. The latter is a 4-dimensional tensor of size  f × f × C[l−1] × C[l] where f × fis the convolve window size, and  C[l]denotes the number of channels of the l-th layer. The gradient of the c-th channel (c = 1, . . . , C[l]) inW[l] is a 3-dimensional tensor of size  f × f × C[l−1], denoted as  dW[l]c , and computed by

image

where  dW[l](i)cis the gradient with respect to the i-th observation, defined as

image

The scalar  dz[l](i)hwindicates the gradient of the activation  z[l](i)hw , and H[l], W [l]denote the height and width of the l-th layer. The tensor  A[l−1](i)hwof size  f × f × C[l−1]corresponds to the activation of the previous layer which was used to generate the activation  z[l](i)hw of the i-th observation.

Therefore, the time-complexity for calculating the mini-batch gradient  dW[l]c (33)(or the set of indi- vidual gradients�dW[l](i)c �Ni=1 (34)) is O�f 2C[l−1]C[l]NH[l]W [l−1]�. Once we have the gradients per-observation, we can proceed to Algorithm 1 that have a time-complexity of  O�f 2C[l−1]C[l]N�,which is lower than the time-complexity of  dW[l]c (33).


Designed for Accessibility and to further Open Science