arXiv(opens in a new tab)cs.LGFeb 2015Cited by 56 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:1502.03167

Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift

Sergey Ioffe, Christian Szegedy

Abstract

Training Deep Neural Networks is complicated by the fact that the distribution of each layer’s inputs changes during training, as the parameters of the previous layers change. This slows down the training by requiring lower learning rates and careful parameter initialization, and makes it notoriously hard to train models with saturating nonlinearities. We refer to this phenomenon as internal covariate shift, and address the problem by normalizing layer inputs. Our method draws its strength from making normalization a part of the model architecture and performing the normalization for each training mini-batch. Batch Normalization allows us to use much higher learning rates and be less careful about initialization. It also acts as a regularizer, in some cases eliminating the need for Dropout. Applied to a state-of-the-art image classification model, Batch Normalization achieves the same accuracy with 14 times fewer training steps, and beats the original model by a significant margin. Using an ensemble of batch-normalized networks, we improve upon the best published result on ImageNet classification: reaching 4.9% top-5 validation error (and 4.8% test error), exceeding the accuracy of human raters.

1 Introduction

Deep learning has dramatically advanced the state of the art in vision, speech, and many other areas. Stochastic gradient descent (SGD) has proved to be an effective way of training deep networks, and SGD variants such as momentum Sutskever et al. (2013) and Adagrad Duchi et al. (2011) have been used to achieve state of the art performance. SGD optimizes the parameters Θ\Theta of the network, so as to minimize the loss

Θ=arg⁡min⁡Θ1N∑i=1Nℓ(xi,Θ)\Theta=\arg\min_{\Theta}\frac{1}{N}\sum_{i=1}^{N}\ell(\mathrm{x}_{i},\Theta)

where x1…N\mathrm{x}_{1\ldots N} is the training data set. With SGD, the training proceeds in steps, and at each step we consider a mini-batch x1…m\mathrm{x}_{1\ldots m} of size mm. The mini-batch is used to approximate the gradient of the loss function with respect to the parameters, by computing

1m∂ℓ(xi,Θ)∂Θ.\frac{1}{m}\frac{\partial\ell(\mathrm{x}_{i},\Theta)}{\partial\Theta}.

Using mini-batches of examples, as opposed to one example at a time, is helpful in several ways. First, the gradient of the loss over a mini-batch is an estimate of the gradient over the training set, whose quality improves as the batch size increases. Second, computation over a batch can be much more efficient than mm computations for individual examples, due to the parallelism afforded by the modern computing platforms.

While stochastic gradient is simple and effective, it requires careful tuning of the model hyper-parameters, specifically the learning rate used in optimization, as well as the initial values for the model parameters. The training is complicated by the fact that the inputs to each layer are affected by the parameters of all preceding layers – so that small changes to the network parameters amplify as the network becomes deeper.

The change in the distributions of layers’ inputs presents a problem because the layers need to continuously adapt to the new distribution. When the input distribution to a learning system changes, it is said to experience covariate shift Shimodaira (2000). This is typically handled via domain adaptation Jiang (2008). However, the notion of covariate shift can be extended beyond the learning system as a whole, to apply to its parts, such as a sub-network or a layer. Consider a network computing

ℓ=F2(F1(u,Θ1),Θ2)\ell=F_{2}(F_{1}(\mathrm{u},\Theta_{1}),\Theta_{2})

where F1F_{1} and F2F_{2} are arbitrary transformations, and the parameters Θ1,Θ2\Theta_{1},\Theta_{2} are to be learned so as to minimize the loss ℓ\ell. Learning Θ2\Theta_{2} can be viewed as if the inputs x=F1(u,Θ1)\mathrm{x}=F_{1}(\mathrm{u},\Theta_{1}) are fed into the sub-network

ℓ=F2(x,Θ2).\ell=F_{2}(\mathrm{x},\Theta_{2}).

For example, a gradient descent step

Θ2←Θ2−αm∑i=1m∂F2(xi,Θ2)∂Θ2\Theta_{2}\leftarrow\Theta_{2}-\frac{\alpha}{m}\sum_{i=1}^{m}\frac{\partial F_{2}(\mathrm{x}_{i},\Theta_{2})}{\partial\Theta_{2}}

(for batch size mm and learning rate α\alpha) is exactly equivalent to that for a stand-alone network F2F_{2} with input x\mathrm{x}. Therefore, the input distribution properties that make training more efficient – such as having the same distribution between the training and test data – apply to training the sub-network as well. As such it is advantageous for the distribution of x\mathrm{x} to remain fixed over time. Then, Θ2\Theta_{2} does not have to readjust to compensate for the change in the distribution of x\mathrm{x}.

Fixed distribution of inputs to a sub-network would have positive consequences for the layers outside the sub-network, as well. Consider a layer with a sigmoid activation function z=g(Wu+b)\mathrm{z}=g(W\mathrm{u}+\mathrm{b}) where u\mathrm{u} is the layer input, the weight matrix WW and bias vector b\mathrm{b} are the layer parameters to be learned, and g(x)=11+exp⁡(−x)g(x)=\frac{1}{1+\exp(-x)}. As ∣x∣|x| increases, g′(x)g^{\prime}(x) tends to zero. This means that for all dimensions of x=Wu+b\mathrm{x}=W\mathrm{u}+\mathrm{b} except those with small absolute values, the gradient flowing down to u\mathrm{u} will vanish and the model will train slowly. However, since x\mathrm{x} is affected by W,bW,\mathrm{b} and the parameters of all the layers below, changes to those parameters during training will likely move many dimensions of x\mathrm{x} into the saturated regime of the nonlinearity and slow down the convergence. This effect is amplified as the network depth increases. In practice, the saturation problem and the resulting vanishing gradients are usually addressed by using Rectified Linear Units Nair & Hinton (2010) ReLU(x)=max⁡(x,0)ReLU(x)=\max(x,0), careful initialization Bengio & Glorot (2010); Saxe et al. (2013), and small learning rates. If, however, we could ensure that the distribution of nonlinearity inputs remains more stable as the network trains, then the optimizer would be less likely to get stuck in the saturated regime, and the training would accelerate.

We refer to the change in the distributions of internal nodes of a deep network, in the course of training, as Internal Covariate Shift. Eliminating it offers a promise of faster training. We propose a new mechanism, which we call Batch Normalization, that takes a step towards reducing internal covariate shift, and in doing so dramatically accelerates the training of deep neural nets. It accomplishes this via a normalization step that fixes the means and variances of layer inputs. Batch Normalization also has a beneficial effect on the gradient flow through the network, by reducing the dependence of gradients on the scale of the parameters or of their initial values. This allows us to use much higher learning rates without the risk of divergence. Furthermore, batch normalization regularizes the model and reduces the need for Dropout Srivastava et al. (2014). Finally, Batch Normalization makes it possible to use saturating nonlinearities by preventing the network from getting stuck in the saturated modes.

In Sec. 4.2, we apply Batch Normalization to the best-performing ImageNet classification network, and show that we can match its performance using only 7% of the training steps, and can further exceed its accuracy by a substantial margin. Using an ensemble of such networks trained with Batch Normalization, we achieve the top-5 error rate that improves upon the best known results on ImageNet classification.

References (21)

Cited by (56)