# DeepCompNet: A Novel Neural Net Model Compression Architecture

Authors: M. Mary Shanthi Rani; P. Chitra; S. Lakshmanan; M. Kalpana Devi; R. Sangeetha; S. Nithya
Journal: Computational Intelligence and Neuroscience
 (2022)

---

## Abstract

The emergence of powerful deep learning architectures has resulted in breakthrough innovations in several fields such as healthcare, precision farming, banking, education, and much more. Despite the advantages, there are limitations in deploying deep learning models in resource-constrained devices due to their huge memory size. This research work reports an innovative hybrid compression pipeline for compressing neural networks exploiting the untapped potential of z-score in weight pruning, followed by quantization using DBSCAN clustering and Huffman encoding. The proposed model has been experimented with state-of-the-art LeNet Deep Neural Network architectures using the standard MNIST and CIFAR datasets. Experimental results prove the compression performance of DeepCompNet by 26x without compromising the accuracy. The synergistic blend of the compression algorithms in the proposed model will ensure effortless deployment of neural networks leveraging DL applications in memory-constrained devices.


---

## Body

## 1. Introduction

Artificial Intelligence (AI) has become very popular in recent years with its broader gamut of applications in every walk of human life. Deep learning, a branch of Artificial Intelligence, aims to build predictive neural network (NN) models for solving complex real-life problems. This has triggered rigorous research towards realizing robust NN models for multitudes of data-intensive learning applications in various domains. Nevertheless, NN models suffer from significant setbacks from vast memory size and high time complexity. Building an NN model involves learning from humongous data samples through the training process. This includes innumerable multiplication of weights, biases, and inputs at each layer placing a huge overhead in training time and energy consumption as well.Furthermore, the trained model consumes considerable memory bandwidth which makes it infeasible for deployment in resource-constrained devices like embedded and mobile systems. Stemming from this point, research is geared towards the compression of neural network models. Yet, the major challenge with model compression is the reduction of model size without significant loss in accuracy. Compression techniques play a vital role in lowering memory bandwidth by reducing the file size exploiting redundancy and irrelevancy.Generally, deep neural networks have plenty of redundancy, which is primarily due to overparameterization. The model complexity arises due to many hyperparameters, specifically weights and biases, fine-tuned for accurate prediction. NN model compression relies mainly on pruning and quantizing weights as there is greater scope for eliminating irrelevant neurons and weak connections.The growing importance of neural network model compression has instigated many researchers to investigate on innovative and scalable compression methods. The fundamental idea behind model compression is to create a sparse network eliminating unwanted connections and weights. Various research on model compression uses weight pruning and quantization [1–3], low-rank factorization [4–6], and knowledge distillation [7–10]. Typically, quantization and low-rank factorization approaches are applied to pretrained models; however, knowledge distillation methods are suited only for training from scratch.Han et al. proposed a state-of-the-art deep compression framework in which weights are pruned iteratively and retrained for efficient compression of neural networks. Besides pruning, quantization of trained weights is carried out through weight sharing using k-means clustering algorithm and Huffman coding for improving compression rate. They experimented their framework on AlexNet, VGG16, and LeNet architectures and achieved compression rates of 35x, 49x, and 39x, respectively. Therefore, this framework has greatly reduced the storage requirement of memory-hungry architectures, thereby making it viable for easy implementation on mobile and embedded devices. Based on the superior achievement of the deep compression model, this work has become a standard reference model for all quantization-based compression methods [1].Iandola et al. designed a novel CNN compression framework, SqueezeNet, which achieved compression by 50x parameters on AlexNet using ImageNet without compromising the accuracy. They enhanced the efficiency of SqueezeNet by employing Dense-Sparse-Dense (DSD) method with improved accuracy [2]. Laude et al. developed a codec for compression of neural network using transform coding [3]. Wu et al. reduced the number of multiplications by introducing the scarcity through matrix factorization [4]. Lawrence et al. introduced a novel neuromorphic architecture for simplifying matrix multiplication operations in neural networks [5].Chung et al. proposed an online knowledge distillation method for transferring the knowledge of the class probabilities and feature map using the adversarial training framework [7]. Cheng et al. proposed a knowledge distillation based task-relevant approach with quantification analysis [8]. Cun and Pun designed a framework for deep neural network using joint learning, inspired by knowledge distillation. The results show that the pruned network recovered by knowledge distillation performs better than the original network [9].The proposed work explored the application of benchmark compression techniques similar to [1] for reducing the model size through pruning and quantization.The novelty of the paper includes the following major contributions:(i)
Development of an efficient model compression framework(ii)
Introduction of z-score for pruning weights(iii)
Application of DBSCAN clustering for weight sharingThe rest of the paper is organized as follows. Section2 explains the fundamental processes in the proposed model with related literature, serially followed by Section 3 which describes the proposed model. Section 4 presents the results and discussion, and Section 5 concludes the paper with the future research directions.


## 2. Related Works

### 2.1. Pruning

Pruning neural networks is a basic but effective strategy for deleting irrelevant synapses and neurons to obtain configured neural networks.In the pruning process, unnecessary weights are pruned away to yield a compact representation of the effective model. However, care should be taken that the resulting sparse weight matrices do not affect the performance the model. A simple basic pruning strategy is that weights below a specific threshold are considered low contribution weights which can be pruned and fine-tuned through retraining to preserve network precision. This procedure is repeated iteratively until a sparse model is obtained, as shown in Figure1.Figure 1
Process of pruning in model compression.Network pruning methods can be broadly grouped into unstructured and structured methods. Insignificant weights are eliminated in a pretrained network with unstructured pruning. These methods work by introducing sparsity constraints to reduce the number of weights. In contrast, structured pruning is coarse-grained and removes unimportant feature maps in the convolution layer. In general, model computational cost decreases as the network squeezing ratio increases. For a fully connected network, the computational cost ratio is roughly approximate to weight compression. Several architectures and architecture-specific pruning methods have been proposed in recent years [11–20].Wu et al. employed differential evolution strategy for pruning weights based on the pruning sensitivity of each layer. Their model has drastically reduced the number of weights when experimented with popular networks, namely, LeNet-300-100, LeNet-5, AlexNet, and VGG16 [14]. Zeng and Urtasun proposed a model compression using the Multilayer Pruning (MLPrune) method for AlexNet and VGG16 architectures [15]. Tian et al. described a deep neural network in which a trainable binary collaborative layer assigned to each filter does the pruning process in neural networks [16].Han et al. introduced Switcher Neural Network (SNN) structure for optimizing the weights in CNN architecture using MNIST, CIFAR10, and Mini-ImageNet datasets. The model obtained better classification accuracy with two different architectures, namely, LetNet5-Caffe-800-500 and VGG [17]. Zhang et al. have explored a framework for unstructured pruning by retaining only the relevant features and significant weights of deep neural networks [18].Tung and Mori developed algorithmic Learning-Compression (LC) framework and it was experimented with different pretrained models. The results revealed that, among all the pretrained models, VGG16 was better compressed with pruning, while quantization was more suitable for ResNet [19]. Kim et al. proposed a neural network compression scheme using rank configuration which reduced the number of floating point (FLP) operations by 25% in VGG16 network model and improved the accuracy as well by 0.7% when compared to the baseline [20].


