Pruning method, device and equipment of neural network and medium

CN116502694BActive Publication Date: 2026-10-16BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210044912.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-14
Publication Date
2026-10-16
Estimated Expiration
2042-01-14

AI Technical Summary

Technical Problem

但是,依赖专家经验的剪枝处理由于人为主观因素较多,根据人工设置的剪枝策略进行剪枝处理,会导致实际的剪枝性能很差,剪枝处理效率较低

Benefits of technology

[0041] Compared with the prior art, the technical solution provided in this disclosure has the following advantages: It obtains the total pruning rate of the original neural network; based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, it determines the target pruning configuration information for each convolutional layer, wherein the pruning information for convolutional layers with channel dependencies is consistent; and it performs pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network. Therefore, this disclosure can adaptively determine the target pruning configuration information, improving the efficiency of pruning processing. It also ensures that the target neural network obtained by pruning processing has a superior pruning configuration and pruning result, and can achieve actual speed gains. When the target neural network obtained by this pruning processing method runs on a mobile terminal, it occupies less computing and storage resources, thereby improving the performance of mobile terminals in data processing applications such as video processing, speech recognition, and image recognition and understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116502694B_ABST
    Figure CN116502694B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to a pruning processing method, device and equipment of a neural network and a medium, wherein the method comprises: obtaining a total pruning rate of an original neural network; determining target pruning configuration information of each convolutional layer according to the total pruning rate and the parameter amount and channel coupling condition of each convolutional layer of the original neural network, wherein the pruning information configured for the convolutional layers with channel dependency in the target pruning configuration information is consistent; and performing pruning compression processing on the original neural network according to the target pruning configuration information to obtain a target neural network. It can be seen that the embodiments of the present disclosure can adaptively determine the target pruning configuration information, improve the efficiency of pruning processing, ensure that the target neural network obtained by pruning processing has a relatively optimal pruning configuration and pruning result, and can achieve actual income speed while occupying less mobile terminal computing power resources, storage resources and the like, thereby improving the performance of the mobile terminal in data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for pruning neural networks. Background Technology

[0002] The application of neural network-based artificial intelligence technology on mobile terminals has led to the rapid development of smart mobile devices to meet various application needs. Key technologies include data processing based on trained neural network models in areas such as video processing, speech recognition, image recognition and understanding, and game vision. Given the limited computing resources of mobile terminals and considering that most convolutional neural networks have a certain degree of parameter redundancy, pruning is used to remove redundant convolutional kernels or neurons from each layer of the neural network. This results in neural networks with smaller computing and storage resources on mobile terminals, thereby improving the computing performance of mobile devices.

[0003] Existing pruning techniques mainly rely on expert experience to prune neural network models. However, pruning based on expert experience is subject to a large number of subjective human factors. Pruning based on manually set pruning strategies can lead to poor actual pruning performance and low pruning efficiency. Summary of the Invention

[0004] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a method, apparatus, device, and medium for pruning neural networks.

[0005] In a first aspect, embodiments of this disclosure provide a method for pruning neural networks, the method comprising:

[0006] Obtain the total pruning rate of the original neural network;

[0007] Based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, the target pruning configuration information of each convolutional layer is determined, wherein the pruning information of convolutional layers with channel dependencies is consistent in the target pruning configuration information.

[0008] The original neural network is pruned and compressed according to the target pruning configuration information to obtain the target neural network.

[0009] In one optional implementation, determining the target pruning configuration information based on the total pruning rate and the parameter count and channel coupling of each convolutional layer of the original neural network includes:

[0010] Based on the preset initial pruning rate and the target growth pruning rate for the current calculation cycle, obtain the real-time pruning rate for the current calculation cycle;

[0011] Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, multiple candidate pruning configuration information of each convolutional layer is obtained, wherein the pruning information of convolutional layers with channel dependencies is consistent among the multiple candidate pruning configuration information.

[0012] The original neural network is pruned and compressed according to each candidate pruning configuration information to obtain multiple candidate neural networks;

[0013] A preset algorithm is invoked to test the multiple candidate neural networks, and the network performance corresponding to each candidate neural network is obtained;

[0014] Determine whether the real-time pruning rate is greater than or equal to the total pruning rate. If so, determine the target pruning configuration information from the plurality of candidate pruning configuration information based on the network performance corresponding to each candidate neural network.

[0015] In an optional implementation, after determining whether the real-time pruning rate is greater than or equal to the total pruning rate, the method further includes:

[0016] If the real-time pruning rate is less than the total pruning rate, then target candidate pruning configuration information that meets the preset conditions is selected from the plurality of candidate pruning configuration information according to the network performance corresponding to each candidate neural network.

[0017] Based on the target candidate pruning configuration information and the real-time pruning rate of the next computation cycle, multiple candidate pruning configuration information for each convolutional layer in the next computation cycle is generated.

[0018] In one optional implementation, obtaining multiple candidate pruning configuration information for each convolutional layer based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer includes:

[0019] The encoding matrix of each convolutional layer is obtained according to the preset gene algorithm search granularity and the number of convolutional layers of the original neural network;

[0020] Based on the search granularity, each row vector in the encoding matrix is ​​normalized and transformed to generate multiple first vectors;

[0021] Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, the multiple first vectors are subjected to bias correction processing to obtain the corresponding multiple second vectors, and the multiple second vectors are used as the multiple candidate pruning configuration information.

