Autoselection of the Ensemble of Convolutional Neural Networks with
  Second-Order Cone Programming
Ensemble techniques are frequently encountered in machine learning and
engineering problems since the method combines different models and produces an
optimal predictive solution. The ensemble concept can be adapted to deep
learning models to provide robustness and reliability. Due to the growth of the
models in deep learning, using ensemble pruning is highly important to deal
with computational complexity. Hence, this study proposes a mathematical model
which prunes the ensemble of Convolutional Neural Networks (CNN) consisting of
different depths and layers that maximizes accuracy and diversity
simultaneously with a sparse second order conic optimization model. The
proposed model is tested on CIFAR-10, CIFAR-100 and MNIST data sets which gives
promising results while reducing the complexity of models, significantly.
Buse Çisil Güldoğuş, Abdullah Nazhat Abdullah, Muhammad Ammar Ali, Süreyya Özöğür-Akyüz
# Autoselection of the Ensemble of Convolutional Neural Networks with Second-Order Cone Programming

###### Abstract

Ensemble techniques are frequently encountered in machine learning and engineering problems since the method combines different models and produces an optimal predictive solution. The ensemble concept can be adapted to deep learning models to provide robustness and reliability. Due to the growth of the models in deep learning, using ensemble pruning is highly important to deal with computational complexity. Hence, this study proposes a mathematical model which prunes the ensemble of Convolutional Neural Networks (CNN) consisting of different depths and layers that maximizes accuracy and diversity simultaneously with a sparse second order conic optimization model. The proposed model is tested on CIFAR-10, CIFAR-100 and MNIST data sets which gives promising results while reducing the complexity of models, significantly.

keywords: pruning, socp, dnn, ensemble, optimization +
## 1 Introduction

Machine learning has made great progress in the last few years due to advances in the use of Deep Neural Networks (DNN), but many of the proposed neural architectures come with high computational and memory requirements Blalock et al. (2020). These demands increase the cost of training and deploying these architectures, and constrain the spectrum of devices that they can be used on.

Although deep learning has been very promising in many areas in terms of technology in recent years, it has some problems that need improvement. Even though deep learning can distinguish changes and subtle differences in data with interconnected neural networks, it makes it very difficult to define hyperparameters and determine their values before training the data. For this reason, different pruning methods have been proposed in the literature to reduce the parameters of convolutional networks Han et al. (2016); Hanson and Pratt (1988); LeCun and Cortes (2010); Strom (1997).

The common problem of deep learning and pruning algorithms that have been studied in recent years is the decision of the pruning percentage with the heuristic approach at the pruning stage, making the success percentage of the deep learning algorithm dependent on the pruning parameter. On the other hand, the optimization models proposed with zero-norm penalty to ensure sparsity ignore the diversity of the layers as they only take into account the percentage of success. The combination of the layers that are close to each other does not increase the percentage of accuracy.

As the primal example of DNNs, Convolutional Neural Networks (CNNs) are feed-forward architectures originally proposed to perform image processing tasks, Li et al. (2021) but they offered such high versatility and capacity that allowed them to be used in many other tasks including time series prediction, signal identification and natural language processing. Inspired by a biological visual perceptron that displays local receptive fields Goodfellow et al. (2016), a CNN uses learnable kernels to extract the relevant features at each processing
level. This provides the advantage of local processing of information and weight sharing. Additionally, the use of the pooling mechanism allows the data to be down-sampled and the features to be invariant representations of previous features.