### 2.2. Quantization

The quantization process compresses models by dropping the number of bits representing the weights or activations and has been very successful in reducing the training and inference time of NN models. An effective way for compressing models is scalar quantization which quantizes multiple parameters to a single scalar value. Recently, there have been two primary study approaches in parameter quantization: weights sharing, in which numerous network weights are shared, and the second based on weight representation with low bit reduction. In deep neural networks, the primary numerical format for model weights is 32-bit float or FP32. Several research works have achieved 8-bit weight representation through quantization without compromising the accuracy [21–32].Li et al. proposed an effective method, “Bit-Quantized-Net,” which quantifies the input weights in both training and testing phases. A Huffman code based on prefix coding is applied to compress the weights. This model has been experimented with three datasets, MNIST, CIFAR-10, and SVHN, and the results show a reduced loss of 8% compared to the base model [24]. The weight-sharing strategy was initially used for rapid acceleration of exploring the architectures, credited as part of the initial success of Neural Architecture Search (NAS) [25, 26].Dupuis et al. reduced the network complexity by approximating the NN weights layer-wise using linear approximations and clustering techniques [27]. Tolba et al. suggested soft weight sharing which is another type of quantization that is combined with weight pruning phase to generate the compressed model. Experiments prove that weight-sharing models achieve reduced 16-bit weight quantization compared to baseline 32-bit floating point representation of uncompressed weight matrices [29].Choi et al. designed a lossy compression model for weight quantization in a neural network. This model adopted vector quantization for source coding and achieved higher compression ratios of 47.1x and 42.5x, respectively, on AlexNet (trained on ImageNet) and ResNet (trained on CIFAR-10) [31]. Tan and Wang described clustering-based quantization using sparse regularization to reduce DNN size for speech enhancement through model compression pipeline process [32].


### 2.3. Lossless Compression

Generally, compression techniques are categorized as lossless and lossy. Lossless techniques compress data by exploiting the redundancy inherent in the data distribution, whereas lossy techniques achieve compression by eliminating irrelevant data in which minor loss of information occurs. Lossless data compression produces the exact version of original data from the encoded stream. Some popular lossless compression algorithms are Run Length Encoding (RLE), Huffman encoding, and LZW encoding [33]. Huffman encoding is a commonly used lossless encoding technique which achieves optimal compression by using variable length prefix code. Frequently occurring symbols are coded with fewer bits than infrequent ones and hence are well suited for redundant data distribution [34–36]. Moreover, the encoding and decoding processes are simple to implement without much increase in complexity. The encoding process of Huffman coding is illustrated in Figure 2.Figure 2
Compression using Huffman coding.Literature shows that most of the model compression algorithms use lossless encoding for posttraining model compression [1, 2]. The major challenge with the model compression framework is the reduction of the size without significant impact on the accuracy.


## 2.1. Pruning

Pruning neural networks is a basic but effective strategy for deleting irrelevant synapses and neurons to obtain configured neural networks.In the pruning process, unnecessary weights are pruned away to yield a compact representation of the effective model. However, care should be taken that the resulting sparse weight matrices do not affect the performance the model. A simple basic pruning strategy is that weights below a specific threshold are considered low contribution weights which can be pruned and fine-tuned through retraining to preserve network precision. This procedure is repeated iteratively until a sparse model is obtained, as shown in Figure1.Figure 1
Process of pruning in model compression.Network pruning methods can be broadly grouped into unstructured and structured methods. Insignificant weights are eliminated in a pretrained network with unstructured pruning. These methods work by introducing sparsity constraints to reduce the number of weights. In contrast, structured pruning is coarse-grained and removes unimportant feature maps in the convolution layer. In general, model computational cost decreases as the network squeezing ratio increases. For a fully connected network, the computational cost ratio is roughly approximate to weight compression. Several architectures and architecture-specific pruning methods have been proposed in recent years [11–20].Wu et al. employed differential evolution strategy for pruning weights based on the pruning sensitivity of each layer. Their model has drastically reduced the number of weights when experimented with popular networks, namely, LeNet-300-100, LeNet-5, AlexNet, and VGG16 [14]. Zeng and Urtasun proposed a model compression using the Multilayer Pruning (MLPrune) method for AlexNet and VGG16 architectures [15]. Tian et al. described a deep neural network in which a trainable binary collaborative layer assigned to each filter does the pruning process in neural networks [16].Han et al. introduced Switcher Neural Network (SNN) structure for optimizing the weights in CNN architecture using MNIST, CIFAR10, and Mini-ImageNet datasets. The model obtained better classification accuracy with two different architectures, namely, LetNet5-Caffe-800-500 and VGG [17]. Zhang et al. have explored a framework for unstructured pruning by retaining only the relevant features and significant weights of deep neural networks [18].Tung and Mori developed algorithmic Learning-Compression (LC) framework and it was experimented with different pretrained models. The results revealed that, among all the pretrained models, VGG16 was better compressed with pruning, while quantization was more suitable for ResNet [19]. Kim et al. proposed a neural network compression scheme using rank configuration which reduced the number of floating point (FLP) operations by 25% in VGG16 network model and improved the accuracy as well by 0.7% when compared to the baseline [20].


## 2.2. Quantization

The quantization process compresses models by dropping the number of bits representing the weights or activations and has been very successful in reducing the training and inference time of NN models. An effective way for compressing models is scalar quantization which quantizes multiple parameters to a single scalar value. Recently, there have been two primary study approaches in parameter quantization: weights sharing, in which numerous network weights are shared, and the second based on weight representation with low bit reduction. In deep neural networks, the primary numerical format for model weights is 32-bit float or FP32. Several research works have achieved 8-bit weight representation through quantization without compromising the accuracy [21–32].Li et al. proposed an effective method, “Bit-Quantized-Net,” which quantifies the input weights in both training and testing phases. A Huffman code based on prefix coding is applied to compress the weights. This model has been experimented with three datasets, MNIST, CIFAR-10, and SVHN, and the results show a reduced loss of 8% compared to the base model [24]. The weight-sharing strategy was initially used for rapid acceleration of exploring the architectures, credited as part of the initial success of Neural Architecture Search (NAS) [25, 26].Dupuis et al. reduced the network complexity by approximating the NN weights layer-wise using linear approximations and clustering techniques [27]. Tolba et al. suggested soft weight sharing which is another type of quantization that is combined with weight pruning phase to generate the compressed model. Experiments prove that weight-sharing models achieve reduced 16-bit weight quantization compared to baseline 32-bit floating point representation of uncompressed weight matrices [29].Choi et al. designed a lossy compression model for weight quantization in a neural network. This model adopted vector quantization for source coding and achieved higher compression ratios of 47.1x and 42.5x, respectively, on AlexNet (trained on ImageNet) and ResNet (trained on CIFAR-10) [31]. Tan and Wang described clustering-based quantization using sparse regularization to reduce DNN size for speech enhancement through model compression pipeline process [32].


## 2.3. Lossless Compression

