DeepCompressioncaffe
Caffe for Deep Compression
view repo
Neural networks are both computationally intensive and memory intensive, making them difficult to deploy on embedded systems with limited hardware resources. To address this limitation, we introduce "deep compression", a three stage pipeline: pruning, trained quantization and Huffman coding, that work together to reduce the storage requirement of neural networks by 35x to 49x without affecting their accuracy. Our method first prunes the network by learning only the important connections. Next, we quantize the weights to enforce weight sharing, finally, we apply Huffman coding. After the first two steps we retrain the network to fine tune the remaining connections and the quantized centroids. Pruning, reduces the number of connections by 9x to 13x; Quantization then reduces the number of bits that represent each connection from 32 to 5. On the ImageNet dataset, our method reduced the storage required by AlexNet by 35x, from 240MB to 6.9MB, without loss of accuracy. Our method reduced the size of VGG16 by 49x from 552MB to 11.3MB, again with no loss of accuracy. This allows fitting the model into onchip SRAM cache rather than offchip DRAM memory. Our compression method also facilitates the use of complex neural networks in mobile applications where application size and download bandwidth are constrained. Benchmarked on CPU, GPU and mobile GPU, compressed network has 3x to 4x layerwise speedup and 3x to 7x better energy efficiency.
READ FULL TEXT VIEW PDF
Neural networks are both computationally intensive and memory intensive,...
read it
Stateoftheart deep neural networks (DNNs) have hundreds of millions o...
read it
Model compression has gained a lot of attention due to its ability to re...
read it
Deep neural networks generally involve some layers with mil lions of
pa...
read it
Spiking Neural Networks (SNNs) with a large number of weights and varied...
read it
We introduce a technique that compresses deep neural networks both durin...
read it
Besides accuracy, the storage of convolutional neural networks (CNN) mod...
read it
Caffe for Deep Compression
This is my final year project of Bachelor of Engineering. Its still incomplete though. I am trying to replicate the research paper "Deep Compression" by Song Han et. al. This paper received best paper award in ICLR 2016
Incremental Network Quantization, Kmeans quantization, Iterative Pruning, Dynamic Network Surgery
Model Compression Based on Geoffery Hinton's Logit Regression Method in Keras applied to MNIST 16x compression over 0.95 percent accuracy
PyTorch Implementation of Deep Compression
Deep neural networks have evolved to the stateoftheart technique for computer vision tasks
(Krizhevsky et al., 2012)(Simonyan & Zisserman, 2014). Though these neural networks are very powerful, the large number of weights consumes considerable storage and memory bandwidth. For example, the AlexNet Caffemodel is over 200MB, and the VGG16 Caffemodel is over 500MB (BVLC, ). This makes it difficult to deploy deep neural networks on mobile system.First, for many mobilefirst companies such as Baidu and Facebook, various apps are updated via different app stores, and they are very sensitive to the size of the binary files. For example, App Store has the restriction “apps above 100 MB will not download until you connect to WiFi”. As a result, a feature that increases the binary size by 100MB will receive much more scrutiny than one that increases it by 10MB. Although having deep neural networks running on mobile has many great features such as better privacy, less network bandwidth and real time processing, the large storage overhead prevents deep neural networks from being incorporated into mobile apps.
The second issue is energy consumption. Running large neural networks require a lot of memory bandwidth to fetch the weights and a lot of computation to do dot products— which in turn consumes considerable energy. Mobile devices are battery constrained, making power hungry applications such as deep neural networks hard to deploy.
Energy consumption is dominated by memory access. Under 45nm CMOS technology, a 32 bit floating point add consumes , a 32bit SRAM cache access takes , while a 32bit DRAM memory access takes , which is 3 orders of magnitude of an add operation. Large networks do not fit in onchip storage and hence require the more costly DRAM accesses. Running a 1 billion connection neural network, for example, at 20fps would require just for DRAM access  well beyond the power envelope of a typical mobile device.
Our goal is to reduce the storage and energy required to run inference on such large networks so they can be deployed on mobile devices. To achieve this goal, we present “deep compression”: a threestage pipeline (Figure 1) to reduce the storage required by neural network in a manner that preserves the original accuracy. First, we prune the networking by removing the redundant connections, keeping only the most informative connections. Next, the weights are quantized so that multiple connections share the same weight, thus only the codebook (effective weights) and the indices need to be stored. Finally, we apply Huffman coding to take advantage of the biased distribution of effective weights.
Our main insight is that, pruning and trained quantization are able to compress the network without interfering each other, thus lead to surprisingly high compression rate. It makes the required storage so small (a few megabytes) that all weights can be cached on chip instead of going to offchip DRAM which is energy consuming. Based on “deep compression”, the EIE hardware accelerator Han et al. (2016) was later proposed that works on the compressed model, achieving significant speedup and energy efficiency improvement.
Network pruning has been widely studied to compress CNN models. In early work, network pruning proved to be a valid way to reduce the network complexity and overfitting (LeCun et al., 1989; Hanson & Pratt, 1989; Hassibi et al., 1993; Ström, 1997). Recently Han et al. (2015) pruned stateoftheart CNN models with no loss of accuracy. We build on top of that approach. As shown on the left side of Figure 1, we start by learning the connectivity via normal network training. Next, we prune the smallweight connections: all connections with weights below a threshold are removed from the network. Finally, we retrain the network to learn the final weights for the remaining sparse connections. Pruning reduced the number of parameters by and for AlexNet and VGG16 model.
We store the sparse structure that results from pruning using compressed sparse row (CSR) or compressed sparse column (CSC) format, which requires numbers, where is the number of nonzero elements and is the number of rows or columns.
To compress further, we store the index difference instead of the absolute position, and encode this difference in 8 bits for conv layer and 5 bits for fc layer. When we need an index difference larger than the bound, we the zero padding solution shown in Figure
2: in case when the difference exceeds 8, the largest 3bit (as an example) unsigned number, we add a filler zero.Network quantization and weight sharing further compresses the pruned network by reducing the number of bits required to represent each weight. We limit the number of effective weights we need to store by having multiple connections share the same weight, and then finetune those shared weights.
Weight sharing is illustrated in Figure 3
. Suppose we have a layer that has 4 input neurons and 4 output neurons, the weight is a
matrix. On the top left is the weight matrix, and on the bottom left is the gradient matrix. The weights are quantized to 4 bins (denoted with 4 colors), all the weights in the same bin share the same value, thus for each weight, we then need to store only a small index into a table of shared weights. During update, all the gradients are grouped by the color and summed together, multiplied by the learning rate and subtracted from the shared centroids from last iteration. For pruned AlexNet, we are able to quantize to 8bits (256 shared weights) for each CONV layers, and 5bits (32 shared weights) for each FC layer without any loss of accuracy.To calculate the compression rate, given clusters, we only need bits to encode the index. In general, for a network with connections and each connection is represented with bits, constraining the connections to have only shared weights will result in a compression rate of:
(1) 
For example, Figure 3 shows the weights of a single layer neural network with four input units and four output units. There are weights originally but there are only shared weights: similar weights are grouped together to share the same value. Originally we need to store 16 weights each has 32 bits, now we need to store only 4 effective weights (blue, green, red and orange), each has 32 bits, together with 16 2bit indices giving a compression rate of
We use kmeans clustering to identify the shared weights for each layer of a trained network, so that all the weights that fall into the same cluster will share the same weight. Weights are not shared across layers. We partition
original weights into clusters , , so as to minimize the withincluster sum of squares (WCSS):(2) 
Different from HashNet (Chen et al., 2015) where weight sharing is determined by a hash function before the networks sees any training data, our method determines weight sharing after a network is fully trained, so that the shared weights approximate the original network.
Centroid initialization impacts the quality of clustering and thus affects the network’s prediction accuracy. We examine three initialization methods: Forgy(random), densitybased, and linear initialization. In Figure 4 we plotted the original weights’ distribution of conv3 layer in AlexNet (CDF in blue, PDF in red). The weights forms a bimodal distribution after network pruning. On the bottom it plots the effective weights (centroids) with 3 different initialization methods (shown in blue, red and yellow). In this example, there are 13 clusters.
Forgy (random) initialization randomly chooses k observations from the data set and uses these as the initial centroids. The initialized centroids are shown in yellow. Since there are two peaks in the bimodal distribution, Forgy method tend to concentrate around those two peaks.
Densitybased initialization linearly spaces the CDF of the weights in the yaxis, then finds the horizontal intersection with the CDF, and finally finds the vertical intersection on the xaxis, which becomes a centroid, as shown in blue dots. This method makes the centroids denser around the two peaks, but more scatted than the Forgy method.
Linear initialization linearly spaces the centroids between the [min, max] of the original weights. This initialization method is invariant to the distribution of the weights and is the most scattered compared with the former two methods.
Larger weights play a more important role than smaller weights (Han et al., 2015), but there are fewer of these large weights. Thus for both Forgy initialization and densitybased initialization, very few centroids have large absolute value which results in poor representation of these few large weights. Linear initialization does not suffer from this problem. The experiment section compares the accuracy of different initialization methods after clustering and finetuning, showing that linear initialization works best.
The centroids of the onedimensional kmeans clustering are the shared weights. There is one level of indirection during feed forward phase and backpropagation phase looking up the weight table. An index into the shared weight table is stored for each connection. During backpropagation, the gradient for each shared weight is calculated and used to update the shared weight. This procedure is shown in Figure 3.
We denote the loss by , the weight in the th column and th row by , the centroid index of element by , the th centroid of the layer by . By using the indicator function , the gradient of the centroids is calculated as:
(3) 
A Huffman code is an optimal prefix code commonly used for lossless data compression(Van Leeuwen, 1976)
. It uses variablelength codewords to encode source symbols. The table is derived from the occurrence probability for each symbol. More common symbols are represented with fewer bits.
Figure 5
shows the probability distribution of quantized weights and the sparse matrix index of the last fully connected layer in AlexNet. Both distributions are biased: most of the quantized weights are distributed around the two peaks; the sparse matrix index difference are rarely above 20. Experiments show that Huffman coding these nonuniformly distributed values saves
of network storage.We pruned, quantized, and Huffman encoded four networks: two on MNIST and two on ImageNet datasets. The network parameters and accuracy^{1}^{1}1
Reference model is from Caffe model zoo, accuracy is measured without data augmentation
before and after pruning are shown in Table 1. The compression pipeline saves network storage by to across different networks without loss of accuracy. The total size of AlexNet decreased from 240MB to 6.9MB, which is small enough to be put into onchip SRAM, eliminating the need to store the model in energyconsuming DRAM memory.Training is performed with the Caffe framework (Jia et al., 2014). Pruning is implemented by adding a mask to the blobs to mask out the update of the pruned connections. Quantization and weight sharing are implemented by maintaining a codebook structure that stores the shared weight, and groupbyindex after calculating the gradient of each layer. Each shared weight is updated with all the gradients that fall into that bucket. Huffman coding doesn’t require training and is implemented offline after all the finetuning is finished.
Network  Top1 Error  Top5 Error  Parameters 



