Global rank-aware neural network model compression method based on filter feature map

Through the global rank-aware method based on filter feature maps, the neural network model is globally sorted and pruned, which solves the problem of filter importance evaluation and low training efficiency in the existing technology, and achieves efficient model compression and edge processing. Equipment adaptability.

CN114037844BActive Publication Date: 2024-09-06XIDIAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111373645.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2024-09-06
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

It is difficult for the existing filter pruning model compression method to globally and uniformly evaluate the importance of all filters in the neural network model, resulting in reduced model accuracy, low training efficiency, and high labor costs.

Method used

A global rank-aware method based on filter feature maps is adopted. By obtaining image data sets, constructing a general convolutional neural network, training and obtaining the average rank of the filter feature maps, the genetic evolutionary algorithm is used to adaptively learn the parameter matrix to construct a layer-by-layer Affine transformation performs global sorting and pruning of all filters to achieve model compression.

Benefits of technology

It achieves unified evaluation and global ranking of filter importance in convolutional neural network models, balances classification accuracy and reasoning speed, reduces labor costs and training efficiency, and is suitable for edge devices with limited computing and storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114037844B
    Figure CN114037844B
Patent Text Reader

Abstract

The present invention discloses a global rank-aware neural network model compression method based on filter feature graph, which solves the problems of high labor cost, low pruning efficiency and poor stability of filter pruning model compression method, and the implementation includes: obtaining image data and preprocessing; constructing a general convolutional neural network, setting hyperparameters; selecting loss function and optimization algorithm; training and saving pre-trained model; obtaining average rank of feature graph; adaptive learning parameter matrix; representing and sorting filter importance; pruning and saving pre-trained model; fine-tuning network model to achieve global rank-aware neural network model compression based on filter feature graph. The present invention adopts "one-time learning and multiple pruning" to globally sort and uniformly prune filters without pathological selection. The pruning effect and stability are better, the pruning efficiency of large-scale networks with different complexities is high, and the adaptability to different edge devices is good. It is used for edge devices with limited computing and storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence technology, and mainly relates to neural network model compression, and specifically to a global rank-aware neural network model compression method based on filter feature graphs. It can be used for neural network deployment on edge devices with limited computing and storage resources. Background Art

[0002] With the continuous development of artificial intelligence in the era of big data, the performance of deep convolutional neural networks has become stronger and stronger, and has achieved great success in computer vision applications such as image classification, target detection, anomaly detection, semantic segmentation, and instance segmentation. However, the network model is getting deeper and deeper, the volume is getting larger, and the computing requirements are getting higher and higher. Therefore, the drawbacks and problems of large computing load and high memory usage have seriously hindered the deployment of most advanced convolutional neural networks in application environments with limited computing and storage resources. It is particularly prominent in online learning and recognition tasks of intelligent embedded devices and field programmable gate arrays (FPGAs), which ultimately leads to the inability to fully utilize convolutional neural networks in edge application fields such as military (disaster relief, enemy situation survey, etc.) and civil (mobile intelligent identification, convenient travel, etc.). Therefore, in view of the above drawbacks and problems, a neural network model compression method that reduces both the model calculation amount and the model volume while maintaining the performance of the neural network model has greater application value, among which the filter pruning method is particularly effective.

[0003] At present, there are many filter pruning model compression methods used to compress and accelerate convolutional neural networks. According to the structure of the neural network, the existing filter pruning model compression methods can be divided into two categories: predefined structure and adaptive structure.

[0004] The filter pruning model compression method based on the predefined structure mainly proposes various importance measurement methods for the filters in a single convolutional layer of the convolutional neural network, that is, to represent and sort the importance of local filters in the convolutional neural network. For example, Li H et al. proposed the L1 norm as a measure of filter importance in the document "Li H, Kadav A, Durdanovic I, et al. Pruning filters for efficient convnets. 2016. arXiv: 1608.08710.", and then sorted the filters between convolutional layers based on it. He Y et al. used the L2 norm to represent the importance of filters in the document "He Y, Kang G, Dong X, et al. Soft filter pruning for accelerating deep convolutional neural networks. 2018. arXiv: 1808.06866." Recently, Lin et al. proposed the Hrank (High-rank) index to measure the importance of filters and achieve pruning compression of convolutional neural networks in the paper “Lin M, Ji R, Wang Y, et al. Hrank: Filter pruning using high-rank feature map. In: Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition, 2020. 1529-1538.”, taking advantage of the fact that the average rank of feature maps generated by a single filter is always equal, and realized the pruning compression of convolutional neural networks. He et al. used the geometric median to judge the similarity of filters in the paper “He Y, Liu P, Wang Z, et al. Filter pruning via geometric median for deep convolutional neural networks acceleration. In: Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition, 2019. 4340-4349.”, and then realized the importance representation and sorting of filters. This type of pruning model compression method represents and sorts the importance of filters within a single convolutional layer. Since the importance comparison of filters between different convolutional layers is not considered, it is usually difficult to determine the optimal structure of the pruned network, so the model accuracy of the pruned network will decrease significantly.

[0005] The filter pruning model compression method based on adaptive structure determines the complexity of the pruned network through controllable parameters, and autonomously learns to obtain an adaptive specific network structure. For example, Wen W et al. in the paper “Wen W, Wu C, Wang Y, et al. Learning structured sparsity in deep neural networks. 2016. arXiv: 1608.03665.” performed Group-Lasso regularization on the filter norm to make the filter weight tend to zero. Liu Z et al. in the paper “Liu Z, Li J, Shen Z, et al. Learning efficient convolutional networks through network slimming. In: Proceedings of the IEEE International Conference on Computer Vision, 2017. 2736-2744.” tried to use Lasso regularization in the Batch Normalization layer to achieve the effect of pruning during training. Based on the assumption that each layer of the convolutional neural network is equally important, the weight of unimportant filters is minimized through regularization operations, that is, a uniform threshold can be applied to each convolutional layer of the network to achieve pruning, but the regularization operation has the problem of ill-conditioned filter selection. He Y et al. proposed the automatic model compression pruning model compression method AMC (Automated Model Compression) in the document "He Y, Lin J, Liu Z, et al. Amc: Automl for model compression and acceleration on mobile devices. In: Proceedings of the European Conference on Computer Vision (ECCV), 2018. 784-800." This filter pruning model compression method uses reinforcement learning to search for a convolutional neural network that meets the user-specified complexity, but the learning time cost of the entire neural network of this algorithm is relatively large.

[0006] In summary, most of the existing filter pruning model compression methods based on predefined structures or adaptive structures represent and rank the importance of local filters in the neural network model, and do not globally and uniformly evaluate the importance of all filters in the neural network model. At the same time, they also face problems such as low training efficiency and high labor costs when pruning general neural networks, and cannot achieve satisfactory results. Summary of the invention

[0007] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and propose a global rank-aware neural network model compression method based on filter feature graph which adopts "one-time learning and multiple pruning" and has low implementation complexity.

[0008] The present invention is a global rank-aware neural network model compression method based on filter feature graph, characterized in that it comprises the following steps:

[0009] (1) Obtain image datasets and perform preprocessing: Obtain natural images, add labels to unlabeled natural images, and form the original image dataset X; generate training sets X through slicing operations. train , validation set X valid and the test set X test ;

[0010] (2) Construct a general convolutional neural network and set hyperparameters: The overall architecture of the constructed general convolutional neural network model is: feature extractor → classifier; the basic network structure of the general convolutional neural network feature extractor and classifier is: input layer → hidden layer → output layer; set hyperparameters related to general neural network model training and testing according to the network model and image dataset, including momentum, weight decay factor, batch, epoch, learning rate, mutation rate, number of fine-tuning iterations, number of input channels, total number of image classifications and parameters related to the network model; and set the pruning rate of the general convolutional neural network model according to different hardware requirements; the pruning rate is also a hyperparameter, and the preset complexity FLOPs that can be derived from the hyperparameter is used as the minimum constant ; Implement multiple pruning operations according to the preset complexity of different target neural network models;

