A neural network compression method and system

By adding a significant representation network to the neural network and using the target sample set to obtain channel importance information, the problem of mis-pruning in structured pruning is solved, and more efficient channel pruning is achieved to maintain network performance.

CN113962389BActive Publication Date: 2025-08-15BEIJING JINGWEI HIRAIN TECH CO INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111447637.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-08-15
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

In the process of structured pruning of neural networks, prior art, important channels are easily pruned by artificial or random selection, which affects network performance.

Method used

Add a significant characterization network to the neural network to be compressed, and train the network while keeping the parameters unchanged, use the target sample set to obtain channel importance information, and perform pruning operations in an automated manner.

Benefits of technology

Effectively and comprehensively express the importance of each channel, avoiding mis-pruning caused by artificial or random selection, and ensuring that the performance of the neural network does not degrade.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113962389B_ABST
    Figure CN113962389B_ABST
Patent Text Reader

Abstract

The present invention discloses a neural network compression method and system. The method adds a saliency representation network to the neural network to be compressed. The method then trains the neural network to be compressed after adding the saliency representation network while keeping the parameters of the neural network to be compressed unchanged. After the training is completed, a target sample set corresponding to a preset compression requirement is used to obtain information used to characterize the importance of output channels in the neural network to be compressed. Finally, based on the information used to characterize the importance of channels in the neural network to be compressed, an operation corresponding to the preset compression requirement is performed on the neural network to be compressed to obtain a compressed neural network. The method utilizes the saliency representation network to determine the importance of each channel in the neural network to be compressed. Compared with manual or random selection, the method can more effectively, comprehensively, and automatically model and express the importance of each channel, avoiding the situation where important channels are pruned due to manual or random selection during structured pruning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a neural network compression method and system. Background Art

[0002] Existing neural network model compression methods can be categorized into two main types: structured pruning and unstructured pruning. Unstructured pruning can prune any parameter in a neural network model, typically directly setting the pruned / compressed parameter to zero, thereby reducing computational effort. Structured pruning typically prunes / compresses channels within the neural network model. Pruned channels are directly removed from the network structure, thereby shrinking the network structure and reducing computational effort. Structured pruning generally establishes relationships between multiple channels, ranks them according to a metric within the relationship that measures their importance, and removes less important channels.

[0003] In existing techniques, when compressing neural network models through structured pruning, the importance of each channel in the neural network model is typically calculated using artificially designed metrics, and then channels with low importance are deleted. Alternatively, channels to be deleted are randomly selected. For example, based on the similarity between channels, important or relatively unique channels are retained, while unimportant or highly similar channels are deleted. This approach has a certain probability of pruning channels that play a critical role in recognition and affect recognition performance, especially when pruning is performed by randomly deleting some similar channels.

[0004] Therefore, how to avoid the pruning of important channels caused by artificial or random selection during structured pruning is an urgent problem to be solved. Summary of the Invention

[0005] In view of this, the present invention provides a neural network compression method and system to avoid the occurrence of important channels being pruned due to artificial or random selection during the structured pruning process.

[0006] A neural network compression method, comprising:

[0007] Obtaining a neural network to be compressed, where the neural network to be compressed is a pre-trained neural network;

[0008] Adding a saliency representation network to the neural network to be compressed;

[0009] While keeping the parameters of the neural network to be compressed unchanged, training the neural network to be compressed after adding the saliency representation network;

[0010] Obtaining a target sample set corresponding to a preset compression requirement;

[0011] Inputting the target sample set into the trained neural network to be compressed with the saliency representation network added thereto, and obtaining information for representing the importance of channels in the neural network to be compressed;

[0012] Based on the information used to characterize the importance of channels in the neural network to be compressed, an operation corresponding to the preset compression requirement is performed on the neural network to be compressed to obtain a compressed neural network.

[0013] Optionally, adding a saliency representation network to the neural network to be compressed includes:

[0014] When the neural network to be compressed includes multiple neural network layers to be compressed and the saliency representation network includes multiple saliency representation sub-networks, a saliency representation sub-network is added after each neural network layer to be compressed.