LeNet300100 Ref  1.64%    1070 KB  
LeNet300100 Compressed  1.58%    27 KB  
LeNet5 Ref  0.80%    1720 KB  
LeNet5 Compressed  0.74%    44 KB  
AlexNet Ref  42.78%  19.73%  240 MB  
AlexNet Compressed  42.78%  19.70%  6.9 MB  
VGG16 Ref  31.50%  11.32%  552 MB  
VGG16 Compressed  31.17%  10.91%  11.3 MB 
Layer  #Weights 









ip1  235K  8%  6  4.4  5  3.7  3.1%  2.32%  
ip2  30K  9%  6  4.4  5  4.3  3.8%  3.04%  
ip3  1K  26%  6  4.3  5  3.2  15.7%  12.70%  
Total  266K  8%()  6  5.1  5  3.7  3.1% ()  2.49% () 
Layer  #Weights 








conv1  0.5K  66%  8  7.2  5  1.5  78.5%  67.45%  
conv2  25K  12%  8  7.2  5  3.9  6.0%  5.28%  
ip1  400K  8%  5  4.5  5  4.5  2.7%  2.45%  
ip2  5K  19%  5  5.2  5  3.7  6.9%  6.13%  
Total  431K  8%()  5.3  4.1  5  4.4  3.05% ()  2.55% () 
We first experimented on MNIST dataset with LeNet300100 and LeNet5 network (LeCun et al., 1998). LeNet300100 is a fully connected network with two hidden layers, with 300 and 100 neurons each, which achieves 1.6% error rate on Mnist. LeNet5 is a convolutional network that has two convolutional layers and two fully connected layers, which achieves 0.8% error rate on Mnist. Table 2 and table 3 show the statistics of the compression pipeline. The compression rate includes the overhead of the codebook and sparse indexes. Most of the saving comes from pruning and quantization (compressed ), while Huffman coding gives a marginal gain (compressed )
We further examine the performance of Deep Compression on the ImageNet ILSVRC2012 dataset, which has 1.2M training examples and 50k validation examples. We use the AlexNet Caffe model as the reference model, which has 61 million parameters and achieved a top1 accuracy of 57.2% and a top5 accuracy of 80.3%. Table 4 shows that AlexNet can be compressed to of its original size without impacting accuracy. There are 256 shared weights in each CONV layer, which are encoded with 8 bits, and 32 shared weights in each FC layer, which are encoded with only 5 bits. The relative sparse index is encoded with 4 bits. Huffman coding compressed additional 22%, resulting in compression in total.
Layer  #Weights 