[0011] (3) Selecting the loss function and optimization algorithm for the neural network model: The loss function uses the cross-entropy loss function as the loss function of the general neural network model; the general neural network model optimization process uses the stochastic gradient descent (SGD) algorithm as the optimization algorithm of the general neural network model;

[0012] (4) Train the feature extractor and classifier of the neural network model and save the pre-trained model: train As the input of the general neural network model, in order to obtain the optimal weight parameters of the feature extractor and the classifier, the neural network model is trained to obtain pre-trained neural network models with different classification accuracy, and the neural network model Ω with the highest classification accuracy of the general neural network model is saved as the pre-trained model;

[0013] (5) Obtain the average rank of the filter feature map in the pre-trained model Ω: train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω and select the images as the input X in , the corresponding label is used as the output Y of the pre-trained model Ω, and the hook function is used to obtain the filter feature maps of all randomly selected images of the pre-trained neural network model Ω, and the average rank of each filter feature map in the pre-trained model is calculated;

[0014] (6) Using the preset pruning rate hyperparameter and the pre-trained neural network model, adaptive learning is used to obtain and save the parameter matrices α and γ: the complexity FLOPs derived from the preset pruning rate is used as the minimum constant , the classification accuracy Acc. of the neural network model in the training process is used as the fitness Fitness of the regulated Evaluation Algorithm (EA) with a regularization term, and the coefficient parameter matrix α and the bias parameter matrix γ are adaptively learned by the genetic evolution algorithm EA with a regularization term. The parameter matrices α and γ obtained by adaptive learning are saved and used to construct a layer-by-layer affine transformation L to represent the importance of the filter in the pre-training model;

[0015] (7) Importance representation and filter ranking of filters in the pre-trained neural network model: The coefficient parameter matrix α and the bias parameter matrix γ are used to construct a layer-by-layer affine transformation L, and the importance of all filters in the general neural network model Ω is globally uniformly represented. Based on the layer-by-layer affine transformation result, i.e., the global uniform representation, all filters in the pre-trained neural network model Ω are globally ranked to obtain the global ranking result of the filters of the neural network model Ω.

[0016] (8) Pruning and saving the pre-trained neural network model: Prune all filters after global sorting in the pre-trained neural network model, remove the bottom-rank filters in the global sorting results of the filters in the pre-trained neural network model, so that the complexity of the network model does not exceed the preset complexity, and save the pruned general neural network model Ω * ;

[0017] (9) Fine-tuning the general neural network model Ω * :The pruned general neural network model Ω * Fine-tune the neural network model to restore the accuracy lost due to pruning, and complete the global rank-aware model compression based on the filter feature map of the general neural network model for natural images.

[0018] The present invention mainly solves the problem of pathological filter selection caused by local filter sorting in a neural network model in the prior art, and also solves the technical problems of low training efficiency and high labor cost when pruning a neural network model.

[0019] Compared with the prior art, the present invention has the following advantages:

[0020] Global sorting and unified pruning of filters: The present invention proposes a global rank-aware neural network model compression method based on filter feature graph, constructs a layer-by-layer affine transformation based on the average rank of the filter feature graph, globally sorts all filters in the network model according to the transformation results, and prunes the filters at the end of the sorting, avoiding the pathological selection problem caused by the norm criterion, and realizing the unified evaluation of the importance of filters in the convolutional neural network model and the global sorting of filters.

[0021] Balancing the classification accuracy and inference speed of deep convolutional neural networks: The present invention targets the classification accuracy and inference speed of the neural network model, takes the classification accuracy of the neural network model in the adaptive learning process as the fitness of the genetic evolution algorithm with a regularization term, and adaptively obtains the parameter matrix through genetic evolution with a regularization term, thereby achieving the best balance between the two and providing a network model with less accuracy loss and faster inference speed.

[0022] "Learn once and prune multiple times": the present invention adaptively learns to obtain the layer-by-layer affine transformation parameter matrix and adopts "learn once and prune multiple times", that is, only the parameter matrix needs to be learned once to construct the layer-by-layer affine transformation and the filters are globally sorted. Based on the sorting results, multiple pruning operations are performed according to the preset complexity of the target neural network model to obtain multiple network models with different model volumes, classification accuracy and inference speeds, which greatly solves the problems of high labor costs and low efficiency.

[0023] Low implementation complexity: The present invention can perform filter pruning model compression for a variety of different general-purpose convolutional neural networks. Compared with the prior art, the average rank of the convolutional layer filter feature map in the neural network, the complexity of the neural network, the time consumption and the difficulty of pruning the neural network model are greatly reduced, while the scope of application is expanded. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a flow chart of the implementation of the present invention;

[0025] Figure 2 It is a flowchart of importance representation, sorting and pruning of filters in a convolutional neural network model in the present invention;

[0026] Figure 3 This is a comparison chart of the “one-time learning and multiple pruning” method used in the present invention and the prior art;

[0027] Figure 4 It is a comparison chart of experimental results of the present invention and the existing filter pruning model compression method using the ResNet-56 neural network on the CIFAR-100 data set;

[0028] Figure 5 It is a flow chart for realizing the adaptive learning coefficient parameter matrix α and the bias parameter matrix γ of the present invention; DETAILED DESCRIPTION

[0029] The present invention is described in detail below with reference to the accompanying drawings.

[0030] Example 1

[0031] Research shows that existing deep convolutional neural network models themselves contain a large amount of redundant information, including filter redundancy in the model's convolutional layer, and the high discrimination performance of the neural network model often depends on a few key parameters and structures in the network model. Therefore, the filter pruning model compression method is an effective model compression method that prunes out filter redundancy in the neural network model. However, when pruning the neural network model, the balance between the classification accuracy, inference speed, and complexity of the network model must be considered.

[0032] Most existing filter pruning model compression methods focus on the importance representation, sorting and network model pruning of local filters in deep convolutional neural networks. They do not globally sort all filters in the neural network model and uniformly evaluate the importance of filters. There is a pathological problem in filter selection, that is, sorting based on the norm of the filter weights may result in a filter with a small norm but a large contribution to the performance of the network model. In addition, each time the preset complexity is set in the existing filter pruning model compression method, a lot of time is required for trial and error verification, resulting in high labor costs and low efficiency of pruned network output, which still needs to be improved.

[0033] In view of the above-mentioned deficiencies of the prior art, the present invention proposes, after analysis and research, a global rank-aware neural network model compression method based on filter feature map (GRMC) which adopts "one-time learning and multiple pruning" and has low implementation complexity.

[0034] The present invention is a global rank-aware neural network model compression method based on filter feature graph, see Figure 1Based on the average rank of the filter feature graph, a genetic evolutionary algorithm with a regularization term is used to adaptively learn the importance of filters in the neural network model, and then all convolutional layer filters in the neural network model are globally sorted and model pruned, including the following steps:

[0035] (1) Obtain image datasets and perform preprocessing: Obtain natural images, add labels to unlabeled natural images, and form the original image dataset X; generate training sets X through slicing operations. train , validation set X valid and the test set X test The specific steps include:

[0036] (1.1) Obtain a public dataset with labels, including the training set X train and the test set X test , such as the CIFAR-10 image dataset and the CIFAR-100 image dataset.

