Training deep neural networks with
low precision multiplications
Abstract
Multipliers are the most space and powerhungry arithmetic operators of the digital implementation of deep neural networks. We train a set of stateoftheart neural networks (Maxout networks) on three benchmark datasets: MNIST, CIFAR10 and SVHN. They are trained with three distinct formats: floating point, fixed point and dynamic fixed point. For each of those datasets and for each of those formats, we assess the impact of the precision of the multiplications on the final error after training. We find that very low precision is sufficient not just for running trained networks but also for training them. For example, it is possible to train Maxout networks with 10 bits multiplications.
Training deep neural networks with
low precision multiplications
Matthieu Courbariaux & JeanPierre David 

École Polytechnique de Montréal 
{matthieu.courbariaux,jeanpierre.david}@polymtl.ca 
Yoshua Bengio 

Université de Montréal, CIFAR Senior Fellow 
yoshua.bengio@gmail.com 
1 Introduction
The training of deep neural networks is very often limited by hardware. Lots of previous works address the best exploitation of generalpurpose hardware, typically CPU clusters (Dean et al., 2012) and GPUs (Coates et al., 2009; Krizhevsky et al., 2012a). Faster implementations usually lead to state of the art results (Dean et al., 2012; Krizhevsky et al., 2012a).
Actually, such approaches always consist in adapting the algorithm to best exploit state of the art generalpurpose hardware. Nevertheless, some dedicated deep learning hardware is appearing as well. FPGA and ASIC implementations claim a better power efficiency than generalpurpose hardware (Kim et al., 2009; Farabet et al., 2011; Pham et al., 2012; Chen et al., 2014a; b). In contrast with generalpurpose hardware, dedicated hardware such as ASIC and FPGA enables to build the hardware from the algorithm.
Hardware is mainly made out of memories and arithmetic operators. Multipliers are the most space and powerhungry arithmetic operators of the digital implementation of deep neural networks. The objective of this article is to assess the possibility to reduce the precision of the multipliers for deep learning:

We train deep neural networks with low precision multipliers and high precision accumulators (Section 2).

We use a higher precision for the parameters during the updates than during the forward and backward propagations (Section 6).

For each of the three datasets and for each of the three formats, we assess the impact of the precision of the multiplications on the final error of the training. We find that very low precision multiplications are sufficient not just for running trained networks but also for training them (Section 9). We made our code available ^{1}^{1}1 https://github.com/MatthieuCourbariaux/deeplearningmultipliers .
2 Multiplieraccumulators
Multiplier (bits)  Accumulator (bits)  Adaptive Logic Modules (ALMs) 
32  32  504 
16  32  138 
16  16  128 
Applying a deep neural network (DNN) mainly consists in convolutions and matrix multiplications. The key arithmetic operation of DNNs is thus the multiplyaccumulate operation. Artificial neurons are basically multiplieraccumulators computing weighted sums of their inputs.
The cost of a fixed point multiplier varies as the square of the precision (of its operands) for small widths while the cost of adders and accumulators varies as a linear function of the precision (David et al., 2007). As a result, the cost of a fixed point multiplieraccumulator mainly depends on the precision of the multiplier, as shown in table 1. In modern FPGAs, the multiplications can also be implemented with dedicated DSP blocks/slices. One DSP block/slice can implement a single multiplier, a double multiplier or a triple multiplier. Reducing the precision can thus lead to a gain of 3 in the number of available multipliers inside a modern FPGA.
In this article, we train deep neural networks with low precision multipliers and high precision accumulators, as illustrated in Algorithm 1.
3 Floating point
Format  Total bitwidth  Exponent bitwidth  Mantissa bitwidth 

Double precision floating point  64  11  52 
Single precision floating point  32  8  23 
Half precision floating point  16  5  10 
Floating point formats are often used to represent real values. They consist in a sign, an exponent, and a mantissa, as illustrated in figure 1. The exponent gives the floating point formats a wide range, and the mantissa gives them a good precision. One can compute the value of a single floating point number using the following formula:
Table 2 shows the exponent and mantissa widths associated with each floating point format. In our experiments, we use single precision floating point format as our reference because it is the most widely used format in deep learning, especially for GPU computation. We show that the use of half precision floating point format has little to no impact on the training of neural networks. At the time of writing this article, no standard exists below the half precision floating point format.
4 Fixed point
Fixed point formats consist in a signed mantissa and a global scaling factor shared between all fixed point variables. The scaling factor can be seen as the position of the radix point. It is usually fixed, hence the name ”fixed point”. Reducing the scaling factor reduces the range and augments the precision of the format. The scaling factor is typically a power of two for computational efficiency (the scaling multiplications are replaced with shifts). As a result, fixed point format can also be seen as a floating point format with a unique shared fixed exponent , as illustrated in figure 1. Fixed point format is commonly found on embedded systems with no FPU (Floating Point Unit). It relies on integer operations. It is hardwarewise cheaper than its floating point counterpart, as the exponent is shared and fixed.
5 Dynamic fixed point
When training deep neural networks,

