A neural network pruning method, device, equipment and storage medium

By constructing the channel kernel set and reconstructing the convolution kernel, the overall channel compression of the multi-branch neural network is achieved, which solves the problem of incomplete channel compression in the multi-branch structure in the existing technology, and improves the compression ratio and calculation efficiency.

CN113705775BActive Publication Date: 2024-10-01LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202110866324.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-29
Publication Date
2024-10-01
Estimated Expiration
2041-07-29

AI Technical Summary

Technical Problem

The existing neural network pruning method only prunes the input and output channels of the middle layer of the bottleneck structure in a multi-branch structure, and fails to effectively compress the number of channels of the entire multi-branch structure, resulting in a low compression ratio and difficulty in improving computational efficiency. .

Method used

By determining the target network layer to be pruned in the neural network, the channel compression ratio and the convolution kernel weight are used to construct a channel kernel set, asynchronous channel pruning is performed, and the convolution kernel is reconstructed to achieve overall channel compression of the multi-branch structure. .

Benefits of technology

It improves the compression ratio of the neural network, reduces the amount of calculation, speeds up task processing, maintains the robustness of the compressed model, and achieves flexible sparse granularity in different network layers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113705775B_ABST
    Figure CN113705775B_ABST
Patent Text Reader

Abstract

The present invention discloses a neural network pruning method, device, equipment and storage medium; when the scheme prunes the neural network, the network layer to be pruned can be used as the target network layer for channel pruning and convolution kernel reconstruction. Therefore, when the scheme compresses a multi-branch structure, it is not limited to the intermediate layer, but can also compress the input layer, output layer, downsampling layer and other network layers, which greatly improves the compression ratio of the neural network, reduces the amount of calculation required for the neural network model to perform tasks, and speeds up the task processing speed of the neural network; and, the scheme is a data-independent asynchronous channel pruning method, which is conducive to maintaining the robustness of the compressed neural network, and can also achieve pruning of different sparse granularities in different network layers of the neural network, thereby improving the flexibility of compression.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep neural network compression and acceleration technology, and more specifically, to a neural network pruning method, device, equipment and storage medium. Background Art

[0002] As neural networks increase in depth and width, they have demonstrated excellent performance in various AI (Artificial Intelligence) application scenarios, such as machine vision tasks such as image recognition and target detection. Faced with the development trend of deep learning-based machine vision software in various embedded devices or mobile devices, deep neural networks with huge parameter volumes are difficult to deploy in devices with limited computing and storage resources. Deep neural network compression and acceleration technology provides a solution for the long-term real-time application of deep learning in these resource-constrained devices. Deep neural network compression technology reduces the storage overhead of neural network models and improves the inference speed by reducing the number of parameters and computing power of neural network models.

[0003] At present, convolutional neural networks have evolved into a variety of multi-branch structures, but the pruning schemes for multi-branch structures only prune the input and output channels of the middle layer of the bottleneck structure, and do not compress the input and output channels of the entire multi-branch structure. The number of channels in the middle layer of the bottleneck structure of the multi-branch structure is originally smaller than the number of input and output channels of the entire module. Therefore, only compressing the middle layer of the multi-branch structure is not conducive to improving the compression ratio of the multi-branch structure. Summary of the invention

[0004] The purpose of the present invention is to provide a neural network pruning method, device, equipment and storage medium to improve the compression ratio of the neural network, reduce the amount of calculation required for the neural network model to perform tasks, and speed up the task processing speed of the neural network.

[0005] To achieve the above object, the present invention provides a neural network pruning method, comprising:

[0006] Determine the target network layer to be pruned in the neural network;

[0007] Determine the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the reserved input channels;

[0008] The original input channels of the target network layer are pruned according to the channel kernel set, and the convolution kernel of the target network layer is reconstructed.

[0009] The step of determining the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution core weight of each original input channel includes:

[0010] Determining a second number of reserved input channels of the target network layer according to the first number of original input channels of the target network layer and the channel compression ratio;

[0011] Determine the importance value of each original input channel by using the first number, the second number, and the Frobenius norm of the convolution kernel weight of each original input channel;

[0012] Determine the sampling probability of each original input channel according to the importance value of each original input channel;

[0013] Each original input channel is independently sampled for R rounds using the sampling probability of each original input channel, and a channel core set corresponding to the target network layer is generated according to the sampling results.

[0014] The determining the importance value of each original input channel by using the first number, the second number, and the Frobenius norm of the convolution kernel weight of each original input channel includes:

[0015] Determine the first number of weighting coefficients using the first number and the second number;

[0016] Determine the Frobenius norm value of each original input channel according to the convolution kernel weight of each original input channel, and assign a corresponding weighting coefficient to each original input channel according to the Frobenius norm value of each original input channel; wherein, the original input channel with a larger Frobenius norm value is assigned a larger weighting coefficient;

[0017] The importance value of each original input channel is determined according to the weight coefficient of each original input channel and the initial importance function of each original input channel.

[0018] Wherein, the reconstructing the convolution kernel of the target network layer includes:

[0019] An optimization function is created using the channel core set; the optimization function is:

[0020]

[0021] Among them, Y k is the output feature map of the original convolution kernel at output channel k, K is the total number of convolution kernel output channels of the target network layer, Represents the calculation of the feature map reconstruction error of the K output channels of the convolution kernel and summation, represents the Frobenius norm, Wik Represents the weight of the convolution kernel in the input channel i and the output channel k, For the channel core set The input data x for each reserved input channel in i The sum of the output feature maps of the convolution kernel output channel k, * represents the convolution operation;

[0022] The optimization function is minimized, and the weights of the convolution kernel of the target network layer are updated.

[0023] To achieve the above object, the present invention further provides a pruning method based on a ResNet downsampling module, including the pruning method in the above scheme; wherein, determining the target network layer to be pruned in the neural network includes:

[0024] The intermediate layer and the output layer of the residual branch in the downsampling module are used as the target network layers in turn to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer;

[0025] Accordingly, the pruning method further includes:

[0026] Using the channel compression ratio of the input layer of the downsampling module, randomly sampling the original input channels of the input layer to obtain a first input channel screening result;