Recently, a great deal of attention has been paid to obtain and train compact CNNs with the effects of pruning Wen et al. (2016); Zhou et al. (2016). Generally, pruning techniques differ from each other in the choice of structure, evaluation, scheduling, and fine-tuning Blalock et al. (2020). However, tuning these choices according to its costs and requirements, the network should be pruned. This is a systematic reduction in neural network parameters while aiming to maintain a performance profile comparable to the original architecture Blalock et al. (2020). Pruning of parameters in neural networks has been used to reduce the complexity of the models and prevent overfitting. Different methods on pruning in deep neural networks are proposed in the literature such as; Biased Weight Decay Hanson and Pratt (1988), Optimal Brain Damage LeCun et al. (1989) and Optimal Brain Surgeon Hassibi and Stork (1992). These aim to identify redundant parameters represented by connections within architectures and perform pruning by removing such redundancies Srinivas and Babu (2015); Han et al. (2016). In another study, a new layer-based pruning technique was proposed for deep neural networks where the parameters of each layer are pruned independently according to the second-order derivatives of a layer-based error function with respect to the relevant parameters Dong et al. (2017). Poor estimation performance is observed after pruning is limited to a linear combination of reconstructed errors occurring in each layer Dong et al. (2017). Some pruning techniques, such as unstructured pruning, work on individual parameters that induce sparsity while the memory footprint of the architecture reduces although there is not any speed advantage. Other techniques work on groups of parameters, where a neuron filter layer is considered as a separate target for the algorithm, thus provides the ability to take advantage of existing computational hardware Li et al. (2016).

Evaluation of pruned parameters can be based on relevance to training
metrics, absolute value, activation, and contribution of gradients Blalock et al. (2020). The architecture can be considered and evaluated as a whole Lee et al. (2019); Frankle and Carbin (2019), while parameters can be scored locally with reference to a small group of closely related groups of networks Han et al. (2016). Iterative pruning is performed by considering a subset of the architecture Han et al. (2016) and the speed of the pruning algorithm varies in a single step process Liu et al. (2019). Changing the pruning rate according to a certain rule have also been tried and implemented in the literature Gale et al. (2019). After applying the pruning algorithm, some techniques continued to use the same training weights; while the reduced architecture obtained in the studies was retrained to a certain state Frankle and Carbin (2019) or initialized and restarted from the initial state Liu et al. (2019).

Deep Ensembling techniques increase reliability of DNNs as multiple diverse models are combined into a stronger model Fort et al. (2019). It was shown that members of the deep ensemble models provide different predictions on the same input increasing diversity Garipov et al. (2018) and providing more calibrated probabilities Lakshminarayanan et al. (2017). In one of the recent studies, ensemble technique is chosen to increase the complexity by training end-to-end two EfficientNet-b0 models with bagging. Adaptive ensemble technique is used by fine-tuning within a trainable combination layer which outperforms different studies for widely known datasets such as CIFAR-10 and CIFAR-100 Bruno et al. (2022). Since pre-trained models boosts efficiency while simplifying the hyperparameter tuning, increasing the performance on these datasets are achieved with the help of transfer learning and pre-training Kolesnikov et al. (2020); Sun et al. (2017). Researchers accelerated CNNs but get lower performance metrics on CIFAR-100. One of these techniques is FATNET algorithm where high resolution kernels are used for classification while reducing the number of trainable parameters based on Fourier transform Ibadulla et al. (2022).

Ensemble pruning methods are used to reduce the computational complexity of ensemble models, and remove the duplicate models existing in the ensemble. Finding a small subset of classifiers that perform equivalent to a boosted ensem
ble is an NP-hard problem Tamon & Xiang (2000). Search based methods can be used to select an ensemble as an alternative. These methods conduct a search in the ensemble space and evaluate performance of various subsets of classifiers Sagi & Rokach (2018). Deep learning can actually be thought as multi-layer artificial neural networks, which is an example of ensemble learning. The overall percentage of success for ensemble learning is proportional to the percentage of average accuracy of the ensemble and the diversity of each learner within the ensemble. However, the percentage of accuracy and diversity have trade-offs among themselves. In other words, an increase in the percentage of accuracy within the community causes a decrease in diversity, which means redundant merge of similar layers. It has been shown that a pruning problem can be reframed to a quadratic integer problem for classification to seek a subset that optimizes accuracy-diversity trade-off using a semi-definite programming technique Zhang et al. (2006). In the vein of that research, multiple optimization models have been proposed to utilize the quadratic nature of pruning problems.