[0022] In one optional implementation, obtaining the encoding matrix of each convolutional layer according to a preset gene algorithm search granularity and the number of convolutional layers in the original neural network includes:

[0023] The encoding matrix is ​​obtained by randomly generating multiple first configuration vectors based on the preset gene algorithm search granularity and the number of convolutional layers of the original neural network.

[0024] In one optional implementation, it further includes:

[0025] Exchange partial vector fragments between multiple pairs of the first configuration vectors to generate multiple second configuration vectors;

[0026] Randomly replace some vector fragments in multiple first configuration vectors to generate multiple third configuration vectors;

[0027] The encoding matrix is ​​obtained based on the plurality of first configuration vectors, the plurality of second configuration vectors, and the plurality of third configuration vectors.

[0028] In one optional implementation, it further includes:

[0029] The parameters of the target neural network are trained based on sample data from the application scenario, so that the input data can be processed by the trained target neural network to obtain output data. The input data includes one or more combinations of multimedia data, audio data, video data, and image data.

[0030] In one optional implementation, training the parameters of the target neural network based on sample data from the application scenario, and then processing the input data using the trained target neural network to obtain output data, includes:

[0031] Obtain the face sample images used to train the original neural network;

[0032] Obtain the rendered image of the key parts corresponding to the face sample image;

[0033] Based on a preset objective function constraint, the parameters of the target neural network are trained according to the face sample image and the key part rendering image, so as to obtain the target image by rendering the test image according to the trained target neural network.

[0034] Secondly, embodiments of this disclosure also provide a neural network pruning processing apparatus, the apparatus comprising:

[0035] The acquisition module is used to obtain the total pruning rate of the original neural network;

[0036] The processing module is used to determine the target pruning configuration information of each convolutional layer based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, wherein the target pruning configuration information is consistent for convolutional layers with channel dependencies.

[0037] The pruning module is used to perform pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network.

[0038] Thirdly, this disclosure provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the above-described method.

[0039] Fourthly, this disclosure provides an apparatus comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method described above.

[0040] Fifthly, this disclosure provides a computer program product comprising a computer program / instruction that, when executed by a processor, implements the method described above.

[0041] Compared with the prior art, the technical solution provided in this disclosure has the following advantages: It obtains the total pruning rate of the original neural network; based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, it determines the target pruning configuration information for each convolutional layer, wherein the pruning information for convolutional layers with channel dependencies is consistent; and it performs pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network. Therefore, this disclosure can adaptively determine the target pruning configuration information, improving the efficiency of pruning processing. It also ensures that the target neural network obtained by pruning processing has a superior pruning configuration and pruning result, and can achieve actual speed gains. When the target neural network obtained by this pruning processing method runs on a mobile terminal, it occupies less computing and storage resources, thereby improving the performance of mobile terminals in data processing applications such as video processing, speech recognition, and image recognition and understanding. Attached Figure Description

[0042] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0043] Figure 1A flowchart illustrating a neural network pruning method provided in an embodiment of this disclosure;

[0044] Figure 2 A schematic diagram of pruning provided in an embodiment of this disclosure;

[0045] Figure 3 A flowchart illustrating another neural network pruning method provided in this embodiment of the disclosure;

[0046] Figure 4 A flowchart illustrating another neural network pruning method provided in this embodiment of the disclosure;

[0047] Figure 5 A schematic diagram of the structure of a neural network pruning device provided in an embodiment of this disclosure;

[0048] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0049] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0050] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0051] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0052] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0053] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0054] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0055] To address the aforementioned problems, this disclosure provides a method for pruning neural networks, which will be described below with reference to specific embodiments.

[0056] Figure 1 This is a flowchart illustrating a neural network pruning method provided in an embodiment of this disclosure. The method can be executed by a neural network pruning device, which can be implemented in software and / or hardware, and is generally integrated into an electronic device. Figure 1 As shown, the method includes:

[0057] Step 101: Obtain the total pruning rate of the original neural network.

[0058] To ensure model performance, the original neural network may contain a certain amount of redundant parameters. Pruning can remove redundant convolutional kernels (i.e., structured pruning) or neurons on convolutional kernels (i.e., unstructured pruning) from each convolutional layer while maintaining accuracy. This results in a "slimmed-down model" with lower computational and storage resource consumption, accelerating the inference process and facilitating edge deployment of the neural network. This embodiment addresses the issues of setting pruning configuration information for each convolutional layer and achieving actual speed gains, specifically including:

[0059] In this embodiment, the original neural network is a neural network model that needs to be pruned. The original neural network can be obtained through training, and the neural network model can be set according to the application scenario and / or user needs, etc. This embodiment does not impose any restrictions. A total pruning rate is set for the original neural network, and the total pruning rate has a relationship with the pruning rate of each convolutional layer and the number of parameters of each convolutional layer.

