Classification method based on pruned convolutional neural network and related device
By using a predefined neural network structure search method and a pre-trained pruning sensitivity analysis model, the weights of the pruned convolutional neural network are directly obtained, solving the problem of long pruning time in existing technologies and achieving efficient model compression and accuracy.
Patent Information
- Application Number
- CN202210458105.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-04-27
AI Technical Summary
Existing techniques for determining sparsity in pruned convolutional neural networks are time-consuming, making it difficult to quickly achieve efficient model compression and accuracy with limited computing resources.
By using a predefined neural network structure search method and a pre-trained pruning sensitivity analysis model, the weights of the pruned classification model can be directly obtained, avoiding fine-tuning training. Combined with weight masking and backpropagation algorithms, the pruning rate and weight mask can be quickly determined.
This significantly reduces pruning time, improves pruning efficiency, and achieves high-efficiency model compression and accuracy with limited computing resources.
Smart Images

Figure CN114881136B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of model pruning, in particular to a classification method based on pruned convolutional neural network and related equipment. BACKGROUND
[0002] At present, deep learning models require a large amount of computing power, memory and power. When real-time inference needs to be performed, the model needs to be run on the device side, and the deep learning model needs to be run in a limited computing resource situation, a small volume and high accuracy deep learning model is needed, and therefore model compression can achieve this goal, and model pruning is one of the model compression.
[0003] Model pruning is mainly used to reduce the amount of calculation in the convolutional neural network, and usually the purpose of reducing the amount of calculation of the entire neural network is achieved by pruning the unimportant tensors in the neural network weights. Before pruning the unimportant tensors, the sparsity of each layer of the model needs to be determined to determine the unimportant tensors.
[0004] The existing sparsity determination method includes a method of consistent sparsity of each layer and a method of analyzing the sensitivity of each layer. Among them, the main idea of the sensitivity analysis method is to analyze the model effect change after each layer pruning in turn to judge the sensitivity of each layer. In order to better analyze the sensitivity of each layer after pruning, fine-tuning training needs to be performed on the model after pruning, and if you want to obtain a pruning configuration under a given target (such as a specific calculation requirement), you need to analyze the pruning sensitivity of all layers to determine the unimportant tensors, and the pruning process is time-consuming. SUMMARY
[0005] The present application provides a classification method based on pruned convolutional neural network and related equipment to solve the above problems.
[0006] The present application provides a classification method based on pruned convolutional neural network, comprising:
[0007] Obtaining a picture to be classified;
[0008] Inputting the picture to be classified into a pruned classification model to obtain a corresponding classification result;
[0009] Among them, the classification model weight in the pruned classification model is obtained by searching a pre-trained pruning sensitivity analysis model through a pre-defined neural network structure search method;
[0010] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0011] According to the pruning convolutional neural network-based classification method provided by the application, the method further comprises:
[0012] An initial pruning sensitivity analysis model is constructed for each network layer to be analyzed in the initial classification model;
[0013] The initial weights of the network layer to be analyzed are obtained by inputting the weight mask training set into the initial pruning sensitivity analysis model; the weight mask training set is generated by a random number generation method, and each weight mask training data in the weight mask training set corresponds to a pruning rate;
[0014] The training picture set is input into the initial classification model, and the initial prediction result is obtained based on the initial weights of each network layer to be analyzed and forward calculation;
[0015] According to the initial prediction result and the label set, the initial weights of each network layer to be analyzed are updated by using the back propagation algorithm, and the updated weights of the network layer to be analyzed are obtained;
[0016] According to the updated weights of the network layer to be analyzed, the weights in the initial pruning sensitivity analysis model are updated by using the chain rule of the back propagation algorithm until the initial classification model converges, so that a pre-trained pruning sensitivity analysis model and a trained classification model are obtained.
[0017] According to the pruning convolutional neural network-based classification method provided by the application, the initial weights of the network layer to be analyzed are obtained by inputting the weight mask training set into the initial pruning sensitivity analysis model, comprising:
[0018] The weight mask training data in the weight mask training set is input into a plurality of convolutional networks to generate feature maps; and
[0019] The feature maps and the weight mask training data are fused to generate the initial weights of the network layer to be analyzed.
[0020] According to the pruning convolutional neural network-based classification method provided by the application, the method further comprises:
[0021] Step 201: The pruning rates of each network layer in the trained classification model are exhaustively searched in a preset pruning rate search space to obtain a pruning rate set; a pruning rate meeting a preset pruning target is selected from the pruning rate set as a pruning rate to be analyzed; wherein the preset pruning target is a pruning target of the trained classification model;
[0022] Step 202: According to the correspondence between the pruning rate and the weight mask, the weight mask corresponding to the pruning rate to be analyzed is determined as a weight mask to be analyzed;
[0023] Step 203, inputting the weight mask to be analyzed into the pre-trained pruning sensitivity analysis model, to obtain the pruned weight corresponding to the trained classification model;
[0024] Step 204, evaluating the performance of the trained classification model based on the pruned weight, to obtain a performance evaluation index value;
[0025] Step 205, repeating the step 203 to the step 204 until all pruning rates to be analyzed are exhausted, thereby obtaining a plurality of performance evaluation index values;
[0026] Step 206, determining the maximum performance evaluation index value from the plurality of performance evaluation index values as the optimal sensitivity, and taking the pruned weight corresponding to the optimal sensitivity as the classification model weight in the pruned classification model.
[0027] According to the classification method based on the pruning convolutional neural network provided by the application, the correspondence between the pruning rate and the weight mask is that the weight mask mask is obtained based on the pruning rate p and the weight dimension information, wherein the weight dimension information includes the channel number C:
[0028] mask[0:C*p]=0, mask[C*p:C]=1
[0029] Wherein, mask[0:C*p]=0 is the weight mask corresponding to the first C*p channels in the C channels, mask[C*p:C]=1 is the weight mask corresponding to the last C-C*p channels in the C channels.
[0030] According to the classification method based on the pruning convolutional neural network provided by the application, the pruning rate of each network layer in the trained classification model is exhausted in the preset pruning rate search space, to obtain a pruning rate set, including:
[0031] According to the preset pruning rate value range and the pruning rate value step, all pruning rates conforming to the pruning rate value step are exhausted in the preset pruning rate value range, thereby obtaining a pruning rate set.
[0032] According to the classification method based on the pruning convolutional neural network provided by the application, the preset pruning target includes at least one of the following: target computing power of the trained classification model; target parameter quantity of the trained classification model.
[0033] The application also provides a classification device based on a pruning convolutional neural network, comprising:
[0034] The picture acquisition module is configured to acquire a picture to be classified;
[0035] a classification module configured to input the picture to be classified into the pruned classification model to obtain a corresponding classification result;
[0036] The classification model weight in the pruned classification model is searched by a pre-defined neural network structure search method from a pre-trained pruning sensitivity analysis model.
[0037] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0038] The application further provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the classification method based on the pruned convolutional neural network according to any one of the above when executing the program.
[0039] The application further provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the classification method based on the pruned convolutional neural network according to any one of the above.
[0040] The application further provides a computer program product, which comprises a computer program, and the computer program is executable on a processor to implement the classification method based on the pruned convolutional neural network according to any one of the above.
[0041] The classification method based on the pruned convolutional neural network and the related device provided by the application perform classification and identification on the picture to be classified by using the pruned classification model, the classification model weight in the pruned classification model is searched by a pre-defined neural network structure search method from a pre-trained pruning sensitivity analysis model, the pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set, thus, the classification model does not need to be fine-tuned after pruning, the corresponding classification model weight is directly obtained from the pre-trained pruning sensitivity analysis model, and the pruning time is greatly saved. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the application or prior art, the following will briefly introduce the drawings needed in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort.
[0043] Figure 1is a flowchart of a classification method based on a pruned convolutional neural network provided by an embodiment of the present application.
[0044] Figure 2 is a network structure diagram of an initial classification model provided by an embodiment of the present application.
[0045] Figure 3 is a network structure diagram of an initial pruning sensitivity analysis model provided by an embodiment of the present application.
[0046] Figure 4 is a structure diagram of a classification device based on a pruned convolutional neural network provided by an embodiment of the present application.
[0047] Figure 5 is a physical structure diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0048] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described below in connection with the drawings in the present application. Obviously, the described embodiments are some embodiments of the present application, but not all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0049] Figure 1 is a flowchart of a classification method based on a pruned convolutional neural network provided by an embodiment of the present application. As shown in Figure 1 , a classification method based on a pruned convolutional neural network includes the following steps:
[0050] S101, obtaining a picture to be classified.
[0051] In this step, the picture to be classified is a vehicle type picture to be classified, which can be directly photographed, obtained from the Internet, or an image in a vehicle type picture database.
[0052] S102, inputting the picture to be classified into a pruned classification model to obtain a corresponding classification result.
[0053] The classification model weight in the pruned classification model is obtained by searching a pre-trained pruning sensitivity analysis model through a pre-defined neural network structure search method.
[0054] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0055] In this embodiment, corresponding to the above-mentioned vehicle type picture to be classified, the pruned classification model is a pruned vehicle type classification model, and the classification result obtained after forward inference of the pruned vehicle type classification model includes a car, a truck, a van, an ambulance, a bus, a bicycle and a tricycle.
[0056] Similarly, the pre-trained pruning sensitivity analysis model is trained based on the initial vehicle type classification model, the vehicle type training picture set, the vehicle type label set corresponding to the vehicle type training picture set and the weight mask training set.
[0057] Specifically, the input corresponding to the pre-trained pruning sensitivity analysis model is a weight mask, and the output result is a classification model weight of the pruned classification model, wherein the input weight mask corresponds to a pruning rate, that is, the classification model weight under a predetermined pruning rate can be obtained through the pre-trained pruning sensitivity analysis model, and the classification model under the predetermined pruning rate is directly obtained based on the classification model weight.
[0058] The optimal classification model weight is obtained by searching the pre-trained pruning sensitivity analysis model through a pre-defined neural network structure search method, that is, the optimal classification model weight with the optimal sensitivity in the pruning sensitivity analysis model can be obtained through the neural network structure search method, the optimal classification model weight is used as the weight in the classification model, and thus the pruned classification model is obtained.
[0059] The classification method based on the pruned convolutional neural network provided in the embodiment of the application obtains the weight with the optimal sensitivity by searching the pre-trained pruning sensitivity analysis model through the pre-defined neural network structure search method, directly obtains the pruned classification model based on the weight with the optimal sensitivity, does not need to perform fine-tuning training after pruning the classification model, and changes the sensitivity analysis time in the pruning process to only the pruning sensitivity analysis model that needs to be trained once, thereby greatly reducing the pruning time consumption.
[0060] Further, the method further comprises:
[0061] constructing an initial pruning sensitivity analysis model for each network layer to be analyzed in the initial classification model;
[0062] inputting the weight mask training set into the initial pruning sensitivity analysis model to obtain the initial weight of the network layer to be analyzed; the weight mask training set is generated through a random number generation method, and each weight mask training data in the weight mask training set corresponds to a pruning rate;
[0063] inputting the training picture set into the initial classification model, and obtaining an initial prediction result based on the initial weight of each network layer to be analyzed and forward calculation;
[0064] According to the initial prediction result and the label set, the initial weight of each network layer to be analyzed is updated by using a back propagation algorithm, to obtain an updated weight of the network layer to be analyzed;
[0065] According to the updated weight of the network layer to be analyzed, the weight in the initial pruning sensitivity analysis model is updated by using a chain rule of the back propagation algorithm, until the initial classification model converges, so as to obtain a pre-trained pruning sensitivity analysis model and a trained classification model.
[0066] Figure 2 is a schematic diagram of a network structure of the initial classification model provided by an embodiment of the present application, as shown in the figure, the initial classification model includes a convolutional layer A, a convolutional layer B, a convolutional layer C, and the like, and the input of the initial classification model is a pre-labeled picture in a training picture set and a corresponding category label, and the output is a predicted category corresponding to the pre-labeled picture. Figure 2
[0067] Each network layer in the initial classification model needs to be analyzed for sensitivity, and therefore each network layer is a network layer to be analyzed. Since each network layer to be analyzed needs to be analyzed for sensitivity, each network layer to be analyzed corresponds to an initial pruning sensitivity analysis model.
[0068] Figure 3 is a schematic diagram of a network structure of the initial pruning sensitivity analysis model provided by an embodiment of the present application, as shown in the figure, the network layer corresponding to the initial pruning sensitivity analysis model includes a convolutional layer 1 and a convolutional layer 2, and the input of the initial pruning sensitivity analysis model is a weight mask randomly generated in a weight mask training set, the weight mask is subjected to convolutional operation of the convolutional layer 1 and the convolutional layer 2, and then the feature map is fused with the initially input weight mask to obtain an output result, and the output result is directly used as the weight of the network layer to be analyzed. Figure 3
[0069] wherein, the input input of the initial pruning sensitivity analysis model is a weight mask mask, and the shape is (an output size layer-out of the network layer to be analyzed, an input size layer-in of the network layer to be analyzed, k, k), and k is the size of a convolution kernel; the shape of Conv1 is (layer-in*2, layer-in, 3, 3); the shape of Conv2 is (layer-out, layer-in*2, 3, 3); and the shape of the output output is (layer-out, layer-in, k, k), and the output output is the weight of the network layer to be analyzed.
[0070] The weight mask corresponds to the pruning rate, that is, the size of the pruning rate affects how many 0s the weight mask takes, if the pruning rate is small, the number of 0s taken by the weight mask in the channel is small, when the weight mask is 0, the weight value in the corresponding channel does not participate in the calculation, when the weight mask takes 1, the weight value in the corresponding channel participates in the calculation. In addition, the above weight mask training set is randomly generated by using the existing random algorithm.
[0071] According to the characteristics and relevance of the above initial classification model and initial pruning sensitivity analysis model, the joint training of the model is as follows:
[0072] The pre-labeled pictures in the training picture set are input into the initial classification model, and the output results (i.e. forward calculation) are obtained after the calculation of each network layer in the initial classification model, that is, the predicted categories. Then, the loss function is used to calculate the loss of the predicted category and the pre-labeled label (i.e. loss calculation), based on the calculated loss value, and the weight value of the network layer in the entire initial classification model is updated by using the back propagation algorithm. When the initial classification model converges, the predicted category matches the corresponding label with the highest degree, and the entire initial classification model is a trained classification model.
[0073] In the classification model weight updating process of each network layer to be analyzed in the above initial classification model, the updated classification model weight is used as the label of the output result of the initial pruning sensitivity analysis model, and the loss function is used to calculate the loss of the label of the output result of the initial pruning sensitivity analysis model and the output result obtained after the weight mask is input into the initial pruning sensitivity analysis model, and the initial pruning sensitivity analysis model is trained according to the loss value and the back propagation algorithm, until each initial pruning sensitivity analysis model converges, thereby obtaining a trained pruning sensitivity analysis model.
[0074] The classification method based on the pruning convolutional neural network provided by the embodiment of the application trains the pruning sensitivity analysis model and the classification model by using the chain rule of back propagation, thereby saving the pruning time.
[0075] Further, the inputting of the weight mask training set into the initial pruning sensitivity analysis model to obtain the initial weight of the network layer to be analyzed comprises:
[0076] The weight mask training data in the weight mask training set is input into a plurality of convolutional networks to generate feature maps; and
[0077] The feature maps and the weight mask training data are fused to generate the initial weight of the network layer to be analyzed.
[0078] Specifically, the randomly generated weight mask is input into the initial pruning sensitivity analysis model, and the pruning sensitivity analysis result corresponding to the weight mask is predicted through the forward calculation of the weight parameters in the initial pruning sensitivity analysis model. The output result is used as the initial weight of the network layer to be analyzed, that is, which weights in the network layer to be analyzed are kept and which weights are set to 0 can be predicted by the initial pruning sensitivity analysis model under the condition of the weight mask being determined.
[0079] The corresponding relationship between the weight mask and the weight in the classification model can be accurately obtained through the joint training of the initial pruning sensitivity analysis model and the initial classification model.
[0080] Further, the method further comprises:
[0081] Step 201: Exhaustively searching for the pruning rate of each network layer in the trained classification model in a preset pruning rate search space to obtain a pruning rate set. The pruning rate meeting the preset pruning target is selected from the pruning rate set as the pruning rate to be analyzed.
[0082] The preset pruning target is the pruning target of the trained classification model.
[0083] In this step, the pruning rate search space is a set pruning rate value range. All possible pruning rates can be exhausted in the above pruning rate value range with a specific step size, so as to obtain the pruning rate set.
[0084] In this step, the preset pruning target refers to the performance of the user's hope for the pruned classification model, for example, the hope that the parameter amount of the pruned classification model reaches a certain target, the computing power (FLOPs) reaches a certain target, so as to measure the compression effect.
[0085] The pruning rate set corresponding to all the network layers to be analyzed is combined, and the pruning rate combination meeting the pruning target is selected, that is, the pruning rate combination selected from each network layer to be analyzed together can meet the above pruning target.
[0086] Step 202: According to the corresponding relationship between the pruning rate and the weight mask, the weight mask corresponding to the pruning rate to be analyzed is determined as the weight mask to be analyzed.
[0087] In this step, according to the above selected pruning rate to be analyzed and the corresponding relationship between the pruning rate and the weight mask, the weight mask corresponding to the pruning rate to be analyzed is determined as the weight mask to be analyzed.
[0088] Step 203: Input the weight mask to be analyzed into the pre-trained pruning sensitivity analysis model to obtain the pruned weight corresponding to the trained classification model.
[0089] In this step, the weight mask to be analyzed corresponding to each network layer to be analyzed is input into the corresponding trained pruning sensitivity analysis model, and the output result obtained is the pruned weight of the network layer to be analyzed. The pruned weights of all network layers to be analyzed are integrated to obtain the pruned weight of the entire classification model.
[0090] In step 204, the performance of the trained classification model is evaluated based on the pruned weight, and a performance evaluation index value is obtained.
[0091] In this step, the performance of the classification model is evaluated according to the pruned weight of the entire classification model, and a performance evaluation index value is obtained.
[0092] In this embodiment, the performance evaluation index includes accuracy ACC; in other embodiments of the application, the performance evaluation index can also be false positive, precision, recall, and other model performance evaluation indexes.
[0093] In step 205, steps 203 to 204 are repeated until all the pruning rates to be analyzed are exhausted, and a plurality of performance evaluation index values are obtained.
[0094] In this step, since there are many combinations of pruning rates to be analyzed that meet the pruning target, all the pruning rates to be analyzed are exhausted, and a plurality of performance evaluation index values of the corresponding classification model under the combination of the pruning rates to be analyzed are obtained.
[0095] In step 206, the maximum performance evaluation index value is determined from the plurality of performance evaluation index values as the optimal sensitivity, and the pruned weight corresponding to the optimal sensitivity is used as the classification model weight in the pruned classification model.
[0096] In this step, the classification model with the best performance evaluation index value is used as the model with the optimal pruning sensitivity, and the corresponding pruned weight is finally used as the classification model weight in the pruned classification model.
[0097] The classification method based on the pruning convolutional neural network provided in the embodiment of the application obtains all pruning rate possibilities according to a predetermined pruning target, further obtains pruning possibilities of all classification models, measures the pruning sensitivity of the classification model through performance evaluation of the model, and finally uses the classification model with the highest performance evaluation index value as the model with the optimal sensitivity. The corresponding pruned weight and pruning rate are the optimal pruned weight and the optimal pruning rate. Thus, the pruned classification model is obtained, and therefore, after pruning, fine-tuning training is not required, and layer-by-layer pruning sensitivity analysis is not required, the pruning efficiency is improved, and the predetermined target can be completed in a short time.
[0098] Further, the pruning rate and the corresponding relationship of the weight mask are that the weight mask mask is obtained based on the pruning rate p and weight dimension information, wherein the weight dimension information includes a channel number C.
[0099] mask[0:C*p] = 0, mask[C*p:C] = 1
[0100] Wherein, mask[0:C*p] = 0 is that the weight mask mask corresponding to the first C*p channels in the C channels is 0, mask[C*p:C] = 1 is that the weight mask mask corresponding to the last C-C*p channels in the C channels is 1, and the pruning rate p [0, 1].
[0101] Specifically, the weight dimension information includes a channel number C and a convolution kernel size k. Assuming that the weight dimension information is (c1, c2, k, k), wherein c1 and c2 are the first dimension channel number and the second dimension channel number respectively. Then in the first dimension c1, the weight mask mask[0:c1*p] = 0, mask[c1*p:c1] = 1, that is, the weight mask value of the first c1*p channels in the c1 channels is 0, and the weight mask value of the last c1-c1*p channels is 1; when the weight mask value is 0, it means that the weights in the first c1*p channels do not participate in the calculation, that is, pruning is completed; when the weight mask value is 1, it means that the weight values in the last c1-c1*p channels remain unchanged and continue to participate in the calculation, that is, they are retained.
[0102] Similarly, in the second dimension c2, the weight mask mask[0:c2*p] = 0, mask[c2*p:c2] = 1, that is, the weight mask value of the first c2*p channels in the c2 channels is 0, and the weight mask value of the last c2-c2*p channels is 1.
[0103] Further, the pruning rate of each network layer in the trained classification model is exhausted in the preset pruning rate search space to obtain a pruning rate set, including:
[0104] According to the preset pruning rate value range and the pruning rate value step, all pruning rates conforming to the pruning rate value step are exhausted in the preset pruning rate value range, so as to obtain a pruning rate set.
[0105] Specifically, assuming that the preset pruning rate value range is (0.1, 0.9) and the pruning rate value step is 0.1, then the pruning rate set is (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9).
[0106] Further, the preset pruning target comprises at least one of a target computing power of the trained classification model and a target parameter quantity of the trained classification model.
[0107] Specifically, if the calculation amount of the classification model without pruning is 12 GFLOPs and the parameter amount is 2M, the pruning target is that the calculation amount after pruning is 2 GFLOPs and the parameter amount is 0.5M, that is, in the above pruning rate screening process, the to-be-analyzed pruning rate screened needs to make the calculation amount of the classification model after pruning not more than 2 GFLOPs and the parameter amount not more than 0.5M, so as to realize the acceleration and compression of the model, and facilitate direct application in the automatic driving scene.
[0108] The classification device based on the pruned convolutional neural network provided by the application is described below, and the classification device based on the pruned convolutional neural network described below can be correspondingly referred to the classification method based on the pruned convolutional neural network described above.
[0109] Figure 4 The structure schematic diagram of the classification device based on the pruned convolutional neural network provided by the embodiment of the application is shown in Figure 4 The classification device based on the pruned convolutional neural network comprises:
[0110] The picture acquisition module 401 is configured to acquire a picture to be classified.
[0111] In this module, the picture to be classified is a vehicle type picture to be classified, which can be directly photographed and acquired, or acquired from the Internet, or an image in a vehicle type picture database.
[0112] The classification module 402 is configured to input the picture to be classified into the pruned classification model to obtain a corresponding classification result.
[0113] The classification model weight in the pruned classification model is searched by a pre-defined neural network structure search method on a pre-trained pruning sensitivity analysis model.
[0114] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0115] In this embodiment, corresponding to the above-mentioned vehicle type picture to be classified, the pruned classification model is a pruned vehicle type classification model, and correspondingly, the classification result obtained after forward inference of the pruned vehicle type classification model comprises a car, a truck, a van, an ambulance, a bus, a bicycle, a tricycle, etc.
[0116] Similarly, the pre-trained pruning sensitivity analysis model is trained based on the initial vehicle type classification model, the vehicle type training picture set, the vehicle type label set corresponding to the vehicle type training picture set, and the weight mask training set.
[0117] Specifically, the input corresponding to the pre-trained pruning sensitivity analysis model is a weight mask, and the output result is the classification model weight of the pruned classification model, wherein the input weight mask also corresponds to a pruning rate, that is, the classification model weight under a predetermined pruning rate can be obtained through the pre-trained pruning sensitivity analysis model, and the classification model under the predetermined pruning rate is directly obtained based on the classification model weight.
[0118] The optimal classification model weight is obtained by searching the pre-trained pruning sensitivity analysis model through a predefined neural network structure search method, that is, the classification model weight with optimal sensitivity in the pruning sensitivity analysis model can be obtained through the neural network structure search method, and the optimal classification model weight is used as the weight in the classification model, thereby obtaining the pruned classification model.
[0119] The above classification results include cars, trucks, vans, ambulances, buses, bicycles, and tricycles.
[0120] The classification device based on the pruning convolutional neural network provided by the embodiment of the present application searches for the weight with optimal sensitivity through a predefined neural network structure search method on the pre-trained pruning sensitivity analysis model, directly obtains the pruned classification model based on the weight with optimal sensitivity, does not need to perform fine-tuning training after pruning the classification model, and the sensitivity analysis time in the pruning process becomes only the pruning sensitivity analysis model that needs to be trained once, thereby greatly reducing the pruning time consumption.
[0121] Figure 5 An entity structure diagram of an electronic device provided by the embodiment of the present application is shown in FIG. 1. Figure 5 As shown in FIG. 1, the electronic device can include a processor 510, a communications interface 520, a memory 530, and a communications bus 540, wherein the processor 510, the communications interface 520, and the memory 530 complete mutual communication through the communications bus 540. The processor 510 can invoke the logical instructions in the memory 530 to execute the classification method based on the pruning convolutional neural network, and the classification method based on the pruning convolutional neural network includes:
[0122] obtaining a picture to be classified;
[0123] inputting the picture to be classified into the pruned classification model to obtain a corresponding classification result;
[0124] The classification model weight in the pruned classification model is searched by a predefined neural network structure search method on a pre-trained pruning sensitivity analysis model.
[0125] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0126] In addition, the logical instructions in the memory 530 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0127] On the other hand, the present application also provides a computer program product, the computer program product comprising a computer program, the computer program being storable on a non-transitory computer-readable storage medium, and the computer program being executable by a processor, the computer being capable of executing a classification method based on a pruned convolutional neural network provided by each of the methods described above, the classification method based on the pruned convolutional neural network comprising:
[0128] Obtaining a picture to be classified;
[0129] Inputting the picture to be classified into the pruned classification model to obtain a corresponding classification result;
[0130] The classification model weight in the pruned classification model is searched by a predefined neural network structure search method on a pre-trained pruning sensitivity analysis model.
[0131] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0132] In yet another aspect, the present application also provides a non-transitory computer readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the pruning-based convolutional neural network classification method provided by the above method, the pruning-based convolutional neural network classification method comprising:
[0133] obtaining a picture to be classified;
[0134] inputting the picture to be classified into the pruned classification model to obtain a corresponding classification result;
[0135] wherein the classification model weight in the pruned classification model is obtained by searching a pre-trained pruning sensitivity analysis model through a predefined neural network structure search method;
[0136] The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set.
[0137] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement without creative labor.
[0138] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software plus necessary universal hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods of the various embodiments or some parts of the embodiments.
[0139] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A pruning convolutional neural network-based classification method, characterized in that, The method comprises: obtaining a picture to be classified; inputting the picture to be classified into a pruned classification model to obtain a corresponding classification result; wherein the classification model weight in the pruned classification model is searched by a pre-defined neural network structure search method on a pre-trained pruning sensitivity analysis model; the pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set; wherein the pre-trained pruning sensitivity analysis model is obtained by updating the weight of the initial pruning sensitivity analysis model according to the updated weight of each network layer to be analyzed in the initial classification model, using the chain rule of the back propagation algorithm, until the initial classification model converges. 2.The pruning convolutional neural network-based classification method of claim 1, wherein, The method further comprises: constructing an initial pruning sensitivity analysis model for each network layer to be analyzed in the initial classification model; inputting the weight mask training set into the initial pruning sensitivity analysis model to obtain the initial weight of the network layer to be analyzed; the weight mask training set is generated by a random number generation method, and each weight mask training data in the weight mask training set corresponds to a pruning rate; inputting the training picture set into the initial classification model to obtain an initial prediction result based on the initial weight of each network layer to be analyzed and forward calculation; updating the initial weight of each network layer to be analyzed using the back propagation algorithm according to the initial prediction result and the label set, to obtain the updated weight of the network layer to be analyzed; updating the weight of the initial pruning sensitivity analysis model using the chain rule of the back propagation algorithm according to the updated weight of the network layer to be analyzed, until the initial classification model converges, thereby obtaining the pre-trained pruning sensitivity analysis model and the trained classification model. 3.The pruning convolutional neural network-based classification method of claim 2, wherein, The method further comprises: inputting the weight mask training data in the weight mask training set into a plurality of convolutional networks to generate feature maps; and fusing the feature maps and the weight mask training data to generate the initial weight of the network layer to be analyzed. 4.The pruning convolutional neural network-based classification method of claim 2, wherein, The method further comprises: step 201: exhaustively searching for the pruning rate of each network layer in the trained classification model within a pre-set pruning rate search space to obtain a pruning rate set; filtering out a pruning rate that meets a pre-set pruning target from the pruning rate set as an analyzed pruning rate; wherein the pre-set pruning target is the pruning target of the trained classification model; step 202: determining the weight mask corresponding to the analyzed pruning rate as an analyzed weight mask according to the correspondence between the pruning rate and the weight mask; step 203: inputting the analyzed weight mask into the pre-trained pruning sensitivity analysis model to obtain the pruned weight corresponding to the trained classification model; step 204: evaluating the performance of the trained classification model based on the pruned weight to obtain a performance evaluation index value; Step 205, repeating the step 203 to the step 204 until all pruning rates to be analyzed are exhausted, thereby obtaining a plurality of performance evaluation index values; Step 206, determining the maximum performance evaluation index value from the plurality of performance evaluation index values as the optimal sensitivity, and taking the pruning weight corresponding to the optimal sensitivity as the classification model weight in the pruned classification model. 5.The pruning convolutional neural network-based classification method according to claim 4, characterized in that, The correspondence between the pruning rate and the weight mask is that the weight mask mask is obtained based on the pruning rate p and weight dimension information, wherein the weight dimension information includes the number of channels C: mask[0:C*p]=0, mask[C*p:C]=1 Wherein, mask[0:C*p]=0 is that the weight mask mask corresponding to the first C*p channels in the C channels is 0, and mask[C*p:C]=1 is that the weight mask mask corresponding to the last C-C*p channels in the C channels is 1. 6.The pruning convolutional neural network-based classification method of claim 4, wherein, The pruning rate set is obtained by enumerating the pruning rate of each network layer in the trained classification model within the preset pruning rate search space, including: According to the preset pruning rate value range and the pruning rate value step, all pruning rates conforming to the pruning rate value step are enumerated within the preset pruning rate value range, thereby obtaining a pruning rate set.
7. The pruning-based convolutional neural network classification method according to any one of claims 4-6, characterized in that, The preset pruning target includes at least one of the following: target computing power of the trained classification model; target parameter quantity of the trained classification model.
8. A pruning convolutional neural network based classification apparatus, characterized in that, Including: The picture acquisition module is configured to acquire a picture to be classified; The classification module is configured to input the picture to be classified into the pruned classification model to obtain a corresponding classification result; Wherein, the classification model weight in the pruned classification model is searched by a pre-defined neural network structure search method on a pre-trained pruning sensitivity analysis model; The pre-trained pruning sensitivity analysis model is trained based on an initial classification model, a training picture set, a label set corresponding to the training picture set, and a weight mask training set; Wherein, the pre-trained pruning sensitivity analysis model is updated according to the updated weight of each network layer to be analyzed in the initial classification model, using the chain rule of the back propagation algorithm, until the initial classification model converges.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to realize the classification method based on the pruning convolutional neural network according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the classification method based on the pruning convolutional neural network according to any one of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to realize the classification method based on the pruning convolutional neural network according to any one of claims 1 to 7.
Citation Information
Patent Citations
Vehicle classifier training method
CN106372658A
Neural network model compression method, system and device and medium
CN111079899A