Sparse problem minimization and low-order approximation techniques have recently been used in numerous fields such as computer vision, machine learning, telecommunications, and more Quach et al. (2017). In such problems, including zero-norm corresponds to sparsity which makes the objective function non-convex in the optimization problem. For this reason, different relaxation techniques have been proposed in the optimization literature for non-convex objective functions. For class of a non-convex quadratic constrained problem, SDP relaxation techniques have been developed based on the difference of two convex functions (Difference of Convex - DC) decomposition strategy Zheng et al. (2011); Ozogur-Akyuz et al. (2020). However, since SDP algorithms for high-dimensional problems are slow and occupy a lot of memory, SDP algorithms have been relaxed into quadratic conic problems.

Second-Order Cone programming (SOCP) is a problem-solving class that lies between linear (LP) or quadratic programming (QP) and semi-definitive programming (SDP). Like LP and SDP, SOCPs can be solved efficiently with primal dual interior-point methods Potra & Wright (2000). Also, various en
gineering problems can be formulated as quadratic conic problems Lobo et al. (1998). In the literature, new convex relaxations are suggested for non-convex quadratically constrained quadratic programming (QCQP) problems related to this issue. Since basic semidefinite programming relaxation is often too loose for general QCQP, recent studies have focused on enhancing convex relaxations using valid linear or SOC inequalities. Valid second-order cone constraints were created for the non-convex QCQP and the duality difference was reduced by using these valid constraints Jiang & Li (2019). In addition, a branch and bound algorithm has been developed in the literature to solve continuous optimization problems in which a non-convex objective function is minimized under non-convex inequality constraints that satisfy certain solvability assumptions Beck & Pan (2017).

In this study, we propose a novel optimization model to prune the ensemble of CNNs with a Second-Order Cone Programming (SOCP) model. The proposed optimization model selects the best subset of models in the ensemble of CNNs by optimizing the accuracy-diversity trade-off while reducing the number of models and computational complexity. In the following chapters; definition of the loss function and relaxations for SOCP model will be introduced in Section 2, developing the ensemble of CNNs with hardware, software specifications, datasets and results will be given in Section 3 and lastly, the conclusions and future work will be mentioned in Section 4, respectively.

### Contribution of The Study

The contributions of the proposed study are listed as follows;

* One of the unique values that this study will add to the literature is the fact that the parameter called the pruning percentage, which will meet the needs of the deep learning literature, will be directly obtained by the proposed second-order conical optimization model.
* Another important original value will be a solution to the ignorance of the diversity criterion in the literature for pruning deep learning networks
only on the basis of accuracy performance. The objective function in the proposed optimization model simultaneously optimizes the accuracy and diversity criteria by pruning the ensemble of CNNs.
* Since SOCP models gives more successful and faster results than the other sparse optimization models. Hence, the number of models in the ensemble of CNNs will be reduced significantly by using the proposed SOCP model.

## 2 Methods and Materials

Suppose that in a system consisting of \(M\) binary classifiers where \(i_{th}\) classifier calculates the probability that a selected sample belongs to Class 1, as \(f_{i}^{1}\). In this system, to find a consensus over all classifiers a weighted majority within the ensemble can be defined as Polikar (2009):

\[f_{ens}=\sum_{i=0}^{M-1}\omega_{i}f_{i}^{1}. \tag{1}\]

In the Equation (1), \(\omega_{i}\) refers to weights which express the success of the classifier and these \(\omega_{i}\) values are determined through the optimization model that will be introduced next in Equation (2). If we denote the output distributions of the classifiers with \(p_{i}\), \(f_{gt}\in\{0,1\}\) where \(f_{gt}\) is the ground truth, we can define the loss function of the ensemble as follows:

\[L_{ens}\left(f\right)=\alpha\left(f_{ens}-f_{gt}\right)^{2}+\left(1-\alpha \right)\left(1-\left(H\left(\sum_{i=0}^{M-1}\omega_{i}p_{i}\right)-\sum_{i=0} ^{M-1}\omega_{i}H(p_{i})\right)\right). \tag{2}\]

In Equation (2), the first term defines the error, and the second term represents \(\left(1-\text{diversity}\right)\). The minimization of \(L_{ens}\) is maximization of accuracy and diversity while the trade-off between these two terms is determined by \(\alpha\). The Equation (2) can be rewritten for multi-class classification problems where \(C\) is the number of classes and \(f_{gt}\in\{0,1\}^{C}\) represents the correct classification
vector:

\[\begin{split} L_{ens}=\alpha\sum_{j=0}^{C-1}\frac{\left(f_{ens,j}-f _{gt,j}\right)^{2}}{C}+\\ (1-\alpha)\left(1-\frac{\sum_{j=0}^{C-1}\left(H\left(\sum_{i=0}^{M -1}\omega_{i}p_{i,j}\right)-\sum_{i=0}^{M-1}\omega_{i}H\left(p_{i,j}\right) \right)}{C}\right).\end{split} \tag{3}\]

Here, the first term refers to the accuracy (quality) while the second term refers to the \((1-\text{diversity})\) defined by the Jensen Shannon Entropy function (\(H(x)=-x\log x\)). The hyperparameter \(\alpha\) provides the trade-off between accuracy and diversity terms. Additional information for the convex form of Shannon Entropy can be found in (A). Thus, ensemble pruning model which optimizes accuracy and diversity can be written as;

\[\min_{\omega}\quad L(\omega;\alpha) \tag{4}\]

where \(\alpha\) is determined through cross validation. The solution of the Equation (4) determines weights for each model in the ensemble. In order to obtain sparse weights, we introduced a regularization term:

\[\min_{\omega}\quad L(\omega;\alpha)+\lambda\|\omega\|_{0}. \tag{5}\]

The Equation (5) can be written in a more generalized form:

\[\min_{x}f(x)+\lambda\|x\|_{0}. \tag{6}\]

The \(f(x)\) used in this Equation 6 is a convex quadratic function as using the Shannon Entropy function above in convex form where conceptualization is given in A. In the Equation 6, \(\|x\|_{0}\) is the zero-norm for sparsity and \(\lambda\) is defined as regularization term. Since the proposed model will be applied to highly correlated and large ensemble of CNNs, a slightest change within the dataset will cause a large error which is called overfitting. In order to avoid this problem, memory usage and model size are reduced by applying regularization term \(\lambda\) to the problem. The zero-norm \(\|x\|_{0}\) is preferred to ensure sparsity and
to penalize the number of non-zero entries of the coefficient vector. Here, the regularization term reflects non-zero inputs in the coefficient vector, at which quantity is usually the zero-norm of the vector. However, it is not a valid norm to use since zero-norm is not differentiable and the best convex approach for \(\|x\|_{0}\) is \(\|x\|_{1}\) which is convex Ramirez et al. (2013). Thus, the \(\|x\|_{0}\) norm is relaxed by using the \(\|x\|_{1}\) norm as the best approximation and the Equation 6 can be rewritten as:

\[\min_{x}f(x)+\lambda\|x\|_{1}, \tag{7}\]

where the minimization problem becomes a convex quadratic problem. The Equation (7) can be written as a SOCP problem by algebraic reformulations as follows:

\[\|x\|_{1}=\sum_{i=1}^{n}|x_{i}|\leq u,\]

where \((x_{i})\in K_{q}^{2}\), \(i=1,\ldots,n\) and \(u\) is defined to be an additional independent variable. Thus, by restricting the variable \(x\) into the cone and adding the additional constraint \(x\in K\), the Equation 7 becomes:

\[\min f(x)+\lambda u\] s.t. \[\sum_{i=1}^{n}|x_{i}|\leq u,\] \[x\in K.\]

A convex cone \(K\) such that \(K=K^{n_{1}}x\ldots xK^{n_{r}}xR^{n_{i}}\) and \(x_{i}\in K^{n},K^{n_{i}}\) is defined as a quadratic cone with dimension \(n_{i}\):

\[K^{n_{i}}=x_{i}=\begin{bmatrix}x_{i_{1}}\\ x_{i_{0}}\end{bmatrix}\in R^{n_{i}-1}xR:\|x_{i_{1}}\|_{2}\leq x_{i_{0}},\]

where \(\|x_{i_{1}}\|_{2}\) is the standard Euclidean norm. Based on relaxation techniques given in B, an additional term \(t=x^{T}Qx\) is introduced as:

\[\min t+c^{T}x\] s.t. \[x^{T}Qx\leq t,\]
and constraints are transformed as follows:

\[t\geq x^{T}Qx,\]

\[0\geq x^{T}Qx-t,\]

\[0\geq 4x^{T}Qx-4t,\]

\[0\geq 4x^{T}Qx+(1-t)^{2}-(1+t)^{2},\]

where \(t\geq 0\). Hence, \(1+t\geq 0\) can be modified to the problem as an additional constraint where \(t\geq 0\), \(x^{T}Qx\geq 0\), \(t\geq x^{T}Qx\) and since \(Q\) is positive definite, Cholesky factorization \(Q=LL^{T}\) can be applied Higham et al. (1990):

\[1+t\geq\sqrt{4x^{T}Qx+(1-t)^{2}},\ 1+t\ \geq 0\]

\[1+t\geq 2Lx1-t,1+t\ \geq 0\]

\[\begin{bmatrix}1+t\\ 2Lx\\ 1-t\end{bmatrix}\ \geq 0.\]

Accordingly, the Equation (6) can be defined as a Second-Order Cone problem:

\[\begin{array}{rl}\min&(\alpha)(t)+(1-\alpha)(c^{T}x)+\lambda u\\ \text{s.t.}&\begin{bmatrix}1+t\\ 2Lx\\ 1-t\end{bmatrix}\ \geq 0,\\ &\sum_{i=1}^{n}|x_{i}|\leq u,\\ &x\in K,\end{array} \tag{8}\]

where \(K=K^{n_{i}}\ldots K^{n_{r}}R^{n_{i}}\) when \(K^{n_{i}}\) is either a second-order cone or a rotated second-order cone \(K^{n_{i}}_{r}\) while \((x_{i})\in K^{2}_{q}\).

## 3 Experiments and Results

Traditionally, the generation of ensembles uses bootstrap aggregation (bagging) techniques, however it was highlighted that random initialization of deep
models in the ensemble is more effective than bagging approaches Lee et al. (2015). These ensembles of randomly initialized DNNs explore the function space of the architectures more extensively covering a wider span of the accuracy-diversity plane and strongly competing with methods such as weight averaging Izmailov et al. (2018) and local Gaussian approximations Nguyen-Tuong et al. (2009) that produce models with low diversity in the function space.

In this study, to achieve a statistical measure for the ensemble with the desired diversity and accuracy it was chosen to generate 300 CNN models with a process of random selection on the following design specifications:

* Convolution Blocks: Each convolution block consists of two convolution layers, one batch normalization layer, ReLU (Rectified Linear Unit) non-linearity activation function and one pooling layer. The range of blocks was randomly selected from 3 to 5.
* Convolution Filters: For each convolution layer the number of convolution filters is subject to randomization with a range of 32 to 256 with a step size of 32.
* Pooling Mechanism : Two pooling mechanisms are randomly chosen from average pooling and maximum pooling.
* Classification Head (Fully Connected layer) size: The fully connected (Dense) layer has its size (number of neurons) randomized in range of 20 to 100 with a step of 10.
* Drop Out Layer Percentage : The drop out regularization layer has its percentage randomized in range of 0 (no Drop Out) to 0.5 with a step of 0.1.
* Learning Rate: The optimizer learning rate was randomized in a range of \(1e^{-4}\) to \(1e^{-2}\) with logarithmic sampling.
* All CNN models are trained using ADAM optimizer and Sparse Categorical Cross-Entropy loss function.
### Hardware, Software and Data Sets

The available hardware system is a desktop personal computer with Intel i9-9900X CPU, 64 Gigabytes of system RAM, NVIDIA RTX 2080ti GPU with 12 Gigabytes of RAM and running an _UBUNTU_ 20 LTS operating system.

The utilized software platform is _Tensorflow-GPU_ (ver. 2.4.1) supported by CUDA toolkit (ver. 10.1.243) and cuDNN (ver. 7.6.5). All implementations performed on _Python_ environment (ver. 3.9.5).

Utilized data sets are of image classification tasks where three have been chosen with differences in input size and number of classes to verify the robustness of the proposed method to changes in data distribution. Datasets chosen are as follows:

* **CIFAR-10:** This data set consists of 60000 32x32 resolution colour images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images Krizhevsky et al. (a).
* **CIFAR-100:** As with CIFAR-10 the data set consists of 60000 32x32 resolution colour images, in 100 classes, resulting in 600 images per class. Similarly to CIFAR-10, There are 50000 training images and 10000 test images Krizhevsky et al. (b).
* **MNIST:** This data set contains 70000 28x28 resolution grey scale handwritten digits in 10 classes. There are 60000 training images and 10000 test images LeCun & Cortes (2010).

In the generation of the ensemble CNN models, the chosen data sets were utilized in the standard train, validation and test splits. The prediction classes and probabilities were recorded to constitute the data for the SOCP process. The samples of CIFAR-10 and CIFAR-100 is splitted as 40k for training and 10k for validation while MNIST data set is divided into 40k samples for training and 20k for validation. All test splits were comprised of 10k samples. The pseudo code of proposed ensemble pruning approach by SOCP modeling is given below in Algorithm 1.
In the Equation (8),\(\alpha\) and \(\lambda\) values are hyperparameters that need to be tuned by using cross-validation. The decided range for these parameters for each dataset was \(\alpha=(0,1;0,2;0,3;0,4;0,5)\) and for \(\lambda=(0,1;0,3;0,5;0,7;0,9)\) where the best values are determined by cross-validation. The solution of the SOCP model given by Equation (8) produces the weight for each model. After obtaining the sparse weights, the CNN models corresponding to non zero weights are chosen within the ensemble which lead to the subensemble. The final decision of the classification was performed by voting among the models in the subensemble. Several thresholds were experimented during validation which leads to different pruning extents (number of remaining models) and it was shown that favorable results were maintained as indicated in Table (1). Threshold values were decided on the training set for weights approaching zero in sparse solutions of the Equation (8). The predictions of the selected models are then combined through a Voting aggregation to obtain the final predictions that are used to get test scores. The sparse solution of the Equation (8), the
weight values closest to zero were taken and voting is performed by choosing CNN models in the corresponding ensemble. The voting corresponds to the weighted sum equation which is given in Equation (1) since the target values are class labels in the classification problem. The weighted sum can be taken directly in a regression problem.

In Table 1, the prediction values (test accuracy) of the model on the test set; number of models and threshold values on pruned and full ensemble models with voting are given. Table 2 shows maximum accuracy estimation (Max. Accuracy score on test set), average accuracy estimation (Avg. Accuracy score on test set) and minimum accuracy estimation of pruned ensemble models and full ensemble models without using the voting method. The resulting 56 pruned models for CIFAR-10, 98 pruned models for CIFAR-100 and 170 pruned models for MNIST performed close to performance of full models which is 300 and it can be seen that pruned models are more advantageous in terms of time and complexity than unpruned models.
## 4 Conclusions and Future Work

This study aims to develop a mathematical model which prunes the ensemble of CNNs which are in response to the need in the literature with sparse SOCP. The strength of this paper is improving the performance and decreasing the complexity of the ensemble of CNNs with pruning. An important part to be considered in modeling the pruning algorithm is the accuracy performance of the networks at different depths which will be randomly generated and the richness of diversity among each other. However, there is a trade off between these two terms, in other words, the diversity is compromised as the percentage of accuracy increases. The mathematical model which is developed in this study is the pruning algorithm that keeps this trade off at the optimum level. The proposed pruning algorithm is a generic algorithm by being independent of the domain of the data set. Success rates are compared of pruned and full ensemble models by applying them in different areas of data sets. It has been observed
that the difference between experiments is around 2% and it can be said that the system is robust. Since the number of models are reduced significantly, similar or better accuracy scores are obtained in all data sets.

Recent studies in the literature Bruno et al. (2022); Kolesnikov et al. (2020); Sun et al. (2017) leads to the conclusion that the use of pre-trained models and transfer learning increases the performance of the model and ensembling techniques outperform other state of the art models. For this reason, it is planned to test the SOCP model on an ensemble that will be created by using the models in the literature instead of the ensemble we randomly generated as a future work.