Generally, compression techniques are categorized as lossless and lossy. Lossless techniques compress data by exploiting the redundancy inherent in the data distribution, whereas lossy techniques achieve compression by eliminating irrelevant data in which minor loss of information occurs. Lossless data compression produces the exact version of original data from the encoded stream. Some popular lossless compression algorithms are Run Length Encoding (RLE), Huffman encoding, and LZW encoding [33]. Huffman encoding is a commonly used lossless encoding technique which achieves optimal compression by using variable length prefix code. Frequently occurring symbols are coded with fewer bits than infrequent ones and hence are well suited for redundant data distribution [34–36]. Moreover, the encoding and decoding processes are simple to implement without much increase in complexity. The encoding process of Huffman coding is illustrated in Figure 2.Figure 2
Compression using Huffman coding.Literature shows that most of the model compression algorithms use lossless encoding for posttraining model compression [1, 2]. The major challenge with the model compression framework is the reduction of the size without significant impact on the accuracy.


## 3. Materials and Methods

This research work uses state-of-the-art deep compression model developed by Han et al. [1] as the baseline model and applies new strategies for weight pruning and weight sharing to augment the compression performance.


### 3.1. Materials

The proposed model has been experimented with LeNet architectures LeNet-300-100 and LeNet-5 using MNIST and CIFAR-10 datasets.Le-Net-300-100 is a multilayer perceptron with two hidden layers, each with 300 and 100 neurons. LeNet-5 is a Convolutional Neural Network designed by LeCun et al. [37]. The model consists of seven layers: two convolutional layers of 5 × 5 filters, three fully connected layers, and two subsampling layers.MNIST consists of 70,000 grayscale 28 × 28 pixel images of handwritten digits from 0 to 9 categorized into ten classes. The dataset is split into 60,000 and 10,000 for training set and test set, respectively.CIFAR-10 dataset is a widely used image dataset created by Canadian Institute for Advanced Research for experimenting ML algorithms in computer vision applications. It encompasses 60,000 32 × 32 RGB images classified into ten classes with 6,000 images in each class.


### 3.2. Methodology

The proposed model DeepCompNet architecture compression framework consists of three primary phases: weight pruning, quantization, and lossless encoding.


#### 3.2.1. Phase I: Weight Pruning Using the z-Score

We use a fine-grained approach for eliminating unimportant weights by introducing a pruning threshold. The baseline model [1] used standard deviation (SD) as the threshold for pruning the weights followed by quantization. All weights below the standard deviation of the weight distribution are zeroed, thus reducing the number of nonzero (alive) nodes. The network is retrained after pruning and, interestingly, the accuracy of the model is not compromised.In the proposed compression framework, we use the z-score of the weight distribution for creating sparse weight matrix. The z-score, also known as standard score, states the position of a raw score based on its distance from the mean [38]. The z-score is positive if the raw score is above the mean and negative otherwise. The z-score (zi) of each weight wi is computed using the formula given in the following equation: (1)zi=Wi−μσ,where wi is the ith weight of the current layer and µ and σ are the mean and the standard deviation of weight vector, respectively.We denote by functionf(x, ⊙) the architecture of a neural network and the weight pruning process is represented as a mathematical transformation as shown in the following equation:(2)fx,W=fx,W′,where W′ represents the new set of weights generated after pruning using the pruning constraint η. It is defined by the absolute value of mean of z-scores (zi) of “n” weights in the input weight vector (W) as given in the following equation:(3)η=absMeanzi∗ρ.We introduce′ρ′ as the sensitivity parameter to normalize the pruning threshold. Different values of ρ yield different pruning percentage and the best value is considered for our experiments.Sparsity of weights is introduced through a binary mask defined by “t” that fixes some of the parameters to 0 using the two following equations:(4)t=1,if abszi≤η,0,otherwise.The weight pruning process of DeepCompNet is defined as(5)fx,W⇒gx,t∗Wt∈0,1,where “g” is defined by Hadamard operator for element-wise multiplication.Figure3 depicts the flow diagram of the pruning phase.Figure 3
Pruning phase.If “a” is the number of alive (nonzero) weights after pruning, “p” is the number of bits required for each weight, and “n” is the total number of weights, the compression rate (C) after pruning is evaluated using the following equation: (6)C=n×pa×p,wherea<n.Usually, the number of bits required for each NN weight (p) would be 32 bits. Hence there would be a drastic reduction in the bit requirement for storing weights after pruning phase which is demonstrated in Section 4.


#### 3.2.2. Phase II: Quantization through Weight Sharing

Generally, the weights Φi in the group are quantized into the centroids of the corresponding clusters in weight-sharing process. Han et al. [1] applied the most popular k-means clustering algorithm, a partitioning clustering approach for weight sharing using Euclidean distance for grouping the closest weights.In this proposed model, we have implemented DBSCAN, a density-based clustering algorithm for weight sharing. Despite the achievement of better compression rate, it is evident from the literature that k-means works well only for spherical clusters and could not handle outlier which significantly affects the quality of the clusters. However, DBSCAN forms clusters of density connected points based on two parameters, Eps (ε), the radius of the neighbourhood, and Min.pts (M), the minimum number of points in each group. The reasons for using DBSCAN for weight sharing are twofold. First, it is robust to outliers; second, a priori decision on the number of clusters is not necessary. In addition to the aforementioned advantages of DBSCAN over k-means, it gives good results for various diverse distributions. The steps of the algorithm for DBSCAN are enumerated in Algorithm 1.Algorithm 1: DBSCAN algorithm.
Input: Set of data points (weights)Output: Core Points (Code Book)(1)
Choose a pointp randomly(2)
Fetch all the density connected points fromp w.r.t.Eps(ε) and Min.Pts(M)(3)
Form a cluster withp as the centroid if it is a core point with Min.pts in its neighbourhood(4)
Visit the next point otherwise(5)
Repeat steps 1–4 until all the points have been assigned to their clustersThe set of trained weights of the model is given as input to the DBSCAN algorithm, which returns the core points, also referred to as cluster centroids. The set of cluster centroids forms the codebook. Each cluster centroid is shared by all the weights in the same cluster, eventually resulting in the quantization of weights. The quality of clustering varies with different values of Eps (ε) and Min.pts (M). It is observed from our experiments that the optimal choice of the above-mentioned parameters is found to be architecture- and dataset-specific, which is discussed in Section 4. The flow diagram of Phase 2 is diagrammatically shown in Figure 4.Figure 4
Weight-sharing phase.Ifm is the number of posttrained weights assigned to k clusters, the compression rate after weight sharing will be(7)CRws=mpmlog2k+kp,where “p” and “log2k” are the bit requirements for representing each weight and cluster index, respectively.


#### 3.2.3. Phase III: Lossless Encoding of Quantized Weights

The final phase uses Huffman coding for encoding the quantized weights generated in Phase II as shown in Figure5. The encoding process starts by listing the weights/symbols in nonincreasing order of their frequency of occurrence. Subsequently, branches of two symbols with the smallest frequencies of occurrence are merged with assignment of 0 and 1 to the top and bottom branches, respectively. This process continues until there are no more symbols left. The big advantage of using Huffman coding after weight-sharing phase is that the redundancy is inherent in the quantized weights (codewords) and code indices. As frequently occurring codewords require fewer bits for encoding, this phase produces higher compression savings [39].Figure 5
Lossless encoding.The entire flow of the proposed three-stage compression pipeline is depicted in Figure6 for visual understanding.Figure 6
Flow diagram of DeepCompNet compression pipeline.