[0060] For example, if the original neural network includes four convolutional layers, arranged in the order of data processing as Conv1, Conv2, Conv3, and Conv4, and Conv1 has N1 parameters and a pruning rate of R1; Conv2 has N2 parameters and a pruning rate of R2; Conv3 has N3 parameters and a pruning rate of R3; and Conv4 has N4 parameters and a pruning rate of R4, then the original neural network can be defined as follows: The total number of parameters before network pruning is N_a = N1 + N2 + N3 + N4, and the total number of parameters after pruning the original neural network according to the pruning rate of each layer is N_b = (1-R1)N1 + (1-R1)(1-R2)N2 + (1-R2)(1-R3)N3 + (1-R3)(1-R4)N4. Therefore, the correspondence between the total pruning rate and N_a and N_b is: total pruning rate R_total = (N_a - N_b) / N_a.

[0061] It should be noted that in the above example, if R1 = R2 = R3 = R4 = R, the overall pruning rate R_total > R. Therefore, if the pruning rate of each convolutional layer in the original neural network is set to the same value, at least two problems exist: Problem 1: The overall pruning rate is different from the pruning rate of each convolutional layer, and the overall pruning rate is greater than the pruning rate of each layer. Therefore, if the overall pruning rate is known, the pruning rate of each convolutional layer should be calculated based on the overall pruning rate and the number of parameters of each convolutional layer. Problem 2: Since the importance and parameter redundancy of each convolutional layer in the convolutional neural network are different, setting the pruning rate of each convolutional layer to the same value ignores the differences between convolutional layers. Furthermore, the sensitivity of each convolutional layer to the pruning rate may differ, so it is necessary to set a pruning rate suitable for the characteristics of each convolutional layer.

[0062] Step 102: Based on the total pruning rate and the parameter count and channel coupling of each convolutional layer in the original neural network, determine the target pruning configuration information for each convolutional layer. The pruning information configured for convolutional layers with channel dependencies is consistent within the target pruning configuration information.

[0063] In this embodiment, channel coupling may exist between convolutional layers in the original neural network. Taking convolutional layer A and convolutional layer B as an example to illustrate this channel coupling, if structured pruning of convolutional layer A reduces the number of output channels of convolutional layer A, and if the same structured pruning operation also reduces the number of input channels of convolutional layer B, then a channel dependency relationship can be considered to exist between convolutional layer A and convolutional layer B. This channel dependency relationship manifests as channel coupling between convolutional layer A and convolutional layer B. It should be noted that there are various methods to determine convolutional layers with channel coupling, and this embodiment does not impose any limitations. For example, it can be determined automatically by the model or by manual configuration, etc.

[0064] Furthermore, to take into account the differences between convolutional layers during pruning, the target pruning configuration information for each convolutional layer can be determined based on the total pruning rate, the number of parameters in each convolutional layer of the original neural network, and the channel coupling of each convolutional layer in the original neural network. It should be noted that, to ensure the actual benefit of pruning, the pruning information for convolutional layers with channel dependencies is consistent in this target pruning configuration information. This ensures that channels of layers with channel dependencies are pruned, thereby achieving actual acceleration during hardware platform operation.

[0065] In one optional implementation, if the pruning information configured in two convolutional layers is consistent, then the convolutional kernels pruned by the two convolutional layers are the same. For example, Figure 2 A pruning diagram provided for an embodiment of this disclosure, such as... Figure 2 As shown, Figure 2 The neural network in the example includes two convolutional layers, Conv-1 and Conv-2. These two convolutional layers have a channel dependency, and each layer contains four convolutional kernels. Therefore, the output feature map of this neural network contains four channels. If a pruning rate of 50% is required for Conv-1 and Conv-2, one pruning method is to prune convolutional kernels 3 and 4 from Conv-1, and convolutional kernels 1 and 2 from Conv-2. Figure 2 The white vertical stripes in the middle indicate the path where the branches were pruned, from Figure 2 As can be seen, this pruning method does not achieve a real speed gain. The specific reason is that Conv-1 and Conv-2 have a channel dependency relationship, meaning their channels are coupled. Furthermore, different convolutional kernels are pruned from Conv-1 and Conv-2, resulting in misalignment of their output feature map channels. Therefore, when performing addition / multiplication operations on the outputs of Conv-1 and Conv-2, zero-padding is required before addition / multiplication, and the actual computational cost is not reduced. Another pruning method is to ensure consistent pruning information for Conv-1 and Conv-2. Even if two convolutional layers with channel dependencies prune the same convolutional kernels, for example, pruning convolutional kernels 3 and 4 from both Conv-1 and Conv-2, zero-padding is unnecessary during addition / multiplication, thus achieving a real reduction in computational cost.

[0066] In one optional implementation, the relationship between the total pruning rate and the parameter count and pruning rate of each convolutional layer in the original neural network, as provided in the above steps (i.e., total pruning rate R_total = (N_a - N_b) / N_a), can be used to determine the target pruning configuration information for each convolutional layer, constrained by the channel coupling of each convolutional layer. This target pruning configuration information includes the pruning rate of each convolutional layer.

[0067] Step 103: Perform pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network.

[0068] After determining the target pruning configuration information, each convolutional layer can be pruned and compressed according to the pruning rate of each convolutional layer in the target pruning configuration information, thereby achieving the pruning and compression of the original neural network and obtaining the target neural network. In this embodiment, there are multiple methods for pruning and compressing the original neural network, which can be selected according to the application scenario. This embodiment does not impose any restrictions. For example, a one-shot pruner can be called to perform actual pruning on the original neural network according to the target pruning configuration information.