[0015] Optionally, each saliency representation sub-network includes a high-dimensional meaning importance channel and / or a physical meaning importance channel.

[0016] Optionally, the physical meaning importance channel includes multiple physical meaning importance sub-channels.

[0017] Optionally, the process of performing an operation corresponding to the preset compression requirement on the neural network to be compressed based on the information used to characterize the importance of channels in the neural network to be compressed to obtain a compressed neural network includes:

[0018] Calculating channel eigenvalues using the information for characterizing the importance of channels in the neural network to be compressed;

[0019] Obtaining a first preset number of compression channels determined according to the preset compression requirement;

[0020] Using the first preset number of compression channels and the channel characteristic values, and according to the preset compression requirements, a channel pruning operation is performed on the neural network to be compressed to obtain a compressed neural network.

[0021] Optionally, also include:

[0022] Calculating a norm value of features of each channel in the compressed neural network;

[0023] A channel pruning operation is performed on the compressed neural network based on a second preset number of compression channels and a norm value of the features of each channel.

[0024] A neural network compression system, comprising:

[0025] A first acquisition module is used to acquire a neural network to be compressed, where the neural network to be compressed is a pre-trained neural network;

[0026] An adding module, configured to add a saliency representation network to the neural network to be compressed;

[0027] A training module, configured to train the neural network to be compressed after adding the saliency representation network while keeping the parameters of the neural network to be compressed unchanged;

[0028] A second acquisition module is used to acquire a target sample set corresponding to a preset compression requirement;

[0029] a data processing module, configured to input the target sample set into the trained neural network to be compressed with the added saliency representation network, and obtain information for representing the importance of channels in the neural network to be compressed;

[0030] The first compression module is used to perform an operation corresponding to the preset compression requirement on the neural network to be compressed based on the information used to characterize the importance of the channels in the neural network to be compressed, so as to obtain a compressed neural network.

[0031] Optionally, the adding module is specifically used to: when the neural network to be compressed includes multiple neural network layers to be compressed and the saliency representation network includes multiple saliency representation sub-networks, add a saliency representation sub-network after each neural network layer to be compressed.

[0032] Optionally, the first compression module includes:

[0033] an eigenvalue calculation unit, configured to calculate a channel eigenvalue using the information characterizing the importance of the channel in the neural network to be compressed;

[0034] a channel number acquisition unit, configured to acquire a first preset number of compression channels determined according to the preset compression requirement;

[0035] The first pruning unit is used to use the first preset number of compression channels and the channel characteristic values to perform a channel pruning operation on the neural network to be compressed according to the preset compression requirements to obtain a compressed neural network.

[0036] Optionally, the method further includes: a second compression module, wherein the second compression module includes:

[0037] A norm calculation unit, configured to calculate a norm value of a feature of each channel in the compressed neural network;

[0038] The second pruning unit is used to perform a channel pruning operation on the compressed neural network based on a second preset number of compression channels and a norm value of the feature of each channel.

[0039] In summary, the present invention discloses a neural network compression method and system. When it is necessary to perform structured pruning on a trained neural network, a saliency characterization network is first added to the neural network to be compressed; then, while keeping the parameters of the neural network to be compressed unchanged, the neural network to be compressed after adding the saliency characterization network is trained. After the training is completed, a target sample set corresponding to a preset compression requirement is used to obtain information for characterizing the importance of output channels in the neural network to be compressed; finally, based on the information for characterizing the importance of channels in the neural network to be compressed, operations corresponding to the preset compression requirement are performed on the neural network to be compressed to obtain a compressed neural network. The present invention uses a saliency characterization network to determine the importance of each channel in the neural network to be compressed. Compared with manual or random selection, the importance of each channel can be modeled and expressed more effectively, comprehensively, and automatically, avoiding the situation where important channels are pruned due to manual or random selection during structured pruning. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.

[0041] Figure 1 This is a flow chart of a neural network compression method disclosed in the present invention;

[0042] Figure 2 Schematic diagram of the structure of the neural network to be compressed;

[0043] Figure 3 A schematic diagram of the structure of the neural network to be compressed with the saliency representation network added;