conv1  35K  84%  8  6.3  4  1.2  32.6%  20.53%  
conv2  307K  38%  8  5.5  4  2.3  14.5%  9.43%  
conv3  885K  35%  8  5.1  4  2.6  13.1%  8.44%  
conv4  663K  37%  8  5.2  4  2.5  14.1%  9.11%  
conv5  442K  37%  8  5.6  4  2.5  14.0%  9.43%  
fc6  38M  9%  5  3.9  4  3.2  3.0%  2.39%  
fc7  17M  9%  5  3.6  4  3.7  3.0%  2.46%  
fc8  4M  25%  5  4  4  3.2  7.3%  5.85%  
Total  61M  11%()  5.4  4  4  3.2  3.7% ()  2.88% () 
With promising results on AlexNet, we also looked at a larger, more recent network, VGG16 (Simonyan & Zisserman, 2014), on the same ILSVRC2012 dataset. VGG16 has far more convolutional layers but still only three fullyconnected layers. Following a similar methodology, we aggressively compressed both convolutional and fullyconnected layers to realize a significant reduction in the number of effective weights, shown in Table5.
Layer  #Weights 








conv1_1  2K  58%  8  6.8  5  1.7  40.0%  29.97%  
conv1_2  37K  22%  8  6.5  5  2.6  9.8%  6.99%  
conv2_1  74K  34%  8  5.6  5  2.4  14.3%  8.91%  
conv2_2  148K  36%  8  5.9  5  2.3  14.7%  9.31%  
conv3_1  295K  53%  8  4.8  5  1.8  21.7%  11.15%  
conv3_2  590K  24%  8  4.6  5  2.9  9.7%  5.67%  
conv3_3  590K  42%  8  4.6  5  2.2  17.0%  8.96%  
conv4_1  1M  32%  8  4.6  5  2.6  13.1%  7.29%  
conv4_2  2M  27%  8  4.2  5  2.9  10.9%  5.93%  
conv4_3  2M  34%  8  4.4  5  2.5  14.0%  7.47%  
conv5_1  2M  35%  8  4.7  5  2.5  14.3%  8.00%  
conv5_2  2M  29%  8  4.6  5  2.7  11.7%  6.52%  
conv5_3  2M  36%  8  4.6  5  2.3  14.8%  7.79%  
fc6  103M  4%  5  3.6  5  3.5  1.6%  1.10%  
fc7  17M  4%  5  4  5  4.3  1.5%  1.25%  
fc8  4M  23%  5  4  5  3.4  7.1%  5.24%  
Total  138M  7.5%()  6.4  4.1  5  3.1  3.2% ()  2.05% () 
The VGG16 network as a whole has been compressed by . Weights in the CONV layers are represented with 8 bits, and FC layers use 5 bits, which does not impact the accuracy. The two largest fullyconnected layers can each be pruned to less than 1.6% of their original size. This reduction is critical for real time image processing, where there is little reuse of these layers across images (unlike batch processing). This is also critical for fast object detection algorithms where one CONV pass is used by many FC passes. The reduced layers will fit in an onchip SRAM and have modest bandwidth requirements. Without the reduction, the bandwidth requirements are prohibitive.
Figure 6 shows the accuracy at different compression rates for pruning and quantization together or individually. When working individually, as shown in the purple and yellow lines, accuracy of pruned network begins to drop significantly when compressed below 8% of its original size; accuracy of quantized network also begins to drop significantly when compressed below 8% of its original size. But when combined, as shown in the red line, the network can be compressed to 3% of original size with no loss of accuracy. On the far right side compared the result of SVD, which is inexpensive but has a poor compression rate.
The three plots in Figure 7 show how accuracy drops with fewer bits per connection for CONV layers (left), FC layers (middle) and all layers (right). Each plot reports both top1 and top5 accuracy. Dashed lines only applied quantization but without pruning; solid lines did both quantization and pruning. There is very little difference between the two. This shows that pruning works well with quantization.
Quantization works well on pruned network because unpruned AlexNet has 60 million weights to quantize, while pruned AlexNet has only 6.7 million weights to quantize. Given the same amount of centroids, the latter has less error.
The first two plots in Figure 7 show that CONV layers require more bits of precision than FC layers. For CONV layers, accuracy drops significantly below 4 bits, while FC layer is more robust: not until 2 bits did the accuracy drop significantly.
Figure 8 compares the accuracy of the three different initialization methods with respect to top1 accuracy (Left) and top5 accuracy (Right). The network is quantized to bits as shown on xaxis. Linear initialization outperforms the density initialization and random initialization in all cases except at 3 bits.
The initial centroids of linear initialization spread equally across the xaxis, from the min value to the max value. That helps to maintain the large weights as the large weights play a more important role than smaller ones, which is also shown in network pruning Han et al. (2015). Neither random nor densitybased initialization retains large centroids. With these initialization methods, large weights are clustered to the small centroids because there are few large weights. In contrast, linear initialization allows large weights a better chance to form a large centroid.
Deep Compression is targeting extremely latencyfocused applications running on mobile, which requires realtime inference, such as pedestrian detection on an embedded processor inside an autonomous vehicle. Waiting for a batch to assemble significantly adds latency. So when benchmarking the performance and energy efficiency, we consider the case when batch size = 1. The cases of batching are given in Appendix A.
Fully connected layer dominates the model size (more than ) and got compressed the most by Deep Compression ( weights pruned in VGG16). In stateoftheart object detection algorithms such as fast RCNN (Girshick, 2015), upto
computation time is consumed on FC layers on uncompressed model. So it’s interesting to benchmark on FC layers, to see the effect of Deep Compression on performance and energy. Thus we setup our benchmark on FC6, FC7, FC8 layers of AlexNet and VGG16. In the nonbatched case, the activation matrix is a vector with just one column, so the computation boils down to dense / sparse matrixvector multiplication for original / pruned model, respectively. Since current BLAS library on CPU and GPU doesn’t support indirect lookup and relative indexing, we didn’t benchmark the quantized model.
We compare three different offtheshelf hardware: the NVIDIA GeForce GTX Titan X and the Intel Core i7 5930K as desktop processors (same package as NVIDIA Digits Dev Box) and NVIDIA Tegra K1 as mobile processor. To run the benchmark on GPU, we used cuBLAS GEMV for the original dense layer. For the pruned sparse layer, we stored the sparse matrix in in CSR format, and used cuSPARSE CSRMV kernel, which is optimized for sparse matrixvector multiplication on GPU. To run the benchmark on CPU, we used MKL CBLAS GEMV for the original dense model and MKL SPBLAS CSRMV for the pruned sparse model.
To compare power consumption between different systems, it is important to measure power at a consistent manner (NVIDIA, b). For our analysis, we are comparing preregulation power of the entire application processor (AP) / SOC and DRAM combined. On CPU, the benchmark is running on single socket with a single HaswellE class Core i75930K processor. CPU socket and DRAM power are as reported by the pcmpower utility provided by Intel. For GPU, we used nvidiasmi utility to report the power of Titan X. For mobile GPU, we use a Jetson TK1 development board and measured the total power consumption with a powermeter. We assume AC to DC conversion loss, regulator efficiency and power consumed by peripheral components (NVIDIA, a) to report the AP+DRAM power for Tegra K1.
#CONV bits / #FC bits  Top1 Error  Top5 Error 