[0027] The input layer of the downsampling module and the original input channel of the downsampling layer are pruned using the first input channel screening result, and the input layer and the downsampling layer of the downsampling module are used as target network layers for convolution kernel reconstruction.

[0028] To achieve the above object, the present invention further provides a pruning method based on a ResNet residual module, including the pruning method in the above scheme; wherein the ResNet includes N stacked residual modules, and the target network layer to be pruned in the neural network is determined to include:

[0029] The intermediate layer and the output layer of each residual module in the N residual modules are used as the target network layer in turn, so as to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer;

[0030] Correspondingly, after pruning the original input channels of the intermediate layer and the output layer and reconstructing the convolution kernels of the intermediate layer and the output layer, the pruning method further includes:

[0031] Using the channel compression ratio of the input layer of the residual module, randomly sampling the original input channel of the input layer of the residual module to obtain a second input channel screening result;

[0032] For each of the N residual modules, the original input channels of the input layer of each residual module are pruned using the second input channel screening result, and the input layer of the residual module is used as the target network layer for convolution kernel reconstruction; the original output channels of the output layer of the residual module are pruned using the second input channel screening result, and the output layer of the residual module is used as the target network layer for convolution kernel reconstruction.

[0033] To achieve the above object, the present invention further provides a pruning method based on SqueezeNet, including the pruning method in the above scheme; wherein, if the target Fire module of the SqueezeNet is pruned, the target network layer to be pruned in the neural network is determined to include:

[0034] The Squeeze layer of the next Fire module of the target Fire module is used as the target network layer, so as to prune the original input channel of the Squeeze layer of the next Fire module and reconstruct the convolution kernel of the Squeeze layer of the next Fire module;

[0035] Accordingly, the pruning method further includes:

[0036] Pruning original output channels of convolution kernels of different sizes in the Expand layer of the target Fire module according to the channel kernel set of the Squeeze layer of the next Fire module;

[0037] Using the channel compression ratio of the Expand layer of the target Fire module, randomly sampling the original input channels of the Expand layer of the target Fire module to obtain a third input channel screening result;

[0038] The original input channels of convolution kernels of different sizes in the Expand layer of the target Fire module are pruned using the third input channel screening result, and the Expand layer of the target Fire module is used as the target network layer to reconstruct the convolution kernels of different sizes in the Expand layer.

[0039] To achieve the above object, the present invention further provides a neural network pruning device, comprising:

[0040] A network layer determination module is used to determine the target network layer to be pruned in the neural network;

[0041] A channel core set determination module, used to determine the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the reserved input channels;

[0042] A channel pruning module, used for pruning the original input channel of the target network layer according to the channel core set;

[0043] The convolution kernel reconstruction module is used to reconstruct the convolution kernel of the target network layer.

[0044] To achieve the above object, the present invention further provides an electronic device, comprising:

[0045] Memory for storing computer programs;

[0046] A processor is used to implement the steps of the above pruning method when executing the computer program.

[0047] To achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above pruning method are implemented.

[0048] It can be seen from the above scheme that an embodiment of the present invention provides a neural network pruning method, including: determining a target network layer to be pruned in a neural network; determining a channel core set of the target network layer using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the retained input channels; pruning the original input channels of the target network layer according to the channel core set, and reconstructing the convolution kernel of the target network layer.

[0049] It can be seen that when pruning a neural network, the present scheme can use the network layer to be pruned as the target network layer for channel pruning and convolution kernel reconstruction. Therefore, when compressing a multi-branch structure, the present scheme is not limited to the intermediate layer, but can also compress the input layer, output layer, downsampling layer and other network layers, which greatly improves the compression ratio of the neural network, reduces the amount of calculation required for the neural network model to perform tasks, and speeds up the task processing speed of the neural network; and, the present scheme is a data-independent pruning method, which is conducive to maintaining the robustness of the compressed neural network. The present scheme is also an asynchronous channel pruning method, which can achieve pruning of different sparse granularities in different network layers of the neural network, thereby improving the flexibility of compression; the present invention also discloses a neural network pruning device, equipment and storage medium, which can also achieve the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0051] Figure 1 A schematic diagram of a neural network pruning method disclosed in an embodiment of the present invention;

[0052] Figure 2 A schematic diagram of the structure of a downsampling module disclosed in an embodiment of the present invention;

[0053] Figure 3 A schematic diagram of the overall process of pruning the downsampling module disclosed in an embodiment of the present invention;

[0054] Figure 4 A schematic diagram of the residual module structure disclosed in an embodiment of the present invention;

[0055] Figure 5 A schematic diagram of the overall process of residual module pruning disclosed in an embodiment of the present invention;

[0056] Figure 6 A schematic diagram of the structure of the Fire module disclosed in an embodiment of the present invention;

[0057] Figure 7 A schematic diagram of the overall process of Fire module pruning disclosed in an embodiment of the present invention;

[0058] Figure 8 A schematic diagram of the structure of a neural network pruning device disclosed in an embodiment of the present invention;

[0059] Fig. 9 The present invention is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] The present invention proposes an asynchronous pruning method for convolutional neural networks based on kernel set theory, which can use the screening criteria based on kernel set theory to prune channels layer by layer during the forward reasoning process of the neural network, and directly obtain the new weights of the compressed convolution kernel by optimizing the feature map reconstruction error. An asynchronous compression process is designed for multi-branch structures such as the ResNet residual module, and the channel pruning of the intermediate layer and the input and output layers of the residual module and other modules is realized respectively. It should be noted that the kernel set theory described in this embodiment specifically refers to the offline and streaming corset constructions (OSCC) algorithm, which provides support for the derivation and proof of various formulas in the kernel set construction process. This solution is rebuilt on the basis of OSCC to realize the construction of channel kernel sets.

