HCE: Improving Performance and Efficiency with Heterogeneously
  Compressed Neural Network Ensemble
Ensemble learning has gain attention in resent deep learning research as a
way to further boost the accuracy and generalizability of deep neural network
(DNN) models. Recent ensemble training method explores different training
algorithms or settings on multiple sub-models with the same model architecture,
which lead to significant burden on memory and computation cost of the ensemble
model. Meanwhile, the heurtsically induced diversity may not lead to
significant performance gain. We propose a new prespective on exploring the
intrinsic diversity within a model architecture to build efficient DNN
ensemble. We make an intriguing observation that pruning and quantization,
while both leading to efficient model architecture at the cost of small
accuracy drop, leads to distinct behavior in the decision boundary. To this
end, we propose Heterogeneously Compressed Ensemble (HCE), where we build an
efficient ensemble with the pruned and quantized variants from a pretrained DNN
model. An diversity-aware training objective is proposed to further boost the
performance of the HCE ensemble. Experiemnt result shows that HCE achieves
significant improvement in the efficiency-accuracy tradeoff comparing to both
traditional DNN ensemble training methods and previous model compression
methods.
Jingchi Zhang, Huanrui Yang, Hai Li
# HCE: Improving Performance and Efficiency with Heterogeneously Compressed Neural Network Ensemble

###### Abstract

Ensemble learning has gain attention in recent deep learning research as a way to further boost the accuracy and generalizability of deep neural network (DNN) models. Recent ensemble training method explores different training algorithms or settings on multiple sub-models with the same model architecture, which lead to significant burden on memory and computation cost of the ensemble model. Meanwhile, the heuristically induced diversity may not lead to significant performance gain. We propose a new respective on exploring the intrinsic diversity within a model architecture to build efficient DNN ensemble. We make an intriguing observation that pruning and quantization, while both leading to efficient model architecture at the cost of small accuracy drop, leads to distinct behavior in the decision boundary. To this end, we propose Heterogeneously Compressed Ensemble (HCE), where we build an efficient ensemble with the pruned and quantized variants from a pretrained DNN model. An diversity-aware training objective is proposed to further boost the performance of the HCE ensemble. Experiemnt result shows that HCE achieves significant improvement in the efficiency-accuracy tradeoff comparing to both traditional DNN ensemble training methods and previous model compression methods.

 Ensemble, model compression, efficient neural network

## I Introduction

Ensemble learning has been widely used to improve the generalization performance of machine learning algorithms by combining multiple diverse weak classifiers [1, 2, 3]. An ensemble achieves better accuracy when its sub-models are diverse (i.e. make different errors). Previous deep ensemble methods induce diversity by training multiple DNN models with the same model architecture but different weight initialization and training data [2, 4, 5, 6]. However, as the performance and size of DNN models increase dramatically, heuristically ensemble repeated model architecture brought limited performance improvement but heavy computation redundancy. This raises a intriguing question:

_Can we build efficient and accurate DNN ensemble while exploring the intrinsic diversity within a pre-trained model?_

Previous exploration in model compression unveils diverse methods to induce efficiency, notably pruning and quantization. Quantization aims to convert floating-point parameters into low precision fixed-point representation [7, 8], whereas pruning aims to remove redundant parameters or structures that have little impact on the accuracy from the model architecture [9, 10]. Both methods can lead to significant reduction in model size and computation cost with a small accuracy drop. In this paper, we make an inspiring discovery that starting from the same pretrained model, quantization and pruning lead to diverse outcome in the decision region: Quantization largely retains (even increase) the margin in decision region, but lead to unsmooth decision boundary due to the discrete representation; Pruning on the other hand retains smoothness of the boundary, but has smaller margin and worse generalizability due to the removal of learnt features. The intrinsic diversity of pruning and quantization can lead to a diverse ensemble with efficient architecture.