## 3.1. Materials

The proposed model has been experimented with LeNet architectures LeNet-300-100 and LeNet-5 using MNIST and CIFAR-10 datasets.Le-Net-300-100 is a multilayer perceptron with two hidden layers, each with 300 and 100 neurons. LeNet-5 is a Convolutional Neural Network designed by LeCun et al. [37]. The model consists of seven layers: two convolutional layers of 5 × 5 filters, three fully connected layers, and two subsampling layers.MNIST consists of 70,000 grayscale 28 × 28 pixel images of handwritten digits from 0 to 9 categorized into ten classes. The dataset is split into 60,000 and 10,000 for training set and test set, respectively.CIFAR-10 dataset is a widely used image dataset created by Canadian Institute for Advanced Research for experimenting ML algorithms in computer vision applications. It encompasses 60,000 32 × 32 RGB images classified into ten classes with 6,000 images in each class.


## 3.2. Methodology

The proposed model DeepCompNet architecture compression framework consists of three primary phases: weight pruning, quantization, and lossless encoding.


### 3.2.1. Phase I: Weight Pruning Using the z-Score

We use a fine-grained approach for eliminating unimportant weights by introducing a pruning threshold. The baseline model [1] used standard deviation (SD) as the threshold for pruning the weights followed by quantization. All weights below the standard deviation of the weight distribution are zeroed, thus reducing the number of nonzero (alive) nodes. The network is retrained after pruning and, interestingly, the accuracy of the model is not compromised.In the proposed compression framework, we use the z-score of the weight distribution for creating sparse weight matrix. The z-score, also known as standard score, states the position of a raw score based on its distance from the mean [38]. The z-score is positive if the raw score is above the mean and negative otherwise. The z-score (zi) of each weight wi is computed using the formula given in the following equation: (1)zi=Wi−μσ,where wi is the ith weight of the current layer and µ and σ are the mean and the standard deviation of weight vector, respectively.We denote by functionf(x, ⊙) the architecture of a neural network and the weight pruning process is represented as a mathematical transformation as shown in the following equation:(2)fx,W=fx,W′,where W′ represents the new set of weights generated after pruning using the pruning constraint η. It is defined by the absolute value of mean of z-scores (zi) of “n” weights in the input weight vector (W) as given in the following equation:(3)η=absMeanzi∗ρ.We introduce′ρ′ as the sensitivity parameter to normalize the pruning threshold. Different values of ρ yield different pruning percentage and the best value is considered for our experiments.Sparsity of weights is introduced through a binary mask defined by “t” that fixes some of the parameters to 0 using the two following equations:(4)t=1,if abszi≤η,0,otherwise.The weight pruning process of DeepCompNet is defined as(5)fx,W⇒gx,t∗Wt∈0,1,where “g” is defined by Hadamard operator for element-wise multiplication.Figure3 depicts the flow diagram of the pruning phase.Figure 3
Pruning phase.If “a” is the number of alive (nonzero) weights after pruning, “p” is the number of bits required for each weight, and “n” is the total number of weights, the compression rate (C) after pruning is evaluated using the following equation: (6)C=n×pa×p,wherea<n.Usually, the number of bits required for each NN weight (p) would be 32 bits. Hence there would be a drastic reduction in the bit requirement for storing weights after pruning phase which is demonstrated in Section 4.


### 3.2.2. Phase II: Quantization through Weight Sharing

Generally, the weights Φi in the group are quantized into the centroids of the corresponding clusters in weight-sharing process. Han et al. [1] applied the most popular k-means clustering algorithm, a partitioning clustering approach for weight sharing using Euclidean distance for grouping the closest weights.In this proposed model, we have implemented DBSCAN, a density-based clustering algorithm for weight sharing. Despite the achievement of better compression rate, it is evident from the literature that k-means works well only for spherical clusters and could not handle outlier which significantly affects the quality of the clusters. However, DBSCAN forms clusters of density connected points based on two parameters, Eps (ε), the radius of the neighbourhood, and Min.pts (M), the minimum number of points in each group. The reasons for using DBSCAN for weight sharing are twofold. First, it is robust to outliers; second, a priori decision on the number of clusters is not necessary. In addition to the aforementioned advantages of DBSCAN over k-means, it gives good results for various diverse distributions. The steps of the algorithm for DBSCAN are enumerated in Algorithm 1.Algorithm 1: DBSCAN algorithm.
Input: Set of data points (weights)Output: Core Points (Code Book)(1)
Choose a pointp randomly(2)
Fetch all the density connected points fromp w.r.t.Eps(ε) and Min.Pts(M)(3)
Form a cluster withp as the centroid if it is a core point with Min.pts in its neighbourhood(4)
Visit the next point otherwise(5)
Repeat steps 1–4 until all the points have been assigned to their clustersThe set of trained weights of the model is given as input to the DBSCAN algorithm, which returns the core points, also referred to as cluster centroids. The set of cluster centroids forms the codebook. Each cluster centroid is shared by all the weights in the same cluster, eventually resulting in the quantization of weights. The quality of clustering varies with different values of Eps (ε) and Min.pts (M). It is observed from our experiments that the optimal choice of the above-mentioned parameters is found to be architecture- and dataset-specific, which is discussed in Section 4. The flow diagram of Phase 2 is diagrammatically shown in Figure 4.Figure 4
Weight-sharing phase.Ifm is the number of posttrained weights assigned to k clusters, the compression rate after weight sharing will be(7)CRws=mpmlog2k+kp,where “p” and “log2k” are the bit requirements for representing each weight and cluster index, respectively.


### 3.2.3. Phase III: Lossless Encoding of Quantized Weights

The final phase uses Huffman coding for encoding the quantized weights generated in Phase II as shown in Figure5. The encoding process starts by listing the weights/symbols in nonincreasing order of their frequency of occurrence. Subsequently, branches of two symbols with the smallest frequencies of occurrence are merged with assignment of 0 and 1 to the top and bottom branches, respectively. This process continues until there are no more symbols left. The big advantage of using Huffman coding after weight-sharing phase is that the redundancy is inherent in the quantized weights (codewords) and code indices. As frequently occurring codewords require fewer bits for encoding, this phase produces higher compression savings [39].Figure 5
Lossless encoding.The entire flow of the proposed three-stage compression pipeline is depicted in Figure6 for visual understanding.Figure 6
Flow diagram of DeepCompNet compression pipeline.


## 3.2.1. Phase I: Weight Pruning Using the z-Score