[0062] The method of the present invention performs filter-level pruning on each convolutional layer of the image recognition network trained on the classification image. Unlike the existing filter-level pruning method, the method of the present invention implements filter-level pruning in the form of asynchronous channel pruning, rather than directly performing filter-level pruning. In the present invention, the convolution kernel is defined as a four-dimensional tensor K×C×H×W, with K output channels, C input channels and a size of H×W, wherein K×1×H×W corresponds to the convolution kernel parameters of a specific input channel, and 1×C×H×W corresponds to the convolution kernel parameters of a specific output channel. When a convolution kernel is pruned for input and output channels in an asynchronous manner, filter 1×1×H×W pruning can be achieved. The method of the present invention adopts the kernel set theory when screening the channels to be pruned, constructs a kernel set for the input or output channel by weighted random sampling, and implements data-independent channel pruning to ensure the robustness of the compressed image recognition network.

[0063] See also Figure 1 , a flowchart of a neural network pruning method provided by an embodiment of the present invention; see Figure 1 , the pruning method specifically includes the following steps:

[0064] S101, determining a target network layer to be pruned in a neural network;

[0065] Specifically, the neural network in this embodiment can be a convolutional neural network applied to tasks such as image recognition. Since the parameters of the neural network have great redundancy, pruning the convolutional neural network through this solution can reduce the amount of calculation required for image recognition and speed up image recognition. The target network layer in this embodiment can be any network layer to be pruned in the neural network, a network layer in a single-branch network structure, or a network layer in a multi-branch structure, such as: input layer, intermediate layer, output layer, downsampling layer, etc., which are not specifically limited here.

[0066] S102, determining a channel core set of the target network layer using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; the channel core set records the reserved input channels;

[0067] It should be noted that the channel compression ratio in this embodiment is the ratio of the number of input channels before compression to the number of input channels after compression. The number of retained input channels after compression can be determined by the channel compression ratio. For example, if the number of original input channels of the target network layer is 50 and the channel compression ratio is 10:5, the number of input channels that need to be retained in the target network layer is 25. The channel core set in this embodiment records the input channels that need to be retained. The specific method of determining the channel core set is not specifically limited here. It can be randomly selected from the original input channels, or it can be selected according to the weight of the convolution kernel of the target network layer, or it can be selected according to the importance value of each original input channel, and so on.

[0068] S103. Prune the original input channels of the target network layer according to the channel kernel set, and reconstruct the convolution kernel of the target network layer.

[0069] In this embodiment, after determining the channel core set of the target network layer, the original input channels recorded in the channel core set need to be retained, and the original input channels not recorded in the channel core set need to be removed, so as to achieve pruning of the original input channels. In addition, after the input channel is pruned, the convolution kernel of the target network layer needs to be reconstructed to update the weights of the convolution kernel. The convolution kernel reconstruction process does not require retraining the network, but is only implemented in the forward reasoning process of the neural network.

[0070] It should be noted that the heuristic screening rules used by the current saliency-based pruning algorithms usually rely on the importance of feature maps or convolution kernel weights, which correspond to the two categories of data-driven pruning algorithms and data-independent pruning algorithms. Studies have shown that neural network compression will affect the generalization of the compressed network model. Even if the average accuracy of the compressed network model is similar to that of the uncompressed complete network, the generalization ability of the compressed network model will decrease in samples of a certain category or on certain categories. Data-independent pruning algorithms can provide robust compression for any test data. For example, the compression method DINP

[0071] (Data-Independent Neural Pruning via Coresets), using offline and streaming corset constructions (OSCC) to construct core sets for hidden neurons in the fully connected layer, the hidden neurons in the core set are regarded as important neurons and retained and the weights of the neurons are updated. In addition, DINP gives the neuron importance measurement rules and core set sampling probabilities based on the upper bound of the activation function value. In the process of core set construction, the input data of the network layer is independent of the calculation and allocation of the weighted coefficients sampled for each neuron, so the neuron core set constructed by DINP has the characteristic of being independent of data. In this application, channel pruning is not performed using feature maps, but channel pruning is performed through convolution kernel weights. Therefore, this scheme is a data-independent pruning method, which is conducive to maintaining the robustness of the compressed neural network.

[0072] In summary, the present invention discloses a structured pruning scheme. When pruning a neural network, the present invention can use the network layer to be pruned as the target network layer for channel pruning and convolution kernel reconstruction. Not only can the single-branch structure be compressed, but also the multi-branch structure can be compressed. When compressing the multi-branch structure, the present invention is not limited to the middle layer of the module, but can also compress the input layer, output layer, downsampling layer and other network layers of the module, thereby pruning the input channel and output channel of the entire module, greatly improving the compression ratio of the neural network, reducing the amount of calculation required for the neural network model to perform tasks, and speeding up the task processing speed of the neural network. Moreover, the present invention prunes different network layers in an asynchronous manner. Therefore, the asynchronous channel pruning method disclosed in the present invention can realize pruning of different sparse granularities in different network layers, improve the flexibility of compression, and can realize filter-level pruning in other network layers on the basis of realizing channel pruning in certain network layers.

[0073] Based on the above embodiment, in this embodiment, the process of determining the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel specifically includes:

[0074] Step 1: determining a second number of reserved input channels of the target network layer according to a first number of original input channels of the target network layer and a channel compression ratio;

[0075] Step 2: Determine the importance value of each original input channel by using the first quantity, the second quantity, and the Frobenius norm of the convolution kernel weight of each original input channel;

[0076] Step 3: Determine the sampling probability of each original input channel according to the importance value of each original input channel;

[0077] Step 4: Use the sampling probability of each original input channel to perform R rounds of independent sampling on each original input channel, and generate a channel core set corresponding to the target network layer based on the sampling results.

[0078] In this embodiment, the target network layer is set to be the lth network layer, and the first number of original input channels of the target network layer can also be understood as the number of output channels of the l-1th network layer. In this embodiment, by n l-1 Represents the first number of original input channels of the target network layer, through a l Indicates the second number of reserved input channels of the target network layer.

[0079] In this embodiment, when determining the importance value of each original input channel in step 2, firstly, a first number of weighting coefficients are determined using the first number and the second number, the Frobenius norm value of each original input channel is determined according to the convolution kernel weight of each original input channel, and a corresponding weighting coefficient is allocated to each original input channel according to the Frobenius norm value of each original input channel; wherein, the original input channel with a larger Frobenius norm value is allocated a larger weighting coefficient, and then the importance value of each original input channel is determined according to the weighting coefficient of each original input channel and the initial importance function of each original input channel.