[0044] Figure 4 Schematic diagram of the structure of the saliency representation subnetwork including the high-dimensional meaning importance channel;

[0045] Figure 5 Schematic diagram of the structure of the saliency representation subnetwork including the physical meaning importance channel;

[0046] Figure 6 Schematic diagram of the structure of the saliency representation subnetwork including the high-dimensional meaning importance channel and the physical meaning importance channel;

[0047] Figure 7Schematic diagram of another structure of a saliency representation subnetwork including a high-dimensional meaning importance channel and a physical meaning importance channel;

[0048] Figure 8 is another flow chart of the neural network compression method disclosed in the present invention;

[0049] Figure 9 It is a structural diagram of the neural network compression system disclosed in the present invention;

[0050] Figure 10 This is another structural diagram of the neural network compression system disclosed in the present invention. DETAILED DESCRIPTION

[0051] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.

[0052] like Figure 1 FIG. 1 is a flowchart of a method for compressing a neural network according to an embodiment of the present invention. The method may include the following steps:

[0053] S101. Obtain a neural network to be compressed.

[0054] The compression method disclosed in the embodiments of the present invention targets pre-trained neural networks, whose parameters have been determined and whose performance has already met the training objectives. The compression operation is performed to minimize the network structure and reduce the computational effort without significantly impacting performance.

[0055] S102. Add a saliency representation network to the neural network to be compressed.

[0056] After obtaining the trained neural network to be compressed, the saliency representation network is added to the trained neural network to obtain a new neural network. The saliency representation network is used to represent the importance of each channel of the neural network to be compressed.

[0057] like Figure 2 The neural network structure to be compressed has two layers of neural network layers, where Op1 and Op2 represent the network layers of the neural network to be compressed (i.e., the neural network layers to be compressed). When the data passes through the network layers of the neural network to be compressed, the output data obtained by processing is X1 and X2. X1 and X2 can be a four-dimensional vector [1, C, H, W], where C is the number of channels; H is the matrix height; and W is the matrix width.

[0058] like Figure 2 As shown in , typically, the neural network to be compressed includes multiple neural network layers to be compressed, and the saliency representation network may also include multiple saliency representation sub-networks. Therefore, when adding a saliency representation network to the neural network to be compressed, a saliency representation sub-network may be added after each neural network layer to be compressed. It is understood that in some embodiments, saliency representation sub-networks may also be added after some neural network layers to be compressed, as long as the final compressed neural network can meet the recognition requirements.

[0059] exist Figure 2 The network structure after adding a saliency representation sub-network after the compressed neural network layer is shown as Figure 3 As shown. Where sr1 is the saliency representation subnetwork of the first neural network layer to be compressed, X1 is the output data of the first neural network layer to be compressed, X1 passes through the saliency representation subnetwork sr1 to obtain the output s1, s1 is a coefficient vector of dimension C, where the coefficient of each dimension corresponds to the importance of the corresponding channel, which is equivalent to a matrix of dimension [1, C, 1, 1]. At this time, the input of the second neural network layer to be compressed changes from X1 to X1'=s1·X1. If the number of network layers contained in the neural network to be compressed is greater than 2, the structure of adding a saliency representation subnetwork after the first layer of the neural network layer to be compressed can refer to Figure 3 As shown in the figure, the principle of adding a saliency representation sub-network to each neural network layer to be compressed is similar.

[0060] The saliency representation subnetwork may include high-dimensional meaning importance channels and / or physical meaning importance channels. In other words, each saliency representation subnetwork may include only high-dimensional meaning importance channels or physical meaning importance channels, or may include both types of channels.

[0061] The composition structure of high-dimensional meaning importance channel is as follows Figure 4 As shown, it includes the sequentially connected convolutional layer Conv, batch normalization BN, activation function Relu, and maximum pooling layer MaxPool.

[0062] If the input is X1, the dimension is [1, C, H, W], after Figure 4 After the saliency representation subnetwork shown, a [1, C, 1, 1]-dimensional matrix can be obtained. After FC (fully connected layers) and activation function Sigmoid processing, a C-dimensional vector is obtained. The data value range of each element in this vector is (0, 1), which is used to represent the relationship and importance of C channels.