We use a fine-grained approach for eliminating unimportant weights by introducing a pruning threshold. The baseline model [1] used standard deviation (SD) as the threshold for pruning the weights followed by quantization. All weights below the standard deviation of the weight distribution are zeroed, thus reducing the number of nonzero (alive) nodes. The network is retrained after pruning and, interestingly, the accuracy of the model is not compromised.In the proposed compression framework, we use the z-score of the weight distribution for creating sparse weight matrix. The z-score, also known as standard score, states the position of a raw score based on its distance from the mean [38]. The z-score is positive if the raw score is above the mean and negative otherwise. The z-score (zi) of each weight wi is computed using the formula given in the following equation: (1)zi=Wi−μσ,where wi is the ith weight of the current layer and µ and σ are the mean and the standard deviation of weight vector, respectively.We denote by functionf(x, ⊙) the architecture of a neural network and the weight pruning process is represented as a mathematical transformation as shown in the following equation:(2)fx,W=fx,W′,where W′ represents the new set of weights generated after pruning using the pruning constraint η. It is defined by the absolute value of mean of z-scores (zi) of “n” weights in the input weight vector (W) as given in the following equation:(3)η=absMeanzi∗ρ.We introduce′ρ′ as the sensitivity parameter to normalize the pruning threshold. Different values of ρ yield different pruning percentage and the best value is considered for our experiments.Sparsity of weights is introduced through a binary mask defined by “t” that fixes some of the parameters to 0 using the two following equations:(4)t=1,if abszi≤η,0,otherwise.The weight pruning process of DeepCompNet is defined as(5)fx,W⇒gx,t∗Wt∈0,1,where “g” is defined by Hadamard operator for element-wise multiplication.Figure3 depicts the flow diagram of the pruning phase.Figure 3
Pruning phase.If “a” is the number of alive (nonzero) weights after pruning, “p” is the number of bits required for each weight, and “n” is the total number of weights, the compression rate (C) after pruning is evaluated using the following equation: (6)C=n×pa×p,wherea<n.Usually, the number of bits required for each NN weight (p) would be 32 bits. Hence there would be a drastic reduction in the bit requirement for storing weights after pruning phase which is demonstrated in Section 4.


## 3.2.2. Phase II: Quantization through Weight Sharing

Generally, the weights Φi in the group are quantized into the centroids of the corresponding clusters in weight-sharing process. Han et al. [1] applied the most popular k-means clustering algorithm, a partitioning clustering approach for weight sharing using Euclidean distance for grouping the closest weights.In this proposed model, we have implemented DBSCAN, a density-based clustering algorithm for weight sharing. Despite the achievement of better compression rate, it is evident from the literature that k-means works well only for spherical clusters and could not handle outlier which significantly affects the quality of the clusters. However, DBSCAN forms clusters of density connected points based on two parameters, Eps (ε), the radius of the neighbourhood, and Min.pts (M), the minimum number of points in each group. The reasons for using DBSCAN for weight sharing are twofold. First, it is robust to outliers; second, a priori decision on the number of clusters is not necessary. In addition to the aforementioned advantages of DBSCAN over k-means, it gives good results for various diverse distributions. The steps of the algorithm for DBSCAN are enumerated in Algorithm 1.Algorithm 1: DBSCAN algorithm.
Input: Set of data points (weights)Output: Core Points (Code Book)(1)
Choose a pointp randomly(2)
Fetch all the density connected points fromp w.r.t.Eps(ε) and Min.Pts(M)(3)
Form a cluster withp as the centroid if it is a core point with Min.pts in its neighbourhood(4)
Visit the next point otherwise(5)
Repeat steps 1–4 until all the points have been assigned to their clustersThe set of trained weights of the model is given as input to the DBSCAN algorithm, which returns the core points, also referred to as cluster centroids. The set of cluster centroids forms the codebook. Each cluster centroid is shared by all the weights in the same cluster, eventually resulting in the quantization of weights. The quality of clustering varies with different values of Eps (ε) and Min.pts (M). It is observed from our experiments that the optimal choice of the above-mentioned parameters is found to be architecture- and dataset-specific, which is discussed in Section 4. The flow diagram of Phase 2 is diagrammatically shown in Figure 4.Figure 4
Weight-sharing phase.Ifm is the number of posttrained weights assigned to k clusters, the compression rate after weight sharing will be(7)CRws=mpmlog2k+kp,where “p” and “log2k” are the bit requirements for representing each weight and cluster index, respectively.


## 3.2.3. Phase III: Lossless Encoding of Quantized Weights

The final phase uses Huffman coding for encoding the quantized weights generated in Phase II as shown in Figure5. The encoding process starts by listing the weights/symbols in nonincreasing order of their frequency of occurrence. Subsequently, branches of two symbols with the smallest frequencies of occurrence are merged with assignment of 0 and 1 to the top and bottom branches, respectively. This process continues until there are no more symbols left. The big advantage of using Huffman coding after weight-sharing phase is that the redundancy is inherent in the quantized weights (codewords) and code indices. As frequently occurring codewords require fewer bits for encoding, this phase produces higher compression savings [39].Figure 5
Lossless encoding.The entire flow of the proposed three-stage compression pipeline is depicted in Figure6 for visual understanding.Figure 6
Flow diagram of DeepCompNet compression pipeline.


## 4. Results and Discussion

The experiments are executed using Anaconda software, an open-source framework to run the Python program offline. The prompts are configured with the essential deep learning and machine learning library files such as TensorFlow, Keras, NumPy, and Pandas. The proposed compression architecture is experimented on LeNet architectures using two datasets, MNIST and CIFAR-10, with the standard network parameters as listed in Table1.Table 1
Parameters used for LeNet-300-100 and LeNet-5.
3Network parametersLeNet-300-100LeNet-5Total parameters including weights and bias26661044426Learning rate0.0010.001Weight decay0.00010.0001Sensitivity valueρ2.32.4Training dataset size (MNIST)5000050000Test dataset size (MNIST)1000010000Training dataset size (CIFAR-10)5000050000Test dataset size (CIFAR-10)1000010000


### 4.1. LeNet-300-100