[0080] In this embodiment, n can be calculated by the following formula: l-1 The weighting factor w i (x):

[0081]

[0082] Among them, w i (x) is the i-th weighting coefficient, which is the weighting coefficient constructed for the non-uniform sampling of each channel. i (x) is not associated with the original input channel, and

[0083] Furthermore, in order to l-1 The weighting factor w i (x) and n l-1 To establish an association relationship between the original input channels, we need to calculate the n convolution kernels of the lth layer. l-1 The Frobenius norm values ​​of the convolution kernel weights of the original input channels are sorted in order of numerical size, and the Frobenius norm values ​​of the original input channels are sorted in order of numerical size, and the Frobenius norm values ​​of the n ... l-1The weighting coefficients are sorted in numerical order. According to the order of the two, the weighting coefficient with a larger value is assigned to the original input channel with a larger Frobenius norm value. After each original input channel is assigned a corresponding weighting coefficient, the importance value of each original input channel can be calculated according to the following formula:

[0084] s i (x) = w i (x)·g i (x) (2)

[0085] In Formula 2, s i (x) is the importance function of the i-th original input channel, which is used to determine the importance value of the i-th original input channel, g i (x) is the initial importance function of the i-th original input channel. In this embodiment, the initial importance function can be customized according to different neural networks. For example, for ResNet and SqueezeNet, g can be set i (x) = 1, for the linear point-wise convolution layer in the mobilenet-v2 network, you can set:

[0086] Among them, i represents the i-th channel, x ij is a data x in the current batch of input data x j The i-th channel of is the Frobenius norm, N is the total number of input channels of the linear point convolution layer; w i (x) is the weighting coefficient of the i-th original input channel. After the importance value of each original input channel is determined, the present embodiment determines the sampling probability p of each original input channel according to the following formula 3 in step 3. i :

[0087] p i =s i (x) / t (3)

[0088] Among them, t is the sum of the importance of all channels, that is,

[0089] In this embodiment, after the sampling probability of each original input channel is determined, it is necessary to perform R rounds of independent sampling according to the sampling probability of each original input channel in step 4 to obtain a sampling result, which is the number of times each original input channel is sampled. The greater the sampling probability of the original input channel, the more times it is sampled. After the sampling result is obtained, the a with the largest number of sampling times in the sampling result can be selected. l The original input channels are added to the channel core set It is not added to the channel core set The original input channels need to be pruned.

[0090] After channel pruning of the target network layer, it is necessary to reconstruct the convolution kernel of the target network layer. In this embodiment, the process of reconstructing the convolution kernel of the target network layer is the process of updating the convolution kernel weight. The process first creates an optimization function using the channel kernel set; the optimization function is:

[0091]

[0092] Among them, Y k is the output feature map of the original convolution kernel at output channel k, K is the total number of convolution kernel output channels of the target network layer, Represents the calculation of the feature map reconstruction error of the K output channels of the convolution kernel and summation, represents the Frobenius norm, W ik Represents the weight of the convolution kernel in the input channel i and the output channel k, For the channel core set The input data x for each reserved input channel in i The sum of the output feature maps of the convolution kernel output channel k, * represents the convolution operation;

[0093] Then the optimization function is minimized and the weights of the convolution kernel of the target network layer are updated.

[0094] It should be noted that the current neural network pruning algorithm designs heuristic screening rules to select parameters, channels, filters and other objects for pruning, and compensates for the accuracy loss caused by compression through training or feature map reconstruction. In addition to the accuracy and compression ratio of the network model, the evaluation criteria of the neural network pruning algorithm also include operation efficiency (construction efficiency). Therefore, the pruning algorithm using feature map reconstruction in this embodiment can improve the operation efficiency of the neural network compression process itself.

[0095] In summary, this scheme uses the features of the convolution kernel rather than the features of the feature map to construct the sampling probability of channel sampling when pruning the channel, thereby realizing a data-independent pruning method, which is beneficial to maintaining the robustness of the compressed neural network; and this scheme reconstructs the convolution kernel by minimizing the reconstruction error of the output feature map corresponding to the channel kernel set, that is, the convolution kernel reconstruction is realized in the forward reasoning process of the network without retraining the network, saving the convolution kernel reconstruction time and improving the operating efficiency of the neural network compression process itself.

[0096] It should be noted that when pruning a network layer with a single-branch structure, the structured pruning method described in the above embodiment can be directly used to prune each network layer in the single-branch structure. However, for a multi-branch structure, in addition to using the structured pruning method described in the above embodiment to prune each network layer in the multi-branch structure, additional processing is required according to the particularities of the multi-branch structure. In this embodiment, the pruning process of the multi-branch structure is explained by taking the downsampling module, residual module of ResNet, and the Fire module of SqueezeNet as examples.

[0097] 1. If the downsampling module of ResNet is pruned, then when executing S101 in the above embodiment, the present solution needs to use the intermediate layer and the output layer of the residual branch in the downsampling module as the target network layer in sequence, and continue to execute S102 to S103 to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer;

[0098] Correspondingly, due to the particularity of the downsampling module, in this embodiment, the pruning method also includes: using the channel compression ratio of the input layer of the downsampling module to randomly sample the original input channels of the input layer to obtain a first input channel screening result; using the first input channel screening result to prune the input layer of the downsampling module and the original input channels of the downsampling layer, and using the input layer and the downsampling layer of the downsampling module as target network layers for convolution kernel reconstruction.

[0099] In this embodiment, for the convenience of explanation, the pruning method described in the above embodiment is called a pruning method based on the kernel set theory, and the process of reconstructing the convolution kernel of any network layer in the downsampling module, residual module, and Fire module in this solution is also the same as the reconstruction process of the target network layer described in the above embodiment, which will not be described in detail here. Figure 2 , is a schematic diagram of the structure of a downsampling module provided in an embodiment of the present invention, Figure 2 The intermediate layer, output layer and input layer belong to the residual branch. When compressing the downsampling module, this scheme first adopts the pruning method based on the kernel set theory described in the above embodiment to prune the input channels of the intermediate layer and output layer of the residual branch, and reconstruct the corresponding convolution kernel. Then, the input layer of the residual branch and the input channel of the downsampling layer are subjected to channel pruning according to the pruning method based on random sampling, and the convolution kernel is reconstructed; wherein, the pruning method based on random sampling specifically refers to: performing an equal probability random sampling on the original input channel according to the corresponding channel compression ratio, obtaining the corresponding input channel screening result, and performing pruning. For the convenience of description, the process is referred to as the pruning method based on random sampling in the following text, and the process is not described in detail.