Inspired by the analysis above, we propose Heterogeneously Compressed Ensemble (HCE) to improve both performance and efficiency of DNN ensembles. We construct HCE as an ensemble of pruned and quantized variants of a pretrained DNN model, which enables us to utilize the intrinsic diversity brought by the heterogeneous model compression methods. Furthermore, we propose a novel diversity-aware model compression method to enable further diversity boost between the compressed variants, therefore improving ensemble performance. Experiment results show that by assembling specially trained sub-models, higher accuracy can be achieved while maintain low model size and computational cost.

Figure 1 shows the result of HCE compared with other SOTA structure pruning methods, including traditional filter pruning [11] (PF), channel pruning [12] (CP), L1 norm based method (L1), Taylor expansion [10] (TE) and KL-divergence metric [13] (KL). In this case, HCE uses uniform quantization and filter pruning [11]. The model size of HCE is the sum of both compressed sub-models. As shown, HCE achieves better accuracy than the original baseline model and other SOTA structural pruning methods under the same model size. We also include a conventional deep ensemble method that trains two full ResNet56 with different initialization. Result shows that HCE achieves comparable accuracy with half of the size.

To the best of our knowledge, HCE is the first work to build deep ensemble with heterogeneous model compression techniques. We make following contributions:

* We propose HCE, a novel efficient DNN ensemble train
ing method that utilizes and enhances the intrinsic diversity between heterogeneously compressed sub-models.
* We unveil the intrinsic difference between pruned and quantized model via the analysis of decision regions.
* We propose a diversity-aware knowledge distillation objective for compressed sub-model that will enable higher pruning rate and diversity in sub-model.
* We perform extensive experiment on CIFAR-10 and ImageNet, where we show HCE achieves better efficiency-accuracy tradeoff than SOTA model compression methods and deep ensemble methods.

The rest of the paper is organized as follows. We first provide background and related work on ensemble and model compression in Sec. II. Then we introduce our decision region visualization and analysis method and training procedure for HCE in Sec. III. In Sec. IV we discuss the experiment result and show effectiveness of HCE.

## II Related work

### _Ensemble_

Ensemble learning has been widely used to improve the performance of machine learning models. By combining the good performance of DNN models and the improved generalization ability from ensemble method, deep ensemble learning models generally show better performance compared to both traditional ensemble models and single DNN model.

Ensemble models can be broadly categorised into homogeneous and heterogeneous ensemble, based on if each sub-model within the ensemble takes the same model architecture or not. In homogeneous ensembles, diversity is induced in the training process since all the model architectures are identical. For neural networks, training multiple sub-models with different initialization is proved to be an effective way to induce diversity [4, 5]. Also, some works use specially designed diversity training objective to increase robustness against adversarial attacks [14]. However, current DNN models have large model size and high training and inference costs, so that training multiple independent models is an inefficient option [15]. Some works have been done to solve this problem [16] but it is still challenging to train multiple DNN sub-models for ensemble since too many parameters and hyper-parameters need to be tuned and optimized.

On the other hand, heterogeneous ensemble methods show the edge of lower computational cost and higher diversity. Some studies used DNN models combined with traditional models, such as support vector machine (SVM) or random forest (RF), to lower computation and increase diversities [17]. By using different data subsets, model architectures and fusion strategy, heterogeneous ensemble will introduce more diversity and hence show better generalization performance.

Our proposed method tries to take advantage of both homogeneous and heterogeneous ensemble. We utilize multiple DNN models for their good performance as in homogeneous ensemble, meanwhile introducing intrinsic model architecture diversity in sub-models via heterogeneous compression. Also, we keep sub-models in small size while introduce diverse model architecture for better ensemble generalization ability.

### _Model Compression_

Model compression for DNNs have been widely used to accelerate models on resource-limited devices. Two popular methods are pruning and quantization.

Neural network pruning aims to zero out redundant parameters to reduce both model size and computation cost. Generally it can be categorized into 1) unstructured pruning and 2) structured pruning. Unstructured pruning can achieve high sparse ration with negligible accuracy drop [18, 19, 20, 21, 22, 23]. However, unstructured pruning can hardly bring actual speedup on hardware because of the irregular non-zero data structure. On the other hand, coarse-gained structured pruning can benefit real-life hardware inference such as filter pruning [9] and channel pruning [11]. Although structured pruning can generate hardware-friendly weight structures, it cannot achieve relatively high sparse ratio compared to unstructured pruning.