[0037] (1.2) If the original image dataset already has a test set X test , then the original training data set X is sliced ​​in a ratio of 2:8, where a small portion of the data constitutes the validation set X for training the neural network valid , and the other part of the data constitutes the training set X for training the neural network train ; If the original image dataset does not exist in the test set X test , then the original training data set X is sliced ​​in a ratio of 6:2:2, and the corresponding ratios are used to generate training sets X train , validation set X valid and the test set X test , that is, most of the data constitutes the training set X for training the neural network train , and the other two parts are validation set X valid and the test set X test .

[0038] (2) Constructing a general convolutional neural network and setting hyperparameters: The overall architecture of the constructed general convolutional neural network model is: feature extractor → classifier; the basic network structure of the general convolutional neural network feature extractor and classifier is: input layer → hidden layer → output layer; the general convolutional neural network model is referred to as the neural network model.

[0039] A general convolutional neural network is constructed by adopting the network architecture of feature extractor connected with classifier in series. The hyperparameters related to the training and testing of the neural network model are set according to the network model and image dataset. The relevant hyperparameters include momentum, weight decay factor, batch, epoch, learning rate, mutation rate, number of fine-tuning iterations and parameters related to the network model. The pruning rate of the general convolutional neural network model is set according to different hardware requirements. The pruning rate is also a hyperparameter. The preset complexity FLOPs that can be derived from the hyperparameter is used as the minimum constant. ; Perform multiple pruning operations based on the preset complexity of different target neural network models.

[0040] It is the technical feature of the present invention that the pruning rate of the general convolutional neural network model is set according to different hardware requirements, which enables the present invention to achieve "one-time learning and multiple pruning", see Figure 3 , Figure 3 This is a comparison chart between the "one-time learning and multiple pruning" adopted in the present invention and the prior art; the existing filter pruning model compression needs to obtain the order of filters in the network model separately according to the different hardware requirements to obtain multiple network models; the present invention only needs to learn the parameter matrix once to construct a layer-by-layer affine transformation, and globally sort the filters. Based on the sorting results, multiple pruning can be performed according to different hardware requirements to obtain multiple network models with different model volumes, classification accuracy, and inference speeds.

[0041] (3) Selecting the loss function and optimization algorithm for the neural network model: The loss function uses the cross-entropy loss function as the loss function of the general neural network model; the general neural network model optimization process uses the stochastic gradient descent (SGD) algorithm as the optimization algorithm of the general neural network model.

[0042] (4) Train the feature extractor and classifier of the neural network model and save the pre-trained model: train As the input of the general neural network model, in order to obtain the optimal weight parameters of the feature extractor and the classifier, the neural network model is fully trained to obtain pre-trained neural network models with different classification accuracies, and the neural network model with the highest classification accuracy is saved as the pre-trained model Ω; the pre-trained model is also the pre-trained neural network model.

[0043] (5) Obtain the average rank of the filter feature map in the pre-trained model Ω: train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω and select the images as the input X in, the corresponding label is used as the input Y of the pre-trained model Ω, and the hook function is used to obtain the filter feature maps of all randomly selected images of the pre-trained neural network model Ω, and the average rank of each filter feature map in the pre-trained model is calculated; that is, for different selected images, the average rank of multiple feature maps output by each filter.

[0044] (6) Using the preset pruning rate hyperparameter and the pre-trained neural network model, adaptive learning is used to obtain and save the parameter matrices α and γ: the complexity FLOPs derived from the preset pruning rate is used as the minimum constant The classification accuracy Acc. of the neural network model in the training process is used as the fitness Fitness of the regulated Evaluation Algorithm (EA) with a regularization term. The coefficient parameter matrix α and the bias parameter matrix γ are adaptively learned through the genetic evolution algorithm EA with a regularization term. The parameter matrices α and γ obtained by adaptive learning are saved and used to construct a layer-by-layer affine transformation L to represent the importance of the filters in the pre-trained model.

[0045] (7) Importance representation and filter sorting of pre-trained neural network models: The coefficient parameter matrix α and the bias parameter matrix γ are used to construct a layer-by-layer affine transformation L, and the importance of all filters in the general neural network model Ω is globally uniformly represented. Based on the layer-by-layer affine transformation result, i.e., the global uniform representation, all filters in the pre-trained neural network model Ω are globally sorted to obtain the global sorting result of the filters of the neural network model Ω.

[0046] (8) Pruning and saving the pre-trained neural network model: Prune all filters after global sorting in the pre-trained neural network model, remove the bottom-rank filters in the global sorting results of the filters in the pre-trained neural network model, so that the complexity of the network model does not exceed the preset complexity, and save the pruned general neural network model Ω * .

[0047] (9) Fine-tuning the general neural network model Ω * :The pruned general neural network model Ω * Fine-tune the neural network model to restore the accuracy lost due to pruning, and complete the global rank-aware model compression based on the filter feature map of the general neural network model for natural images.

[0048] The present invention provides a complete technical solution for a global rank-aware neural network model compression method based on filter feature graph.

[0049] Most of the existing model compression methods for filter pruning are aimed at expressing the importance of local filters in the neural network model, sorting filters and pruning network models, without uniformly evaluating and globally sorting the importance of all filters in the neural network model, and there is an ill-conditioned problem in filter selection, that is, sorting according to the norm of the filter weight, which may result in a situation where the norm of the filter is small but the filter contributes greatly to the performance of the network model. In addition, each time the target complexity is set in the existing model compression methods based on filter pruning, a lot of time is required for trial and error verification, resulting in high labor costs and low output efficiency of the pruned network, which still needs to be improved. In view of this situation, the idea of ​​the present invention is to use a genetic evolutionary algorithm with a regularization term to adaptively learn the importance of filters in the neural network model based on the average rank of the filter feature graph, and then globally sort all the convolutional layer filters in the neural network model, and finally prune and fine-tune the model. The present invention is based on the average rank of the convolutional layer filter feature map in the neural network model, and adaptively learns the parameter matrix through the genetic evolution algorithm with a regularization term to construct a layer-by-layer affine transformation, uniformly represent the importance of all filters in the neural network model, globally sort the filters, and then select and prune the bottom-rank filters that meet the preset complexity according to the sorting results, and finally fine-tune the neural network model to complete the pruning and compression of the neural network model. The present invention avoids the pathological selection problem caused by the norm criterion, realizes the unified evaluation of the importance of filters in the convolutional neural network model and the global sorting of filters; balances the classification accuracy and reasoning speed of the convolutional neural network model, and provides a network model with less accuracy loss and faster reasoning speed; the "one-time learning and multiple pruning" of the present invention can implement multiple different model pruning operations according to the preset complexity of the target neural network model, and obtain multiple target networks that meet different preset complexity requirements, which greatly solves the problems of high labor cost, low efficiency and poor stability; the average rank of the convolutional layer filter feature map, the complexity of the neural network, the time consumption and the difficulty of the network model pruning operation are greatly reduced.

[0050] Example 2

[0051] The global rank-aware neural network model compression method based on filter feature graph is the same as that in Example 1, and the step (5) of obtaining the average rank of the filter feature graph in the pre-trained model Ω specifically includes the following steps:

[0052] (5.1) Obtain the feature maps of all filters in the neural network : In the training data set X train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω and select the images as the input X in, the corresponding label is used as the output Y of the pre-trained model Ω, and the hook function is used to obtain the feature maps of all filters in the neural network

[0053]

[0054] Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, Indicates that the hook function acts on C i , n i-1 Represents C i The number of input channels, n i represents the number of filters, k i Represents C i The size of the filter, Represents C i The set of filter parameters in , Represents C i Input, Represents C i The bias, Represents C i The output of is the feature map, Indicates the pre-trained model The jth feature map generated, h i The height of the feature map represented by w i Represents C i The width of the feature map.

