NICE: Noise Injection and Clamping Estimation for Neural Network Quantization
Convolutional Neural Networks (CNN) are very popular in many fields including computer vision, speech recognition, natural language processing, to name a few. Though deep learning leads to groundbreaking performance in these domains, the networks used are very demanding computationally and are far from real-time even on a GPU, which is not power efficient and therefore does not suit low power systems such as mobile devices. To overcome this challenge, some solutions have been proposed for quantizing the weights and activations of these networks, which accelerate the runtime significantly. Yet, this acceleration comes at the cost of a larger error. The NICE method proposed in this work trains quantized neural networks by noise injection and a learned clamping, which improve the accuracy. This leads to state-of-the-art results on various regression and classification tasks, e.g., ImageNet classification with architectures such as ResNet-18/34/50 with low as 3-bit weights and activations. We implement the proposed solution on an FPGA to demonstrate its applicability for low power real-time applications. The implementation of the paper is available at https://github.com/Lancer555/NICE.
Deep neural networks have established themselves as an important tool in the machine learning arsenal. They have shown spectacular success in a variety of tasks in a broad range of fields such computer vision, computational and medical imaging, signal, image, speech and language processing (Hinton et al., 2012; Lai et al., 2015; Chen et al., 2018).
However, while deep learning models’ performance is impressive, the computational and storage requirements of both training and inference are harsh. For example, ResNet-50 (He et al., 2016), a popular choice for image detection, has 98 MB parameters and requires 4 GFLOPs of computations for a single inference. In many cases, the devices do not have such a big amount of resources, which makes deep learning infeasible in smart phones and the Internet of Things (IoT).
In attempt to solve these problems, many researchers have recently came up with less demanding models, often at the expense of more complicated training procedure. Since the training is usually performed on servers with much larger resources, this is usually an acceptable trade-off.
One prominent approach is to quantize the networks. The default choice for the data type of the neural networks’ weights and feature maps (activations) is 32-bit (single precision) floating point. Gupta et al. (2015) have shown that quantizing the pre-trained weights to -bit fixed point have almost no effect on the accuracy of the networks. Moreover, minor modifications allow performing an integer-only 8-bit inference with reasonable performance degradation (Jacob et al., 2018), which is utilized in DL frameworks, such as TensorFlow. One of the current challenges in network quantization is reducing the precision even further, up to 1-5 bits per value. In this case, straightforward techniques result in unacceptable quality degradation.
Contribution. This paper introduces a novel simple approach denoted NICE (noise injection and clamping estimation) for neural network quantization that relies on the following two easy to implement components: (i) Noise injection during training that emulates the quantization noise introduced at inference time; and (ii) Statistics-based initialization of parameter and activation clamping, for faster model convergence. In addition, activation clamp is learned during train time. We also propose integer-only scheme for an FPGA on regression task (Schwartz et al., 2018).
Our proposed strategy for network training lead to an improvement over the state-of-the-art quantization techniques in the performance vs. complexity tradeoff. Unlike several leading methods, our approach can be applied directly to existing architectures without the need to modify them at training (as opposed, for example, to the teacher-student approaches (Polino et al., 2018) that require to train a bigger network, or the XNOR networks (Rastegari et al., 2016) that typically increase the number of parameters by a significant factor in order to meet accuracy goals).
Moreover, our new technique allows quantizing all the parameters in the network to fixed point (integer) values. This include the batch-norm component that is usually not quantized in other works. Thus, our proposed solution makes the integration of neural networks in dedicated hardware devices such as FPGA and ASIC easier. As a proof-of-concept, we present also a case study of such an implementation on hardware.
2 Related work
Expressiveness based methods. The quantization of neural network to extremely low-precision representations (up to 2 or 3 possible values) was actively studied in recent years (Rastegari et al., 2016; Hubara et al., 2018; Mishra et al., 2018; Zhang et al., 2018). To overcome the accuracy reduction, some works proposed to use a wider network (Zhu et al., 2016; Polino et al., 2018; Banner et al., 2018), which compensates the expressiveness reduction of the quantized networks network. For example, 32-bit feature maps were regarded as 32 binary ones. Another way to improve expressiveness, adopted by Zhu et al. (2016) and Zhou et al. (2017) is to add a linear scaling layer after each of the quantized layers.
Keeping full-precision copy of quantized weights. Lately, the most common approach to training a quantized neural network (Hubara et al., 2016, 2018; Zhou et al., 2016; Rastegari et al., 2016; Cai et al., 2017) is keep two sets of weights — forward pass is performed with quantized weights, and updates are performed on full precision ones, i.e., approximating gradients with straight-through estimator (STE) (Bengio et al., 2013). For quantizing the parameters, either stochastic or deterministic function can be used.
Distillation. One of the leading approaches used today for quantization relies on the idea of distillation (Hinton et al., 2015). In distillation a teacher-student setup is used, where the teacher is either the same or a larger full precision neural network and the student is the quantized one. The student network is trained to imitate the output of the teacher network. This strategy is successfully used to boost the performance of existing quantization methods (Mishra & Marr, 2018; Polino et al., 2018; Jung et al., 2018).
Model parametrization. Zhang et al. (2018) proposed to represent the parameters with learned basis vectors that allow acquiring an optimized non-uniform representation. In this case MAC operations can be computed with bitwise operations. Choi et al. (2018) proposed to learn the clamping value of the activations to find the balance between clamping and quantization errors. In this work we also learn this value but with the difference that we are learning the clamps value directly using STE back-propagation method without any regulations on the loss. Jung et al. (2018) created a more complex parametrization of both weights and activations, and approximated them with symmetric piecewise linear function, learning both the domains and the parameters directly from the loss function of the network.
Optimization techniques. Zhou et al. (2017) and Dong et al. (2017) used the idea of not quantizing all the weights simultaneously but rather gradually increasing the number of quantized weights to improve the convergence. McKinstry et al. (2018) demonstrated that 4-bit fully integer neural networks can achieve full-precision performance by applying simple techniques to combat varience of gradients: larger batches and proper learning rate annealing with longer training time. However, 8-bit and 32-bit integer representations were used for the multiplicative (i.e., batch normalization) and additive constants (biases), respectively.
Generalization bounds. Interestingly, quantization of neural networks have been used recently as a theoretical tool to understand better the generalization of neural networks. It has been shown that while the generalization error does not scale with the number of parameters in over-parameterized networks, it does so when these networks are being quantized (Arora et al., 2018).
In this work we propose a training scheme for quantized neural networks designed for fast inference on hardware with integer-only arithmetic. To achieve maximum performance, we apply a combination of several well-known as well as novel techniques. Firstly, in order to emulate the effect of quantization, we inject additive random noise into the network weights. Uniform noise distribution is known to approximate well the quantization error for fine quantizers; however, our experiments detailed in the sequel show that it is also suitable for relatively coarse quantization (Appendix A). Furthermore, some amount of random weight perturbation seems to have a regularization effect beneficial for the overall convergence of the training algorithm. Secondly, we use a gradual training scheme to minimize the perturbation of network parameters performed simultaneously. In order to give the quantized layers as much gradient updates as possible, we used the STE approach to pass the gradients to the quantized layers. After the gradual phase, the whole network is quantized and trained for a number of fine-tuning epochs. Thirdly, we propose to clamp both the activations and the weights in order to reduce the quantization bin size (and, thus, the quantization error) at the expense of some sacrifice of the dynamic range. The clamping values are initialized using the statistics of each layer. In order to truly optimize the tradeoff between the reduction of the quantization error vs that of the dynamic range, we learn optimal clamping values by defining a loss on the quantization error.
Lastly, following common approach proposed by Zhou et al. (2016), we don’t quantize first and last layers of the networks, which have significantly higher impact on network performance. The remainder of the section details these main ingredients of our method.
We propose to inject uniform additive noise to weights and biases during model training to emulate the effect of quantization incurred at inference. Prior works have investigated the behavior of quantization error (Sripad & Snyder, 1977; Gray, 1990) and concluded that in sufficiently fine-grain quantizers it can be approximated as a uniform random variale. We have observed the same phenomena and empirically verified it for weight quantization as coarse as bits.
The advantage of the proposed method is that the updates performed during the backward pass immediately influence the forward pass, in contrast to strategies that directly quantize the weights, where small updates often leave them in the same bin, thus, effectively unchanged.
In order to achieve a dropout-like effect in the noise injection, we use a Bernoulli distributed mask , quantizing part of the weights and adding noise to the others. From empirical evidence, we chose as it gave the best results for the range of bitwidths in our experiments. Instead of using the quantized value of a weight in the forward pass, is used with , where denotes size of the quantization bin.
3.1 Gradual quantization
In order to improve the scalability of the method for deeper networks, it is desirale to avoid the significant change of the network behavior due to quantization. Thus, we start from gradually adding a subset of weights to the set of quantized parameters, allowing the rest of the network to adapt to the changes.
The gradual quantization is performed in the following way: the network is split into equally-sized blocks of layers . At the -th stage, we inject the noise into the weights of the layers from the block . The previous blocks are quantized, while the following blocks remain at full precision. We apply the gradual process only once, i.e., when the -th stage finishes, in the remaining training epochs we quantize and train all the layers using the STE approach.
This gradual increasing of the number of quantized layers is similar to the one proposed by Xu et al. (2018). This gradual process reduces, via the number of parameters, the amount of simultaneously injected noise and improves convergence. Since we start from the earlier blocks, the later ones have an opportunity adapt to the quantization error affecting their inputs and thus the network does not change drastically during any phase of quantization. After finishing the training with the noise injection into the block of layers , we continue the training of the fully quantized network for several epochs until convergence. In the case of a pre-trained network destined for quantization, we have found that the optimal block size is a single layer with the corresponding activation, while using more than one epoch of training with the noise injection per block does not improve performance.
3.2 Clamping and quantization
In order to quantize the network weights, we clamp their values in the range :
The parameter is defined per layer and is initialized with , where are the weighs of the layer and is a hyper-parameter. Given , we uniformly quantize the clamped weight into bits according to
where denotes the rounding operation.
The quantization of the network activations is performed in a similar manner. The conventional ReLU activation function in CNNs is replaced by the clamped ReLU,
where denotes the output of the linear part of the layer, is nonnegative value of the clamped activation prior to quantization, and is the clamping range. The constant is set as a local parameter of each layer and is learned with the other parameters of the network via backpropagation. We used the initialization with the statistics computed on the training dataset and set as a hyper-parameter.
A quantized version of the truncated activation is obtained by quantizing uniformly to bits,
Since the function is non-differentiable, we use the STE approach to propagate the gradients through it to the next layer. For the update of , we calculate the derivative of with respect to as
Additional analysis of the clamping parameter convergence is presented in Appendix B.
The quantization of the layer biases is more complex, since their scale depends on the scales of both the activations and the weights. For each layer, we initialize the bias clamping value as
where denotes the bias bitwidth. The biases are clamped and quantized in the same manner as the weights.
4 Experimental results
To demonstrate the effectiveness of our method, we implemented it in PyTorch and evaluated on image classification datasets (ImageNet and CIFAR-10) and a regression scenario (the MSR joint denoising and demosaicing dataset (Khashabi et al., 2014)). The CIFAR-10 results are presented in Appendix C. In all the experiments, we use a pre-trained FP32 model, which is then quantized using NICE .
For quantizing the ResNet-18/34/50 networks for ImageNet, we fine-tune a given pre-trained network using NICE . We train a network for a total of 120 epochs, following the gradual process described in Section 3.1 with the number of stages set to the number of trainable layers. We use an SGD optimizer with learning rate is , momentum and weight decay .
Table 2 compares NICE with other leading approaches to low-precision quantization (Jung et al., 2018; Choi et al., 2018; Zhang et al., 2018; McKinstry et al., 2018). Various quantization levels of the weights and activations are presented. As a baseline, we use a pre-trained full-precision model.
Our approach achieves state-of-the-art results for 4 and 5 bits quantization and comparable results for 3 bits quantization, on the different network architectures. Moreover, notice that our results for the 5,5 setup, on all the tested architectures, have slightly outperformed the FAQ 8,8 results.
4.2 Regression - joint denoising and demosaicing
|WRPN (our experiments)||39.696||38.086||37.496||36.258||36.002|
In addition to the classification tasks, we apply NICE on a regression task, namely joint image denoising and demosaicing. The network we use is the one proposed in (Schwartz et al., 2018). We slightly modify it by adding to it Dropout with , removing the activations and adding skip connections between the input and the output images. These skip connections improve the quantization results as in this case the network only needs to learn the necessary modifications to the input image. Figure 1 shows the whole network, where the modifications are marked in red. The three channels of the input image are quantized to 16 bit, while the output of each convolution, when followed by an activation, are quantized to 8 bits (marked in Fig. 1). The first and last layers are also quantized.
We apply NICE on a full precision pre-trained network for 500 epochs with Adam optimizer with learning rate of . The data is augmented with random horizontal and vertical flipping. Since we are not aware of any other work of quantization for this task, we implemented WRPN (Mishra et al., 2018) as a baseline for comparison. Table 1 reports the test set PSNR for the MSR dataset (Khashabi et al., 2014). It can be clearly seen that NICE achieves significantly better results than WRPN, especially for low weight bitwidths.
|Network||Method||Precision (w,a)||Accuracy (% top-1)||Accuracy (% top-5)|
4.3 Ablation study
In order to show the importance of each part of our NICE method, we use ResNet-18 on ImageNet. Table 3 reports the accuracy for various combinations of the NICE components. Notice that for high bitwidths, i.e., 5,5 the noise addition and gradual training contribute to the accuracy more than the clamp learning. This happens since (i) the noise distribution is indeed uniform in this case as we show in Appendix A; and (ii) the relatively high number of activation quantization levels almost negates the effect of clamping. For low bitwidths, i.e 3,3, we observe the opposite. The uniform noise assumption is no longer accurate. Moreover, due to the small number of bits, clamping the range of values becomes more significant.
|Activation clamping learning||Accuracy on 5,5 [W,A]||Accuracy on 3,3 [W,A]|
5 Hardware Implementation
5.1 optimizing quantization flow for hardware inference
Our quantization scheme can fits an FPGA implementation well for several reasons. Firstly, uniform quantization of both the weights and activation induces uniform steps between each quantized bin. This means that we can avoid the use of a resource costly code-book (look-up table) with the size , for each layer. This also saves calculation time.
Secondly, our method enables having an integer-only arithmetic. In order to achieve that, we start, following (5), by representing each activation and network parameter in the form of , where N is the integer code and S is a pre-calculated scale. We then reformulate the scaling factors into the form , where . Practically, we found that it is sufficient to constrain these values to and without an accuracy drop .This representation allows the replacement of hardware costly floating point operations by a combination of cheap shift operations and integer arithmetics.
5.2 Hardware Flow
In the hardware implementation, for both the regression and the classification tasks, we adopt the PipeCNN (Wang et al., 2016a) implementation released by the authors.111https://github.com/doonny/PipeCNN In this implementation, the FPGA is programmed with an image containing data moving, convolution and a pooling kernels. Layers are calculated sequentially. Figure 2 illustrates the flow of feature maps in the residual block from a previous layer to the next one. are the activations and weights scale factors of layer , respectively. All these factors are calculated off-line and are loaded to the memory along with the rest of the parameters. Note that we use the FPGA for inference only.
We have compiled the OpenCL kernel to Intel’s Arria 10 FPGA and run it with the regression architecture in Fig 1. Weights are quantized to 4 bits, activations to 8 bits, and biases and the input image to 16 bits. The resource utilization is amounted to 222K LUTs, 650 DSP Blocks and 35.3 Mb of on-chip RAM. With the maximum clock frequency of 240MHz, the processing of a single image takes 250ms. In terms of power, the FPGA requires while an NVIDIA Titan X GPU requires . From standard hardware design practices, we can project that a dedicated ASIC manufactured using a similar process would be much more efficient by at least one order of magnitude.
We introduced NICE – a training scheme for quantized neural networks. The scheme is based on using uniform quantized parameters, additive uniform noise injection and learning the quantization clamping range. The scheme is amenable to efficient training by back propagation in full precision arithmetic. One advantage of NICE is the ease of its implementation on existing networks. In particular, it does not requires changes in the architecture of the network, such as increasing the number of filters as required by some previous works. Moreover, NICE can be used for various types of tasks such as classification and regression.
We report state-of-the-art results on ImageNet for a range of bitwidths and network architectures. Our solution outperforms current works on both the 4,4 and 5,5 setups, for all tested architectures, including non-uniform solutions such as (Zhang et al., 2018). It shows comparable results in the 3,3 setup.
We have shown that quantization error for 4 and 5 bits distributes uniformly, which explains the larger success of our method in these bitwidths compared to the case of 3 bits. This implies that the results for less than 4 bits may be further improved by adding non-uniform noise to the parameters. However, the 4 bit quantization is of special interest since, being a power of 2, it is considered more hardware friendly, and INT4 matrix multiplications are supported by Tensor Cores in recently announced inference-oriented Nvidia’s Tesla GPUs.
The research was funded by ERC StG RAPID and ERC StG SPADE.
- Arora et al. (2018) Sanjeev Arora, Rong Ge, Behnam Neyshabur, and Yi Zhang. Stronger generalization bounds for deep nets via a compression approach. In international conference on machine learning (ICML), 2018.
- Aydonat et al. (2017) Utku Aydonat, Shane O’Connell, Davor Capalija, Andrew C. Ling, and Gordon R. Chiu. An opencl™deep learning accelerator on arria 10. In Proceedings of the 2017 ACM/SIGDA International Symposium on Field-Programmable Gate Arrays, FPGA ’17, pp. 55–64, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-4354-1. doi: 10.1145/3020078.3021738. URL http://doi.acm.org/10.1145/3020078.3021738.
- Banner et al. (2018) Ron Banner, Itay Hubara, Elad Hoffer, and Daniel Soudry. Scalable methods for 8-bit training of neural networks. CoRR, abs/1805.11046, 2018. URL http://arxiv.org/abs/1805.11046.
- Bengio et al. (2013) Yoshua Bengio, Nicholas Léonard, and Aaron C. Courville. Estimating or propagating gradients through stochastic neurons for conditional computation. CoRR, abs/1308.3432, 2013. URL http://arxiv.org/abs/1308.3432.
- Cai et al. (2017) Zhaowei Cai, Xiaodong He, Jian Sun, and Nuno Vasconcelos. Deep learning with low precision by half-wave gaussian quantization. In IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2017.
- Chen et al. (2018) Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L. Yuille. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. IEEE Transactions on Pattern Analysis and Machine Intelligence, 40(4):834–848, April 2018. ISSN 0162-8828. doi: 10.1109/TPAMI.2017.2699184.
- Chen et al. (2016) Yu-Hsin Chen, Joel Emer, and Vivienne Sze. Eyeriss: A spatial architecture for energy-efficient dataflow for convolutional neural networks. In 2016 ACM/IEEE 43rd Annual International Symposium on Computer Architecture (ISCA), volume 44, pp. 367–379, June 2016. doi: 10.1109/ISCA.2016.40.
- Choi et al. (2018) Jungwook Choi, Zhuo Wang, Swagath Venkataramani, Pierce I-Jen Chuang, Vijayalakshmi Srinivasan, and Kailash Gopalakrishnan. PACT: parameterized clipping activation for quantized neural networks. CoRR, abs/1805.06085, 2018. URL http://arxiv.org/abs/1805.06085.
- Dong et al. (2017) Yinpeng Dong, Renkun Ni, Jianguo Li, Yurong Chen, Jun Zhu, and Hang Su. Learning accurate low-bit deep neural networks with stochastic quantization. In British Machine Vision Conference (BMVC’17), 2017.
- Ghaffari & Sharifian (2016) Sina Ghaffari and Saeed Sharifian. Fpga-based convolutional neural network accelerator design using high level synthesize. In 2016 2nd International Conference of Signal Processing and Intelligent Systems (ICSPIS), pp. 1–6, Dec 2016. doi: 10.1109/ICSPIS.2016.7869873.
- Gray (1990) Robert M Gray. Quantization noise spectra. IEEE Transactions on information theory, 36(6):1220–1244, 1990.
- Gupta et al. (2015) Suyog Gupta, Ankur Agrawal, Kailash Gopalakrishnan, and Pritish Narayanan. Deep learning with limited numerical precision. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1737–1746, 2015.
- He et al. (2016) Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016.
- Hinton et al. (2012) Geoffrey Hinton, Li Deng, Dong Yu, George E Dahl, Abdel-rahman Mohamed, Navdeep Jaitly, Andrew Senior, Vincent Vanhoucke, Patrick Nguyen, Tara N Sainath, and Brian Kingsbury. Deep neural networks for acoustic modeling in speech recognition: The shared views of four research groups. IEEE Signal Processing Magazine, 29(6):82–97, Nov 2012. ISSN 1053-5888. doi: 10.1109/MSP.2012.2205597.
- Hinton et al. (2015) Geoffrey Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. 2015. URL http://arxiv.org/abs/1503.02531.
- Hubara et al. (2016) Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Binarized neural networks. In Advances in neural information processing systems, pp. 4107–4115, 2016.
- Hubara et al. (2018) Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Quantized neural networks: Training neural networks with low precision weights and activations. Journal of Machine Learning Research, 18(187):1–30, 2018. URL http://jmlr.org/papers/v18/16-456.html.
- Jacob et al. (2018) Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
- Jouppi et al. (2017) Norman P. Jouppi, Cliff Young, Nishant Patil, David A. Patterson, Gaurav Agrawal, Raminder Bajwa, Sarah Bates, Suresh Bhatia, Nan Boden, Al Borchers, Rick Boyle, Pierre-luc Cantin, Clifford Chao, Chris Clark, Jeremy Coriell, Mike Daley, Matt Dau, Jeffrey Dean, Ben Gelb, Tara Vazir Ghaemmaghami, Rajendra Gottipati, William Gulland, Robert Hagmann, Richard C. Ho, Doug Hogberg, John Hu, Robert Hundt, Dan Hurt, Julian Ibarz, Aaron Jaffey, Alek Jaworski, Alexander Kaplan, Harshit Khaitan, Andy Koch, Naveen Kumar, Steve Lacy, James Laudon, James Law, Diemthu Le, Chris Leary, Zhuyuan Liu, Kyle Lucke, Alan Lundin, Gordon MacKean, Adriana Maggiore, Maire Mahony, Kieran Miller, Rahul Nagarajan, Ravi Narayanaswami, Ray Ni, Kathy Nix, Thomas Norrie, Mark Omernick, Narayana Penukonda, Andy Phelps, Jonathan Ross, Amir Salek, Emad Samadiani, Chris Severn, Gregory Sizikov, Matthew Snelham, Jed Souter, Dan Steinberg, Andy Swing, Mercedes Tan, Gregory Thorson, Bo Tian, Horia Toma, Erick Tuttle, Vijay Vasudevan, Richard Walter, Walter Wang, Eric Wilcox, and Doe Hyun Yoon. In-datacenter performance analysis of a tensor processing unit. In 2017 ACM/IEEE 44th Annual International Symposium on Computer Architecture (ISCA), pp. 1–12, June 2017. doi: 10.1145/3079856.3080246.
- Jung et al. (2018) Sangil Jung, Changyong Son, Seohyung Lee, Jinwoo Son, Youngjun Kwak, Jae-Joon Han, and Changkyu Choi. Joint Training of Low-Precision Neural Network with Quantization Interval Parameters. ArXiv e-prints, August 2018.
- Khashabi et al. (2014) Daniel Khashabi, Sebastian Nowozin, Jeremy Jancsary, and Andrew W. Fitzgibbon. Joint demosaicing and denoising via learned nonparametric random fields. IEEE Transactions on Image Processing, 23(12):4968–4981, 2014. URL http://dx.doi.org/10.1109/TIP.2014.2359774.
- Lai et al. (2015) Siwei Lai, Liheng Xu, Kang Liu, and Jun Zhao. Recurrent convolutional neural networks for text classification. In Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, AAAI’15, pp. 2267–2273. AAAI Press, 2015. ISBN 0-262-51129-0. URL http://dl.acm.org/citation.cfm?id=2886521.2886636.
- McKinstry et al. (2018) Jeffrey L. McKinstry, Steven K. Esser, Rathinakumar Appuswamy, Deepika Bablani, John V. Arthur, Izzet B. Yildiz, and Dharmendra S. Modha. Discovering Low-Precision Networks Close to Full-Precision Networks for Efficient Embedded Inference. ArXiv e-prints, September 2018.
- Mishra & Marr (2018) Asit Mishra and Debbie Marr. Apprentice: Using knowledge distillation techniques to improve low-precision network accuracy. International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=B1ae1lZRb.
- Mishra et al. (2018) Asit Mishra, Eriko Nurvitadhi, Jeffrey J Cook, and Debbie Marr. Wrpn: Wide reduced-precision networks. International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=B1ZvaaeAZ.
- Polino et al. (2018) Antonio Polino, Razvan Pascanu, and Dan Alistarh. Model compression via distillation and quantization. International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=S1XolQbRW.
- Rastegari et al. (2016) Mohammad Rastegari, Vicente Ordonez, Joseph Redmon, and Ali Farhadi. Xnor-net: Imagenet classification using binary convolutional neural networks. In European Conference on Computer Vision, pp. 525–542. Springer, 2016.
- Schwartz et al. (2018) Eli Schwartz, Raja Giryes, and Alex M Bronstein. Deepisp: Learning end-to-end image processing pipeline. arXiv preprint arXiv:1801.06724, 2018.
- Sripad & Snyder (1977) Anekal Sripad and Donald Snyder. A necessary and sufficient condition for quantization errors to be uniform and white. IEEE Transactions on Acoustics, Speech, and Signal Processing, 25(5):442–448, 1977.
- Umuroglu et al. (2017) Yaman Umuroglu, Nicholas J. Fraser, Giulio Gambardella, Michaela Blott, Philip Leong, Magnus Jahre, and Kees Vissers. Finn: A framework for fast, scalable binarized neural network inference. In Proceedings of the 2017 ACM/SIGDA International Symposium on Field-Programmable Gate Arrays, FPGA ’17, pp. 65–74, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-4354-1. doi: 10.1145/3020078.3021744. URL http://doi.acm.org/10.1145/3020078.3021744.
- Wang et al. (2016a) Dong Wang, Jianjing An, and Ke Xu. Pipecnn: An opencl-based FPGA accelerator for large-scale convolution neuron networks. CoRR, abs/1611.02450, 2016a. URL http://arxiv.org/abs/1611.02450.
- Wang et al. (2016b) Zhengrong Wang, Fei Qiao, Zhen Liu, Yuxiang Shan, Xunyi Zhou, Li Luo, and Huazhong Yang. Optimizing convolutional neural network on fpga under heterogeneous computing framework with opencl. In 2016 IEEE Region 10 Conference (TENCON), pp. 3433–3438, Nov 2016b. doi: 10.1109/TENCON.2016.7848692.
- Xu et al. (2018) Yuhui Xu, Yongzhuang Wang, Aojun Zhou, Weiyao Lin, and Hongkai Xiong. Deep neural network compression with single and multiple level quantization, 2018. URL https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/view/16479.
- Zhang et al. (2018) Dongqing Zhang, Jiaolong Yang, Dongqiangzi Ye, and Gang Hua. Lq-nets: Learned quantization for highly accurate and compact deep neural networks. In European Conference on Computer Vision (ECCV), 2018.
- Zhao et al. (2017) Ritchie Zhao, Weinan Song, Wentao Zhang, Tianwei Xing, Jeng-Hau Lin, Mani Srivastava, Rajesh Gupta, and Zhiru Zhang. Accelerating binarized convolutional neural networks with software-programmable fpgas. In Proceedings of the 2017 ACM/SIGDA International Symposium on Field-Programmable Gate Arrays, FPGA ’17, pp. 15–24, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-4354-1. doi: 10.1145/3020078.3021741. URL http://doi.acm.org/10.1145/3020078.3021741.
- Zhou et al. (2017) Aojun Zhou, Anbang Yao, Yiwen Guo, Lin Xu, and Yurong Chen. Incremental network quantization: Towards lossless cnns with low-precision weights. In International Conference on Learning Representations,ICLR2017, 2017.
- Zhou et al. (2016) Shuchang Zhou, Yuxin Wu, Zekun Ni, Xinyu Zhou, He Wen, and Yuheng Zou. Dorefa-net: Training low bitwidth convolutional neural networks with low bitwidth gradients. arXiv preprint arXiv:1606.06160, 2016.
- Zhu et al. (2016) Chenzhuo Zhu, Song Han, Huizi Mao, and William J Dally. Trained ternary quantization. International Conference on Learning Representations (ICLR), 2016.
Appendix A Quantization error distribution
The general statement is that for large number of bins, the distribution of quantization error is independent on the quantized value, and thus distributed uniformly. However, this is true only in limit of high number of bins, which is not exactly the case of neural network quantization. However, empirically the distribution of noise is almost uniform for 4 and 5 bits and only starts to deviate deviating from the uniform model (Figure A.1) for 3 bits, which corresponds to only 8 bins.
Appendix B Clamping parameter convergence
Figure B.1 depicts the evolution of the activation clamp values throughout the epochs. In this experiment was set to 5. It can be seen that activation clamp values converge to values smaller than the initialization. This shows that the layer prefers to shrink the dynamic range of the activations, which can be interpreted as a form of regularization similar in its purpose to weight decay on weights.
Appendix C Experiments on CIFAR-10
As an additional experiment, we test NICE with ResNet-18 on CIFAR-10 for various quantization levels of the weights and activations. Table C.1 reports the results. Notice that for the case of 3-bit weights activations we get the same accuracy and for the 2-bit case only a small degradation. Moreover, observe that when we quantize only the weights or activations, we get a nice regularization effect that improves the achieved accuracy.
Appendix D Background for Neural Networks on custom hardware
When implementing systems involving arbitrary precision, FPGAs and ASICs are a natural selection as target device due to their customizable nature. It was already shown that there is a lot of redundancy when using floating point representation in Neural Network(NN). Therefore, custom low-precision representation can be used with little impact to the accuracy. Due to the steadily increasing on-chip memory size (tens of megabytes) and the integration of high bandwidth memory (hundreds of megabytes), it is feasible to fit all the parameters inside an ASIC or FPGA, when using low bitwidth. Besides the obvious advantage of reducing the latency, this approach has several advantages: power consumption reduction and smaller resource utilization, which in addition to DSP blocks and LUTs, also includes routing resource. The motivation of quantizing the activations is similar to that of the parameters. Although activations are not stored during inference, their quantization can lead to major saving in routing resources which in turn can increase the maximal operational frequency of the fabric, resulting in increased throughput. In recent years, FPGAs has become more popular as an inference accelerator. And while ASICs (Chen et al., 2016; Jouppi et al., 2017) usually offers more throughput with lower energy consumption, they don’t enjoy the advantage of reconfigurability as FPGAs. This is important since neural network algorithm evolve with time, so should their hardware implementation. Since the implementation of neural network involves complex scheduling and data movement, FPGA-based inference accelerators has been described as heterogeneous system using OpenCL (Wang et al., 2016a, b; Aydonat et al., 2017) or as standalone accelerator using HLS compilers (Ghaffari & Sharifian, 2016; Umuroglu et al., 2017; Zhao et al., 2017)