32bits / 32bits  42.78%  19.73%      
8 bits / 5 bits  42.78%  19.70%  0.00%  0.03%  
8 bits / 4 bits  42.79%  19.73%  0.01%  0.00%  
4 bits / 2 bits  44.77%  22.33%  1.99%  2.60% 
The ratio of memory access over computation characteristic with and without batching is different. When the input activations are batched to a matrix the computation becomes matrixmatrix multiplication, where locality can be improved by blocking. Matrix could be blocked to fit in caches and reused efficiently. In this case, the amount of memory access is , and that of computation is , the ratio between memory access and computation is in the order of .
In real time processing when batching is not allowed, the input activation is a single vector and the computation is matrixvector multiplication. In this case, the amount of memory access is , and the computation is , memory access and computation are of the same magnitude (as opposed to ). That indicates MV is more memorybounded than MM. So reducing the memory footprint is critical for the nonbatching case.
Figure 9 illustrates the speedup of pruning on different hardware. There are 6 columns for each benchmark, showing the computation time of CPU / GPU / TK1 on dense / pruned network. Time is normalized to CPU. When batch size = 1, pruned network layer obtained to speedup over the dense network on average because it has smaller memory footprint and alleviates the data transferring overhead, especially for large matrices that are unable to fit into the caches. For example VGG16’s FC6 layer, the largest layer in our experiment, contains data, which is far from the capacity of L3 cache.
In those latencytolerating applications , batching improves memory locality, where weights could be blocked and reused in matrixmatrix multiplication. In this scenario, pruned network no longer shows its advantage. We give detailed timing results in Appendix A.
Figure 10 illustrates the energy efficiency of pruning on different hardware. We multiply power consumption with computation time to get energy consumption, then normalized to CPU to get energy efficiency. When batch size = 1, pruned network layer consumes to less energy over the dense network on average. Reported by nvidiasmi, GPU utilization is for both dense and sparse cases.
Pruning makes the weight matrix sparse, so extra space is needed to store the indexes of nonzero elements. Quantization adds storage for a codebook. The experiment section has already included these two factors. Figure 11 shows the breakdown of three different components when quantizing four networks. Since on average both the weights and the sparse indexes are encoded with 5 bits, their storage is roughly half and half. The overhead of codebook is very small and often negligible.
Neural networks are typically overparametrized, and there is significant redundancy for deep learning models
(Denil et al., 2013). This results in a waste of both computation and memory usage. There have been various proposals to remove the redundancy: Vanhoucke et al. (2011) explored a fixedpoint implementation with 8bit integer (vs 32bit floating point) activations. Hwang & Sung (2014) proposed an optimization method for the fixedpoint network with ternary weights and 3bit activations. Anwar et al. (2015) quantized the neural network using L2 error minimization and achieved better accuracy on MNIST and CIFAR10 datasets.Denton et al. (2014) exploited the linear structure of the neural network by finding an appropriate lowrank approximation of the parameters and keeping the accuracy within 1% of the original model.The empirical success in this paper is consistent with the theoretical study of randomlike sparse networks with +1/0/1 weights (Arora et al., 2014), which have been proved to enjoy nice properties (e.g. reversibility), and to allow a provably polynomial time algorithm for training.
Much work has been focused on binning the network parameters into buckets, and only the values in the buckets need to be stored. HashedNets(Chen et al., 2015) reduce model sizes by using a hash function to randomly group connection weights, so that all connections within the same hash bucket share a single parameter value. In their method, the weight binning is predetermined by the hash function, instead of being learned through training, which doesn’t capture the nature of images. Gong et al. (2014) compressed deep convnets using vector quantization, which resulted in 1% accuracy loss. Both methods studied only the fully connected layer, ignoring the convolutional layers.
Network  Top1 Error  Top5 Error  Parameters 