We first run the experiments on LeNet-300-100 with a learning rate of 0.001 for MNIST and CIFAR-10 datasets. To illustrate the performance of the developed model after each phase, stage-wise results are presented in Tables2–4 for LeNet-300-100. We computed the z-score based pruning threshold “η” for different sensitivity values “ρ” in the range of 0.25–3.5 and recorded the pruning performance. It has been found out that ρ = 2.3 achieves good pruning percentage. Both the proposed model and reference model [1] do not compress bias parameters.Table 2
Accuracy and compression rate versus epochs for LeNet-300-100.
LeNet-300-100No. of epochsDatasetTotal parametersAlive weightsCRAccuracy5MNIST2666101690415.7792.26CIFAR-109530106461414.7542.7510MNIST2666101504817.7293.31CIFAR-109530105128318.5843.5615MNIST2666101712515.5794.89CIFAR-109530108304611.4845.4520MNIST2666101728615.4291.70CIFAR-109530108694710.9645.9725MNIST2666101759315.1595.87CIFAR-109530105188818.3747.25Table 3
Accuracy and compression rate versus batch size for LeNet-300-100.
LeNet-300-100Batch sizeDatasetAliveCRAccuracy100MNIST1720315.5095.52CIFAR-107987911.9342.04128MNIST1759315.1595.87CIFAR-106461414.7542.75200MNIST1833214.5495.22CIFAR-107395812.8947.00256MNIST1822914.6394.09CIFAR-109004710.5845.08512MNIST1712515.5794.89CIFAR-105188818.3747.251024MNIST1504817.7293.31CIFAR-101365716.9843.97Table 4
Layer-wise compression statistics for LeNet-300-100.
ArchitectureDatasetLayerTotal number of weightsAlive weights after pruningPruned weightsPruning percentageLeNet-300-100MNISTFC12352001527121992993.51FC23000018432815793.86FC310006993193.01CIFAR-10FC192000480684393294.78FC23000031792682189.40FC3100023176976.90Table2 shows the compression rate and accuracy achieved after pruning for different epochs and the results show that maximum accuracy has been attained at 25 epochs for both MNIST and CIFAR-10 datasets. The values in bold show the best values for each metric.It is also obvious from Table2 that the proposed compression pipeline achieves moderate accuracy and good compression rates of 17.72 and 18.58 for both MNIST and CIFAR-10 datasets, respectively, for 10 epochs.Also, the proposed model is experimented with different batch sizes and the results are presented in Table3. The best accuracy of 95.87 is attained for batch size 128.The graphical representations of Tables2 and 3 are depicted in Figure 7.Figure 7
Performance analysis of LeNet-300-100 for MNIST and CIFAR-10: (a) accuracy and compression rate versus epochs; (b) accuracy and compression rate versus batch size.
(a)(b)The layer-wise compression statistics of DeepCompNet for LeNet-300-100 are shown in Table4 and its pictorial representation is shown in Figure 8.Figure 8
Result of the analysis using layer-wise compression for MNIST and CIFAR-10 datasets.Table4 and Figure 8 reveal that higher pruning is witnessed for all the three fully connected (FC) layers with MNIST dataset, whereas better pruning is seen only in FC1 layer for CIFAR-10 dataset.The proposed model investigated the use of DBSCAN for weight sharing. We run the DBSCAN algorithm for different values of Eps and Min.pts to analyse their impact on the accuracy as shown in Table5. We set the value of Min.pts to 1 to minimize the effect of outliers on the overall model performance (Table 5).Table 5
DBSCAN parameters versus accuracy comparison on LeNet-300-100.
DatasetEPSMin.ptsN-clustersAccuracyLossMNIST0.000111673.411.06210.000212081.960.97140.000312286.540.90130.000412391.120.86340.000612396.740.8290It is notable that the value of 0.0006 for Eps yields optimal accuracy. It is also worth noting that k-means clustering proposed in [1] uses fixed number of 32 clusters for weight sharing, whereas the number of clusters formed in DBSCAN varies with different set of weights and hence discovers natural clusters inherent in the weight distribution. The output of any clustering process would be a codebook representing a set of cluster centroids with their respective code indices. If “k” is the number of clusters generated and “m” is the total number of alive weights after pruning, the weight-sharing process can be defined as a mapping of “m” weights to “k” cluster centroids such that k < m, resulting in scalar quantization.Table6 and Figure 9 showcase the effect of quantized weights on the accuracy using the reference baseline model and the proposed compression pipelines.Table 6
Accuracy and compression rate comparison after weight sharing on LeNet-300-100.
MethodAccuracyCRExistingSTD (pruning) + k-means clustering (weight sharing) [1]96.566.32ProposedMethod 1STD (pruning) + DBSCAN (weight sharing)50.966.34Method 2z-score (pruning) + k-means clustering (weight sharing)95.566.31Method 3z-score (pruning) + DBSCAN (weight sharing)96.746.35Figure 9
Accuracy and compression rate comparison after weight sharing for LeNet-300-100.The quantized weights are further compressed using Huffman coding in Phase 3 and the compression savings for different pipelines are depicted in Table7.Table 7
Comparison of compression savings for different compression pipelines on LeNet-300-100.
MethodOriginalCompressedCRExistingSTD (pruning) + k-means clustering (weight sharing) + Huffman coding [1]305388809043.77ProposedMethod 1STD (pruning) + DBSCAN (weight sharing) + Huffman coding3353402283601.47Method 2z-score (pruning) + k-means clustering (weight sharing) + Huffman coding4222681019914.14Method 3z-score (pruning) + DBSCAN (weight sharing) + Huffman coding422268986604.28It is apparent from Table7 that the proposed compression framework achieves better compression rate than the classical reference model [1] without compromising the accuracy.


### 4.2. LeNet-5

DeepCompNet is experimented with LeNet-5 architecture using MNIST dataset and CIFAR-10 dataset with the network parameters listed in Table1. The pruning efficiencies in terms of alive weights and accuracy for different epochs and batch sizes are presented in Tables 8–10.Table 8
Accuracy and compression rate versus epochs for LeNet-5 architecture.
No. of epochsDatasetTotalAliveCRAccuracy5MNIST44426102981.3088.64CIFAR-102589822302911.2529.7810MNIST44426103601.3098.40CIFAR-102589822270511.4132.5615MNIST44426103441.3098.26CIFAR-102589822474910.4633.8920MNIST44426103371.3098.25CIFAR-1025898225.6410.3333.0325MNIST44426103001.3098.74CIFAR-102589822319741.7525.00Table 9
Accuracy and compression rate versus batch size for LeNet-5 architecture.
Batch sizeDatasetAliveCRAccuracy50MNIST103221.3097.88CIFAR-102270511.4132.56100MNIST103441.3098.53CIFAR-10764633.8716.26150MNIST102741.3088.67CIFAR-10827331.3017.33200MNIST102851.3089.84CIFAR-10698937.0621.15250MNIST103001.3098.74CIFAR-10620341.7525.00Table 10
Layer-wise compression statistics for LeNet-5.
ArchitectureDatasetLayerTotal number of weightsAlive weights after pruningPruned weightsPruning percentageLeNet-5MNISTFC110000525947594.79FC28403880295.48CIFAR-10FC158048175994044993.98FC284010074088.10Analyses of the above tables are visually represented in Figure10. It is revealed that the proposed compression model achieves a moderate CR of 1.3 and good accuracy of 98.74 for 25 epochs and 250 batch size for MNIST dataset in the pruning phase for LeNet-5 architecture. On the contrary, the proposed model achieves good CR for CIFAR-10 dataset but with noticeable loss in accuracy. Table 10 shows the layer-wise pruning compression statistics for LeNet-5 architecture and its diagrammatic representation in Figure 11.Figure 10
Performance analysis of LeNet-5 for MNIST and CIFAR-10: (a) accuracy and compression rate versus epochs for LeNet-5; (b) accuracy and compression rate versus batch size for LeNet-5.
(a)(b)Figure 11
Layer-wise compression statistics for LeNet-5.As discussed in the previous section, the efficiency of DBSCAN in weight-sharing phase lies on the optimal values of Eps and Min.pts which in turn depend on the weight distribution. We tried for different values for MNIST dataset as shown in Table11 and inferred that Eps = 0.0001 produces good results for k = 33.Table 11
DBSCAN parameters versus accuracy comparison for LeNet-5.
EpsMin.ptsN-clusters (k)AccuracyLoss0.00312767.350.89720.000113396.350.22650.000213293.180.35260.000313290.360.42530.0000313388.950.4799We compare the accuracy obtained before and after weight sharing by the proposed frameworks with reference model [1] for LeNet-5 in Table 12 and its graphical analysis is in Figure 12.Table 12
Accuracy and compression rate comparison after weight sharing for LeNet-5.
MethodAccuracyCRSTD (pruning) + k-means clustering (weight sharing) [1]95.926.27ProposedSTD (pruning) + DBSCAN (weight sharing)93.575.36z-score (pruning) + k-means clustering (weight sharing)84.036.28z-score (pruning) + DBSCAN (weight sharing)96.356.32Figure 12
Accuracy and compression rate comparison after weight sharing for LeNet-5.The compression savings due to Huffman coding for LeNet-5 architecture are shown in Table13.Table 13
Comparison of compression savings for different compression pipelines for LeNet-5.
MethodOriginalCompressedCRSTD (pruning) + k-means clustering (weight sharing) + Huffman coding7049206794301.04Proposed pipelinesz-score (pruning) + k-means clustering (weight sharing) + Huffman coding3813963678561.04STD (pruning) + DBSCAN (weight sharing) + Huffman coding3813963361081.13z-score (pruning) + DBSCAN (weight sharing) + Huffman coding3813963687421.03The comparison of the results of the proposed DeepCompNet model and existing neural net compression techniques is summarized in Table14.Table 14
Performance comparison of DeepCompNet with similar methods.
Architecture/datasetMethodsAccuracyCRLeNet-300-100/MNISTOriginal (before compression)97.74—Naivecut [14]97.162.49Iterative pruning [39]97.639.92MONNP [40]97.86.01DENNC [14]97.9324.33Deep compression [1]96.5624.66DeepCompNet95.8725.78LeNet-5/MNISTOriginal (before compression)99.05—Naivecut98.292.35Iterative pruning98.2811.83MONNP99.095.32DENNC [14]98.5914.47Deep compression [1]95.926.27DeepCompNet98.748.65Table14 demonstrates the superior performance of the proposed DeepCompNet compared to similar compression frameworks. Moreover, it is evident that the proposed model achieves good compression rate for LeNet-300-100 architecture.We experimented the proposed DeepCompNet model on VGG19 architecture for CIFAR-10 dataset and the results did not show good compression savings and accuracy.Results analysis demonstrates better performance of DeepCompNet achieving good compression and accuracy for LeNet architectures, specifically on LeNet-300-100 with MNIST dataset. However, it produces performance that is comparable with that of LeNet-5 when compared to similar compression frameworks. The performance of the model can be further accelerated with execution in GPU architectures.