[0063] Figure 4The high-dimensional meaning importance channel structure can make full use of the powerful modeling and representation capabilities of neural networks to represent the importance of channels from the perspective of high dimensions that are difficult to describe with simple physical meanings, or in other words, it realizes the process of setting weights based on the importance of channels.

[0064] Physical meaning Importance Channel structure such as Figure 5 As shown in the figure, after the binary adaptive maximum pooling AdaptivMaxpool2d operation, a [1, C, 1, 1]-dimensional matrix can be obtained. After the 1*1 convolution layer Conv and Relu and the activation function Sigmoid processing, a new [1, C, 1, 1]-dimensional matrix is obtained, which represents the relationship and importance of C channels.

[0065] Figure 5 The physical meaning of the importance of the channel structure can make full use of the angle with more obvious physical meaning, such as the maximum value to represent the importance of the channel. Of course, the average value can also be used to represent the importance of the channel.

[0066] The saliency representation subnetwork can also include both high-dimensional meaning importance channels and physical meaning importance channels, such as Figure 6 As shown, the results of the high-dimensional meaning importance channel and the physical meaning importance channel are multiplied together to more comprehensively represent the importance of the channel.

[0067] In a possible implementation, the physical meaning importance channel can be composed of multiple physical meaning importance sub-channels, such as Figure 7 As shown, the physical importance channel includes two physical importance sub-channels: AdaptivMaxpool2d (binary adaptive max pooling) and AdaptivAvepool2d (binary adaptive average pooling). It can also be seen that the physical meanings of the physical importance sub-channels of the multiple channels that comprise the physical importance channel can vary. For example, the physical meaning can be maximum, average, or sum of squares. This allows you to select the physical meaning of each sub-channel as needed, thereby describing channel importance from multiple perspectives and providing a more comprehensive representation of channel importance.

[0068] S103. While keeping the parameters of the neural network to be compressed unchanged, train the neural network to be compressed with the saliency representation network added.

[0069] To ensure that the pre-compressed neural network with the added saliency representation network can output information representing channel importance, it is necessary to train the pre-compressed neural network with the added saliency representation network. During training, to maintain the performance of the pre-compressed neural network and avoid performance degradation after pruning, the parameters of the pre-compressed neural network must remain unchanged; only the parameters of the added saliency representation network are modified. The training samples and training termination conditions are the same as those used in the pre-training process for the pre-compressed neural network.

[0070] S104: Acquire a target sample set corresponding to a preset compression requirement.

[0071] In the present invention, different target sample sets can be selected based on different compression requirements for the neural network. In other words, neural network compression is usually performed to reduce the number of channels and reduce the complexity of the neural network. In this case, the compression requirement only includes the number of channels that need to be trimmed or the number of channels that are retained.

[0072] Furthermore, the inventors discovered during the research process that when the neural network to be compressed was trained by adding a saliency representation network using the samples used when training the neural network, and then compressing the neural network to be compressed, the number of channels of the neural network to be compressed was reduced. Although the result was still similar to that of the uncompressed neural network, the recognition result also had some changes. From this, it can be inferred that in addition to reducing the number of channels, the compression process can also be used for a purpose according to the requirements of the recognition results.

[0073] That is to say, if the preset compression requirement is not to change the recognition result of the neural network to be compressed, that is, the data output by the compressed neural network is similar to the data output by the neural network to be compressed, then the sample set of the pre-trained neural network to be compressed can be used as the target sample set in the steps of this embodiment.

[0074] If the preset compression requirement is that the compressed neural network is enhanced in some aspect relative to the data to be output by the neural network, the samples of the corresponding type can be used as the target sample set, so that in the subsequent steps, the channels that are more important and more relevant to the corresponding category can be identified, and then these channels can be retained during the pruning process.