[0055] (5.2) Calculate the average rank of each filter feature map in the pre-trained model * :

[0056]

[0057] Among them, t is the number of images used to obtain the average rank, that is, the number of randomly selected pictures, C i represents the i-th convolutional layer in the pre-trained neural network model, Represents C i The output feature map, Represented by the pre-trained model The jth feature map generated, h i Represents the height of the feature map, w i Indicates the width of the feature map, n i Represents C i The number of filters in Indicates that C in the pre-trained neural network model when the sth picture is input i The feature map of the jth filter rank.

[0058] The present invention is based on filter feature graphs, and utilizes the rule that the average rank of feature graphs generated by single filters in the convolutional layer of a neural network model is always equal, that is, the average rank of the filter feature graphs in the network model is insensitive to the network input image, constructs a layer-by-layer affine transformation, uniformly evaluates the importance of all filters in the network model, and globally sorts them, so as to complete the evaluation and selection of filters in a reasonable manner, avoid the pathological problem of filter selection caused by the norm criterion, and make the network model smaller, less calculated, and faster inference speed after pruning.

[0059] Example 3

[0060] The global rank-aware neural network model compression method based on the filter feature graph is the same as that in Example 1-2. The preset pruning rate hyperparameter and the pre-trained neural network model are used in step (6) to adaptively learn and obtain and save the parameter matrices α and γ. Figure 5 , specifically including the following steps:

[0061] (6.1) Parameter setting: Set the parameters related to the genetic evolution algorithm, including the population size P, the maximum number of iterations E, the sample size S, the mutation rate μ, the random step size σ, and the minimum constant , fine-tuning iteration number τ;

[0062] (6.2) Introduce related variables: introduce the population queue, iterator and initialize them, introduce the coefficient parameter matrix α, the bias parameter matrix γ, collectively referred to as the parameter matrix;

[0063] (6.3) Parameter matrix update: the iterator is incremented by 1, the coefficient parameter matrix α and the bias parameter matrix γ are initialized; sampling mutation is performed from the population queue, the sampling sample size is S, the mutation rate is μ, and the coefficient parameter matrix α and the bias parameter matrix γ are updated using the standard deviation of the average rank of the filter in each convolutional layer after mutation;

[0064] (6.4) Importance representation and sorting of filters: Based on the updated coefficient parameter matrix α and bias parameter matrix γ, the importance representation L of the filters is performed using layer-by-layer affine transformation, and the filters are sorted from large to small according to the representation results. The importance representation of the convolutional layer filters of the deep convolutional neural network of the present invention makes the general convolutional neural network smaller, less computationally intensive, and faster inference.

[0065] (6.5) Prune the terminal filter and obtain the classification accuracy of the network model: Prune the terminal filter in the sorting result to meet the minimum constant Requirements: Fine-tune the network after τ times of pruning and measure the classification accuracy of the pruned neural network model;

[0066] (6.6) Population queue update: Use the classification accuracy, coefficient parameter matrix α and bias parameter matrix γ of the pruned network model to update the population queue;

[0067] (6.7) Judgment: Determine whether the iterator has reached the maximum number of iterations E;

[0068] (6.8) Obtain and maintain the parameter matrix: output the optimal parameter matrix obtained by iteration and save the optimal coefficient parameter matrix α and bias parameter matrix γ.

[0069] The present invention aims at the classification accuracy and inference speed of the neural network model, takes the classification accuracy of the neural network model in the adaptive learning process as the fitness of the genetic evolution algorithm with a regularization term, and adaptively obtains the parameter matrix, namely the coefficient parameter matrix α and the bias parameter matrix γ, through the genetic evolution with a regularization term, thereby achieving the best balance between the classification accuracy and inference speed of the network model, and providing a network model with less accuracy loss and faster inference speed.

[0070] Example 4

[0071] The global rank-aware neural network model compression method based on the filter feature graph is the same as in Example 1-3. The preset pruning rate hyperparameter and the pre-trained neural network model are used in step (6) to adaptively learn and obtain and save the parameter matrices α and γ. For details, refer to Algorithm 1

[0072]

[0073] Based on the average rank of the filter feature map obtained in the pre-trained model * , taking the complexity derived from the preset pruning rate as the minimum constant , the classification accuracy Acc. of the neural network model in the training process is used as the fitness Fitness of the regularized genetic evolution algorithm, and the coefficient parameter matrix α and the bias parameter matrix γ are adaptively learned through the genetic evolution algorithm EA with regularization term, and the parameter matrices α and γ are saved as local .data files;

[0074] The filter pruning model compression method designed by the present invention uses the classification accuracy of the neural network model in the adaptive learning process as the fitness of the genetic evolution algorithm with a regularization term, adaptively obtains the parameter matrix through the genetic evolution method with a regularization term, represents and sorts the importance of the filters in the neural network, and then implements the pruning operation accordingly. The optimal balance between the classification accuracy and reasoning speed of the network model is achieved, and a network model with less accuracy loss and faster reasoning speed is provided.

[0075] Example 5

[0076] The global rank-aware neural network model compression method based on the filter feature graph is the same as that in Embodiment 1-4, except that the importance representation of the filters in the pre-trained neural network model and the filter sorting in step (7), and the pruning and saving of the pre-trained neural network model in step (8) specifically include the following steps:

[0077] A. Construct layer-by-layer affine transformation to represent the importance of filters in the pre-trained neural network model Ω

[0078]

[0079] Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, represents the average rank of the jth filter feature map in the i-th convolutional layer in the convolutional neural network model Ω, K represents the number of convolutional layers in the pre-trained model, n i is the number of filters in the i-th convolutional layer, are respectively the coefficient parameter matrix and the bias parameter matrix learned in step (6) of claim 1, represents the coefficient of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation, represents the bias of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation; this step is performed in step (7);

[0080] B. Sorting and pruning filters in the pre-trained neural network model Ω

[0081]

[0082] Among them, Sort(L) means sorting the filters from large to small for the result L of layer-by-layer affine transformation. K represents the number of convolutional layers in the pre-trained model, n i represents the number of filters in the i-th convolutional layer, Represents the layer-by-layer affine transformation result of the j-th filter in the i-th convolutional layer in the network model, Represents the constraint condition of the target neural network model, i.e., the complexity FLOPs. The bottom-rank filter in the Sort(L) result is cut off so that the complexity of the network model does not exceed the preset complexity. Ω * Represents the neural network model after filter pruning; saves the pruned general neural network model Ω * ; This step is carried out in step (8).

[0083] The present invention is based on filter feature graphs, and utilizes the rule that the average rank of feature graphs generated by single filters in the convolutional layer of a neural network model is always equal, that is, the average rank of the filter feature graphs in the network model is insensitive to the network input image, constructs a layer-by-layer affine transformation, uniformly evaluates the importance of all filters in the network model, and globally sorts them. When the preset complexity requirements are met, the redundant bottom-rank filters in the sorting results are pruned, and the filter evaluation and selection are completed in a reasonable manner, avoiding the pathological problem of filter selection caused by the norm criterion, so that the pruned network model is smaller, the calculation amount is reduced, and the reasoning speed is faster.

[0084] The present invention mainly solves the problems of high labor cost, low pruning efficiency and poor stability of the existing filter pruning algorithm. The implementation steps are as follows: obtain a labeled image data set and preprocess the data set; construct a general convolutional neural network; select the cost function and optimization algorithm of the neural network model; pre-train the feature extractor and classifier; obtain the average rank of the filter feature map based on the pre-trained neural network; use a genetic evolution algorithm with a regularization term to adaptively learn the parameter matrix of layer-by-layer affine transformation; represent and sort the importance of filters in the neural network model; prune the convolutional neural network according to the importance of the filter; and fine-tune the pruned neural network to restore accuracy. Simulations have shown that the pruning effect and stability of the present invention are better, and it is more efficient for large-scale acquisition of pruned networks of different complexities, which greatly improves the adaptability of neural networks to edge devices with different degrees of computing and storage resource constraints.