## 4.1. LeNet-300-100

We first run the experiments on LeNet-300-100 with a learning rate of 0.001 for MNIST and CIFAR-10 datasets. To illustrate the performance of the developed model after each phase, stage-wise results are presented in Tables2–4 for LeNet-300-100. We computed the z-score based pruning threshold “η” for different sensitivity values “ρ” in the range of 0.25–3.5 and recorded the pruning performance. It has been found out that ρ = 2.3 achieves good pruning percentage. Both the proposed model and reference model [1] do not compress bias parameters.Table 2
Accuracy and compression rate versus epochs for LeNet-300-100.
LeNet-300-100No. of epochsDatasetTotal parametersAlive weightsCRAccuracy5MNIST2666101690415.7792.26CIFAR-109530106461414.7542.7510MNIST2666101504817.7293.31CIFAR-109530105128318.5843.5615MNIST2666101712515.5794.89CIFAR-109530108304611.4845.4520MNIST2666101728615.4291.70CIFAR-109530108694710.9645.9725MNIST2666101759315.1595.87CIFAR-109530105188818.3747.25Table 3
Accuracy and compression rate versus batch size for LeNet-300-100.
LeNet-300-100Batch sizeDatasetAliveCRAccuracy100MNIST1720315.5095.52CIFAR-107987911.9342.04128MNIST1759315.1595.87CIFAR-106461414.7542.75200MNIST1833214.5495.22CIFAR-107395812.8947.00256MNIST1822914.6394.09CIFAR-109004710.5845.08512MNIST1712515.5794.89CIFAR-105188818.3747.251024MNIST1504817.7293.31CIFAR-101365716.9843.97Table 4
Layer-wise compression statistics for LeNet-300-100.
ArchitectureDatasetLayerTotal number of weightsAlive weights after pruningPruned weightsPruning percentageLeNet-300-100MNISTFC12352001527121992993.51FC23000018432815793.86FC310006993193.01CIFAR-10FC192000480684393294.78FC23000031792682189.40FC3100023176976.90Table2 shows the compression rate and accuracy achieved after pruning for different epochs and the results show that maximum accuracy has been attained at 25 epochs for both MNIST and CIFAR-10 datasets. The values in bold show the best values for each metric.It is also obvious from Table2 that the proposed compression pipeline achieves moderate accuracy and good compression rates of 17.72 and 18.58 for both MNIST and CIFAR-10 datasets, respectively, for 10 epochs.Also, the proposed model is experimented with different batch sizes and the results are presented in Table3. The best accuracy of 95.87 is attained for batch size 128.The graphical representations of Tables2 and 3 are depicted in Figure 7.Figure 7
Performance analysis of LeNet-300-100 for MNIST and CIFAR-10: (a) accuracy and compression rate versus epochs; (b) accuracy and compression rate versus batch size.
(a)(b)The layer-wise compression statistics of DeepCompNet for LeNet-300-100 are shown in Table4 and its pictorial representation is shown in Figure 8.Figure 8
Result of the analysis using layer-wise compression for MNIST and CIFAR-10 datasets.Table4 and Figure 8 reveal that higher pruning is witnessed for all the three fully connected (FC) layers with MNIST dataset, whereas better pruning is seen only in FC1 layer for CIFAR-10 dataset.The proposed model investigated the use of DBSCAN for weight sharing. We run the DBSCAN algorithm for different values of Eps and Min.pts to analyse their impact on the accuracy as shown in Table5. We set the value of Min.pts to 1 to minimize the effect of outliers on the overall model performance (Table 5).Table 5
DBSCAN parameters versus accuracy comparison on LeNet-300-100.
DatasetEPSMin.ptsN-clustersAccuracyLossMNIST0.000111673.411.06210.000212081.960.97140.000312286.540.90130.000412391.120.86340.000612396.740.8290It is notable that the value of 0.0006 for Eps yields optimal accuracy. It is also worth noting that k-means clustering proposed in [1] uses fixed number of 32 clusters for weight sharing, whereas the number of clusters formed in DBSCAN varies with different set of weights and hence discovers natural clusters inherent in the weight distribution. The output of any clustering process would be a codebook representing a set of cluster centroids with their respective code indices. If “k” is the number of clusters generated and “m” is the total number of alive weights after pruning, the weight-sharing process can be defined as a mapping of “m” weights to “k” cluster centroids such that k < m, resulting in scalar quantization.Table6 and Figure 9 showcase the effect of quantized weights on the accuracy using the reference baseline model and the proposed compression pipelines.Table 6
Accuracy and compression rate comparison after weight sharing on LeNet-300-100.
MethodAccuracyCRExistingSTD (pruning) + k-means clustering (weight sharing) [1]96.566.32ProposedMethod 1STD (pruning) + DBSCAN (weight sharing)50.966.34Method 2z-score (pruning) + k-means clustering (weight sharing)95.566.31Method 3z-score (pruning) + DBSCAN (weight sharing)96.746.35Figure 9
Accuracy and compression rate comparison after weight sharing for LeNet-300-100.The quantized weights are further compressed using Huffman coding in Phase 3 and the compression savings for different pipelines are depicted in Table7.Table 7
Comparison of compression savings for different compression pipelines on LeNet-300-100.
MethodOriginalCompressedCRExistingSTD (pruning) + k-means clustering (weight sharing) + Huffman coding [1]305388809043.77ProposedMethod 1STD (pruning) + DBSCAN (weight sharing) + Huffman coding3353402283601.47Method 2z-score (pruning) + k-means clustering (weight sharing) + Huffman coding4222681019914.14Method 3z-score (pruning) + DBSCAN (weight sharing) + Huffman coding422268986604.28It is apparent from Table7 that the proposed compression framework achieves better compression rate than the classical reference model [1] without compromising the accuracy.


