LeNet 5 implementation to be used on MNIST Data
We introduce the "exponential linear unit" (ELU) which speeds up learning in deep neural networks and leads to higher classification accuracies. Like rectified linear units (ReLUs), leaky ReLUs (LReLUs) and parametrized ReLUs (PReLUs), ELUs alleviate the vanishing gradient problem via the identity for positive values. However, ELUs have improved learning characteristics compared to the units with other activation functions. In contrast to ReLUs, ELUs have negative values which allows them to push mean unit activations closer to zero like batch normalization but with lower computational complexity. Mean shifts toward zero speed up learning by bringing the normal gradient closer to the unit natural gradient because of a reduced bias shift effect. While LReLUs and PReLUs have negative values, too, they do not ensure a noise-robust deactivation state. ELUs saturate to a negative value with smaller inputs and thereby decrease the forward propagated variation and information. Therefore, ELUs code the degree of presence of particular phenomena in the input, while they do not quantitatively model the degree of their absence. In experiments, ELUs lead not only to faster learning, but also to significantly better generalization performance than ReLUs and LReLUs on networks with more than 5 layers. On CIFAR-100 ELUs networks significantly outperform ReLU networks with batch normalization while batch normalization does not improve ELU networks. ELU networks are among the top 10 reported CIFAR-10 results and yield the best published result on CIFAR-100, without resorting to multi-view evaluation or model averaging. On ImageNet, ELU networks considerably speed up learning compared to a ReLU network with the same architecture, obtaining less than 10 classification error for a single crop, single model network.READ FULL TEXT VIEW PDF
Very deep convolutional neural networks introduced new problems like
The activation function is an important component in Convolutional Neura...
In this work, we show that saturating output activation functions, such ...
In this paper, we introduce "Power Linear Unit" (PoLU) which increases t...
Recently, self-normalizing neural networks (SNNs) have been proposed wit...
Deep Learning has revolutionized vision via convolutional neural network...
Very deep CNNs achieve state-of-the-art results in both computer vision ...
LeNet 5 implementation to be used on MNIST Data
Recognizes Images of Latin Alphabet with up to 89% accuracy. Credits to gregv for his dataset on Kaggle which can be found here: https://www.kaggle.com/gregvial/comnist
Tutorial for building a model that generates steering angle based on image input. The model is then deployed on to a video game for testing. The complete description can be found on the readme.md document.
Currently the most popular activation function for neural networks is the rectified linear unit (ReLU), which was first proposed for restricted Boltzmann machines(Nair & Hinton, 2010) and then successfully used for neural networks (Glorot et al., 2011). The ReLU activation function is the identity for positive arguments and zero otherwise. Besides producing sparse codes, the main advantage of ReLUs is that they alleviate the vanishing gradient problem (Hochreiter, 1998; Hochreiter et al., 2001) since the derivative of 1 for positive values is not contractive (Glorot et al., 2011). However ReLUs are non-negative and, therefore, have a mean activation larger than zero.
Units that have a non-zero mean activation act as bias for the next layer. If such units do not cancel each other out, learning causes a bias shift for units in next layer. The more the units are correlated, the higher their bias shift. We will see that Fisher optimal learning, i.e., the natural gradient (Amari, 1998), would correct for the bias shift by adjusting the weight updates. Thus, less bias shift brings the standard gradient closer to the natural gradient and speeds up learning. We aim at activation functions that push activation means closer to zero to decrease the bias shift effect.
Centering the activations at zero has been proposed in order to keep the off-diagonal entries of the Fisher information matrix small (Raiko et al., 2012). For neural network it is known that centering the activations speeds up learning (LeCun et al., 1991, 1998; Schraudolph, 1998). “Batch normalization” also centers activations with the goal to counter the internal covariate shift (Ioffe & Szegedy, 2015). Also the Projected Natural Gradient Descent algorithm (PRONG) centers the activations by implicitly whitening them (Desjardins et al., 2015).
An alternative to centering is to push the mean activation toward zero by an appropriate activation function. Therefore has been preferred over logistic functions (LeCun et al., 1991, 1998). Recently “Leaky ReLUs” (LReLUs) that replace the negative part of the ReLU with a linear function have been shown to be superior to ReLUs (Maas et al., 2013). Parametric Rectified Linear Units (PReLUs) generalize LReLUs by learning the slope of the negative part which yielded improved learning behavior on large image benchmark data sets (He et al., 2015). Another variant are Randomized Leaky Rectified Linear Units (RReLUs) which randomly sample the slope of the negative part which raised the performance on image benchmark datasets and convolutional networks (Xu et al., 2015).
In contrast to ReLUs, activation functions like LReLUs, PReLUs, and RReLUs do not ensure a noise-robust deactivation state. We propose an activation function that has negative values to allow for mean activations close to zero, but which saturates to a negative value with smaller arguments. The saturation decreases the variation of the units if deactivated, so the precise deactivation argument is less relevant. Such an activation function can code the degree of presence of particular phenomena in the input, but does not quantitatively model the degree of their absence. Therefore, such an activation function is more robust to noise. Consequently, dependencies between coding units are much easier to model and much easier to interpret since only activated code units carry much information. Furthermore, distinct concepts are much less likely to interfere with such activation functions since the deactivation state is non-informative, i.e. variance decreasing.
To derive and analyze the bias shift effect mentioned in the introduction, we utilize the natural gradient. The natural gradient corrects the gradient direction with the inverse Fisher information matrix and, thereby, enables Fisher optimal learning, which ensures the steepest descent in the Riemannian parameter manifold and Fisher efficiency for online learning (Amari, 1998). The recently introduced Hessian-Free Optimization technique (Martens, 2010) and the Krylov Subspace Descent methods (Vinyals & Povey, 2012) use an extended Gauss-Newton approximation of the Hessian, therefore they can be interpreted as versions of natural gradient descent (Pascanu & Bengio, 2014).
Since for neural networks the Fisher information matrix is typically too expensive to compute, different approximations of the natural gradient have been proposed. Topmoumoute Online natural Gradient Algorithm (TONGA) (LeRoux et al., 2008) uses a low-rank approximation of natural gradient descent. FActorized Natural Gradient (FANG) (Grosse & Salakhudinov, 2015)estimates the natural gradient via an approximation of the Fisher information matrix by a Gaussian graphical model. The Fisher information matrix can be approximated by a block-diagonal matrix, where unit or quasi-diagonal natural gradients are used (Olivier, 2013). Unit natural gradients or “Unitwise Fisher’s scoring” (Kurita, 1993)
are based on natural gradients for perceptrons(Amari, 1998; Yang & Amari, 1998). We will base our analysis on the unit natural gradient.
We assume a parameterized probabilistic model
with parameter vectorand data . The training data are with , where is the input for example and is its label. is the loss of example using model . The average loss on the training data is the empirical risk . Gradient descent updates the weight vector by where is the learning rate. The natural gradient is the inverse Fisher information matrix multiplied by the gradient of the empirical risk: . For a multi-layer perceptron is the unit activation vector and is the bias unit activation. We consider the ingoing weights to unit , therefore we drop the index : for the weight from unit to unit , for the activation, and for the bias weight of unit . The activation function maps the net input of unit to its activation
. For computing the Fisher information matrix, the derivative of the log-output probabilityis required. Therefore we define the at unit as .
We restrict the Fisher information matrix to weights leading to unit which is the unit Fisher information matrix . captures only the interactions of weights to unit . Consequently, the unit natural gradient only corrects the interactions of weights to unit , i.e. considers the Riemannian parameter manifold only in a subspace. The unit Fisher information matrix is
Weighting the activations by is equivalent to adjusting the probability of drawing inputs . Inputs with large are drawn with higher probability. Since , we can define a distribution :
Using , the entries of
can be expressed as second moments:
If the bias unit is with weight then the weight vector can be divided into a bias part and the rest : . For the row that corresponds to the bias weight, we have:
The unit natural gradient corrects the weight update to a unit by following affine transformation of the gradient :
where is the unit Fisher information matrix without row 0 and column 0 corresponding to the bias weight. The vector is the zeroth column of corresponding to the bias weight, and the positive scalar is
where is the vector of activations of units with weights to unit and .
Multiplying the inverse Fisher matrix with the separated gradient gives the weight update :
The bias shift (mean shift) of unit is the change of unit ’s mean value due to the weight update. Bias shifts of unit lead to oscillations and impede learning. See Section 4.4 in LeCun et al. (1998) for demonstrating this effect at the inputs and in LeCun et al. (1991) for explaining this effect using the input covariance matrix. Such bias shifts are mitigated or even prevented by the unit natural gradient. The bias shift correction of the unit natural gradient is the effect on the bias shift due to which captures the interaction between the bias unit and the incoming units. Without bias shift correction, i.e., and , the weight updates are and . As only the activations depend on the input, the bias shift can be computed by multiplying the weight update by the mean of the activation vector . Thus we obtain the bias shift . The bias shift strongly depends on the correlation of the incoming units which is captured by .
Next, Theorem 2 states that the bias shift correction by the unit natural gradient can be considered to correct the incoming mean proportional to toward zero.
The bias shift correction by the unit natural gradient is equivalent to an additive correction of the incoming mean by and a multiplicative correction of the bias unit by , where
Using , the bias shift is:
In Theorem 2 we can reformulate . Therefore increases with the length of for given variances and covariances. Consequently the bias shift correction through the unit natural gradient is governed by the length of . The bias shift correction is zero for since does not correct the bias unit multiplicatively. Using Eq. (4), is split into an offset and an information containing term:
In general, smaller positive lead to smaller positive , therefore to smaller corrections. The reason is that in general the largest absolute components of are positive, since activated inputs will activate the unit which in turn will have large impact on the output.
To summarize, the unit natural gradient corrects the bias shift of unit via the interactions of incoming units with the bias unit to ensure efficient learning. This correction is equivalent to shifting the mean activations of the incoming units toward zero and scaling up the bias unit. To reduce the undesired bias shift effect without the natural gradient, either the (i) activation of incoming units can be centered at zero or (ii) activation functions with negative values can be used. We introduce a new activation function with negative values while keeping the identity for positive arguments where it is not contradicting.
The exponential linear unit (ELU) with is
The ELU hyperparametercontrols the value to which an ELU saturates for negative net inputs (see Fig. 1). ELUs diminish the vanishing gradient effect as rectified linear units (ReLUs) and leaky ReLUs (LReLUs) do. The vanishing gradient problem is alleviated because the positive part of these functions is the identity, therefore their derivative is one and not contractive. In contrast, and sigmoid activation functions are contractive almost everywhere.
In contrast to ReLUs, ELUs have negative values which pushes the mean of the activations closer to zero. Mean activations that are closer to zero enable faster learning as they bring the gradient closer to the natural gradient (see Theorem 2 and text thereafter). ELUs saturate to a negative value when the argument gets smaller. Saturation means a small derivative which decreases the variation and the information that is propagated to the next layer. Therefore the representation is both noise-robust and low-complex (Hochreiter & Schmidhuber, 1999). ELUs code the degree of presence of input concepts, while they neither quantify the degree of their absence nor distinguish the causes of their absence. This property of non-informative deactivation states is also present at ReLUs and allowed to detect biclusters corresponding to biological modules in gene expression datasets (Clevert et al., 2015) and to identify toxicophores in toxicity prediction (Unterthiner et al., 2015; Mayr et al., 2015). The enabling features for these interpretations is that activation can be clearly distinguished from deactivation and that only active units carry relevant information and can crosstalk.
ELU networks evaluated at MNIST. Lines are the average over five runs with different random initializations, error bars show standard deviation. Panel (a): median of the average unit activation for different activation functions. Panel (b): Training set (straight line) and validation set (dotted line) cross entropy loss. All lines stay flat after epoch 25.
We first want to verify that ELUs keep the mean activations closer to zero than other units. Fully connected deep neural networks with ELUs (), ReLUs, and LReLUs (
) were trained on the MNIST digit classification dataset while each hidden unit’s activation was tracked. Each network had eight hidden layers of 128 units each, and was trained for 300 epochs by stochastic gradient descent with learning rateand mini-batches of size 64. The weights have been initialized according to (He et al., 2015). After each epoch we calculated the units’ average activations on a fixed subset of the training data. Fig. 2 shows the median over all units along learning. ELUs stay have smaller median throughout the training process. The training error of ELU networks decreases much more rapidly than for the other networks.
Section C in the appendix compares the variance of median activation in ReLU and ELU networks. The median varies much more in ReLU networks. This indicates that ReLU networks continuously try to correct the bias shift introduced by previous weight updates while this effect is much less prominent in ELU networks.
To evaluate ELU networks at unsupervised settings, we followed Martens (2010) and Desjardins et al. (2015) and trained a deep autoencoder on the MNIST dataset. The encoder part consisted of four fully connected hidden layers with sizes 1000, 500, 250 and 30, respectively. The decoder part was symmetrical to the encoder. For learning we applied stochastic gradient descent with mini-batches of 64 samples for 500 epochs using the fixed learning rates (). Fig. 3 shows, that ELUs outperform the competing activation functions in terms of training / test set reconstruction error for all learning rates. As already noted by Desjardins et al. (2015), higher learning rates seem to perform better.
In this subsection we show that ELUs indeed possess a superior learning behavior compared to other activation functions as postulated in Section 3
. Furthermore we show that ELU networks perform better than ReLU networks with batch normalization. We use as benchmark dataset CIFAR-100 and use a relatively simple convolutional neural network (CNN) architecture to keep the computational complexity reasonable for comparisons.
The CNN for these CIFAR-100 experiments consists of 11 convolutional layers arranged in stacks of () layers units receptive fields. 2). The -weight decay regularization term was set to . The following learning rate schedule was applied () (iterations [learning rate]). For fair comparisons, we used this learning rate schedule for all networks. During previous experiments, this schedule was optimized for ReLU networks, however as ELUs converge faster they would benefit from an adjusted schedule. The momentum term learning rate was fixed to 0.9. The dataset was preprocessed as described in Goodfellow et al. (2013)
with global contrast normalization and ZCA whitening. Additionally, the images were padded with four zero pixels at all borders. The model was trained onrandom crops with random horizontal flipping. Besides that, we no further augmented the dataset during training. Each network was run 10 times with different weight initialization. Across networks with different activation functions the same run number had the same initial weights.
Mean test error results of networks with different activation functions are compared in Fig. 4(c), which also shows the standard deviation. ELUs yield on average a test error of 28.75(0.24)%, while SReLUs, ReLUs and LReLUs yield 29.35(0.29)%, 31.56(0.37)% and 30.59(0.29)%, respectively. ELUs achieve both lower training loss and lower test error than ReLUs, LReLUs, and SReLUs. Both the ELU training and test performance is significantly better than for other activation functions (Wilcoxon signed-rank test with -value0.001). Batch normalization improved ReLU and LReLU networks, but did not improve ELU and SReLU networks (see Fig. 5(c)). ELU networks significantly outperform ReLU networks with batch normalization (Wilcoxon signed-rank test with -value0.001).
The following experiments should highlight the generalization capabilities of ELU networks. The CNN architecture is more sophisticated than in the previous subsection and consists of 18 convolutional layers arranged in stacks of (). Initial drop-out rate, Max-pooling after each stack, -weight decay, momentum term, data preprocessing, padding, and cropping were as in previous section. The initial learning rate was set to 0.01 and decreased by a factor of 10 after 35k iterations. The mini-batch size was 100. For the final 50k iterations fine-tuning we increased the drop-out rate for all layers in a stack to (), thereafter increased the drop-out rate by a factor of 1.5 for 40k additional iterations.
|Network||CIFAR-10 (test error %)||CIFAR-100 (test error %)||augmented|
ELU networks are compared to following recent successful CNN architectures: AlexNet (Krizhevsky et al., 2012), DSN (Lee et al., 2015), NiN (Lin et al., 2013), Maxout (Goodfellow et al., 2013), All-CNN (Springenberg et al., 2014), Highway Network (Srivastava et al., 2015) and Fractional Max-Pooling (Graham, 2014). The test error in percent misclassification are given in Tab. 1. ELU-networks are the second best on CIFAR-10 with a test error of 6.55% but still they are among the top 10 best results reported for CIFAR-10. ELU networks performed best on CIFAR-100 with a test error of 24.28%. This is the best published result on CIFAR-100, without even resorting to multi-view evaluation or model averaging.
Finally, we evaluated ELU-networks on the 1000-class ImageNet dataset. It contains about 1.3M training color images as well as additional 50k images and 100k images for validation and testing, respectively. For this task, we designed a 15 layer CNN, which was arranged in stacks of () layers units receptive fields or fully-connected (FC). 22 max-pooling with a stride of 2 was applied after each stack and spatial pyramid pooling (SPP) with 3 levels before the first FC layer (He et al., 2015). For network regularization we set the -weight decay term to and used 50% drop-out in the two penultimate FC layers. Images were re-sized to 256256 pixels and per-pixel mean subtracted. Trained was on random crops with random horizontal flipping. Besides that, we did not augment the dataset during training.
Fig. 6 shows the learning behavior of ELU vs. ReLU networks. Panel (b) shows that ELUs start reducing the error earlier. The ELU-network already reaches the 20% top-5 error after 160k iterations, while the ReLU network needs 200k iterations to reach the same error rate. The single-model performance was evaluated on the single center crop with no further augmentation and yielded a top-5 validation error below 10%.
Currently ELU nets are 5% slower on ImageNet than ReLU nets. The difference is small because activation functions generally have only minor influence on the overall training time (Jia, 2014). In terms of wall clock time, ELUs require 12.15h vs. ReLUs with 11.48h for 10k iterations. We expect that ELU implementations can be improved, e.g. by faster exponential functions (Schraudolph, 1999).
We have introduced the exponential linear units (ELUs) for faster and more precise learning in deep neural networks. ELUs have negative values, which allows the network to push the mean activations closer to zero. Therefore ELUs decrease the gap between the normal gradient and the unit natural gradient and, thereby speed up learning. We believe that this property is also the reason for the success of activation functions like LReLUs and PReLUs and of batch normalization. In contrast to LReLUs and PReLUs, ELUs have a clear saturation plateau in its negative regime, allowing them to learn a more robust and stable representation. Experimental results show that ELUs significantly outperform other activation functions on different vision datasets. Further ELU networks perform significantly better than ReLU networks trained with batch normalization. ELU networks achieved one of the top 10 best reported results on CIFAR-10 and set a new state of the art in CIFAR-100 without the need for multi-view test evaluation or model averaging. Furthermore, ELU networks produced competitive results on the ImageNet in much fewer epochs than a corresponding ReLU network. Given their outstanding performance, we expect ELU networks to become a real time saver in convolutional networks, which are notably time-intensive to train from scratch otherwise.
We thank the NVIDIA Corporation for supporting this research with several Titan X GPUs and Roland Vollgraf and Martin Heusel for helpful discussions and comments on this work.
JMLR W&CP: Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics (AISTATS 2011), volume 15, pp. 315–323, 2011.
Journal of Machine Learning Research, 37:2304–2313, 2015. URL http://jmlr.org/proceedings/papers/v37/grosse15.pdf. Proceedings of the 32nd International Conference on Machine Learning (ICML15).
IEEE International Conference on Computer Vision (ICCV), 2015.
A Field Guide to Dynamical Recurrent Neural Networks. IEEE Press, 2001.
Iterative weighted least squares algorithms for neural networks classifiers.In Proceedings of the Third Workshop on Algorithmic Learning Theory (ALT92), volume 743 of Lecture Notes in Computer Science, pp. 77–86. Springer, 1993.
Rectified linear units improve restricted Boltzmann machines.In Fürnkranz, J. and Joachims, T. (eds.), Proceedings of the 27th International Conference on Machine Learning (ICML10), pp. 807–814, 2010.
Deep learning made easier by linear transformations in perceptrons.In Lawrence, N. D. and Girolami, M. A. (eds.), Proceedings of the 15th International Conference on Artificial Intelligence and Statistics (AISTATS12), volume 22, pp. 924–932, 2012.
Complexity issues in natural gradient descent method for training multilayer perceptrons.Neural Computation, 10(8), 1998.
The positive definite matrix is in block format with matrix , vector , and scalar . The inverse of is
For block matrices the inverse is
where the matrices on the right hand side are:
Further if follows that
We now use this formula for being a vector and a scalar. We obtain
where the right hand side matrices, vectors, and the scalar are:
Again it follows that
A reformulation using gives
For a random variable
For a random variableholds
The Sherman-Morrison Theorem states
Therefore we have
Using the identity
for the second moment and Eq. (40), we get
The last inequality follows from the fact that is positive definite. From last equation, we obtain further
For the mixed quadratic form we get from Eq. (40)
From this equation follows
Therefore we get
To compare the variance of median activation in ReLU and ELU networks, we trained a neural network with 5 hidden layers of 256 hidden units for 200 epochs using a learning rate of 0.01, once using ReLU and once using ELU activation functions on the MNIST dataset. After each epoch, we calculated the median activation of each hidden unit on the whole training set. We then calculated the variance of these changes, which is depicted in Figure 7 . The median varies much more in ReLU networks. This indicates that ReLU networks continuously try to correct the bias shift introduced by previous weight updates while this effect is much less prominent in ELU networks.