Baseline Caffemodel (BVLC, )  42.78%  19.73%  240MB  
Fastfood32AD (Yang et al., 2014)  41.93%    131MB  
Fastfood16AD (Yang et al., 2014)  42.90%    64MB  
Collins & Kohli (Collins & Kohli, 2014)  44.40%    61MB  
SVD (Denton et al., 2014)  44.02%  20.56%  47.6MB  
Pruning (Han et al., 2015)  42.77%  19.67%  27MB  
Pruning+Quantization  42.78%  19.70%  8.9MB  
Pruning+Quantization+Huffman  42.78%  19.70%  6.9MB 
There have been other attempts to reduce the number of parameters of neural networks by replacing the fully connected layer with global average pooling. The Network in Network architecture(Lin et al., 2013) and GoogLenet(Szegedy et al., 2014)
achieves stateoftheart results on several benchmarks by adopting this idea. However, transfer learning, i.e. reusing features learned on the ImageNet dataset and applying them to new tasks by only finetuning the fully connected layers, is more difficult with this approach. This problem is noted by
Szegedy et al. (2014) and motivates them to add a linear layer on the top of their networks to enable transfer learning.Network pruning has been used both to reduce network complexity and to reduce overfitting. An early approach to pruning was biased weight decay (Hanson & Pratt, 1989). Optimal Brain Damage (LeCun et al., 1989) and Optimal Brain Surgeon (Hassibi et al., 1993)
prune networks to reduce the number of connections based on the Hessian of the loss function and suggest that such pruning is more accurate than magnitudebased pruning such as weight decay. A recent work
(Han et al., 2015) successfully pruned several state of the art large scale networks and showed that the number of parameters could be reduce by an order of magnitude. There are also attempts to reduce the number of activations for both compression and acceleration Van Nguyen et al. (2015).While the pruned network has been benchmarked on various hardware, the quantized network with weight sharing has not, because offtheshelf cuSPARSE or MKL SPBLAS library does not support indirect matrix entry lookup, nor is the relative index in CSC or CSR format supported. So the full advantage of Deep Compression that fit the model in cache is not fully unveiled. A software solution is to write customized GPU kernels that support this. A hardware solution is to build custom ASIC architecture specialized to traverse the sparse and quantized network structure, which also supports customized quantization bit width. We expect this architecture to have energy dominated by onchip SRAM access instead of offchip DRAM access.
We have presented “Deep Compression” that compressed neural networks without affecting accuracy. Our method operates by pruning the unimportant connections, quantizing the network using weight sharing, and then applying Huffman coding. We highlight our experiments on AlexNet which reduced the weight storage by without loss of accuracy. We show similar results for VGG16 and LeNet networks compressed by and without loss of accuracy. This leads to smaller storage requirement of putting convnets into mobile app. After Deep Compression the size of these networks fit into onchip SRAM cache (5pJ/access) rather than requiring offchip DRAM memory (640pJ/access). This potentially makes deep neural networks more energy efficient to run on mobile. Our compression method also facilitates the use of complex neural networks in mobile applications where application size and download bandwidth are constrained.
Fixed point optimization of deep convolutional neural networks for object recognition.
In Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on, pp. 1131–1135. IEEE, 2015.Proceedings of the 31th International Conference on Machine Learning, ICML 2014
, pp. 584–592, 2014.Phoneme probability estimation with dynamic sparsely connected artificial neural networks.
The Free Speech Journal, 1(5):1–41, 1997.Time (us) 