activations, gradients and parameters have very different ranges.

gradients ranges slowly diminish during the training.
As a result, the fixed point format, with its unique shared fixed exponent, is illsuited to deep learning.
The dynamic fixed point format (Williamson, 1991) is a variant of the fixed point format in which there are several scaling factors instead of a single global one. Those scaling factors are not fixed. As such, it can be seen as a compromise between floating point format  where each scalar variable owns its scaling factor which is updated during each operations  and fixed point format  where there is only one global scaling factor which is never updated. With dynamic fixed point, a few grouped variables share a scaling factor which is updated from time to time to reflect the statistics of values in the group.
In practice, we associate each layer’s weights, bias, weighted sum, outputs (postnonlinearity) and the respective gradients vectors and matrices with a different scaling factor. Those scaling factors are initialized with a global value. The initial values can also be found during the training with a higher precision format. During the training, we update those scaling factors at a given frequency, following the policy described in Algorithm 2.
6 Updates vs. propagations
We use a higher precision for the parameters during the updates than during the forward and backward propagations, respectively called fprop and bprop. The idea behind this is to be able to accumulate small changes in the parameters (which requires more precision) and while on the other hand sparing a few bits of memory bandwidth during fprop. This can be done because of the implicit averaging performed via stochastic gradient descent during training:
where is the cost to minimize over the minibatch visited at iteration using as parameters and is the learning rate. We see that the resulting parameter is the sum
The terms of this sum are not statistically independent (because the value of depends on the value of ) but the dominant variations come from the random sample of examples in the minibatch ( moves slowly) so that a strong averaging effect takes place, and each contribution in the sum is relatively small, hence the demand for sufficient precision (when adding a small number with a large number).
7 Maxout networks
A Maxout network is a multilayer neural network that uses maxout units in its hidden layers. A maxout unit outputs the maximum of a set of dot products between weight vectors and the input vector of the unit (e.g., the output of the previous layer):
where is the vector of activations at layer and weight vectors and biases are the parameters of the th filter of unit on layer .
A maxout unit can be seen as a generalization of the rectifying units (Jarrett et al., 2009; Nair and Hinton, 2010; Glorot et al., 2011; Krizhevsky et al., 2012b)
which corresponds to a maxout unit when and one of the filters is forced at 0 (Goodfellow et al., 2013a). Combined with dropout, a very effective regularization method (Hinton et al., 2012), maxout networks achieved stateoftheart results on a number of benchmarks (Goodfellow et al., 2013a), both as part of fully connected feedforward deep nets and as part of deep convolutional nets. The dropout technique provides a good approximation of model averaging with shared parameters across an exponentially large number of networks that are formed by subsets of the units of the original noisefree deep network.
8 Baseline results
We train Maxout networks with slightly less capacity than Goodfellow et al. (2013a) on three benchmark datasets: MNIST, CIFAR10 and SVHN. In Section 9, we use the same hyperparameters as in this section to train Maxout networks with low precision multiplications.
Dataset  Dimension  Labels  Training set  Test set 

MNIST  784 (28 28 grayscale)  10  60K  10K 
CIFAR10  3072 (32 32 color)  10  50K  10K 
SVHN  3072 (32 32 color)  10  604K  26K 
Format  Prop.  Up.  PI MNIST  MNIST  CIFAR10  SVHN 

