A density peak pruning method for fully convolutional neural networks for image segmentation
Through the pruning method that combines density peak clustering and zero activation rate, the convolutional neural network is lightweight, which solves the problem of large scale of convolutional neural network model and limited computing resources on edge devices, and achieves efficient image segmentation tasks. , and maintain high segmentation accuracy.
Patent Information
- Application Number
- CN202210257014.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-03-16
AI Technical Summary
Existing convolutional neural network models have problems such as complex structure, large storage overhead, and limited computing resources when deployed on edge node devices, making it difficult to achieve efficient image segmentation tasks.
A fully convolutional neural network lightweight pruning method based on density peak clustering is used to cluster the convolution kernels through the density peak clustering algorithm, and prune based on the zero activation rate value within the clustering result, combined with the weight value Parameters are retrained to achieve high-ratio compression of convolution kernels.
It effectively reduces the model size, alleviates the over-fitting problem, improves the feasibility of deploying the model on edge devices, while maintaining high segmentation accuracy and avoiding the problem of weight data distortion.
Smart Images

Figure CN114742997B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing and relates to a lightweight pruning method of a fully convolutional neural network based on density peak clustering for edge computing, which can be used for image segmentation technology based on deep learning and deployment in edge node devices. Background Art
[0002] While the Convolutional Neural Network (CNN) continues to improve the upper limit of computer vision task accuracy, the depth and size of its network structure are also increasing exponentially. To solve the problem of semantic image segmentation, Jonathan Long proposed a fully convolutional neural network (FCN) to classify images at the pixel level (Long, J., Shelhamer, E., & Darrell, T., 2015. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3431-3440.). Unlike the classic CNN, which uses a fully connected layer after the convolution layer to obtain a fixed-length feature vector for classification, FCN can accept input images of any size and use a deconvolution layer to upsample the feature map of the last convolution layer to restore it to the same size as the input image. Based on this method, FCN can generate a prediction for each pixel while retaining the spatial information in the original input image, and finally perform pixel-by-pixel classification on the upsampled feature map.
[0003] Although the convolutional neural network model has high accuracy and ideal effects in visual tasks, it also has disadvantages such as complex structure, high storage overhead, and high computing resources. Taking the typical convolutional neural network VGG16 as an example, its parameters amount to more than 130 million, the model occupies nearly 500MB of storage space, and an image recognition task requires more than 30 billion floating-point operations. However, due to the limited storage and computing resources of edge node devices, many deep learning models such as CNN are difficult to accurately and efficiently implement on the edge hardware platform, which has become an important topic of concern to industry, academia, and research. Since the convolutional layer structure of the FCN model is the same as that of VGG16, the FCN model often has a large number of redundant neurons, and the parameters that participate in the main calculation and affect the final result only account for a part of the total, which provides a theoretical basis for neural network compression. If reasonable compression methods can be used to compress neural network models, these models can be more widely deployed in many edge node devices.
[0004] From the perspective of data, model and hardware, there are two main methods to compress and accelerate models. One is to build a new lightweight network structure. For example, the Google team proposed a network model MobileNet for mobile terminals. With the help of depth-wise separable convolution (Depth-wise Separable Convolution) instead of traditional convolution, the number of network weights can be effectively reduced (Howard, AG, Zhu, M., Chen, B., Kalenichenko, D., Wang, W., Weyand, T., Andreetto, M. and Adam, H., 2017. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv: 1704.04861.). The other is to compress existing network models, involving pruning, quantization, low-rank factorization, knowledge distillation and other methods, among which pruning is the most commonly used neural network compression method.
[0005] Pruning is a model optimization technique that removes redundant neurons in a neural network. The pruned neural network runs faster and has lower network training costs. This technique is particularly critical when the model is lightweight. The study of neural network pruning methods began in the late 1980s and early 1990s. Hanson et al. proposed a magnitude-based pruning method that minimizes the number of hidden layer nodes by applying a weight decay related to the absolute value of each hidden layer node in the network (Hanson, S. and Pratt, L., 1988. Comparing biases for minimal network construction with back-propagation. Advances in neural information processing systems, pp. 177-185.). LeCun and Hassibi proposed the OBD (LeCun, Y., Denker, JS and Solla, SA, 1990. Optimal brain damage. Advances in neural information processing systems, pp. 598-605.) and OBS (Hassibi, B. and Stork, DG, 1993. Second order derivatives for network pruning: Optimal brain surgeon. Morgan Kaufmann, pp. 164-171.) methods respectively, which use the second order derivative of the loss function with respect to the weight to measure the importance of the network weights and then trim them.
[0006] In 2016, Hu et al. used the Average Percentage of Zeros (APoZ) to measure the importance of activation values, and removed minor weights according to the APoZ value calculated for each convolution kernel, thereby achieving pruning (Hu, H., Peng, R., Tai, YWand Tang, CK, 2016. Network trimming: A data-driven neuronpruning approach towards efficient deep architectures. arXiv preprint arXiv: 1607.03250.). The zero activation rate is the percentage of zero activation values of the convolution kernel, which means the ratio of the number of neurons with zero output in the feature map to the number of all neurons in the feature map after the convolution kernel of each convolution layer is activated by ReLU. The larger the zero activation value, the lower the activation rate of the convolution kernel, and the smaller the value, the higher the activation rate of the convolution kernel. The calculation rule is:
[0007]
[0008] In the formula, represents the zero activation rate value of the c-th channel in the i-th layer, N represents the total number of verification images, and M represents the number of elements in the c-th channel of the output feature map of the i-th layer. represents the value of the jth element in the output of the i-th layer and the c-th channel obtained based on the k-th verification image. f(·) is used to determine whether the function input value is 0.
[0009] Most pruning methods are irreversible processes of weight loss. If during the weight removal process, the potential laws of weight data can be reasonably mined and learned with the help of machine learning and other means, more accurate pruning results will be achieved. Taking clustering as an example, clustering is an unsupervised learning method used to divide a set into several clusters, and the similarity of samples within a cluster is high, and the similarity of samples between clusters is low. Among the many clustering algorithms, density peak clustering can divide data clusters of arbitrary distribution shapes according to the intrinsic distribution information of the data. It is a widely used clustering algorithm. In this algorithm, the density of the cluster center point is greater than the density of the surrounding neighbor points, and the distance between the cluster center point and the higher density point is relatively large. The process of the density peak clustering algorithm is as follows:
[0010] Step 1: Calculate the sample density based on the number of neighbor points within the specified radius:
[0011]
[0012] In the formula, ρ i represents the density of the i-th sample, r represents the radius, dij represents the distance between the i-th sample and the j-th sample, χ(·) is the number of sample points statistically distributed within the specified radius,
[0013] Step 2: Based on the sample density obtained in step 1, solve the cluster center distance of each sample:
[0014]
[0015] In the formula, δ i Represents the cluster center distance of the i-th sample;
[0016] Step 3: Select samples with relatively high cluster center distance and local density as cluster centers;
[0017] Step 4: Define ρ min , if the density of the sample is lower than ρ min , then it is an outlier and is classified into a single cluster;
[0018] Step 5: Assign samples other than outliers to the cluster represented by the cluster center closest to them. Summary of the invention
[0019] The technical problem to be solved by the present invention is to provide a density peak pruning method for a full convolutional neural network for edge computing. Pruning according to the APoZ value of the convolution kernel can be understood as starting from the numerical distribution angle of the convolution kernel and pruning according to the numerical characteristics. In order to consider the performance of the convolution kernel more comprehensively and prune the convolution kernel more effectively, in addition to considering the numerical angle of the convolution kernel, it is also necessary to consider the structural angle of the convolution kernel itself. In the same output channel, similar convolution kernels will collect image features from similar angles, which constitutes information redundancy. Therefore, the present invention designs a lightweight pruning method for clustering-based models from two perspectives: the numerical distribution characteristics of the convolution kernel and the structural characteristics of the convolution kernel itself. By using the density peak algorithm to cluster the convolution kernels of each convolution layer according to the output channel, and then pruning according to the APoZ value in each cluster for the clustering result to achieve high-ratio compression of the convolution kernel, the purpose of improving the model performance while ensuring the model accuracy is achieved, thereby improving the feasibility of deploying convolutional neural networks on lightweight devices such as edge nodes.
[0020] The specific technical solutions of the present invention are as follows:
[0021] A fully convolutional neural network density peak pruning method for image segmentation includes two parts: fully convolutional neural network density peak pruning and image segmentation.
[0022] (I) Density Peak Pruning of Fully Convolutional Neural Networks
[0023] The described full convolutional neural network density peak pruning method is divided into three steps: convolution kernel clustering based on density peak clustering, APoZ pruning within the convolution kernel cluster, and retraining of weight value parameters;
[0024] (1) Convolution kernel clustering based on density peak clustering
[0025] Let K = [k1, k2, ..., k n ] T , represents the convolution kernel corresponding to the i-th convolution layer in the convolutional neural network, where n represents the number of convolution kernels in the i-th layer, and k α ∈R h×w×d (α=1,2,...,n) represents the αth convolution kernel, h, w and d represent the height, width and depth of the i-th convolution kernel respectively.
[0026] K α Expanded into a one-dimensional convolution kernel vector, then k α '∈R s×1 , s = h × w × d, that is, s is the product of height, width, and depth. Then all convolution kernel vectors k' of the i-th layer are α Combined into a set:
[0027] K'=[k1',k'2,...,k' n ] (4)
[0028] Apply the density peak clustering algorithm to K'. Assuming that the convolution kernels are clustered into m clusters, the result is:
[0029] CL=CL1∪CL2∪...∪CL m (5)
[0030] In the formula, Represents the set of convolution kernels contained in cluster β after all convolution kernels in layer i are clustered, where α γ (γ=1,2,...,|CL β |) represents the corresponding convolution kernel index value in the cluster, |CL β | represents the number of convolution kernels contained in cluster β.
[0031] (2) APoZ pruning within a convolution kernel cluster
[0032] Calculate the zero activation rate of each convolution kernel in the i-th layer Since the number of convolution kernels in each cluster is different, the threshold within each cluster is defined according to the number of convolution kernels in each cluster. So that the proportion of convolution kernels pruned in each cluster is the same. Then traverse each cluster β. If CL β The zero activation rate of a convolution kernel is higher than the threshold Then it will be removed. The set of convolution kernels to be deleted in cluster β is:
[0033]
[0034] Therefore, the set of convolution kernels to be deleted selected in the i-th layer is:
[0035]
[0036] (3) Retraining of weight value parameters
[0037] The training set is used to retrain some parameters in the convolutional neural network. The set of convolution kernels waiting to be retrained is:
[0038]
[0039] After the parameter retraining is completed, the convolution layer completes a pruning process. At this time, if the number of remaining convolution kernels in this layer meets the compression ratio requirement, the i+1 layer of the full convolutional neural network will be pruned, otherwise the above process will be repeated.
[0040] (II) Image Segmentation
[0041] After all layers of the full convolutional neural network have been pruned, the lightweight operation of the network is completed; since the network has a small number of parameters, it can be deployed in embedded devices with limited hardware resources and used for edge devices to process image segmentation tasks; the present invention takes image data as input, and for each image input, the network will output a segmented image of equal size.
[0042] The beneficial effects of the present invention are in the following two aspects: First, the model parameters of the fully convolutional neural network are many, and the computational and storage overheads are large. Eliminating redundant convolution kernels can effectively achieve model scale compression and alleviate the model overfitting problem to a certain extent. Secondly, compared with the traditional zero activation rate pruning algorithm, the present invention starts from the numerical characteristics of the convolution kernel and the structural characteristics of the convolution kernel, and organically combines the zero activation rate with the density peak clustering algorithm to guide pruning, which effectively avoids the distortion of weight data caused by model compression, and can improve model performance while ensuring model accuracy. In summary, the present invention can facilitate the marginalization deployment of convolutional neural networks. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is an implementation flow chart of the present invention.
[0044] In the figure: ① Convolution kernel clustering based on density peak clustering; ② APoZ pruning within the convolution kernel cluster; ③ Weight value parameter retraining.
[0045] Figure 2 This is a workflow diagram of the pruning scheme for a fully convolutional neural network of the present invention. DETAILED DESCRIPTION
[0046] The specific implementation of the present invention is described in detail below in conjunction with the content of the invention and the accompanying drawings.
[0047] Figure 1 Taking the i-th layer of convolution kernel as an example, the implementation process of the present invention is described. Assume that the i-th layer of convolution kernel has n convolution kernels in total, and the weight values of all convolution kernels form a two-dimensional matrix K = [k1, k2, ..., k n ] T During clustering, the weight value vector k of each convolution kernel is α '∈R s×1 (α=1,2,...,n) is regarded as a single sample, and the n convolution kernel samples are clustered based on the density peak clustering algorithm. Assuming that the number of clusters obtained by clustering is m, the n convolution kernel samples will be divided into different clusters according to their distance from the cluster center. After clustering, the zero activation rate of each convolution kernel is calculated, and the threshold value is defined. The convolution kernels in different clusters are pruned, that is, the convolution kernels with APoZ values greater than the threshold are directly deleted. Finally, the weight value parameters of the convolution kernels that are not removed in the i-th layer are retrained.
[0048] Taking the classic dataset VOC2012 and the classic model FCN in the field of image segmentation as examples, the i-th convolutional layer of FCN is pruned as follows:
[0049] (1) Convolution kernel clustering based on density peak clustering
[0050] Let K = [k1, k2, ..., k n ] T , represents the convolution kernel corresponding to the i-th convolution layer in the convolutional neural network. Where n represents the number of convolution kernels in the i-th layer, and k α ∈R h×w×d (α=1,2,...,n) represents the αth convolution kernel, h, w and d represent the height, width and depth of the i-th convolution kernel (the number of channels of the input feature map of this layer). α Expanded into a one-dimensional convolution kernel vector, then k α '∈R s×1 , s = h × w × d, that is, s is the product of height, width, and depth. Then all convolution kernel vectors k' of the i-th layer are α Combined into a set:
[0051] K'=[k1',k'2,...,k' n ] (9)
[0052] Apply density peak clustering algorithm to K' to generate m clusters. Assume that the clustering result is:
[0053] CL=CL1∪CL2∪...∪CL m (10)
[0054] In the formula, Represents the set of convolution kernels contained in cluster β after all convolution kernels in layer i are clustered, where α γ (γ=1,2,...,|CL β |) represents the corresponding convolution kernel index value in the cluster, |CL β | represents the number of convolution kernels contained in cluster β.
[0055] (2) APoZ pruning within a convolution kernel cluster
[0056] Calculate the zero activation rate of each convolution kernel in the i-th layer Since the number of convolution kernels in each cluster is different, the threshold within each cluster is defined according to the number of convolution kernels in each cluster. So that the proportion of convolution kernels pruned in each cluster is the same. Then traverse each cluster β. If CL β The zero activation rate of a convolution kernel is higher than the threshold Then it will be removed. The set of convolution kernels to be deleted in cluster β is:
[0057]
[0058] Therefore, the set of convolution kernels to be deleted selected in the i-th layer is:
[0059]
[0060] (3) Retraining of weight value parameters
[0061] The training set is used to retrain some parameters in the full convolutional neural network. The parameter set to be retrained is:
[0062]
[0063] Put the retrained parameters back into the original network model, thus completing the pruning process of the i-th layer.
[0064] (4) Prune all convolutional layers of the FCN network according to the above single pruning process
[0065] The workflow of FCN model pruning is detailed in Figure 2 , and its specific operations are:
[0066] Step 1: Set the number i of the convolutional layer to be accessed to 1;
[0067] Step 2: Use the training set to train the full convolutional network parameters;
[0068] Step 3: Reorganize the weight value data of the i-th convolutional layer into a two-dimensional matrix K i ';
[0069] Step 4: Convolution kernel weight matrix K i 'Perform density peak clustering;
[0070] Step 5: Calculate the APoZ value of each convolution kernel in the cluster;
[0071] Step 6: Cut off the convolution kernels whose APoZ values are greater than the threshold;
[0072] Step 7: Pass the pruned convolutional layer parameters back to the original network;
[0073] Step 8: If the network parameter scale of this layer has reached the expected level, go to step 9; otherwise, return to step 2 directly;
[0074] Step 9: If all convolutional layers in the network have been pruned, go to step 10; otherwise, set the number i of the convolutional layer to be accessed to i+1 and return to step 2;
[0075] Step 10: Save all convolution kernel parameters of the network and conclude that the network model is a lightweight network model.
[0076] Three classic image segmentation data sets are selected in the experiment to verify the segmentation accuracy of the lightweight network model obtained by the present invention. The data set description is shown in Table 1. The pruning rates are 10%, 30%, and 50% respectively.
[0077] Table 1 Dataset description
[0078]
[0079] The experiment compares three methods, namely: L1 norm pruning method based on convolution kernel weight parameter value (L1), pruning method based on zero activation rate of convolution kernel (APoZ), and zero activation rate pruning method based on density peak clustering (APoZ-C) proposed by this invention. The experiment uses global pixel accuracy (Global Accuracy) and various average intersection over union ratios (MeanIoU) to measure the effect of image segmentation. Table 2 shows the average IoU index and global accuracy results of the three network structures on the data set, and the best result is shown in bold.
[0080] Table 2 Image segmentation evaluation indicators of three networks
[0081]
[0082]
[0083] As can be seen from Table 2, whether in terms of global pixel accuracy results or average intersection-over-union ratio indicators, the method of the present invention has better performance among all the compared methods. When the pruning rate is 10%, the segmentation accuracy exceeds the original network structure because the model eliminates the overfitting problem of the full convolutional neural network to a certain extent. The method of the present invention evaluates the numerical distribution characteristics of the weight value itself from a positive perspective based on density peak clustering, thereby restricting the pruning process and avoiding excessive pruning of certain clusters. It can maintain the spatial distribution structure of the convolution kernel as much as possible, thereby ensuring the diversity of feature extraction after pruning. Experiments have verified that the method of the present invention can still maintain a relatively good segmentation accuracy after high-proportion compression of the full convolutional neural network model.
Claims
1. A fully convolutional neural network density peak pruning method for image segmentation, including two parts: fully convolutional neural network density peak pruning and image segmentation, characterized in that: (I) Density Peak Pruning of Fully Convolutional Neural Networks The described full convolutional neural network density peak pruning method is divided into three steps: convolution kernel clustering based on density peak clustering, APoZ pruning within the convolution kernel cluster, and retraining of weight value parameters; (1) Convolution kernel clustering based on density peak clustering Let K = [k1, k2, ..., k n ] T , represents the convolution kernel corresponding to the i-th convolution layer in the convolutional neural network, where n represents the number of convolution kernels in the i-th layer, and k α ∈R h×w×d represents the αth convolution kernel, α=1,2,...,n, h, w and d represent the height, width and depth of the i-th convolution kernel respectively; K α Expanded into a one-dimensional convolution kernel vector, then k α '∈R s×1 , s = h × w × d, that is, s is the product of height, width, and depth; then all convolution kernel vectors k' of the i-th layer α Combined into a set: K'=[k′1,k′2,...,k′ n ] (4) Apply the density peak clustering algorithm to K', assuming that the convolution kernel is clustered into m clusters, then the result is: CL=CL1∪CL2∪...∪CL m (5) In the formula, Represents the set of convolution kernels contained in cluster β after clustering all convolution kernels in layer i, where α γ Represents the corresponding convolution kernel index value in the cluster, γ=1,2,...,|CL β |,|CL β | represents the number of convolution kernels contained in cluster β; (2) APoZ pruning within a convolution kernel cluster Calculate the zero activation rate of each convolution kernel in the i-th layer Since the number of convolution kernels in each cluster is different, the threshold within each cluster is defined according to the number of convolution kernels in each cluster. So that the proportion of convolution kernels pruned in each cluster is the same; then traverse each cluster β, if CL β Zero activation rate of a convolution kernel Above threshold Then it will be removed; the set of convolution kernels to be deleted in cluster β is: Therefore, the set of convolution kernels to be deleted selected in the i-th layer is: (3) Retraining of weight value parameters The training set is used to retrain some parameters in the convolutional neural network. The set of convolution kernels waiting to be retrained is: After the parameter retraining is completed, the convolution layer completes a pruning process; at this time, if the number of remaining convolution kernels in this layer meets the compression ratio requirement, the i+1 layer of the full convolutional neural network will be pruned, otherwise the above process will be repeated; (II) Image Segmentation After all layers of the fully convolutional neural network have been pruned, the network is lightweighted. The network after the lightweight operation is used by edge devices to process image segmentation tasks. With image data as input, the network outputs a segmented image of equal size for each image input.