[0085] A detailed example is given below to further illustrate the present invention.

[0086] Example 6

[0087] The global rank-aware neural network model compression method based on the filter feature graph is the same as in Example 1-5, refer to Figure 2 , Figure 2 In, C i represents the i-th convolutional layer in the pre-trained neural network model, Represented by the pre-trained model The jth feature map generated, h i Represents the height of the feature map, w i represents the width of the feature map, represents the average rank of the jth filter feature map in the i-th convolutional layer in the convolutional neural network model Ω, K represents the number of convolutional layers in the pre-trained model, n i Represents the number of filters in the i-th convolutional layer, abbreviated as The FLOPs threshold condition represents the preset complexity, ω represents the layer-by-layer affine transformation, α represents the coefficient parameter matrix, γ represents the bias parameter matrix, the solid line outside the numerical circle represents the filter retained before or after filter pruning, the dotted line outside the numerical circle represents the filter to be pruned, the numerical value on the left represents the average rank of the filter feature map before the layer-by-layer affine transformation, and the numerical value on the right represents the result of the layer-by-layer affine transformation.

[0088] See also Figure 1 , the present invention comprises the following steps:

[0089] Step 1. Obtain image dataset and preprocess: obtain natural images, add labels to unlabeled natural images to form the original image dataset X; generate training sets X through slicing operations train , validation set X valid and the test set X test ;

[0090] (1.1) Obtain a public dataset with labels, including the training set X train and the test set X test ,In this example, the experiment uses the CIFAR-100 dataset, W and H represent the length and width of each image in the dataset, respectively;

[0091] (1.2) In this example, the CIFAR-100 image dataset already has a test set X test , then the training set in the original training data set is sliced ​​at a ratio of 2:8, where a small portion of the data constitutes the validation set X for training the neural network valid , and the other part of the data constitutes a new training set X for training the neural network train ;

[0092] Step 2. Build a general convolutional neural network and set hyperparameters: The overall architecture of the constructed general convolutional neural network model is: feature extractor → classifier; the basic network structure of the general convolutional neural network feature extractor and classifier is: input layer → hidden layer → output layer; the general convolutional neural network model is referred to as the neural network model.

[0093] A general convolutional neural network is constructed by using a network architecture that connects a feature extractor and a classifier in series. In this example, a general ResNet-56 residual neural network model is used.

[0094] For the feature extractor, the present invention sets the total number of network nodes of the input layer to the number of bands of the picture in the CIFAR-100 image dataset, which is set to 3 in the experiment. The feature extractor has 3 sublayers, each of which includes 9 residual blocks. All residual blocks adopt the following network structure: Convolution layer→Batch Normalization layer→ReLU layer→Convolution layer→Batch Normalization layer→ReLU layer→Shortcut layer, wherein the number of network nodes of the 3 Convolution layers of the residual block in each sublayer is set to 16, 32, and 64 respectively, the convolution kernel size is set to 3×3, the step size is set to 1×1, and the padding is set to 1×1. The number of input channels of each Batch Normalization layer is consistent with the number of output channels of the previous convolution layer, the activation function uses the ReLU activation function, and the pooling layer uses the MaxPool function for downsampling.

[0095] For the classifier, the network structure adopted by the present invention is AdaptiveAvgPool layer→Linear layer, wherein the total number of network nodes in the input layer is set to 64, there is no hidden layer, and the network nodes in the output layer are set to the total number of image data set categories, which is set to 10 in this example.

[0096] According to the network model and image dataset, the hyperparameters related to neural network model training and testing are set. In this example, the hyperparameters of the experiment are set as follows: momentum is set to 9e-1, weight decay factor is set to 5e-4, training batch size is set to 128, that is, m=128, epochs is set to 400, the initial value of the learning rate is set to 1e-1, and the learning rate decays 5 times when epochs is {120, 240, 320}, the number of architecture search iterations is set to 400, the mutation rate μ in the genetic evolution algorithm is set to 10%, and the number of fine-tuning iterations τ is set to 200. In addition, in the fine-tuning stage of the neural network, the initial learning rate and epochs are set to 1e-2 and 60 respectively; and the pruning rate of the general convolutional neural network model is set according to different hardware requirements. In this example, the pruning rates are set to 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, and 0.8 respectively; the pruning rate is also a hyperparameter, and the complexity FLOPs derived from the hyperparameter is used as the minimum constant It is also the preset complexity of the present invention.

[0097] Step 3. Select the loss function and optimization algorithm for the neural network model: The loss function uses the cross-entropy loss function J(θ) as the loss function of the general neural network model.

[0098]

[0099] Among them, θ represents the parameter matrix in the neural network model, Represents input X k The output of the neural network model, h θ (·) represents the prediction function with θ as the parameter matrix, X k represents the kth input image, and m represents the number of input images, i.e., the batch size;

[0100] The neural network model optimization process uses the stochastic gradient descent (SGD) algorithm, which is a general neural network model optimization algorithm. The parameter matrix is ​​updated using the following formula:

[0101]

[0102] Among them, θ j represents the jth parameter matrix in the neural network model, β represents the learning rate, m represents the batch size, X k represents the kth input image, Y represents X k The corresponding label, :=, means assigning the calculation result on the right side to the left side.

[0103] Step 4. Train the feature extractor and classifier of the neural network model and save the pre-trained model: train As the input of the general neural network model, in order to obtain the optimal weight parameters of the feature extractor and classifier, the neural network model is fully trained. In this example, 600 epochs are trained, and the network parameters θ are updated using the loss function J(θ) and the stochastic gradient descent algorithm SGD in step (3). valid Perform gradient correction on the neural network, stop training when the loss function J(θ) converges or the training epochs is greater than the set epochs, and obtain pre-trained neural network models with different classification accuracy. Save the neural network model with the highest classification accuracy as the pre-trained model Ω; the pre-trained model is also the pre-trained neural network model.

[0104] Step 5. Get the average rank of the filter feature map in the pre-trained model Ω:

[0105] (5.1) Obtain the feature maps of all filters in the neural network : In the training data set X train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω. In this example, 500 images are randomly selected and the images are selected as the input X of the pre-trained model Ω. in, the corresponding label is used as the output Y of the pre-trained model Ω, and the hook function is used to obtain the feature maps of all filters in the neural network

[0106]

[0107] Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, Indicates that the hook function acts on C i , n i-1 Represents C i The number of input channels, n i represents the number of filters, k i Represents C i The size of the filter, Represents C i The set of filter parameters in , Represents C i Input, Represents C i The bias, Represents C i The output of is the feature map, Indicates the pre-trained model The jth feature map generated, h i The height of the feature map represented by w i Represents C i The width of the feature map.

[0108] (5.2) Calculate the average rank of each filter feature map in the pre-trained model * , that is, the average rank of multiple feature maps output by each filter for different selected images

[0109]

[0110] Among them, t represents the number of images used to obtain the average rank, that is, the number of randomly selected images, C i represents the i-th convolutional layer in the pre-trained neural network model, Represents C i The output feature map, Represented by the pre-trained model The jth feature map generated, h i Represents the height of the feature map, w i Indicates the width of the feature map, n i Represents C i The number of filters in Indicates that C in the pre-trained neural network model when the sth picture is input i The feature map of the jth filter rank; save the average rank of all convolutional layer filter feature maps in the neural network model as a local .npy file.