[0069] In summary, the neural network pruning method according to the embodiments of this disclosure obtains the total pruning rate of the original neural network; based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, the target pruning configuration information of each convolutional layer is determined, wherein the pruning information of convolutional layers with channel dependencies is consistent in the target pruning configuration information; the original neural network is pruned and compressed according to the target pruning configuration information to obtain the target neural network. It is evident that the embodiments of this disclosure can adaptively determine the target pruning configuration information, improving the efficiency of pruning processing, while ensuring that the target neural network obtained by pruning processing has a superior pruning configuration and pruning result, and can achieve actual speed gains. When the target neural network obtained by this pruning processing method runs on a mobile terminal, it occupies less computing and storage resources, thereby improving the performance of the mobile terminal in data processing applications such as video processing, speech recognition, and image recognition and understanding.

[0070] Figure 3 A flowchart illustrating another neural network pruning method provided in this disclosure embodiment is shown below. Figure 3 As shown, this method determines the target pruning configuration information based on the total pruning rate and the parameter count and channel coupling of each convolutional layer in the original neural network, including the following steps:

[0071] Step 301: Obtain the real-time pruning rate for the current calculation period based on the preset initial pruning rate and the target growth pruning rate for the current calculation period.

[0072] In this embodiment, the target growth pruning rate is the increase of the pruning rate of the current calculation period compared to the pruning rate of the previous calculation period. The target growth pruning rate for each calculation period can be different or the same, and this embodiment does not impose any restrictions.

[0073] For example, if the target growth pruning rate is the same P_i in each calculation cycle, and the preset initial pruning rate is P_s, if the current calculation cycle is the first cycle, then the real-time pruning rate of the first cycle is the same as the initial pruning rate, and the real-time pruning rate P_c = P_s. If the current calculation cycle is the Nth cycle (N is a positive integer greater than 1), then the real-time pruning rate of the Nth cycle P_c = P_s + (N-1)P_i.

[0074] In one optional implementation, pruning hyperparameters can be preset, which may include: target growth pruning rate P_i, initial pruning rate P_s, real-time pruning rate P_c, and total pruning rate P_t.

[0075] Step 302: Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, obtain multiple candidate pruning configuration information for each convolutional layer. Among the multiple candidate pruning configuration information, the pruning information configured for convolutional layers with channel dependencies is consistent.

[0076] Furthermore, based on the real-time pruning rate of the current computation cycle, the number of parameters in each convolutional layer of the original neural network, and the channel coupling of each convolutional layer, multiple candidate pruning configurations for each convolutional layer are determined. Moreover, among these multiple candidate pruning matching information, the pruning information configured is consistent for convolutional layers with channel dependencies.

[0077] Step 303: Perform pruning and compression processing on the original neural network according to the pruning configuration information of each candidate neural network to obtain multiple candidate neural networks.

[0078] Furthermore, the performance of each candidate pruning configuration is evaluated. Specifically, the pruning rate corresponding to each convolutional layer can be determined based on the candidate pruning configuration, thereby pruning and compressing the original neural network to obtain the candidate neural network corresponding to each candidate pruning configuration. In an optional implementation, the original neural network can be sparsified and trained according to the candidate pruning configuration based on the Alternating Direction Method of Multipliers (ADMM) to obtain the corresponding candidate neural network.

[0079] Step 304: Call the preset algorithm to test multiple candidate neural networks and obtain the network performance corresponding to each candidate neural network.

[0080] In this embodiment, the network performance can be scored from one or more dimensions for candidate neural networks. Then, the network performance corresponding to each candidate network can be obtained through the preset algorithm. The preset algorithm can be set according to the application scenario. This embodiment does not impose any restrictions. For example, a one-shot pruning tool can be called to verify the pruning performance of multiple candidate networks and obtain scores for accuracy, stability, etc., for each candidate network.

[0081] Step 305: Determine whether the real-time pruning rate is greater than or equal to the total pruning rate. If so, determine the target pruning configuration information from multiple candidate pruning configuration information based on the network performance corresponding to each candidate neural network.

[0082] Furthermore, it is determined whether the real-time pruning rate is greater than or equal to the total pruning rate. If the real-time pruning rate is greater than or equal to the total pruning rate, it means that the current pruning rate has met the pruning rate requirements of the original neural network. Then, based on the network performance of each candidate neural network, the candidate pruning configuration information corresponding to the candidate neural network with the best network performance is selected as the target pruning configuration information.

[0083] In one optional implementation, the total score of each candidate neural network can be calculated based on the network performance of each candidate neural network. The higher the total score, the better the overall network performance of the candidate neural network. The candidate pruning configuration information corresponding to the candidate neural network with the highest total score among multiple candidate neural networks is determined as the target pruning configuration information.

[0084] Step 306: If the real-time pruning rate is less than the total pruning rate, then based on the network performance corresponding to each candidate neural network, select the target candidate pruning configuration information that meets the preset conditions from multiple candidate pruning configuration information.

[0085] If the real-time pruning rate is less than the total pruning rate, it means that the current pruning rate does not meet the pruning rate requirements of the original neural network. Therefore, further processing of the pruning configuration information is required. Specifically, this includes: filtering multiple candidate pruning configuration information based on the network performance corresponding to each candidate neural network, and determining the target candidate pruning configuration information that meets the preset conditions. The preset conditions can be set according to the application scenario, and this embodiment does not impose any restrictions.