Titan X  dense (batch=1)  541.5  243.0  80.5  1467.8  243.0  80.5  
sparse (batch=1)  134.8  65.8  54.6  167.0  39.8  48.0  
dense (batch=64)  19.8  8.9  5.9  53.6  8.9  5.9  
sparse (batch=64)  94.6  51.5  23.2  121.5  24.4  22.0  

dense (batch=1)  7516.2  6187.1  1134.9  35022.8  5372.8  774.2  
sparse (batch=1)  3066.5  1282.1  890.5  3774.3  545.1  777.3  
dense (batch=64)  318.4  188.9  45.8  1056.0  188.3  45.7  
sparse (batch=64)  1417.6  682.1  407.7  1780.3  274.9  363.1  
Tegra K1  dense (batch=1)  12437.2  5765.0  2252.1  35427.0  5544.3  2243.1  
sparse (batch=1)  2879.3  1256.5  837.0  4377.2  626.3  745.1  
dense (batch=64)  1663.6  2056.8  298.0  2001.4  2050.7  483.9  
sparse (batch=64)  4003.9  1372.8  576.7  8024.8  660.2  544.1 
Average time on different layers. To avoid variance, we measured the time spent on each layer for 4096 input samples, and averaged the time regarding each input sample. For GPU, the time consumed by
cudaMalloc and cudaMemcpy is not counted. For batch size = 1, gemv is used; For batch size = 64, gemm is used. For sparse case, csrmv and csrmm is used, respectively.Power (Watts) 








TitanX  dense (batch=1)  157  159  159  166  163  159  
sparse (batch=1)  181  183  162  189  166  162  
dense (batch=64)  168  173  166  173  173  167  
sparse (batch=64)  156  158  163  160  158  161  

dense (batch=1)  83.5  72.8  77.6  70.6  74.6  77.0  
sparse (batch=1)  42.3  37.4  36.5  38.0  37.4  36.0  
dense (batch=64)  85.4  84.7  101.6  83.1  97.1  87.5  
sparse (batch=64)  37.2  37.1  38  39.5  36.6  38.2  
Tegra K1  dense (batch=1)  5.1  5.1  5.4  5.3  5.3  5.4  
sparse (batch=1)  5.9  6.1  5.8  5.6  6.3  5.8  
dense (batch=64)  5.6  5.6  6.3  5.4  5.6  6.3  
sparse (batch=64)  5.0  4.6  5.1  4.8  4.7  5.0 
Comments
There are no comments yet.