[0100] See also Figure 3, is a schematic diagram of the overall process of downsampling module pruning provided by an embodiment of the present invention, and the overall process diagram specifically includes the following steps:

[0101] S201, screening and pruning the original input channels of the intermediate layer of the residual branch based on the pruning method of the kernel set theory, and reconstructing the convolution kernel of the output layer;

[0102] S202, screening and pruning the original input channel of the output layer of the residual branch based on the pruning method of the kernel set theory, and reconstructing the convolution kernel of the output layer;

[0103] S203, screening the original input channel of the input layer of the residual branch based on a random sampling pruning method to obtain a first input channel screening result;

[0104] S204: Prune the original input channels of the input layer and the downsampling layer of the residual branch according to the first input channel screening result, and reconstruct the convolution kernels of the input layer and the downsampling layer of the residual branch.

[0105] It should be noted that since the input layer and the downsampling layer of the residual branch have the same input, after the channel core set is obtained by channel screening of the input layer of the residual branch, the channel core set can be directly applied to the downsampling layer of the downsampling module without recalculation.

[0106] 2. If the N residual modules stacked in ResNet are pruned, when executing S101 in the above embodiment, the present solution needs to use the intermediate layer and output layer of each residual module in the N residual modules as the target network layer in turn, and continue to execute S102 to S103 to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer;

[0107] Correspondingly, due to the particularity of the residual module, in this embodiment, after the original input channels of the intermediate layer and the output layer are pruned and the convolution kernels of the intermediate layer and the output layer are reconstructed, it also includes: using the channel compression ratio of the input layer of the residual module, randomly sampling the original input channels of the input layer of the residual module, and obtaining a second input channel screening result; for each of the N residual modules, the second input channel screening result is used to prune the original input channels of the input layer of each residual module, and the input layer of the residual module is used as the target network layer for convolution kernel reconstruction; the second input channel screening result is used to prune the original output channel of the output layer of the residual module, and the output layer of the residual module is used as the target network layer for convolution kernel reconstruction.

[0108] See also Figure 4 , is a schematic diagram of the structure of a residual module provided in an embodiment of the present invention, wherein the residual module comprises: an input layer, an intermediate layer, an output layer and a shortcut; and, Figure 4 Only one residual module structure is recorded. For stacked residual modules, multiple Figure 4 The structure shown is composed of. When compressing the stacked residual modules, the input layers of multiple residual modules can share the channel core set obtained by the pruning method based on random sampling, and retain the channels with the same number. Therefore, when compressing the stacked residual modules, this scheme first performs pruning and convolution kernel reconstruction based on the core set theory on the input channels of the intermediate layers and output layers of the stacked multiple residual modules, and then obtains the input channel screening result for one of the residual modules based on the pruning method based on random sampling, and uses the input channel screening result to prune the input layer and output layer of the stacked multiple residual modules and reconstruct the convolution kernel in turn, that is, the convolution kernel reconstruction is performed twice on the output layer of the residual module in different steps.

[0109] If the total number of residual modules is N, i and i' represent the i-th and i'-th residual modules currently being pruned, and i and i' are 1 in the initial case. Figure 5 , is a schematic diagram of the overall process of residual module pruning provided by an embodiment of the present invention, and the overall process diagram specifically includes the following steps:

[0110] S301, based on the pruning method of the kernel set theory, the original input channel of the middle layer of the i-th residual module is screened and pruned, and the convolution kernel of the middle layer is reconstructed;

[0111] S302, based on the pruning method of the kernel set theory, the original input channel of the output layer of the i-th residual module is screened and pruned, and the convolution kernel of the output layer is reconstructed;

[0112] S303, determine whether i is less than or equal to N; if so, add 1 to i and continue S301 to S302; if not, continue to execute S304;

[0113] S304, based on the random sampling pruning method, the original input channel of the input layer of the i'th residual module is screened to obtain a second input channel screening result; the initial value of i' is 1;

[0114] S305, pruning the original input channel of the input layer of the i'th residual module according to the second input channel screening result, and reconstructing the convolution kernel of the input layer;

[0115] S306 , pruning the original output channel of the output layer of the i′th residual module according to the second input channel screening result, and reconstructing the convolution kernel of the output layer.

[0116] S307, determine whether i' is less than or equal to N; if so, add 1 to i' and continue to execute S305 to S306; if not, end the process.

[0117] It should be noted that, since the residual module includes a shortcut, S306 is to prune the original output channels of the shortcut branch of the output layer. Since the output channels of the output layer change, the convolution kernel of the output layer is reconstructed according to the changed number of channels.

[0118] 3. If the target Fire module of SqueezeNet is pruned, then when executing S101 in the above embodiment, this solution needs to use the Squeeze layer of the next Fire module of the target Fire module as the target network layer, and continue to execute S102 to S103, so as to use the original input channel of the Squeeze layer of the next Fire module for pruning, and reconstruct the convolution kernel of the Squeeze layer of the next Fire module;

[0119] Accordingly, due to the particularity of the Fire module, in this embodiment, the pruning method further includes:

[0120] Pruning original output channels of convolution kernels of different sizes in the Expand layer of the target Fire module according to the channel kernel set of the Squeeze layer of the next Fire module;

[0121] Using the channel compression ratio of the Expand layer of the target Fire module, randomly sample the original input channels of the Expand layer of the target Fire module to obtain the third input channel screening result;

[0122] The third input channel screening result is used to prune the original input channels of convolution kernels of different sizes in the Expand layer of the target Fire module, and the Expand layer of the target Fire module is used as the target network layer to reconstruct the convolution kernels of different sizes in the Expand layer.