[0111] Step 6. Use the preset pruning rate hyperparameters and pre-trained neural network model to adaptively learn and obtain and save the parameter matrices α and γ, see Figure 5 , specifically including the following steps:

[0112] (6.1) Parameter setting: Set the parameters related to the genetic evolution algorithm, including the population size P, the maximum number of iterations E, the sample size S, the mutation rate μ, the random step size σ, and the minimum constant , fine-tune the number of iterations τ.

[0113] (6.2) Introduce related variables: introduce the population queue, iterator and initialize them, introduce the coefficient parameter matrix α, the bias parameter matrix γ, collectively referred to as the parameter matrix.

[0114] (6.3) Parameter matrix update: The iterator is incremented by 1, and the coefficient parameter matrix α and the bias parameter matrix γ are initialized; sampling mutation is performed from the population queue, with a sampling size of S and a mutation rate of μ, and the coefficient parameter matrix α and the bias parameter matrix γ are updated using the standard deviation of the average rank of the filter in each convolutional layer after mutation.

[0115] (6.4) Importance representation and sorting of filters: Based on the updated coefficient parameter matrix α and bias parameter matrix γ, the importance of the filters is represented L using layer-by-layer affine transformation, and the filters are sorted from large to small according to the representation results.

[0116] (6.5) Prune the terminal filter and obtain the classification accuracy of the network model: Prune the terminal filter in the sorting result to meet the minimum constant Requirements: Fine-tune the network after τ pruned times and measure the classification accuracy of the pruned neural network model.

[0117] (6.6) Population queue update: The classification accuracy, coefficient parameter matrix α and bias parameter matrix γ of the pruned network model are used to update the population queue.

[0118] (6.7) Judgment: Determine whether the iterator has reached the maximum number of iterations E.

[0119] (6.8) Obtain and maintain the parameter matrix: output the optimal parameter matrix obtained by iteration and save the optimal coefficient parameter matrix α and bias parameter matrix γ.

[0120] Step 7. Importance representation and filter ordering of filters in the pre-trained neural network model: Construct layer-by-layer affine transformation using coefficient parameter matrix α and bias parameter matrix γ , a global unified representation of the importance of all filters in the general neural network model Ω

[0121]

[0122] Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, represents the average rank of the jth filter feature map in the i-th convolutional layer in the convolutional neural network model Ω, K represents the number of convolutional layers in the pre-trained model, n i represents the number of filters in the i-th convolutional layer, They respectively represent the coefficient parameter matrix and the bias parameter matrix learned in step (6) of claim 1, represents the coefficient of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation, The bias of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation is used; according to the layer-by-layer affine transformation result, that is, the global unified representation result L, all filters in the pre-trained neural network model Ω are globally sorted to obtain the global sorting result of the filters of the neural network model Ω.

[0123] Step 8. Prune and save the pre-trained neural network model: Prune all filters after global sorting in the pre-trained neural network model, remove the bottom-rank filters of the global sorting results of the filters in the pre-trained neural network model, so that the complexity of the network model does not exceed the preset complexity, and save the pruned general neural network model Ω *

[0124]

[0125] Among them, Sort(L) means sorting the filters from large to small for the result L of layer-by-layer affine transformation. K represents the number of convolutional layers in the pre-trained model, n i is the number of filters in the i-th convolutional layer, Represents the layer-by-layer affine transformation result of the j-th filter in the i-th convolutional layer in the network model, Represents the constraint condition of the target neural network model, i.e., the complexity FLOPs. The bottom-rank filter in the Sort(L) result is cut off so that the complexity of the network model does not exceed the preset complexity. Ω * Represents the neural network model after filter pruning; saves the pruned general neural network model Ω * .

[0126] Step 9. Fine-tune the general neural network model Ω *:The pruned general neural network model Ω * Fine-tuning

[0127] Ω * :=Fine-tuning(Ω * )

[0128] Among them, := means assigning the calculation result on the right to the left, fine-tuning and restoring the accuracy of the neural network model lost due to pruning, and completing the global rank-aware model compression based on the filter feature map of the general neural network model for natural images.

[0129] The present invention utilizes a convolutional neural network model to extract image data features. According to the average rank of the filter feature map in the network layer that will not be affected by the number of input images, the average rank is used as a benchmark for measuring the importance of the filter, and a layer-by-layer affine transformation is introduced. Based on the benchmark of the average rank, the importance of all filters in the convolutional neural network is uniformly represented and globally sorted. The model classification accuracy of the deep convolutional neural network is used as the fitness of a genetic evolution algorithm with a regularization term to obtain the optimal parameter matrix for layer-by-layer affine transformation. Different preset complexities of the neural network model are used as pruning constraints. Finally, small adjustments are made to obtain a large number of pruned network models of different complexities. A global rank-aware neural network model compression method based on the filter feature map is proposed, which greatly improves the adaptability of the neural network model to edge devices with different degrees of computing and storage resource constraints.

[0130] The effect of the present invention is described below in conjunction with simulation experiments.

[0131] Example 7

[0132] The global rank-aware neural network model compression method based on filter feature graph is the same as Example 1-6.

[0133] Simulation conditions:

[0134] The image dataset used in the experiment is the CIFAR-10 dataset, which contains 10 types of labeled images, each type contains 6,000 images, of which 5,000 and 1,000 are used for training and testing respectively. Each image is 32×32 in size and provides data for three commonly used bands.

[0135] The experiment uses Top-1 model classification accuracy Top-1 Acc., parameters Parameters, and FLOPs indicators to objectively and quantitatively analyze the pruning effect of deep convolutional neural networks.

[0136] The experiment uses the VGG-16 general-purpose convolutional neural network model, deployed on the Linux operating system, and uses NVIDIA RTX 2080Ti for data acceleration.

[0137] Simulation content:

[0138] The simulation experiment of the present invention adopts the method of the present invention and the filter pruning model compression method in the prior art, and conducts simulation experiments respectively under the above-mentioned simulation conditions. Four most advanced filter pruning algorithms are used to compare relevant performance indicators, and the specific indicators include model classification accuracy Top-1 Acc., parameter quantity Parameters, FLOPs, and PR represents pruning. Under the condition of maintaining the model classification accuracy Top-1 Acc., the smaller the parameter quantity Parameters and FLOPs, the better the rate. Compared with the latest existing filter pruning algorithm, the present invention maintains better model classification accuracy and faster inference speed under the same target network complexity.

[0139] Simulation results analysis:

[0140] Table 1 shows the comparison results of the present invention and the existing filter pruning model compression method for model compression of the VGGNet-16 neural network model on the CIFAR-10 dataset.

[0141]

[0142] The experiment in the present invention adopts "one-time learning and multiple pruning" to learn the global ordering of all filters in the neural network model once. In this example, three pruning experiments were conducted according to different preset complexities, and each group of pruning experiments obtained three experimental results. The Top-1 Acc. (%) indicator in Table 1 shows the results as the mean and standard deviation of the results of three independent repeated experiments. 92.16 ± 0.44 in the Top-1 Acc. (%) indicator in Table 1 is the mean and standard deviation of the results of three independent repeated experiments under the unified preset complexity.