[0075] For example, the neural network to be compressed is pre-trained to recognize pedestrians and cars. The neural network's recognition of pedestrians is more pronounced in channels 1 to 100, while its recognition of cars is more pronounced in channels 101 to 200. If the compressed neural network is expected to have a stronger ability to recognize pedestrians, the preset compression requirement is to maintain or enhance pedestrian recognition. In this case, samples containing more pedestrians can be targeted as the target sample set, and during the pruning process, channels from channels 101 to 200 can be selected for pruning.

[0076] S105 , inputting the target sample set into the trained neural network to be compressed with the saliency representation network added, to obtain information for representing the importance of channels in the neural network to be compressed.

[0077] Assume that the target sample set is Γ, and there are M samples in the target sample set. All samples are input into the trained neural network to be compressed with the added saliency representation network for forward reasoning. For example, when the input is sample m i Time (m i is the i-th sample in the sample set), and the output s1 of the saliency representation subnetwork corresponding to the first neural network layer to be compressed is recorded as s1 mi , s1mi is sample m i The corresponding C-dimensional coefficient vector represents the importance of each of the C channels; after all samples are input, the output matrix of the saliency representation sub-network corresponding to the first neural network layer to be compressed (s1 m1 , s1 m2 ,......,s1 mi ,......,s1 mM ), the output matrix of the saliency representation sub-network corresponding to each subsequent layer of the neural network to be compressed is still derived in the above manner, which will not be repeated here. The output matrices of all saliency representation sub-networks are used to represent the channel importance in the neural network to be compressed.

[0078] S106. Based on the information used to characterize the importance of channels in the neural network to be compressed, perform operations corresponding to preset compression requirements on the neural network to be compressed to obtain a compressed neural network.

[0079] In this step, the channel eigenvalues are first calculated using information used to characterize the importance of the channels in the neural network to be compressed.

[0080] Taking the first neural network layer to be compressed as an example, the above output matrix (s1 m1 , s1 m2 ,......,s1 mi ,......,s1 mM) is used to perform a mean removal operation, that is, to subtract the mean of all elements in the row corresponding to each element from the element (for each channel, there are M values in total, and the mean is the mean of the M values of each channel).

[0081] Then the output matrix (s1 m1 , s1 m2 ,......,s1 mi ,......,s1 mM ) is used to perform data statistics to obtain the corresponding covariance matrix, which has a dimension of C*C and represents the relationship between C channels.

[0082] Finally, the eigenvalues of the covariance matrix are calculated, which are the channel eigenvalues.

[0083] Different compression requirements correspond to different pruning methods and quantities. After obtaining the first preset number of compression channels determined according to the preset compression requirements, the first preset number of compression channels and channel characteristic values are used to perform channel pruning operations on the compressed neural network according to the preset compression requirements to obtain the compressed neural network.

[0084] Assuming that the original number of channels of the first neural network layer to be compressed is C, and the preset compression requirement corresponds to retaining C1 channels with the largest channel eigenvalues, it can be determined that the first preset number of compressed channels is C1, and the channel eigenvalues are sorted from large to small according to the preset compression requirement, and the channels corresponding to the first C1 channel eigenvalues are retained; or, according to the preset compression requirement, the eigenvalues are sorted from small to large, the channels corresponding to the first (C-C1) channel eigenvalues are cut off, and the channels corresponding to the last C1 channel eigenvalues are retained.

[0085] The pruning methods for other neural network layers to be compressed are similar and will not be described here.

[0086] In the neural network compression method disclosed in the above embodiment, when it is necessary to perform structured pruning on the trained neural network, first, a saliency representation network is added to the neural network to be compressed; then, while keeping the parameters of the neural network to be compressed unchanged, the neural network to be compressed after adding the saliency representation network is trained; after the training is completed, the target sample set corresponding to the preset compression requirement is used to obtain information for characterizing the importance of the output channels in the neural network to be compressed; finally, based on the information for characterizing the importance of the channels in the neural network to be compressed, the operation corresponding to the preset compression requirement is performed on the neural network to be compressed to obtain the compressed neural network. The present invention uses the saliency representation network to determine the importance of each channel in the neural network to be compressed. Compared with manual or random selection, it can more effectively, comprehensively and automatically model and express the importance of each channel, avoiding the situation where important channels are pruned due to manual or random selection during the structured pruning process.