[0086] In one optional implementation, if a genetic algorithm is used to determine the target pruning configuration information, and the number of maintenance populations in the genetic algorithm is H, the candidate neural networks can be sorted in order of network performance from best to worst. The preset condition is that the candidate neural networks ranked in the top H / 2 are the candidate pruning configuration information.

[0087] Step 307: Based on the target candidate pruning configuration information and the real-time pruning rate of the next computation cycle, generate multiple candidate pruning configuration information for each convolutional layer in the next computation cycle.

[0088] In this embodiment, the real-time pruning rate of the current computing cycle and the target growth pruning rate of the next computing cycle can be summed to determine the real-time pruning rate of the next computing cycle. Based on the real-time pruning rate of the next cycle, the currently obtained target candidate pruning configuration information is processed to generate multiple candidate pruning configuration information for each convolutional layer in the next computing cycle.

[0089] In summary, the neural network pruning method of this disclosure optimizes the problem of determining the pruning matching information of each convolutional layer of the original neural network, which previously relied on expert experience for manual configuration in related technologies, into an automated solution. Furthermore, during the solution process, each convolutional layer is treated as a whole, taking into account the channel coupling between convolutional layers. This results in more accurate modeling, higher performance of the pruning results, and achieves a better slimmed-down model while satisfying the overall pruning rate. This pruning method considers the channel dependencies between convolutional layers, and through bias correction, it ensures that the pruning information of convolutional layers with channel dependencies is consistent, thereby ensuring that the pruning benefits are converted into actual speed benefits.

[0090] Based on the above embodiments, there are various methods to obtain multiple candidate pruning configuration information for each convolutional layer according to the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer. Figure 4 A flowchart illustrating another neural network pruning method provided in this disclosure embodiment is shown below. Figure 4 As shown, the configuration information for these multiple candidate pruning branches can be determined based on a genetic algorithm, specifically including:

[0091] Step 401: Obtain the encoding matrix of each convolutional layer according to the preset gene algorithm search granularity and the number of convolutional layers of the original neural network.

[0092] In this embodiment, the search granularity of the gene algorithm can characterize the granularity of the determined pruning rate of each convolutional layer. This search granularity can be set according to the application scenario and / or user needs, etc., and this embodiment does not impose any restrictions. It can be understood that the larger the search granularity value, the finer the granularity of the corresponding pruning rate of each convolutional layer; the smaller the search granularity value, the coarser the granularity of the corresponding pruning rate of each convolutional layer. Furthermore, the gene algorithm can also maintain a population size, which can characterize the scale of the population maintained by the gene algorithm.

[0093] Then, the encoding matrix of each convolutional layer is obtained according to the preset search granularity of the gene algorithm and the number of convolutional layers of the original neural network. In an optional embodiment, if the preset search granularity is S, the number of maintenance populations in the gene algorithm is H, and the number of convolutional layers in the original neural network is M, then the encoding matrix of each convolutional layer is an H*M matrix, and the value range of each element in the matrix is ​​[1, S]. The search granularity S, the number of maintenance populations H, and the number of convolutional layers M can be selected according to the application scenario. This embodiment does not impose any restrictions. For example, S = 32, H = 50, and M = 8 can be selected.

[0094] In this embodiment, the method for obtaining the encoding matrix of each convolutional layer can be set according to the application scenario. This embodiment does not impose any restrictions. An example is shown below:

[0095] In one optional implementation, multiple first configuration vectors are randomly generated based on a preset gene algorithm search granularity and the number of convolutional layers in the original neural network to obtain the encoding matrix.

[0096] In this embodiment, the number of elements in the first configuration vector is the same as the number of convolutional layers in the original neural network, and the values ​​of each element in the first configuration vector are randomly generated according to the search granularity of the gene algorithm. For example, if the search granularity is 32, the values ​​of each element in the first configuration vector can be positive integers between 1 and 32. This maps the pruning rate of each convolutional layer from a continuous space to a discrete search space. Furthermore, the number of first configuration vectors generated in each round can be set according to the application scenario; this embodiment does not impose any limitations. For example, the number of first configuration vectors, R = 10, can be set.

[0097] In another alternative implementation, further, partial vector fragments of multiple pairs of first configuration vectors can be exchanged to generate multiple second configuration vectors, and / or partial vector fragments of multiple first configuration vectors can be randomly replaced to generate multiple third configuration vectors.

[0098] For a first configuration vector, one or more adjacent elements of the first configuration vector can be considered as a vector segment. In this embodiment, two first configuration vectors can be defined as a pair of first configuration vectors, and one or more vector segments from these two first configuration vectors can be swapped to achieve cross-processing of the pair of first configuration vectors, generating a set of second configuration vectors. It is understood that the vector length of the second configuration vector is the same as the vector length of the first configuration vector, and this cross-processing can be performed on multiple pairs of first configuration vectors to generate multiple second configuration vectors. In this embodiment, the number of second configuration vectors generated in each round can be set according to the application scenario; this embodiment does not impose a limitation. For example, the number of second configuration vectors can be set to C = 20.