## 4.2. LeNet-5

DeepCompNet is experimented with LeNet-5 architecture using MNIST dataset and CIFAR-10 dataset with the network parameters listed in Table1. The pruning efficiencies in terms of alive weights and accuracy for different epochs and batch sizes are presented in Tables 8–10.Table 8
Accuracy and compression rate versus epochs for LeNet-5 architecture.
No. of epochsDatasetTotalAliveCRAccuracy5MNIST44426102981.3088.64CIFAR-102589822302911.2529.7810MNIST44426103601.3098.40CIFAR-102589822270511.4132.5615MNIST44426103441.3098.26CIFAR-102589822474910.4633.8920MNIST44426103371.3098.25CIFAR-1025898225.6410.3333.0325MNIST44426103001.3098.74CIFAR-102589822319741.7525.00Table 9
Accuracy and compression rate versus batch size for LeNet-5 architecture.
Batch sizeDatasetAliveCRAccuracy50MNIST103221.3097.88CIFAR-102270511.4132.56100MNIST103441.3098.53CIFAR-10764633.8716.26150MNIST102741.3088.67CIFAR-10827331.3017.33200MNIST102851.3089.84CIFAR-10698937.0621.15250MNIST103001.3098.74CIFAR-10620341.7525.00Table 10
Layer-wise compression statistics for LeNet-5.
ArchitectureDatasetLayerTotal number of weightsAlive weights after pruningPruned weightsPruning percentageLeNet-5MNISTFC110000525947594.79FC28403880295.48CIFAR-10FC158048175994044993.98FC284010074088.10Analyses of the above tables are visually represented in Figure10. It is revealed that the proposed compression model achieves a moderate CR of 1.3 and good accuracy of 98.74 for 25 epochs and 250 batch size for MNIST dataset in the pruning phase for LeNet-5 architecture. On the contrary, the proposed model achieves good CR for CIFAR-10 dataset but with noticeable loss in accuracy. Table 10 shows the layer-wise pruning compression statistics for LeNet-5 architecture and its diagrammatic representation in Figure 11.Figure 10
Performance analysis of LeNet-5 for MNIST and CIFAR-10: (a) accuracy and compression rate versus epochs for LeNet-5; (b) accuracy and compression rate versus batch size for LeNet-5.
(a)(b)Figure 11
Layer-wise compression statistics for LeNet-5.As discussed in the previous section, the efficiency of DBSCAN in weight-sharing phase lies on the optimal values of Eps and Min.pts which in turn depend on the weight distribution. We tried for different values for MNIST dataset as shown in Table11 and inferred that Eps = 0.0001 produces good results for k = 33.Table 11
DBSCAN parameters versus accuracy comparison for LeNet-5.
EpsMin.ptsN-clusters (k)AccuracyLoss0.00312767.350.89720.000113396.350.22650.000213293.180.35260.000313290.360.42530.0000313388.950.4799We compare the accuracy obtained before and after weight sharing by the proposed frameworks with reference model [1] for LeNet-5 in Table 12 and its graphical analysis is in Figure 12.Table 12
Accuracy and compression rate comparison after weight sharing for LeNet-5.
MethodAccuracyCRSTD (pruning) + k-means clustering (weight sharing) [1]95.926.27ProposedSTD (pruning) + DBSCAN (weight sharing)93.575.36z-score (pruning) + k-means clustering (weight sharing)84.036.28z-score (pruning) + DBSCAN (weight sharing)96.356.32Figure 12
Accuracy and compression rate comparison after weight sharing for LeNet-5.The compression savings due to Huffman coding for LeNet-5 architecture are shown in Table13.Table 13
Comparison of compression savings for different compression pipelines for LeNet-5.
MethodOriginalCompressedCRSTD (pruning) + k-means clustering (weight sharing) + Huffman coding7049206794301.04Proposed pipelinesz-score (pruning) + k-means clustering (weight sharing) + Huffman coding3813963678561.04STD (pruning) + DBSCAN (weight sharing) + Huffman coding3813963361081.13z-score (pruning) + DBSCAN (weight sharing) + Huffman coding3813963687421.03The comparison of the results of the proposed DeepCompNet model and existing neural net compression techniques is summarized in Table14.Table 14
Performance comparison of DeepCompNet with similar methods.
Architecture/datasetMethodsAccuracyCRLeNet-300-100/MNISTOriginal (before compression)97.74—Naivecut [14]97.162.49Iterative pruning [39]97.639.92MONNP [40]97.86.01DENNC [14]97.9324.33Deep compression [1]96.5624.66DeepCompNet95.8725.78LeNet-5/MNISTOriginal (before compression)99.05—Naivecut98.292.35Iterative pruning98.2811.83MONNP99.095.32DENNC [14]98.5914.47Deep compression [1]95.926.27DeepCompNet98.748.65Table14 demonstrates the superior performance of the proposed DeepCompNet compared to similar compression frameworks. Moreover, it is evident that the proposed model achieves good compression rate for LeNet-300-100 architecture.We experimented the proposed DeepCompNet model on VGG19 architecture for CIFAR-10 dataset and the results did not show good compression savings and accuracy.Results analysis demonstrates better performance of DeepCompNet achieving good compression and accuracy for LeNet architectures, specifically on LeNet-300-100 with MNIST dataset. However, it produces performance that is comparable with that of LeNet-5 when compared to similar compression frameworks. The performance of the model can be further accelerated with execution in GPU architectures.


## 5. Conclusion

In this research work, we have proposed a new compression pipeline, DeepCompNet, venturing novel compression strategies for neural network compression. The novelty of this proposed framework relies on the use of z-score for weight pruning and robust density-based clustering DBSCAN in weight sharing. The major challenge of our work is finding the optimal value for the parameter Eps (ε) of DBSCAN algorithm and it was found to be architecture-specific. The proposed model is experimented with LeNet architectures using the MNIST and CIFAR-10 datasets, and the results demonstrate comparable compression performance with recent similar works without compromising the accuracy. Furthermore, the pruning process using z-score is simple to implement and hence will be a feasible framework for deployment in resource-constrained devices. The proposed compression framework is well suited for LeNet architectures. Our future research directions would be fine-tuning the DeepCompNet for other CNN and RNN architectures with different datasets. Furthermore, the speed of the inference model will be expedited using parallel architectures.



---

*Source: 2213273-2022-02-22.xml*