[0087] In actual application, if Figure 1 If the structure of the neural network after compression is still complex or the amount of computation is still large, it can be compressed again. Figure 1 The process shown is just to reselect the target sample set and execute the subsequent process again according to further compression requirements.

[0088] Alternatively, the importance of each channel can be assessed based on the L1 / L2 norm, and the importance of each channel of the compressed neural network can be assessed again before pruning. The specific process is as follows Figure 8 As shown, steps S801-S806 are Figure 1 S101-S106 in the embodiment shown are basically the same, and the specific description can be referred to Figure 1 The embodiment shown. Figure 1 compared to, Figure 8 The additional steps include:

[0089] S807, calculating the norm value of the features of each channel in the compressed neural network;

[0090] In order to further prune the neural network, L2, L1 or other forms of norm calculation are performed on the features of each channel of the compressed neural network to obtain the norm value of the features of each channel.

[0091] S808. Perform a channel pruning operation on the compressed neural network based on a second preset number of compression channels and a norm value of the features of each channel.

[0092] Combine Figure 1 In the embodiment shown, after the processing of steps S801-806, the number of channels of the first compressed neural network layer in the neural network is compressed from C to C1. In this embodiment, the second preset number of compressed channels is determined to be C2. Then, the norm values of the features of each channel are sorted from large to small, and the channels corresponding to the norm values of the first C2 features are retained; the other channels are pruned, or the norm values of the features of each channel are sorted from small to large, and the channels corresponding to the norm values of the first C2 features are retained; 1- The pruning methods for other compressed neural network layers are similar and will not be described here.

[0093] In this embodiment, the first preset number of compression channels and the second preset number of compression channels are directly related to a preset compression ratio. Furthermore, the preset compression ratio is set based on empirical values to ensure that the recognition capability of the compressed neural network remains within an allowable range, thereby preventing the recognition capability from being too low.

[0094] This method can further compress the neural network. Furthermore, in this embodiment, the neural network is first compressed using a saliency representation network approach, ensuring the accuracy of the compression result. Although further compression is subsequently performed using the L1 / L2 norm approach, its accuracy can still be passed back to the final compression result. Therefore, while taking into account accuracy, the neural network architecture is further reduced, reducing the amount of computation.

[0095] The present invention uses the L1 / L2 norm method for further compressing the compressed neural network for illustrative purposes only and is not intended to limit the use of this method for further compression. Those skilled in the art may determine further compression methods based on different needs, and the details will not be repeated here.

[0096] The embodiment of the present invention also discloses a neural network compression system, the structure of which is as follows: Figure 9 As shown, including:

[0097] The first acquisition module 901 is used to acquire the neural network to be compressed, where the neural network to be compressed is a pre-trained neural network.

[0098] The adding module 902 is configured to add a saliency representation network to the neural network to be compressed.

[0099] The training module 903 is configured to train the neural network to be compressed after adding the saliency representation network while keeping the parameters of the neural network to be compressed unchanged.

[0100] The second acquisition module 904 is configured to acquire a target sample set corresponding to a preset compression requirement.

[0101] The data processing module 905 is configured to input the target sample set into the trained neural network to be compressed with the saliency representation network added thereto, and obtain information for representing the importance of channels in the neural network to be compressed.

[0102] The first compression module 906 is used to perform an operation corresponding to the preset compression requirement on the neural network to be compressed based on the information used to characterize the importance of the channels in the neural network to be compressed, so as to obtain a compressed neural network.

[0103] The neural network compression system disclosed in this embodiment, when performing a structured pruning operation on a trained neural network, first adds a saliency representation network to the neural network to be compressed; then, while keeping the parameters of the neural network to be compressed unchanged, trains the neural network to be compressed after adding the saliency representation network; after the training is completed, uses a target sample set corresponding to a preset compression requirement to obtain information used to characterize the importance of output channels in the neural network to be compressed; finally, based on the information used to characterize the importance of channels in the neural network to be compressed, performs operations corresponding to the preset compression requirement on the neural network to be compressed, and finally obtains a compressed neural network. This system uses the saliency representation network to determine the importance of each channel in the neural network to be compressed. Compared with manual or random selection, it can more effectively, comprehensively, and automatically model and express the importance of each channel, avoiding the situation where important channels are pruned due to manual or random selection during the structured pruning process.