[0099] In this embodiment, elements in one or more vector segments of the first configuration vector can be randomly replaced to mutate the first configuration vector and generate multiple third configuration vectors. It should be noted that the random value used to replace the elements in the third configuration vector needs to be randomly generated based on the granularity of the gene algorithm search, and this random value can be a positive integer not greater than the search granularity. In this embodiment, the number of third configuration vectors generated in each round can be set according to the application scenario; this embodiment does not impose any restrictions. For example, the number of third configuration vectors, D = 20, can be set.

[0100] In some application scenarios, the number of generated second and third configuration vectors is less than the preset number. In such cases, configuration vectors can be randomly generated according to the search granularity to fill the gaps.

[0101] Furthermore, an encoding matrix is ​​obtained based on the multiple first configuration vectors, multiple second configuration vectors, and multiple third configuration vectors. For example, if the number of populations maintained in the gene algorithm is H, H configuration vectors can be selected from the multiple first configuration vectors, second configuration vectors, and third configuration vectors, and the H configuration vectors can be concatenated to generate an encoding matrix.

[0102] Step 402: Normalize each row vector in the encoding matrix according to the search granularity to generate multiple first vectors.

[0103] Each row vector in the encoding matrix represents a pruning scheme for the original neural network. Through normalization transformation, the range of each element of the row vector can be transformed from [1,S] (where S is the search granularity) to [0,1].

[0104] In one alternative implementation, each element of each row vector can be divided by the search granularity to achieve normalization of each row vector, generating multiple first vectors. For example, if the search granularity is 32, then the elements of each row vector are divided by 32.

[0105] Step 403: Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, perform bias correction processing on multiple first vectors to obtain multiple corresponding second vectors, and use multiple second vectors as multiple candidate pruning configuration information.

[0106] Furthermore, based on the real-time pruning rate, the number of parameters in each convolutional layer, and the channel coupling of each convolutional layer, multiple first vectors are subjected to bias correction processing to generate multiple corresponding second vectors. This bias correction processing ensures that the pruning rate determined by the second vectors is the same as the total pruning rate of the original neural network, and that the pruning rates of convolutional layers with channel dependencies are the same among those determined by the second vectors. These multiple second vectors are then used as multiple candidate pruning configuration information.

[0107] In summary, the neural network pruning method of this disclosure can solve for the optimal target pruning configuration information of each convolutional layer based on the genetic algorithm, thereby ensuring the effectiveness of the pruning process.

[0108] Based on the above embodiments, the target neural network can be further trained to improve the accuracy of the neural network after pruning, specifically including:

[0109] The parameters of the target neural network are trained based on sample data from the application scenario, so that the input data can be processed by the trained target neural network to obtain output data. The input data includes one or more combinations of multimedia data, audio data, video data, and image data.

[0110] In this embodiment, the application scenarios include, but are not limited to, any one of video processing speech recognition, image recognition and understanding, and game vision. The sample data is data that meets the training requirements of the application scenario. This sample data can be data used to train the original neural network, or other data that meets the requirements of the application scenario; this embodiment does not impose any limitations. The parameters of the target neural network obtained through pruning are trained using this sample data, thereby improving the accuracy of the neural network. The trained target neural network is then used to process the input data in the application scenario to generate corresponding output data. It is understood that different application scenarios have corresponding input data, which includes one or more combinations of multimedia data, audio data, video data, and image data.

[0111] Taking the application scenario of rendering key facial features as an example, in this application scenario, the input data of the trained target neural network includes image data. The steps described above involve training the parameters of the target neural network based on sample data from the application scenario, and then processing the input data using the trained target neural network to obtain output data, including:

[0112] First, obtain the face sample images used to train the original neural network.

[0113] Furthermore, the key part rendering image corresponding to the face sample image is obtained.

[0114] In this embodiment, face sample images and their corresponding key part rendering images used to train the original neural network can be used as sample data, and the target neural network can be trained to improve accuracy using this sample data.

[0115] Furthermore, based on the preset objective function constraints, the parameters of the target neural network are trained according to the face sample image and the rendered image of the key part, so as to obtain the target image by rendering the test image according to the trained target neural network.

[0116] In this embodiment, a preset objective function is used as a loss function to constrain the training of the target neural network. This objective function can be selected according to the application scenario requirements, and this embodiment does not impose any restrictions. Furthermore, face sample images can be used as input data for the target neural network, and rendered images of key parts can be used as the output images of the target neural network. Based on the constraints of the objective function, the target neural network is trained. The trained target neural network can then render the input test images to generate the corresponding target images.

[0117] In summary, the neural network pruning method of this disclosure can prune the original neural network and perform further precision training in application scenarios such as video processing language recognition, image recognition and understanding, and game vision, thereby reducing the number of neural network parameters and computing power consumption in the application scenario, while ensuring the accuracy of the neural network.

[0118] Figure 5 This is a schematic diagram of a neural network pruning processing device provided in an embodiment of the present disclosure. The device can be implemented by software and / or hardware and is generally integrated into an electronic device.

[0119] like Figure 5 As shown, the device includes:

[0120] Module 501 is used to obtain the total pruning rate of the original neural network;

[0121] Processing module 502 is used to determine the target pruning configuration information of each convolutional layer based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, wherein the target pruning configuration information is consistent for convolutional layers with channel dependencies.

[0122] The pruning module 503 is used to perform pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network.

[0123] In one optional implementation, the processing module 502 includes:

[0124] The first acquisition unit is used to acquire the real-time pruning rate of the current calculation cycle based on the preset initial pruning rate and the target growth pruning rate of the current calculation cycle.