[0143] Through the quantitative analysis of the filter pruning comparison results of the general VGGNet-16 convolutional neural network on the CIFAR-10 dataset in Table 1, it can be found that compared with other filter pruning model compression methods, the classification accuracy of the model of the present invention is only reduced by 0.1% compared with the original benchmark network model. Compared with the L1 filter pruning model compression method, when the classification accuracy of the Top-1 model is similar in the test phase (93.50% vs. 93.40%), the global rank-aware neural network model compression method based on the filter feature map of the present invention can obtain a network model with lower FLOPs and fewer parameters (108.78M vs. 206.00M, 3.01M vs. 5.40M). In particular, when the present invention is compared with the GAL-0.1 filter pruning model compression method, it can be observed that when the number of parameters of the network model is similar (2.74M vs. 2.67M), the present invention performs better in terms of FLOPs and model classification accuracy (73.65M vs. 171.89M, 92.16% vs. 91.23%).

[0144] The above experimental results show that the present invention can not only be applied to the VGGNet network, expanding the scope of application, but also effectively discover redundant filters in the VGGNet network model and accurately prune them while achieving a balance between the classification accuracy and inference speed of the network model.

[0145] Example 8

[0146] The global rank-aware neural network model compression method based on filter feature graph is the same as that in Example 1-6. The experiment uses the ResNet-56 general convolutional neural network, and the other simulation conditions are the same as those in Example 7.

[0147] The experiment uses 6 most advanced filter pruning model compression methods to compare relevant performance indicators, including Top-1 model classification accuracy Top-1 Acc. (%), Top-1 model classification accuracy reduction Top-1 Acc.↓ (%) and network model complexity FLOPs. PR represents the pruning rate, where the smaller the Top-1 Acc.↓ (%) and FLOPs, the better the rate is while maintaining the model classification accuracy Top-1 Acc. Table 2 shows the comparison results of the filter pruning model compression of the present invention and the existing filter pruning model compression method on the CIFAR-10 dataset for the ResNet-56 general convolutional neural network.

[0148]

[0149] The experiment in the present invention adopts "one-time learning and multiple pruning" to learn the global ordering of all filters in the neural network model once. In this example, three pruning experiments were conducted according to different preset complexities, and each group of pruning experiments obtained three experimental results. The Top-1 Acc. (%) indicator in Table 2 shows the results as the mean and standard deviation of the results of three independent repeated experiments. 94.4 ± 0.08 in the Top-1 Acc. (%) indicator in Table 2 is the mean and standard deviation of the results of three independent repeated experiments under the unified preset complexity.

[0150] Table 2 shows a comparative experiment of filter pruning model compression of ResNet-56 general convolutional neural network on CIFAR-10 dataset. After quantitative analysis, it is found that the experimental results of the filter pruning model compression method of the present invention and TAYLOR are compared. It is found that when the Top-1 classification accuracy of the network model is the same (93.9%), the model complexity FLOPs after filter pruning compression of the present invention only accounts for 65.94% of the model after filter pruning compression of TAYLOR (59.9M vs.

[0151] 90.8M), that is, the reasoning speed of the present invention is increased by 1.5 times. In addition, by comparing the present invention and the HRank filter pruning model compression method with similar FLOPs (32.4M vs. 32.5M, 59.9M vs. 62.7M, 87.8M vs. 88.7M), it is found that the present invention performs better in the classification accuracy of the Top-1 model in the test phase (91.3% vs. 90.7%, 93.9% vs. 93.2%, 94.4% vs. 93.5%).

[0152] The above experimental results show that the present invention can be well applied to the ResNet general neural network under the condition of achieving a balance between the classification accuracy and inference speed of the network model, which expands the scope of application and fully proves the importance of the average rank-aware filter of the feature graph used in the present invention and the superiority of the global sorting of the filter.

[0153] Example 9

[0154] The global rank-aware neural network model compression method based on filter feature graph is the same as Example 1-6.

[0155] Simulation conditions:

[0156] The image dataset used in the experiment is the CIFAR-100 dataset, which is similar to the CIFAR-10 dataset, but contains 100 types of labeled images, each type contains 600 images, of which the number of images used for training and testing is 500 and 100 respectively. The rest of the simulation conditions are the same as in Example 7.

[0157] Reference Figure 4 , wherein the horizontal axis represents the network model complexity FLOPs and its percentage of the original benchmark network model complexity, the vertical axis represents the Top-1 classification accuracy of the network model in the test phase, the horizontal dotted line represents the Top-1 classification accuracy of the benchmark network model in the test phase, the dotted line with a "five-pointed star" represents the Top-1 classification accuracy of the present invention in the test phase under different complexities, the dotted line with an "upper triangle" represents the Top-1 classification accuracy of the AMC filter pruning model compression method in the test phase under different complexities, the dotted line with a "right triangle" represents the Top-1 classification accuracy of the Uniform filter pruning model compression method in the test phase under different complexities, the dotted line with a "solid circle" represents the Top-1 classification accuracy of the Morphnet filter pruning model compression method in the test phase under different complexities, and the upper and lower solid lines around the measurement points in the figure represent the standard deviation of the model classification accuracy of three compression experiments of the same filter pruning model under the complexity conditions.

[0158] By comparing the results of the prior art including AMC, Uniform, and Morphnet filter pruning model compression methods, it is found that when the pruning rate (PR) is small, the present invention can be comparable to the existing filter pruning model compression method, or even better than the AMC filter pruning model compression method; when the pruning rate PR is large, the Top-1 classification accuracy standard deviation of the AMC filter pruning model compression method and the Morphnet filter pruning model compression method is large, while the standard deviation of the present invention is small and the algorithm stability is good; especially when the network model complexity FLOPs is very small, the present invention performs better in the Top-1 classification accuracy and stability of the network model.

[0159] This performance is closely related to the following fact: Figure 3 , the present invention only performs adaptive learning of the coefficient parameter matrix α and the bias parameter matrix γ once, and then reuses the coefficient parameter matrix α and the bias parameter matrix γ under the constraints of different preset complexity FLOPs, that is, "one-time learning and multiple pruning". In contrast, the AMC filter pruning model compression method and the Morphnet filter pruning model compression method must re-search the network structure to meet the constraints of each preset complexity FLOPs. Therefore, the present invention has better stability than other filter pruning model compression methods and is more efficient in providing a group of convolutional neural networks with different preset complexity FLOPs scales.

[0160] In summary, the global rank-aware neural network model compression method based on the filter feature map of the present invention mainly solves the problems of high labor cost, low pruning efficiency and poor stability of the existing filter pruning model compression method, and the implementation steps are as follows: obtaining an image data set and preprocessing it; building a general convolutional neural network and setting hyperparameters; selecting a loss function and an optimization algorithm for the neural network model; training a feature extractor and a classifier of the neural network model, and saving the pre-trained model; obtaining the average rank of the filter feature map in the pre-trained model Ω; using a preset pruning rate hyperparameter and a pre-trained neural network model, adaptively learning to obtain and save parameter matrices α and γ; expressing the importance of filters in the pre-trained neural network model and sorting filters; pruning and saving the pre-trained neural network model; fine-tuning the general neural network model Ω * , realizing global rank-aware neural network model compression based on filter feature graph. The technical solution of the present invention adopts "one-time learning and multiple pruning" to solve the problems of high labor cost and low efficiency, constructs layer-by-layer affine transformation to globally sort and uniformly prune the filters, and avoids the pathological selection problem caused by the norm criterion. Simulation proves that the pruning effect and stability of the present invention are better, and it is more efficient for large-scale acquisition of pruned networks of different complexities, which greatly improves the adaptability of neural networks to edge devices with different degrees of computing and storage resource constraints. It can be used for edge devices with different degrees of computing and storage resource constraints.

Claims