[0123] See also Figure 6, is a schematic diagram of the Fire module structure provided by an embodiment of the present invention, wherein the Fire module includes: a Squeeze layer and an Expand layer; and the Expand layer has two convolution kernels of different sizes. The process of channel pruning for the Fire module in this scheme is as follows: the original input channel of the Squeeze layer of the Fire module i+1 is pruned and the convolution kernel is reconstructed based on the pruning method of the kernel set theory, and then the output channel of the expand layer of the Fire module i is pruned, and then the input channel of the expand layer of the Fire module i is pruned and the convolution kernel is reconstructed based on the pruning method of random sampling. Moreover, in the input channel pruning of the squeeze layer, the input channel screening result of the squeeze layer of the i+1th Fire module is divided into two parts, which correspond to the output channels of the 3×3 convolution and the 1×1 convolution of the expand layer of the i-th Fire module respectively; in the input channel pruning of the expand layer of the i-th Fire module, the input channel screening result is shared between the 3×3 convolution and the 1×1 convolution.

[0124] See also Figure 7 , is a schematic diagram of the overall process of Fire module pruning provided by an embodiment of the present invention, and the overall process diagram specifically includes the following steps:

[0125] S401. Based on the pruning method of the kernel set theory, the original input channels of the Squeeze layer of the Fire module i+1 are screened to generate a channel kernel set, and the channel pruning and convolution kernel reconstruction of the Squeeze layer of the Fire module i+1 are performed according to the channel kernel set.

[0126] S402, dividing the channel core set into two parts, which respectively correspond to the original output channels of convolution kernels of different sizes in the expand layer of the Fire module i, and pruning the original output channels.

[0127] It should be noted that, although there is a corresponding relationship between the input channel of the Squeeze layer of the Fire module i+1 and the output channel of the expand layer of the Fire module i, in the pruning process, the convolution kernels in the two layers need to be pruned respectively through S401 and S402.

[0128] S403. Based on the random sampling pruning method, the original input channels of the expand layer of the Fire module i are screened to generate a channel kernel set, and the input channels of the convolution kernels of different sizes in the expand layer of the Fire module i are pruned according to the channel kernel set, and the convolution kernels of different sizes are reconstructed.

[0129] In summary, the channel pruning method described in this scheme realizes filter-level pruning by pruning input and output channels in an asynchronous manner, and designs a pruning process based on the multi-branch structure characteristics of ResNet and SqueezeNet, which solves the limitation that the existing pruning method only prunes the input and output channels of the intermediate layers of the residual module, downsampling module and Fire module when compressing ResNe and SqueezeNett, but does not compress the input and output channels of the entire module, and can achieve a higher compression ratio, reduce the amount of computation of the network in the forward reasoning process, and can realize pruning of different sparsity granularities in different layers of the network. In addition, the channel screening rule based on the core set theory designed by the method of the present invention has data-independent characteristics, which is conducive to maintaining the robustness of the compressed image recognition network.

[0130] Furthermore, this solution can also be deployed in software platforms based on FPGA-based neural network acceleration applications or AI acceleration chips. This solution can prune image recognition networks with a high compression ratio to reduce the amount of computation required by image recognition networks in real-time image classification applications. This technical solution can also be expanded to apply compression to backbone networks of target detection networks, such as YOLO or Faster RCNN.

[0131] The following is an introduction to the pruning device, equipment and medium provided in the embodiments of the present invention. The pruning device, equipment and medium described below and the pruning method described above can be referenced to each other.

[0132] See also Figure 8 , a schematic diagram of a neural network pruning device structure provided by an embodiment of the present invention, through Figure 8 It can be seen that the device includes:

[0133] A network layer determination module 11 is used to determine a target network layer to be pruned in a neural network;

[0134] A channel core set determination module 12 is used to determine the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the reserved input channels;

[0135] A channel pruning module 13, used for pruning the original input channel of the target network layer according to the channel core set;

[0136] The convolution kernel reconstruction module 14 is used to reconstruct the convolution kernel of the target network layer.

[0137] The channel core set determination module includes:

[0138] A first determining unit, configured to determine a second number of reserved input channels of the target network layer according to a first number of original input channels of the target network layer and the channel compression ratio;

[0139] A second determining unit is used to determine the importance value of each original input channel by using the first number, the second number, and the Frobenius norm of the convolution kernel weight of each original input channel;

[0140] A third determining unit, used to determine the sampling probability of each original input channel according to the importance value of each original input channel;

[0141] The channel core set generation unit is used to perform R rounds of independent sampling on each original input channel using the sampling probability of each original input channel, and generate a channel core set corresponding to the target network layer according to the sampling results.

[0142] Wherein, the second determining unit includes:

[0143] a weighting coefficient determination subunit, configured to determine the first number of weighting coefficients using the first number and the second number;

[0144] A weighted coefficient allocation subunit is used to determine the Frobenius norm value of each original input channel according to the convolution kernel weight of each original input channel, and allocate a corresponding weighted coefficient to each original input channel according to the Frobenius norm value of each original input channel; wherein, the original input channel with a larger Frobenius norm value is allocated a larger weighted coefficient;

[0145] The importance value determination subunit is used to determine the importance value of each original input channel according to the weight coefficient of each original input channel and the initial importance function of each original input channel.

[0146] Wherein, the convolution kernel reconstruction module includes:

[0147] A function creation unit is used to create an optimization function using the channel core set; the optimization function is:

[0148]

[0149] Among them, Y k is the output feature map of the original convolution kernel at output channel k, K is the total number of convolution kernel output channels of the target network layer, Represents the calculation of the feature map reconstruction error of the K output channels of the convolution kernel and summation, represents the Frobenius norm, W ik Represents the weight of the convolution kernel in the input channel i and the output channel k, For the channel core set The input data x for each reserved input channel in i The sum of the output feature maps of the convolution kernel output channel k, * represents the convolution operation;

[0150] A weight updating unit is used to minimize the optimization function and update the weight of the convolution kernel of the target network layer.

[0151] Among them, if the downsampling module of ResNet is pruned, the network layer determination module is specifically used to: use the intermediate layer and the output layer of the residual branch in the downsampling module as the target network layer in sequence, to prune the original input channels of the intermediate layer and the output layer, and to reconstruct the convolution kernels of the intermediate layer and the output layer;