[0125] The second acquisition unit is used to acquire multiple candidate pruning configuration information of each convolutional layer based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, wherein the pruning information of the convolutional layers with channel dependency is consistent among the multiple candidate pruning configuration information.

[0126] The third acquisition unit is used to perform pruning and compression processing on the original neural network according to each candidate pruning configuration information to acquire multiple candidate neural networks.

[0127] The fourth acquisition unit is used to call a preset algorithm to test the plurality of candidate neural networks and obtain the network performance corresponding to each candidate neural network.

[0128] The first determining unit is used to determine whether the real-time pruning rate is greater than or equal to the total pruning rate. If so, it determines the target pruning configuration information from the plurality of candidate pruning configuration information based on the network performance corresponding to each candidate neural network.

[0129] In one optional implementation, the processing module 502 further includes:

[0130] The second determining unit is used to select target candidate pruning configuration information that meets preset conditions from the plurality of candidate pruning configuration information based on the network performance corresponding to each candidate neural network if the real-time pruning rate is less than the total pruning rate.

[0131] The generation unit is used to generate multiple candidate pruning configuration information for each convolutional layer in the next computation cycle based on the target candidate pruning configuration information and the real-time pruning rate of the next computation cycle.

[0132] In one optional implementation, the second acquisition unit is configured to:

[0133] The encoding matrix of each convolutional layer is obtained according to the preset gene algorithm search granularity and the number of convolutional layers of the original neural network;

[0134] Based on the search granularity, each row vector in the encoding matrix is ​​normalized and transformed to generate multiple first vectors;

[0135] Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, the multiple first vectors are subjected to bias correction processing to obtain the corresponding multiple second vectors, and the multiple second vectors are used as the multiple candidate pruning configuration information.

[0136] In an optional implementation, the second acquisition unit is further configured to:

[0137] The encoding matrix is ​​obtained by randomly generating multiple first configuration vectors based on the preset gene algorithm search granularity and the number of convolutional layers of the original neural network.

[0138] In an optional implementation, the second acquisition unit is further configured to:

[0139] Exchange partial vector fragments between multiple pairs of the first configuration vectors to generate multiple second configuration vectors;

[0140] Randomly replace some vector fragments in multiple first configuration vectors to generate multiple third configuration vectors;

[0141] The encoding matrix is ​​obtained based on the plurality of first configuration vectors, the plurality of second configuration vectors, and the plurality of third configuration vectors.

[0142] In one optional implementation, it further includes:

[0143] The training module is used to train the parameters of the target neural network based on sample data of the application scenario, so as to process the input data and obtain output data based on the trained target neural network. The input data includes one or more combinations of multimedia data, audio data, video data, and image data.

[0144] In one optional implementation, the training module is used for:

[0145] Obtain the face sample images used to train the original neural network;

[0146] Obtain the rendered image of the key parts corresponding to the face sample image;

[0147] Based on a preset objective function constraint, the parameters of the target neural network are trained according to the face sample image and the key part rendering image, so as to obtain the target image by rendering the test image according to the trained target neural network.

[0148] The neural network pruning processing apparatus provided in this disclosure can execute the neural network pruning processing method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of executing the method.

[0149] In addition to the methods and apparatus described above, this disclosure also provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to implement the neural network pruning method described in this disclosure.

[0150] This disclosure also provides a computer program product, which includes a computer program / instructions that, when executed by a processor, implement the neural network pruning method described in this disclosure.

[0151] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.

[0152] The following is a detailed reference. Figure 6 The diagram illustrates a structural schematic suitable for implementing the electronic device 600 in the embodiments of this disclosure. The electronic device 600 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0153] like Figure 6 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0154] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0155] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 609, or installed from storage device 608, or installed from ROM 602. When the computer program is executed by processing device 601, it performs the functions defined in the neural network pruning method of embodiments of this disclosure.

[0156] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0157] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0158] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0159] The aforementioned computer-readable medium carries one or more programs. When the electronic device executes these programs, the electronic device: first, obtains the total pruning rate of the original neural network; further, based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer of the original neural network, determines the target pruning configuration information for each convolutional layer, wherein the pruning information for convolutional layers with channel dependencies is consistent in the target pruning configuration information; further, performs pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network. It is evident that the embodiments of this disclosure can adaptively determine the target pruning configuration information, improving the efficiency of the pruning process, while ensuring that the target neural network obtained by the pruning process has a superior pruning configuration and pruning result, and can achieve actual speed gains. When the target neural network obtained by this pruning processing method runs on a mobile terminal, it occupies less computing and storage resources, thereby improving the performance of the mobile terminal in data processing applications such as video processing, speech recognition, and image recognition and understanding.

[0160] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0161] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0162] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0163] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0164] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0165] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0166] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0167] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A method for pruning neural networks, characterized in that, include: Obtain the total pruning rate of the original neural network; Based on the total pruning rate and the parameter count and channel coupling of each convolutional layer in the original neural network, the target pruning configuration information for each convolutional layer is determined. The target pruning configuration information is consistent for convolutional layers with channel dependencies. The target pruning configuration information is determined based on multiple candidate pruning configurations when the real-time pruning rate is greater than or equal to the total pruning rate. The multiple candidate pruning configurations are consistent for convolutional layers with channel dependencies. The multiple candidate pruning configurations for each convolutional layer are obtained based on the real-time pruning rate and the parameter count and channel coupling of each convolutional layer. The real-time pruning rate for the current computation cycle is obtained based on a preset initial pruning rate and the target growth pruning rate for the current computation cycle. The original neural network is pruned and compressed according to the target pruning configuration information to obtain the target neural network; wherein the input data processed by the target neural network includes one or more combinations of multimedia data, audio data, video data, and image data.