[0104] Optionally, the adding module 902 is specifically used to: when the neural network to be compressed includes multiple neural network layers to be compressed and the saliency representation network includes multiple saliency representation sub-networks, add a saliency representation sub-network after each neural network layer to be compressed.

[0105] Further, Figure 9 It is also shown that in a possible implementation, the specific structure of the first compression module 906 includes:

[0106] The eigenvalue calculation unit 9061 is used to calculate the channel eigenvalue using the information used to characterize the importance of the channel in the neural network to be compressed.

[0107] The channel number acquisition unit 9062 is configured to acquire a first preset number of compression channels determined according to a preset compression requirement.

[0108] The first pruning unit 9063 is used to use the first preset number of compression channels and channel characteristic values to perform channel pruning operations on the neural network to be compressed according to preset compression requirements to obtain a compressed neural network.

[0109] The specific workflow of the neural network compression system disclosed in this embodiment can be referred to Figure 1 The embodiments shown will not be described in detail here.

[0110] The embodiment of the present invention also discloses another neural network compression system, which has a similar structure to the Figure 9 Compared to the embodiment shown, modules 1001-1006 are Figure 9 The structures 901-906 shown in FIG are the same, and in addition, they also include: a second compression module 1007 for further compressing the compressed neural network.

[0111] An implementation of the second compression module 1007 is as follows Figure 10 As shown in , including:

[0112] The norm calculation unit 10071 is used to calculate the norm value of the features of each channel in the compressed neural network.

[0113] The second pruning unit 10072 is used to perform a channel pruning operation on the compressed neural network based on a second preset number of compression channels and a norm value of the feature of each channel.

[0114] The neural network compression system disclosed in this embodiment can further compress the compressed neural network. Furthermore, this embodiment first compresses the neural network using a saliency representation network approach, ensuring the accuracy of the compression result. Although further compression is subsequently performed using a norm calculation unit based on the L1 / L2 norm, the accuracy is still transmitted to the final compression result. Therefore, while maintaining accuracy, the neural network architecture is further reduced, reducing the amount of computation.

[0115] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0116] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.

[0117] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0118] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily 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 is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A neural network compression method, characterized in that: include: Obtaining a neural network to be compressed, where the neural network to be compressed is a pre-trained neural network for identifying pedestrians and / or cars; Adding a saliency representation network to the neural network to be compressed, wherein the saliency representation network includes a plurality of saliency representation sub-networks, and each saliency representation sub-network includes a high-dimensional meaning importance channel and / or a physical meaning importance channel; While keeping the parameters of the neural network to be compressed unchanged, training the neural network to be compressed after adding the saliency representation network; Obtaining a target sample set corresponding to a preset compression requirement, wherein the preset compression requirement is a requirement related to the ability of the neural network to recognize pedestrians and / or cars, and the target sample set includes samples of pedestrians and / or cars; Inputting the target sample set into the trained neural network to be compressed with the saliency representation network added thereto, and obtaining information for representing the importance of channels in the neural network to be compressed; Based on the information used to characterize the importance of the channels in the neural network to be compressed, an output matrix of the significance characterization subnetwork is obtained, data statistics are performed on the output matrix to obtain a corresponding covariance matrix, the eigenvalues of the covariance matrix are calculated to obtain channel eigenvalues, and based on the channel eigenvalues, an operation corresponding to the preset compression requirements is performed on the neural network to be compressed to obtain a compressed neural network.

2. The neural network compression method according to claim 1, wherein: Adding a saliency representation network to the neural network to be compressed includes: When the neural network to be compressed includes multiple neural network layers to be compressed and the saliency representation network includes multiple saliency representation sub-networks, a saliency representation sub-network is added after each neural network layer to be compressed.

3. The neural network compression method according to claim 1, wherein: The physical meaning importance channel includes a plurality of physical meaning importance sub-channels.