1. A global rank-aware neural network model compression method based on filter feature graph, characterized in that: The steps include: (1) Obtain image datasets and perform preprocessing: Obtain natural images, add labels to unlabeled natural images, and form the original image dataset X; generate training sets X through slicing operations. train , validation set X valid and the test set X test ; (2) Constructing a general convolutional neural network and setting hyperparameters: The overall architecture of the constructed general convolutional neural network model is: feature extractor → classifier; the basic network structure of the general convolutional neural network feature extractor and classifier is: input layer → hidden layer → output layer; According to the network model and image dataset, set the hyperparameters related to network model training and testing, including momentum, weight decay factor, batch, epoch, learning rate, mutation rate, number of fine-tuning iterations, number of input channels, total number of image classifications, and parameters related to the network model; and set the pruning rate of the general convolutional neural network model according to different hardware requirements; the pruning rate is also a hyperparameter, and the preset complexity FLOPs that can be derived from the hyperparameter is used as the minimum constant Perform multiple pruning operations according to the preset complexity of different target neural network models; (3) Selecting the loss function and optimization algorithm for the neural network model: The loss function uses the cross-entropy loss function as the loss function of the general neural network model; the general neural network model optimization process uses the stochastic gradient descent (SGD) algorithm as the optimization algorithm of the general neural network model; (4) Train the feature extractor and classifier of the neural network model and save the pre-trained model: train As the input of the general neural network model, in order to obtain the optimal weight parameters of the feature extractor and the classifier, the neural network model is trained, and the neural network model with the highest classification accuracy of the general neural network model is saved as the pre-trained model Ω; (5) Obtain the average rank of the filter feature map in the pre-trained model Ω: train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω and select the images as the input X in , the corresponding label is used as the input Y of the pre-trained model Ω, and the hook function is used to obtain the filter feature maps of all randomly selected images of the pre-trained neural network model Ω, and the average rank of each filter feature map in the pre-trained model is calculated; (6) Using the preset pruning rate hyperparameter and the pre-trained neural network model, adaptive learning is used to obtain and save the parameter matrices α and γ: the complexity FLOPs derived from the preset pruning rate is used as the minimum constant The classification accuracy Acc. of the neural network model in the training process is used as the fitness Fitness of the regulated Evaluation Algorithm (EA) with a regularization term. The coefficient parameter matrix α and the bias parameter matrix γ are adaptively learned by the regulated Evaluation Algorithm EA with a regularization term. The parameter matrices α and γ obtained by adaptive learning are saved and used to construct a layer-by-layer affine transformation L to represent the importance of the filter in the pre-training model. (7) Importance representation and filter ranking of filters in the pre-trained neural network model: The coefficient parameter matrix α and the bias parameter matrix γ are used to construct a layer-by-layer affine transformation L, and the importance of all filters in the general neural network model Ω is globally uniformly represented. Based on the layer-by-layer affine transformation result, i.e., the global uniform representation, all filters in the pre-trained neural network model Ω are globally ranked to obtain the global ranking result of the filters of the neural network model Ω. (8) Pruning and saving the pre-trained neural network model: Prune all filters after global sorting in the pre-trained neural network model, remove the bottom-rank filters in the global sorting results of the filters in the pre-trained neural network model, so that the complexity of the network model does not exceed the preset complexity, and save the pruned general neural network model Ω * ; (9) Fine-tuning the general neural network model Ω * :The pruned general neural network model Ω * Fine-tune the neural network model to restore the accuracy lost due to pruning, and complete the global rank-aware model compression based on the filter feature map of the general neural network model for natural images.

2. The global rank-aware neural network model compression method based on filter feature graph according to claim 1, characterized in that: The process of obtaining the average rank of the filter feature graph in the pre-trained model Ω described in step (5) specifically includes the following steps: (5.1) Obtain the feature maps of all filters in the neural network In the training dataset X train Randomly select a sufficient number of images and corresponding labels from the pre-trained model Ω and select the images as the input X in , the corresponding label is used as the output Y of the pre-trained model Ω, and the hook function is used to obtain the feature maps of all filters in the neural network Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, Indicates that the hook function acts on C i , n i-1 Represents C i The number of input channels, n i represents the number of filters, k i Represents C i The size of the filter, Represents C i The set of filter parameters in , Represents C i Input, Represents C i The bias of Represents C i The output of is the feature map, Indicates the pre-trained model The jth feature map generated, h i The height of the feature map represented by w i Represents C i The width of the feature map; (5.2) Calculate the average rank of each filter feature map in the pre-trained model * : Among them, t is the number of images used to obtain the average rank, that is, the number of randomly selected pictures, C i represents the i-th convolutional layer in the pre-trained neural network model, Represents C i The output feature map, Represented by the pre-trained model The jth feature map generated, h i Represents the height of the feature map, w i Indicates the width of the feature map, n i C i The number of filters in When inputting the sth picture, C in the pre-trained neural network model i The feature map of the jth filter rank.

3. The global rank-aware neural network model compression method based on filter feature graph according to claim 1, characterized in that: The step (6) of using the preset pruning rate hyperparameter and the pre-trained neural network model to adaptively learn and obtain and save the parameter matrices α and γ specifically includes the following steps: (6.1) Set the parameters related to the genetic evolution algorithm, including the population size P, the maximum number of iterations E, the sample size S, the mutation rate μ, the random step size σ, and the minimum constant The number of fine-tuning iterations τ; (6.2) Introduce the population queue, iterator and initialize it, introduce the coefficient parameter matrix α and the bias parameter matrix γ; (6.3) The iterator increments by 1, and the coefficient parameter matrix α and the bias parameter matrix γ are initialized; sampling mutation is performed from the population queue, and the coefficient parameter matrix α and the bias parameter matrix γ are updated using the standard deviation of the average rank of the filter in each convolutional layer after the mutation; (6.4) Based on the updated coefficient parameter matrix α and bias parameter matrix γ, the importance of the filter is represented L by layer-by-layer affine transformation, and the filters are sorted from large to small according to the representation results; (6.5) Remove the terminal filter from the sorting result to meet the minimum constant degree Requirements: Fine-tune the network after τ times of pruning and measure the classification accuracy of the pruned network model; (6.6) Use the classification accuracy, coefficient parameter matrix α and bias parameter matrix γ of the pruned network model to update the population queue; (6.7) Determine whether the iterator has reached the maximum number of iterations E; (6.8) Output and save the optimal coefficient parameter matrix α and bias parameter matrix γ.

4. The global rank-aware neural network model compression method based on filter feature graph according to claim 1, characterized in that: The importance representation and filter sorting of the filters in the pre-trained neural network model described in step (7), and the pruning and saving of the pre-trained neural network model described in step (8) specifically include the following steps: A. Construct layer-by-layer affine transformation to represent the importance of filters in the pre-trained neural network model Ω Among them, C i represents the i-th convolutional layer in the pre-trained neural network model, The average rank of the jth filter feature map in the i-th convolutional layer in the convolutional neural network model Ω, K represents the number of convolutional layers in the pre-trained model, n i is the number of filters in the i-th convolutional layer, are respectively the coefficient parameter matrix and the bias parameter matrix learned in step (6) of claim 1, represents the coefficient of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation, Bias of the jth filter in the i-th convolutional layer for layer-by-layer affine transformation; this step is performed in step (7); B. Sorting and pruning filters in the pre-trained neural network model Ω Among them, Sort(L) sorts the filters of the result L of layer-by-layer affine transformation from large to small. K represents the number of convolutional layers in the pre-trained model, n i is the number of filters in the i-th convolutional layer, Represents the layer-by-layer affine transformation result of the j-th filter in the i-th convolutional layer in the network model, Represents the constraint condition of the target neural network model, i.e., the complexity FLOPs. The bottom-rank filter in the Sort(L) result is cut off so that the complexity of the network model does not exceed the preset complexity. Ω * Represents the neural network model after filter pruning; saves the pruned general neural network model Ω * ; This step is carried out in step (8).