2. The method according to claim 1, characterized in that, The step of determining the target pruning configuration information for each convolutional layer based on the total pruning rate and the parameter quantity and channel coupling of each convolutional layer in the original neural network includes: Based on the preset initial pruning rate and the target growth pruning rate for the current calculation cycle, obtain the real-time pruning rate for the current calculation cycle; Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, multiple candidate pruning configuration information of each convolutional layer is obtained, wherein the pruning information of convolutional layers with channel dependencies is consistent among the multiple candidate pruning configuration information. The original neural network is pruned and compressed according to each candidate pruning configuration information to obtain multiple candidate neural networks; A preset algorithm is invoked to test the multiple candidate neural networks, and the network performance corresponding to each candidate neural network is obtained; Determine whether the real-time pruning rate is greater than or equal to the total pruning rate. If so, determine the target pruning configuration information from the plurality of candidate pruning configuration information based on the network performance corresponding to each candidate neural network.

3. The method according to claim 2, characterized in that, After determining whether the real-time pruning rate is greater than or equal to the total pruning rate, the method further includes: If the real-time pruning rate is less than the total pruning rate, then target candidate pruning configuration information that meets the preset conditions is selected from the plurality of candidate pruning configuration information according to the network performance corresponding to each candidate neural network. Based on the target candidate pruning configuration information and the real-time pruning rate of the next computation cycle, multiple candidate pruning configuration information for each convolutional layer in the next computation cycle is generated.

4. The method according to claim 2, characterized in that, The step of obtaining multiple candidate pruning configuration information for each convolutional layer based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer includes: The encoding matrix of each convolutional layer is obtained according to the preset gene algorithm search granularity and the number of convolutional layers of the original neural network; Based on the search granularity, each row vector in the encoding matrix is ​​normalized and transformed to generate multiple first vectors; Based on the real-time pruning rate and the parameter quantity and channel coupling of each convolutional layer, the multiple first vectors are subjected to bias correction processing to obtain multiple corresponding second vectors, and the multiple second vectors are used as the multiple candidate pruning configuration information.

5. The method according to claim 4, characterized in that, The step of obtaining the encoding matrix of each convolutional layer according to the preset gene algorithm search granularity and the number of convolutional layers of the original neural network includes: The encoding matrix is ​​obtained by randomly generating multiple first configuration vectors based on the preset gene algorithm search granularity and the number of convolutional layers of the original neural network.

6. The method according to claim 5, characterized in that, Also includes: Exchange partial vector fragments between multiple pairs of the first configuration vectors to generate multiple second configuration vectors; Randomly replace some vector fragments in multiple first configuration vectors to generate multiple third configuration vectors; The encoding matrix is ​​obtained based on the plurality of first configuration vectors, the plurality of second configuration vectors, and the plurality of third configuration vectors.

7. The method according to any one of claims 1-6, characterized in that, Also includes: The parameters of the target neural network are trained based on sample data from the application scenario, so that the input data can be processed by the trained target neural network to obtain output data.

8. The method according to claim 7, characterized in that, The step of training the parameters of the target neural network based on sample data from the application scenario, and then processing the input data using the trained target neural network to obtain output data, includes: Obtain the face sample images used to train the original neural network; Obtain the rendered image of the key parts corresponding to the face sample image; Based on a preset objective function constraint, the parameters of the target neural network are trained according to the face sample image and the key part rendering image, so as to obtain the target image by rendering the test image according to the trained target neural network.

9. A pruning device for a neural network, characterized in that, The device includes: The acquisition module is used to obtain the total pruning rate of the original neural network; The processing module is configured to determine the target pruning configuration information for each convolutional layer based on the total pruning rate and the parameter count and channel coupling of each convolutional layer in the original neural network. The target pruning configuration information is consistent for convolutional layers with channel dependencies. The target pruning configuration information is determined based on multiple candidate pruning configurations when the real-time pruning rate is greater than or equal to the total pruning rate. The multiple candidate pruning configurations for each convolutional layer are obtained based on the real-time pruning rate and the parameter count and channel coupling of each convolutional layer. The real-time pruning rate for the current computation cycle is obtained based on a preset initial pruning rate and the target growth pruning rate for the current computation cycle. The pruning module is used to perform pruning and compression processing on the original neural network according to the target pruning configuration information to obtain the target neural network; wherein, the input data processed by the target neural network includes one or more combinations of multimedia data, audio data, video data, and image data.

10. An electronic device, characterized in that, The electronic device includes: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method of any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The storage medium stores a computer program for performing the method described in any one of claims 1-8.

12. A computer program product, characterized in that, The computer program product includes a computer program / instruction that, when executed by a processor, implements the method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Neural network pruning method and device and model generation method and device

    CN112488297A

  • Convolutional network pruning method and device and electronic equipment

    CN113642730A