[0152] Accordingly, the device further comprises:

[0153] A first screening module, configured to randomly sample original input channels of the input layer by using the channel compression ratio of the input layer of the downsampling module to obtain a first input channel screening result;

[0154] The channel pruning module is further used to: prune the input layer of the downsampling module and the original input channel of the downsampling layer using the first input channel screening result;

[0155] The convolution kernel reconstruction module is also used to reconstruct the convolution kernels of the input layer and the downsampling layer.

[0156] Among them, if the N residual modules stacked in ResNet are pruned, the network layer determination module is specifically used to: use the intermediate layer and the output layer of the N residual modules as the target network layer in sequence, to prune the original input channels of the intermediate layer and the output layer, and to reconstruct the convolution kernels of the intermediate layer and the output layer;

[0157] Accordingly, the device further comprises:

[0158] The second screening module is used to prune the original input channels of the intermediate layer and the output layer and reconstruct the convolution kernels of the intermediate layer and the output layer, and then use the channel compression ratio of the input layer of the residual module to randomly sample the original input channels of the input layer of the residual module to obtain a second input channel screening result;

[0159] The channel pruning module is further used to: use the second input channel screening result to sequentially prune the original input channels of the input layers of the N residual modules, and prune the original output channels of the output layers of the N residual modules;

[0160] The convolution kernel reconstruction module is also used to: reconstruct the convolution kernel of the input layer and reconstruct the convolution kernel of the output layer.

[0161] Wherein, if the target Fire module of SqueezeNet is pruned, the network layer determination module is specifically used to: use the Squeeze layer of the next Fire module of the target Fire module as the target network layer, so as to use the original input channel of the Squeeze layer of the next Fire module for pruning, and reconstruct the convolution kernel of the Squeeze layer of the next Fire module;

[0162] Accordingly, the device further comprises:

[0163] A second screening module is used to randomly sample the original input channels of the Expand layer of the target Fire module by using the channel compression ratio of the Expand layer of the target Fire module to obtain a third input channel screening result;

[0164] The channel pruning module is further used to: prune original input channels of convolution kernels of different sizes in the Expand layer of the target Fire module using the third input channel screening result;

[0165] The convolution kernel reconstruction module is also used to reconstruct convolution kernels of different sizes in the Expand layer of the target Fire module.

[0166] See also Fig. 9 , is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention, through Fig. 9 It can be seen that the electronic device includes:

[0167] A memory 21, used for storing computer programs;

[0168] The processor 22 is used to implement the steps of the neural network pruning method described in any of the above method embodiments when executing the computer program.

[0169] In this embodiment, the device may be a PC (Personal Computer), or may be a terminal device such as a smart phone, a tablet computer, a PDA, or a portable computer.

[0170] The device may include a memory 21 , a processor 22 , and a bus 23 .

[0171] Among them, the memory 21 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 21 can be an internal storage unit of the device, such as the hard disk of the device. In other embodiments, the memory 21 can also be an external storage device of the device, such as a plug-in hard disk equipped on the device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 21 can also include both the internal storage unit of the device and the external storage device. The memory 21 can not only be used to store application software and various types of data installed in the device, such as program code for executing the pruning method, but also can be used to temporarily store data that has been output or is to be output.

[0172] In some embodiments, the processor 22 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 21, such as program codes for executing pruning methods.

[0173] The bus 23 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0174] Furthermore, the device may also include a network interface 24, which may optionally include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the device and other electronic devices.

[0175] Optionally, the device may further include a user interface 25, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 25 may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the device and to display a visual user interface.

[0176] Fig. 9 Only the device with components 21-25 is shown, and it can be understood by those skilled in the art that Fig. 9 The structure shown does not constitute a limitation of the device, and may include fewer or more components than shown, or combine certain components, or arrange the components differently.

[0177] An embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the neural network pruning method described in any of the above method embodiments are implemented.

[0178] The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0179] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0180] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A neural network pruning method, It is characterized in that include: Determine a target network layer to be pruned in a neural network; wherein the target network layer is any network layer to be pruned in the neural network, including an input layer, an intermediate layer, an output layer, and a downsampling layer; the neural network is a convolutional neural network applied to image recognition; Determine the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the reserved input channels; Pruning the original input channels of the target network layer according to the channel kernel set, and reconstructing the convolution kernel of the target network layer; When the pruning method is applied to a ResNet-based downsampling module, determining a target network layer to be pruned in a neural network includes: The intermediate layer and the output layer of the residual branch in the downsampling module are used as the target network layers in turn to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer; Accordingly, the pruning method further includes: Using the channel compression ratio of the input layer of the downsampling module, randomly sampling the original input channels of the input layer to obtain a first input channel screening result; Pruning the input layer of the downsampling module and the original input channel of the downsampling layer using the first input channel screening result, and using the input layer and the downsampling layer of the downsampling module as target network layers for convolution kernel reconstruction; When the pruning method is applied to a ResNet residual module, the ResNet includes N stacked residual modules, and determining the target network layer to be pruned in the neural network includes: The intermediate layer and the output layer of each residual module in the N residual modules are used as the target network layer in turn, so as to prune the original input channels of the intermediate layer and the output layer, and reconstruct the convolution kernels of the intermediate layer and the output layer; Correspondingly, after pruning the original input channels of the intermediate layer and the output layer and reconstructing the convolution kernels of the intermediate layer and the output layer, the pruning method further includes: Using the channel compression ratio of the input layer of the residual module, randomly sampling the original input channel of the input layer of the residual module to obtain a second input channel screening result; For each residual module in the N residual modules, the original input channel of the input layer of each residual module is pruned using the second input channel screening result, and the input layer of the residual module is used as the target network layer for convolution kernel reconstruction; the original output channel of the output layer of the residual module is pruned using the second input channel screening result, and the output layer of the residual module is used as the target network layer for convolution kernel reconstruction; When the pruning method is applied to the target Fire module of SqueezeNet, determining the target network layer to be pruned in the neural network includes: The Squeeze layer of the next Fire module of the target Fire module is used as the target network layer, so as to prune the original input channel of the Squeeze layer of the next Fire module and reconstruct the convolution kernel of the Squeeze layer of the next Fire module; Accordingly, the pruning method further includes: Pruning original output channels of convolution kernels of different sizes in the Expand layer of the target Fire module according to the channel kernel set of the Squeeze layer of the next Fire module; Using the channel compression ratio of the Expand layer of the target Fire module, randomly sampling the original input channels of the Expand layer of the target Fire module to obtain a third input channel screening result; The original input channels of convolution kernels of different sizes in the Expand layer of the target Fire module are pruned using the third input channel screening result, and the Expand layer of the target Fire module is used as the target network layer to reconstruct the convolution kernels of different sizes in the Expand layer.