Quantization is another common and effective way to compress the deep learning models. It reduces the DNN model size and lower computation cost by replacing the floating point weights with low precision fixed-point data. Common quantization methods including directly apply uniform quantizers [24, 25], quantization-aware fine-tuning [26] and mixed-precision quantization [7, 8, 27]. Quantization can largely decrease DNN's arithmetic intensity but still cause significant accuracy degradation for ultra-low data precision.

Our work explores the intrinsic diversity in the compressed model decision boundary induced by different compression methods. HCE utilizes the diversity between pruned and quantized model to build efficient ensemble, and further improves the ensemble performance with a diversity-aware sub-model training objective.

## III Method

In this section, we will first analysis the diversity of heterogeneously compressed DNN models by visualizing the

Figure 1: Comparison of HCE with baselines and other model compression methods on ResNet56, CIFAR-10. Model size ratio denotes the size of the pruned model compared to the 32bit ResNet56. Size of HCE is calculated by the sum of all sub-models in ensemble.
decision region. Then we propose the HCE architecture and training scheme, which is an efficient way to produce highly-compressed sub-models for deep ensemble while guarantee high diversity within each individual sub-model. We visualize the improvement on sub-model diversity and ensemble decision regions brought by HCE in the end.

### _Decision Region Visualization_

We first illustrate how heterogeneously compressed DNN models learn different representations in the feature space. Figure 2 shows how decision region changes in the quantized and pruned models when the quantization precision and the sparsity varies. We first trained a 32-bit ResNet56 model on CIFAR-10 as baseline. For Figure 2(a), we generate a series of quantized models, 5-bit, 4-bit and 3-bit, progressively using post-training uniform quantization method. Also for Figure 2(b), We generate a series of structure pruned models with 90%, 70%, 40% and 10% size ratio using filter pruning [11]. No finetuning is performed after the compression. For all the subplots in each figure, we plot the decision boundaries in the vicinity of the same testing data point and with the same scale on a 2-D plane span by two random vectors.

Figure 2(a) shows that when bit precision decreases, the decision region grows larger correspondingly while the decision boundaries become unsmooth. In detail, the top left figure in 2(a) is the decision region of the pre-trained baseline 32-bit ResNet56 model. When quantize the model into 5-bit, the decision region enlarges and the surface gets larger and rougher compared to the baseline. This trend follows when bit precision further decreases to 4-bit and 3-bit. One explanation for this decision region change is, since we quantize both weight and activation parameters in the model, the output feature of each layer becomes inaccurate and sensitive to input disturbs. The quantized activation makes the output feature more discrete so that the decision region may vary a lot when there is small perturbation on input. In fact, the decision region does not expand after quantized but get sensitive to input disturbs. However, with quantized activation layers, the output feature falls into discrete spaces. That is why the decision boundary gets unsmooth when data precision decrease.

Unlike the quantized, the pruned case shows the opposite phenomenon. Figure 2(b) shows the trend of decision region when the sparisty increases in the model. In this case, we use structure pruning method to prune the filter inside the baseline model. As is shown in Figure 2(b), when sparsity level increases, i.e. size ratio decreases, the decision boundaries get smaller. This is because when structure pruning zeros out filters in the model, fewer features can be extracted to feature space. With fewer information extracted, the generalization ability of the DNN model decreases and so as the margin of decision boundary.

From above, we can infer that although compressed from the same baseline model, quantized and pruned models show great difference on feature representation in hyperspace. From generalization perspective, quantization and pruning both effect the sensitiveness of the DNN model. The difference is that quantization makes the decision boundary unsmooth and sensitive to perturbation and pruning decrease the generalization capability but the decision boundary remain smooth. This difference introduces different properties in quantization and pruned models. By applying different model compression methods, we can foster diversity in deep ensembles.

### _Training Method_