4. The neural network compression method according to any one of claims 1 to 3, characterized in that: The process of obtaining an output matrix of a significance characterization subnetwork based on the information used to characterize the importance of channels in the neural network to be compressed, performing data statistics on the output matrix to obtain a corresponding covariance matrix, calculating eigenvalues of the covariance matrix to obtain channel eigenvalues, and performing an operation corresponding to the preset compression requirement on the neural network to be compressed based on the channel eigenvalues to obtain a compressed neural network includes: Using the information used to characterize the importance of channels in the neural network to be compressed, an output matrix of the significance characterization subnetwork is obtained, data statistics are performed on the output matrix to obtain a corresponding covariance matrix, eigenvalues of the covariance matrix are calculated, and channel eigenvalues are obtained; Obtaining a first preset number of compression channels determined according to the preset compression requirement; Using the first preset number of compression channels and the channel characteristic values, and according to the preset compression requirements, a channel pruning operation is performed on the neural network to be compressed to obtain a compressed neural network.

5. The neural network compression method according to claim 4, wherein: Also includes: Calculating a norm value of features of each channel in the compressed neural network; A channel pruning operation is performed on the compressed neural network based on a second preset number of compression channels and a norm value of the features of each channel.

6. A neural network compression system, characterized in that: include: A first acquisition module is used to acquire a neural network to be compressed, where the neural network to be compressed is a pre-trained neural network for identifying pedestrians and / or cars; An adding module, configured to add a saliency representation network to the neural network to be compressed, wherein the saliency representation network includes a plurality of saliency representation sub-networks, and each saliency representation sub-network includes a high-dimensional meaning importance channel and / or a physical meaning importance channel; A training module, configured to train the neural network to be compressed after adding the saliency representation network while keeping the parameters of the neural network to be compressed unchanged; a second acquisition module, configured to acquire a target sample set corresponding to a preset compression requirement, wherein the preset compression requirement is a requirement related to the ability of the neural network to recognize pedestrians and / or cars, and the target sample set includes samples of pedestrians and / or cars; a data processing module, configured to input the target sample set into the trained neural network to be compressed with the added saliency representation network, and obtain information for representing the importance of channels in the neural network to be compressed; The first compression module is used to obtain the output matrix of the significance characterization sub-network based on the information used to characterize the importance of the channels in the neural network to be compressed, perform data statistics on the output matrix to obtain the corresponding covariance matrix, calculate the eigenvalues of the covariance matrix to obtain channel eigenvalues, and perform operations corresponding to the preset compression requirements on the neural network to be compressed based on the channel eigenvalues to obtain a compressed neural network.

7. The neural network compression system according to claim 6, characterized in that The adding module is specifically used for: When the neural network to be compressed includes multiple neural network layers to be compressed and the saliency representation network includes multiple saliency representation sub-networks, a saliency representation sub-network is added after each neural network layer to be compressed.

8. The neural network compression system according to claim 6 or 7, characterized in that: The first compression module includes: an eigenvalue calculation unit, configured to obtain an output matrix of a significance characterization subnetwork using the information for characterizing the importance of channels in the neural network to be compressed, perform data statistics on the output matrix to obtain a corresponding covariance matrix, calculate eigenvalues of the covariance matrix, and obtain channel eigenvalues; a channel number acquisition unit, configured to acquire a first preset number of compression channels determined according to the preset compression requirement; The first pruning unit is used to use the first preset number of compression channels and the channel characteristic values to perform a channel pruning operation on the neural network to be compressed according to the preset compression requirements to obtain a compressed neural network.

9. The neural network compression system according to claim 8, wherein: Also includes: A second compression module, wherein the second compression module includes: A norm calculation unit, configured to calculate a norm value of a feature of each channel in the compressed neural network; The second pruning unit is used to perform a channel pruning operation on the compressed neural network based on a second preset number of compression channels and a norm value of the feature of each channel.

Citation Information

Patent Citations

  • Flexible deep learning network model compression method based on channel gradient pruning

    CN112396179A

  • Neural network architecture pruning

    US20210264278A1