2. The pruning method according to claim 1, It is characterized in that The method of determining the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel includes: Determining a second number of reserved input channels of the target network layer according to the first number of original input channels of the target network layer and the channel compression ratio; Determine the importance value of each original input channel by using the first number, the second number, and the Frobenius norm of the convolution kernel weight of each original input channel; Determine the sampling probability of each original input channel according to the importance value of each original input channel; Each original input channel is independently sampled for R rounds using the sampling probability of each original input channel, and a channel core set corresponding to the target network layer is generated according to the sampling results.

3. The pruning method according to claim 2, It is characterized in that The determining the importance value of each original input channel by using the first number, the second number, and the Frobenius norm of the convolution kernel weight of each original input channel includes: Determine the first number of weighting coefficients using the first number and the second number; Determine the Frobenius norm value of each original input channel according to the convolution kernel weight of each original input channel, and assign a corresponding weighting coefficient to each original input channel according to the Frobenius norm value of each original input channel; wherein, the original input channel with a larger Frobenius norm value is assigned a larger weighting coefficient; The importance value of each original input channel is determined according to the weight coefficient of each original input channel and the initial importance function of each original input channel.

4. The pruning method according to claim 1, It is characterized in that The reconstructing the convolution kernel of the target network layer includes: An optimization function is created using the channel core set; the optimization function is: Among them, Y k is the output feature map of the original convolution kernel at output channel k, K is the total number of convolution kernel output channels of the target network layer, Represents the calculation of the feature map reconstruction error of the K output channels of the convolution kernel and summation, represents the Frobenius norm, W ik Represents the weight of the convolution kernel in the input channel i and the output channel k, For the channel core set The input data x for each reserved input channel in i The sum of the output feature maps of the convolution kernel output channel k, * represents the convolution operation; The optimization function is minimized, and the weights of the convolution kernel of the target network layer are updated.

5. A neural network pruning device, It is characterized in that include: A network layer determination module, used to determine a target network layer to be pruned in a neural network; wherein the target network layer is any network layer to be pruned in the neural network, including an input layer, an intermediate layer, an output layer, and a downsampling layer; and the neural network is a convolutional neural network applied to image recognition; A channel core set determination module, used to determine the channel core set of the target network layer by using the channel compression ratio of the target network layer and the convolution kernel weight of each original input channel; wherein the channel core set records the reserved input channels; A channel pruning module, used for pruning the original input channel of the target network layer according to the channel core set; A convolution kernel reconstruction module, used to reconstruct the convolution kernel of the target network layer; Among them, if the downsampling module of ResNet is pruned, the network layer determination module is specifically used to: use the intermediate layer and the output layer of the residual branch in the downsampling module as the target network layer in sequence, to prune the original input channels of the intermediate layer and the output layer, and to reconstruct the convolution kernels of the intermediate layer and the output layer; Accordingly, the device further comprises: A first screening module, configured to randomly sample original input channels of the input layer by using the channel compression ratio of the input layer of the downsampling module to obtain a first input channel screening result; The channel pruning module is further used to: prune the input layer of the downsampling module and the original input channel of the downsampling layer using the first input channel screening result; The convolution kernel reconstruction module is also used to: reconstruct the convolution kernels of the input layer and the downsampling layer; Among them, if the N residual modules stacked in ResNet are pruned, the network layer determination module is specifically used to: use the intermediate layer and the output layer of the N residual modules as the target network layer in sequence, to prune the original input channels of the intermediate layer and the output layer, and to reconstruct the convolution kernels of the intermediate layer and the output layer; Accordingly, the device further comprises: The second screening module is used to prune the original input channels of the intermediate layer and the output layer and reconstruct the convolution kernels of the intermediate layer and the output layer, and then use the channel compression ratio of the input layer of the residual module to randomly sample the original input channels of the input layer of the residual module to obtain a second input channel screening result; The channel pruning module is further used to: use the second input channel screening result to sequentially prune the original input channels of the input layers of the N residual modules, and prune the original output channels of the output layers of the N residual modules; The convolution kernel reconstruction module is also used to: reconstruct the convolution kernel of the input layer and reconstruct the convolution kernel of the output layer; Wherein, if the target Fire module of SqueezeNet is pruned, the network layer determination module is specifically used to: use the Squeeze layer of the next Fire module of the target Fire module as the target network layer, so as to use the original input channel of the Squeeze layer of the next Fire module for pruning, and reconstruct the convolution kernel of the Squeeze layer of the next Fire module; Accordingly, the device further comprises: A third screening module is used to randomly sample the original input channels of the Expand layer of the target Fire module by using the channel compression ratio of the Expand layer of the target Fire module to obtain a third input channel screening result; The channel pruning module is further used to: prune original input channels of convolution kernels of different sizes in the Expand layer of the target Fire module using the third input channel screening result; The convolution kernel reconstruction module is also used to reconstruct convolution kernels of different sizes in the Expand layer of the target Fire module.

6. An electronic device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the neural network pruning method as claimed in any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the neural network pruning method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Image stylizing method capable of being operated in real time

    CN106886975A

  • Convolutional neural network model compression method and device, storage medium and electronic device

    CN110033083A

  • Spark convolutional neural network system suitable for edge computing platform and circuit of Spark convolutional neural network system

    CN111079923A

  • Face recognition model compression algorithm based on model distillation, medium and terminal

    CN111695375A

  • GIS equipment cavity internal foreign matter detection method and system

    CN111768372A