Based on previous discussion, we propose our novel HCE training scheme, that ensembles the quantized and pruned model to introduce more diversity while maintaining low computation cost. Our HCE training method is composed of four steps. As is shown in Figure 3, the HCE training algorithm is designed as follows: 1) Train the full-precision, full-size model O as baseline. 2) Quantize the baseline model and get low-precision model Q. 3) Iteratively prune a sparse model based on O and Q while training with our proposed ensemble-aware training object. 4) For inference, simply average the output of quantized model and pruned model. Here we propose to fix the quantized model while training the pruned model for accuracy improvement, because the discrete weight and activation representation in the quantized model may hinder the stability of the training process.

Specifically, the pruned model is trained with the object function in Equation (1).

\[\begin{split} Loss(S)=\alpha*L_{CE}(output(S))+\\ (1-\alpha)*L_{KL}(output(S),(output(O)-output(Q))\end{split} \tag{1}\]

The object function is inspired by Knowledge Distillation (KD) training. The first part is the cross entropy of the sparse model S. The latter part of the object function is the KL divergence between the output probability of the base model O and the quantized model Q. This part keeps the pruned model focus on the information that lost during the quantization. \(\alpha\) is a coefficient that controls the level of

Fig. 2: Decision region visualizations of quantized and pruned model of a ResNet56 trained on CIFAR-10. The vertical and horizontal axes are two random Rademacher vectors. The zero point represents a test data point. Same color indicates the predicated label. Decision region can be inferred from the shape of the pattern with the same color.
learning from the difference and directly from the training data. In detail, given a input \(x\), the base model would produce a score vector \(s^{O}(x)=[s^{O}_{1}(x),s^{O}_{2}(x),...,s^{O}_{K}(x)]\) and convert to probability by softmax: \(p^{O}_{k}(x)=\frac{e^{s^{\mathcal{L}_{k}^{O}(x)}}}{\sum_{j}e^{s^{O}_{j}(x)}}\). We also "soften" the probabilities using temperature scaling [28]:

\[p^{O}_{k}(x)=\frac{e^{s^{\mathcal{Q}_{k}^{O}(x)/\tau}}}{\sum_{j}e^{s^{O}_{j}(x) /\tau}} \tag{2}\]

where \(\tau>1\) is the temperature hyperparameter. Same as base model, quantized also generates a corresponding probability: \(p^{Q}_{k}(x)=\frac{e^{s^{\mathcal{Q}_{k}^{O}(x)/\tau}}}{\sum_{j}e^{s^{O}_{j}(x )/\tau}}\) and training sparse model has its own prediction \(p^{Q}_{k}(x)\). So the probability difference is \(p^{D}_{k}(x)=p^{O}_{k}(x)-p^{Q}_{k}(x)\) and the KL divergence loss is:

\[L_{KL}=-\tau^{2}\sum_{k}p^{D}_{k}(x)\log P^{S}_{k}(x) \tag{3}\]

Unlike training a student model from the teacher model in knowledge distillation, we try to force the pruned model to focus more on the prediction gap between the base model O and quantized model Q. Since quantized models often remain acceptable accuracy so that the gap between O and Q is limited. With less information to learn, the pruned model can achieve higher pruning rate.

The goal of our training objective in Equation (1) is to make the output of the ensembled models close to that of the original model. In other word, the pruning method is aware of the diverse ensemble training. The KL divergence push the sparse model to produce output logits \(output(S)\) similar to \(output(O)-output(Q)\). In this case, during the inference when ensembling the pruned model \(S\) and quantized model \(Q\), the output \(output(S)+output(Q)\) should be close to the output of the original model \(output(O)\). Our experiment results prove that performing iterative pruning with the proposed diversity-aware training objective can lead to very sparse sub-model that can still result in high ensemble accuracy.

It is worth to point out that our method has no limitations on the quantization or pruning methods. Our experiments will demonstrate that both the structural or unstructural pruning can be effective.

### _HCE Diversity Analysis_

To further analyse the effectiveness of our ensemble method, we look into the wrongly predicted labels of each individual sub-model. Still, We evaluate our method on ResNet56 model on the CIFAR-10 dataset. We first generated a 3-bit quantized model from the pretrained model and then trained a 60% pruned model filter pruning [11] with the HCE objective. As Shown in Figure 4, among 10,000 testcases, the baseline model have 590 error cases. The quantized submodel has 1,181 error cases and HCE pruned submodel has 654 error cases. However, among all error cases, only 401 cases are overlapped. The percentage of overlapped error cases in all error cases is \((E_{Q}\cup E_{S})/(E_{Q}\cap E_{S})=27.96\%\), which denotes that although quantized and pruned model are trained from the same pretrained model, they make very different error predictions, i.e. diversity. After ensemble, HCE produces similar accuracy as the baseline. 58.79% errors made by individual sub-model are corrected, including 90% of the errors made by quantized model alone. This indicates the proposed training objective is effective.

We also compare the decision boundaries of HCE under different situations in Figure 5. Figure 5(a) shows that, as we discussion above, the decision boundary of quantized model is unsmooth while that of pruned model has small margin. HCE can restore the behavior of the original model by

Figure 4: Venn figure of wrongly predicted images of ResNet56 on CIFAR-10. Numbers in the dash circles indicates the image wrongly classified by individual sub-model but corrected by the ensemble.

Figure 5: Decision region visualizations showing (a) Quantized and HCE both make correct prediction and (b) HCE corrects mispredicted labels from quantized model

Figure 3: training pipeline of HCE
ensembling two compressed model. Figure 5(b) shows the case where quantized model makes mistake while HCE corrects the predictions. As the quantized model is perturbed into a wrong prediciont, the smooth decision region of the pruned model enables the ensemble to achieve correct output. This show that our HCE can indeed introduce and make use of the diverse model compression methods and produce similar performance as the original full-precision model.

## IV Experiment Result

### _Setup_

We compare HCE with various model compression counterparts. The base ResNet is implemented following [29] and we used both ResNet20 and ResNet56 on CIFAR-10. On ImageNet we tried HCE with ResNet50 and MobileNetV2. We used conventional uniform quantization and filter pruning [11] for experiment but HCE can be extended on other model compression methods. We also conduct an ablation study on hyper-parameters \(\alpha\) mentioned in Section III-B. To make comparable estimation on the computation cost of quantized and sparse model, we use a unified notion of FLOPs. Since quantized model only requires fixed-point operations, we first calculated the bit operations (BOPs) for the quantized model, then convert it to an estimated FLOPs by dividing a scaling factor of 23, which is the number of fraction bits in a Float32 representation [30].

### _CIFAR-10 Result_

We first evaluate HCE on CIFAR-10 datasets and results are shown in Table I. The FLOPs of HCE is measured for both compressed sub-models in HCE. The quantized model in HCE is 3bit with accuracy of 88.19%. For large models like ResNet56, HCE can remove more than half FLOPs and achieve 93.56% accuracy, higher than other SOTA structured pruning methods. One important information is that, if we directly apply the PF method, the accuracy is 92.07% when FLOPs is 50%. But in our experiment, our pruning method is also PF combining with our training objective. By ensembling with a 3-bit model, the accuracy increases 1.5% with less FLOPs. The pruning method in HCE can be substituted with any other structured pruning method like DCF and SFP and HCE result can be better.

As for smaller model ResNet20, HCE still achieved best accuracy compared to all other counterparts. With 57% FLOPs, the ensemble accuracy can achieve 91.99%. The hyperparameter \(\alpha\) in training object is 0.2 and 0.4 individually.

### _ImageNet result_

For ImageNet dataset, we test our HCE on ResNet50 and MobileNetV2 and the result is shown in Table II. For ResNet50, HCE achieve highest accuracy compared to other popular structured pruning methods under similar FLOPs. We also try HCE on MobileNetV2. MobileNetV2 is a relative small and thin DNN model compared to ResNet50 so compress MobileNetV2 on ImageNet is not easy. We would like to see how HCE works on such small models. As is shown in Table II, HCE also achieves better performance under similar FLOPs.

However, in ImageNet experiments, \(\alpha\) is 0.3 on ResNet50 and 0.5 on MobileNetV2. We will further discuss this \(\alpha\) hyperparameter later.

### _Ablation study on \(alpha\)_

To study the effectiveness of the hyperparameter \(\alpha\) in sectionIII-B, we did a series experiment by tuning \(\alpha\). In this ablation study we apply HCE on ResNet20 on CIFAR-10. Different from above experiment setting, we applied L1 unstructured pruning in this case to demonstrate the extension ability of HCE. As is shown on Figure 6, on ResNet20 unstructured pruning case, \(\alpha\)=0.5 achieves higher accuracy than other \(\alpha\) values in most cases and seems to be superior than other values. Meanwhile \(\alpha\) =0.1 always produces lowest accuracy. However, on structured pruning of ResNet56 in section IV-B, \(\alpha\)=0.2 is the best choice. The explanation is that for our training objective 1, \(\alpha\) denotes the portion of HCE learning from the cross entropy of the input data while (1-\(\alpha\)) represents the learning from the difference between baseline and the quantized model. For large models, learning too much from the difference will cause the heavy overfitting and degrade the accuracy. But for small models like MobileNetV2 for ImageNet, overfitting will not occur when \(\alpha\) increases.

## V Conclusion

This work propose HCE, a novel scheme to build heterogeneous deep ensemble to improve the generalization and

\begin{table}
\begin{tabular}{c c c c} \hline \hline Model & Approach & Accuracy & FLOPs(G) \\ \hline ResNet50 & Baseline & 76.01 & 4.1 (100\%) \\  & DCP [32] & 74.95 & 1.8 (44.5\%) \\  & FPGM [34]. & 74.83 & 1.9 (46.5\%) \\  & AutoPrunter [36] & 74.76 & 2.0 (48.8\%) \\  & SFP [33] & 74.61 & 1.7 (41.8\%) \\  & **HCE(\(\alpha\)=0.3)** & **75.13** & 1.8 (44.7\%) \\ \hline MobileNetV2 & Baseline & 71.8 & 0.32 (100\%) \\  & AMC [31] & 70.80 & 0.22 (70.0\%) \\  & MetaPruning [37] & 71.2 & 0.23 (72.3\%) \\  & **HCE(\(\alpha\)=0.5)** & **71.35** & 0.23 (71.8\%) \\ \hline \hline \end{tabular}
\end{table}
Table II: HCE results on ImageNet

\begin{table}
\begin{tabular}{c c c c} \hline \hline Model & Approach & Accuracy & FLOPs(M) \\ \hline ResNet56 & Baseline & 93.80 & 126.8 (100\%) \\  & PF [11] & 92.07 & 63.4 (50.0\%) \\  & CP [12] & 91.80 & 63.4 (50.0\%) \\  & AMC [31]. & 91.90 & 63.4 (50.0\%) \\  & DCF [32] & 93.49 & 63.4 (50.0\%) \\  & SFP [33] & 93.35 & 59.6 (47.1\%) \\  & FPGM [34] & 93.49 & 59.6 (47.1\%) \\  & CCP [35] & 93.46 & 67.2 (53.0\%) \\  & **HCE(\(\alpha\)=0.2)** & **93.56** & 60.6 (47.8\%) \\ \hline ResNet20 & Baseline & 92.20 & 41.2 (100\%) \\  & SFP [33] & 90.83 & 23.9 (58.0\%) \\  & FPGM [34] & 91.99 & 19.0 (46.1\%) \\  & **HCE(\(\alpha\)=0.4)** & **92.35** & 23.4 (56.8\%) \\ \hline \hline \end{tabular}
\end{table}
Table I: HCE results on CIFAR-10
efficiency simultaneously. We also introduce a new method to illustrate the intrinsic diversity within compressed models and show that HCE can generate highly compressed but diverse sub-models. Both CIFAR-10 and Imagenet experiments show the effectiveness of HCE. We hope our work can bring new perspective on deep ensemble and help deploying ensembles on resource-limited devices.