Goodfellow et al. (2013a)  32  32  0.94%  0.45%  11.68%  2.47% 
Single precision floating point  32  32  1.05%  0.51%  14.05%  2.71% 
Half precision floating point  16  16  1.10%  0.51%  14.14%  3.02% 
Fixed point  20  20  1.39%  0.57%  15.98%  2.97% 
Dynamic fixed point  10  12  1.28%  0.59%  14.82%  4.95% 
8.1 Mnist
The MNIST (LeCun et al., 1998) dataset is described in Table 3. We do not use any dataaugmentation (e.g. distortions) nor any unsupervised pretraining. We simply use minibatch stochastic gradient descent (SGD) with momentum. We use a linearly decaying learning rate and a linearly saturating momentum. We regularize the model with dropout and a constraint on the norm of each weight vector, as in (Srebro and Shraibman, 2005).
We train two different models on MNIST. The first is a permutation invariant (PI) model which is unaware of the structure of the data. It consists in two fully connected maxout layers followed by a softmax layer. The second model consists in three convolutional maxout hidden layers (with spatial max pooling on top of the maxout layers) followed by a densely connected softmax layer.
8.2 Cifar10
Some comparative characteristics of the CIFAR10 (Krizhevsky and Hinton, 2009) dataset are given in Table 3. We preprocess the data using global contrast normalization and ZCA whitening. The model consists in three convolutional maxout layers, a fully connected maxout layer, and a fully connected softmax layer. We follow a similar procedure as with the MNIST dataset. This is the same procedure as in Goodfellow et al. (2013a), except that we reduced the number of hidden units and that we do not train our model on the validation examples. As a consequence, our test error is slightly larger than the one reported in Goodfellow et al. (2013a). The final test error is in Table 4.
8.3 Street View House Numbers
The SVHN (Netzer et al., 2011) dataset is described in Table 3. We applied local contrast normalization preprocessing the same way as Zeiler and Fergus (2013). The model consists in three convolutional maxout layers, a fully connected maxout layer, and a fully connected softmax layer. Otherwise, we followed the same approach as on the MNIST dataset. This is the same procedure as in Goodfellow et al. (2013a), except that we reduced the length of the training. As a consequence, our test error is bigger than the one reported in Goodfellow et al. (2013a). The final test error is in Table 4.
9 Low precision results
9.1 Floating point
Half precision floating point format has little to no impact on the test set error rate, as shown in Table 4. We conjecture that a highprecision finetuning could recover the small degradation of the error rate.
9.2 Fixed point
The optimal radix point position in fixed point is after the fifth (or arguably the sixth) most important bit, as illustrated in Figure 2. The corresponding range is approximately [32,32]. The corresponding scaling factor depends on the bitwidth we are using. The minimum bitwidth for propagations in fixed point is 19 (20 with the sign). Below this bitwidth, the test set error rate rises very sharply, as illustrated in Figure 3. The minimum bitwidth for parameter updates in fixed point is 19 (20 with the sign). Below this bitwidth, the test set error rate rises very sharply, as illustrated in Figure 4. Doubling the number of hidden units does not allow any further reduction of the bitwidths on the permutation invariant MNIST. In the end, using 19 (20 with the sign) bits for both the propagations and the parameter updates has little impact on the final test error, as shown in Table 4.
9.3 Dynamic fixed point
We find the initial scaling factors by training with a higher precision format. Once those scaling factors are found, we reinitialize the model parameters. We update the scaling factors once every 10000 examples. Augmenting the maximum overflow rate allows us to reduce the propagations bitwidth but it also significantly augments the final test error rate, as illustrated in Figure 5. As a consequence, we use a low maximum overflow rate of 0.01% for the rest of the experiments. The minimum bitwidth for the propagations in dynamic fixed point is 9 (10 with the sign). Below this bitwidth, the test set error rate rises very sharply, as illustrated in Figure 3. The minimum bitwidth for the parameter updates in dynamic fixed point is 11 (12 with the sign). Below this bitwidth, the test set error rate rises very sharply, as illustrated in Figure 4. Doubling the number of hidden units does not allow any further reduction of the bitwidths on the permutation invariant MNIST. In the end, using 9 (10 with the sign) bits for the propagations and 11 (12 with the sign) bits for the parameter updates has little impact on the final test error, with the exception of the SVHN dataset, as shown in Table 4. This is significantly better than fixed point format, which is consistent with our predictions of Section 5.
10 Related works
Vanhoucke et al. (2011) use 8 bits linear quantization to store activations and weights. Weights are scaled by taking their maximum magnitude in each layer and normalizing them to fall in the [128, 127] range. The total memory footprint of the network is reduced by between 3 and 4. This is very similar to the dynamic fixed point format we use (Section 5). However, Vanhoucke et al. (2011) only apply already trained neural networks while we actually train them.
Training neural networks with low precision arithmetic has already been done in previous works (Holt and Baker, 1991; Presley and Haggard, 1994; Simard and Graf, 1994; Wawrzynek et al., 1996; Savich et al., 2007) ^{2}^{2}2 A very recent work (Gupta et al., 2015) also trains neural networks with low precision. The authors propose to replace roundtonearest with stochastic rounding, which allows to reduce the numerical precision to 16 bits while using the fixed point format. It would be very interesting to combine dynamic fixed point and stochastic rounding. . Our work is nevertheless original in several regards:

We are the first to train deep neural networks with the dynamic fixed point format.

We use a higher precision for the weights during the updates.

We train some of the latest models on some of the latest benchmarks.
11 Conclusion and future works
We have shown that:

Very low precision multipliers are sufficient for training deep neural networks.

Dynamic fixed point seems well suited for training deep neural networks.

Using a higher precision for the parameters during the updates helps.
Our work can be exploited to:

Optimize memory usage on generalpurpose hardware (Gray et al., 2015).

Design very powerefficient hardware dedicated to deep learning.
There is plenty of room for extending our work:

Other tasks than image classification.

Other models than Maxout networks.

Other formats than floating point, fixed point and dynamic fixed point.
12 Acknowledgement
We thank the developers of Theano (Bergstra et al., 2010; Bastien et al., 2012), a Python library which allowed us to easily develop a fast and optimized code for GPU. We also thank the developers of Pylearn2 (Goodfellow et al., 2013b), a Python library built on the top of Theano which allowed us to easily interface the datasets with our Theano code. We are also grateful for funding from NSERC, the Canada Research Chairs, Compute Canada, and CIFAR.
References
 Bastien et al. (2012) Bastien, F., Lamblin, P., Pascanu, R., Bergstra, J., Goodfellow, I. J., Bergeron, A., Bouchard, N., and Bengio, Y. (2012). Theano: new features and speed improvements. Deep Learning and Unsupervised Feature Learning NIPS 2012 Workshop.
 Bergstra et al. (2010) Bergstra, J., Breuleux, O., Bastien, F., Lamblin, P., Pascanu, R., Desjardins, G., Turian, J., WardeFarley, D., and Bengio, Y. (2010). Theano: a CPU and GPU math expression compiler. In Proceedings of the Python for Scientific Computing Conference (SciPy). Oral Presentation.
 Chen et al. (2014a) Chen, T., Du, Z., Sun, N., Wang, J., Wu, C., Chen, Y., and Temam, O. (2014a). Diannao: A smallfootprint highthroughput accelerator for ubiquitous machinelearning. In Proceedings of the 19th international conference on Architectural support for programming languages and operating systems, pages 269–284. ACM.
 Chen et al. (2014b) Chen, Y., Luo, T., Liu, S., Zhang, S., He, L., Wang, J., Li, L., Chen, T., Xu, Z., Sun, N., et al. (2014b). Dadiannao: A machinelearning supercomputer. In Microarchitecture (MICRO), 2014 47th Annual IEEE/ACM International Symposium on, pages 609–622. IEEE.
 Coates et al. (2009) Coates, A., Baumstarck, P., Le, Q., and Ng, A. Y. (2009). Scalable learning for object detection with gpu hardware. In Intelligent Robots and Systems, 2009. IROS 2009. IEEE/RSJ International Conference on, pages 4287–4293. IEEE.
 David et al. (2007) David, J., Kalach, K., and Tittley, N. (2007). Hardware complexity of modular multiplication and exponentiation. Computers, IEEE Transactions on, 56(10), 1308–1319.
 Dean et al. (2012) Dean, J., Corrado, G., Monga, R., Chen, K., Devin, M., Le, Q., Mao, M., Ranzato, M., Senior, A., Tucker, P., Yang, K., and Ng, A. Y. (2012). Large scale distributed deep networks. In NIPS’2012.
 Farabet et al. (2011) Farabet, C., Martini, B., Corda, B., Akselrod, P., Culurciello, E., and LeCun, Y. (2011). Neuflow: A runtime reconfigurable dataflow processor for vision. In Computer Vision and Pattern Recognition Workshops (CVPRW), 2011 IEEE Computer Society Conference on, pages 109–116. IEEE.
 Glorot et al. (2011) Glorot, X., Bordes, A., and Bengio, Y. (2011). Deep sparse rectifier neural networks. In AISTATS’2011.
 Goodfellow et al. (2013a) Goodfellow, I. J., WardeFarley, D., Mirza, M., Courville, A., and Bengio, Y. (2013a). Maxout networks. Technical Report Arxiv report 1302.4389, Université de Montréal.
 Goodfellow et al. (2013b) Goodfellow, I. J., WardeFarley, D., Lamblin, P., Dumoulin, V., Mirza, M., Pascanu, R., Bergstra, J., Bastien, F., and Bengio, Y. (2013b). Pylearn2: a machine learning research library. arXiv preprint arXiv:1308.4214.
 Gray et al. (2015) Gray, S., Leishman, S., and Koster, U. (2015). Nervanagpu library. Accessed: 20150630.
 Gupta et al. (2015) Gupta, S., Agrawal, A., Gopalakrishnan, K., and Narayanan, P. (2015). Deep learning with limited numerical precision. CoRR, abs/1502.02551.
 Hinton et al. (2012) Hinton, G. E., Srivastava, N., Krizhevsky, A., Sutskever, I., and Salakhutdinov, R. (2012). Improving neural networks by preventing coadaptation of feature detectors. Technical report, arXiv:1207.0580.
 Holt and Baker (1991) Holt, J. L. and Baker, T. E. (1991). Back propagation simulations using limited precision calculations. In Neural Networks, 1991., IJCNN91Seattle International Joint Conference on, volume 2, pages 121–126. IEEE.
 Jarrett et al. (2009) Jarrett, K., Kavukcuoglu, K., Ranzato, M., and LeCun, Y. (2009). What is the best multistage architecture for object recognition? In Proc. International Conference on Computer Vision (ICCV’09), pages 2146–2153. IEEE.
 Kim et al. (2009) Kim, S. K., McAfee, L. C., McMahon, P. L., and Olukotun, K. (2009). A highly scalable restricted Boltzmann machine FPGA implementation. In Field Programmable Logic and Applications, 2009. FPL 2009. International Conference on, pages 367–372. IEEE.
 Krizhevsky and Hinton (2009) Krizhevsky, A. and Hinton, G. (2009). Learning multiple layers of features from tiny images. Technical report, University of Toronto.
 Krizhevsky et al. (2012a) Krizhevsky, A., Sutskever, I., and Hinton, G. (2012a). ImageNet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems 25 (NIPS’2012).
 Krizhevsky et al. (2012b) Krizhevsky, A., Sutskever, I., and Hinton, G. (2012b). ImageNet classification with deep convolutional neural networks. In NIPS’2012.
 LeCun et al. (1998) LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. (1998). Gradientbased learning applied to document recognition. Proceedings of the IEEE, 86(11), 2278–2324.
 Nair and Hinton (2010) Nair, V. and Hinton, G. (2010). Rectified linear units improve restricted Boltzmann machines. In ICML’2010.
 Netzer et al. (2011) Netzer, Y., Wang, T., Coates, A., Bissacco, A., Wu, B., and Ng, A. Y. (2011). Reading digits in natural images with unsupervised feature learning. Deep Learning and Unsupervised Feature Learning Workshop, NIPS.
 Pham et al. (2012) Pham, P.H., Jelaca, D., Farabet, C., Martini, B., LeCun, Y., and Culurciello, E. (2012). Neuflow: dataflow vision processing systemonachip. In Circuits and Systems (MWSCAS), 2012 IEEE 55th International Midwest Symposium on, pages 1044–1047. IEEE.
 Presley and Haggard (1994) Presley, R. K. and Haggard, R. L. (1994). A fixed point implementation of the backpropagation learning algorithm. In Southeastcon’94. Creative Technology TransferA Global Affair., Proceedings of the 1994 IEEE, pages 136–138. IEEE.
 Savich et al. (2007) Savich, A. W., Moussa, M., and Areibi, S. (2007). The impact of arithmetic representation on implementing mlpbp on fpgas: A study. Neural Networks, IEEE Transactions on, 18(1), 240–252.
 Simard and Graf (1994) Simard, P. and Graf, H. P. (1994). Backpropagation without multiplication. In Advances in Neural Information Processing Systems, pages 232–239.
 Srebro and Shraibman (2005) Srebro, N. and Shraibman, A. (2005). Rank, tracenorm and maxnorm. In Proceedings of the 18th Annual Conference on Learning Theory, pages 545–560. SpringerVerlag.
 Vanhoucke et al. (2011) Vanhoucke, V., Senior, A., and Mao, M. Z. (2011). Improving the speed of neural networks on cpus. In Proc. Deep Learning and Unsupervised Feature Learning NIPS Workshop.
 Wawrzynek et al. (1996) Wawrzynek, J., Asanovic, K., Kingsbury, B., Johnson, D., Beck, J., and Morgan, N. (1996). Spertii: A vector microprocessor system. Computer, 29(3), 79–86.
 Williamson (1991) Williamson, D. (1991//). Dynamically scaled fixed point arithmetic. pages 315 – 18, New York, NY, USA. dynamic scaling;iteration stages;digital filters;overflow probability;fixed point arithmetic;fixedpoint filter;.
 Zeiler and Fergus (2013) Zeiler, M. D. and Fergus, R. (2013). Stochastic pooling for regularization of deep convolutional neural networks. In International Conference on Learning Representations.