A machine learning model compression method, device and equipment

By learning the two-dimensional information entropy of the intermediate layer feature map of the model and cutting it, the problem of poor model compression effect in the prior art is solved, and the effect of significantly reducing the model storage space and computing resources while retaining the calculation accuracy is achieved.

CN112508187BActive Publication Date: 2025-02-28LENOVO (BEIJING) LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011141545.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-22
Publication Date
2025-02-28
Estimated Expiration
2041-02-28

AI Technical Summary

Technical Problem

In the existing machine learning model compression methods, it is difficult to find redundant information in the model in the geometric averaging method, resulting in poor compression effect and low accuracy.

Method used

By obtaining the intermediate layer feature map information of the model to be compressed, the two-dimensional information entropy of each feature map is calculated, and the model is cropped based on the two-dimensional information entropy to obtain the compressed model data.

Benefits of technology

The importance of feature maps is reasonably evaluated by using two-dimensional information entropy, and by cropping feature maps with smaller two-dimensional information entropy, the machine learning model is compressed, significantly reducing the model storage space and computing resources, and improving the equipment operation speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and equipment for compressing a machine learning model, the method comprising: obtaining original model data of a model to be compressed, the original model data comprising feature map information of an intermediate layer of the model to be compressed; determining the two-dimensional information entropy of each feature map of the intermediate layer according to the feature map information; and clipping the model to be compressed according to the two-dimensional information entropy to obtain compressed model data. Thus, the importance of feature maps is reasonably evaluated using the two-dimensional information entropy, and the machine learning model is compressed by clipping feature maps with smaller two-dimensional information entropy, which significantly reduces the model storage space and saves computing resources while retaining the calculation accuracy of the machine learning model, so that the machine learning model can be deployed to more devices, greatly increasing the application scope of the machine learning model and effectively improving the device operation speed.
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 machine learning model compression method, device and equipment. Background Art

[0002] With the rapid development of artificial intelligence technology, there are more and more types of machine learning models trained by machine learning technology, such as neural network models obtained by using neural network algorithms. Machine learning models are applied to various industries to solve many technical problems. However, machine learning models have many model parameters and require more computing resources. As a result, it is often difficult to deploy machine learning models with a large number of parameters and to perform the corresponding amount of calculations for mobile terminals or embedded devices with limited storage space and computing resources. Alternatively, even if the machine learning model can be deployed to the corresponding device, the model will occupy more storage space and computing resources, which will have a great impact on the operation of the device. Therefore, the model needs to be compressed.

[0003] The commonly used model compression method is to prune the model, but the model sparsity caused by irregular pruning requires additional sparse calculation algorithms to accelerate the model, while the model can be directly accelerated by regular pruning. At present, regular pruning of the model is mainly performed through geometric averaging, but it is difficult for geometric averaging to find redundant information in the model, resulting in poor model compression effect and low accuracy. Summary of the invention

[0004] In order to solve the above-mentioned problems existing in the model compression process, the embodiments of the present invention creatively provide a machine learning model compression method, device and equipment.

[0005] According to a first aspect of the present invention, a machine learning model compression method is provided, the method comprising: obtaining original model data of a model to be compressed, the original model data comprising feature map information of an intermediate layer of the model to be compressed; determining the two-dimensional information entropy of each feature map of the intermediate layer based on the feature map information; and cropping the model to be compressed based on the two-dimensional information entropy to obtain compressed model data.

[0006] According to one embodiment of the present invention, the model to be compressed is cropped according to the two-dimensional information entropy to obtain compressed model data, including: obtaining the number of feature map croppings for each of the intermediate layers; and according to the number of feature map croppings, each intermediate layer of the model to be compressed is cropped in sequence in the order from the input unit layer to the output unit layer of the intermediate layer.

[0007] According to one embodiment of the present invention, each intermediate layer of the model to be compressed is cropped in sequence in the order from the input unit layer to the output unit layer of the intermediate layer, including: for each of the intermediate layers, according to the value of the two-dimensional information entropy of each feature map in the intermediate layer from small to large, according to the corresponding feature map cropping number, determining the feature map to be cropped; deleting or setting the parameter value of the feature map to be cropped to zero to obtain the feature map of the cropped intermediate layer; inputting the feature map of the cropped intermediate layer to the next intermediate layer to obtain the feature map of the next intermediate layer; cropping each of the intermediate layers in sequence according to the above steps until the cropping of all the intermediate layers is completed.

[0008] According to one embodiment of the present invention, obtaining the number of feature map croppings of each intermediate layer includes: obtaining the cropping ratio of each intermediate layer and the corresponding total number of feature maps; and determining the number of feature map croppings of the corresponding intermediate layer according to each cropping ratio and the corresponding total number of feature maps.

[0009] According to one embodiment of the present invention, the two-dimensional information entropy of each feature map of the intermediate layer is determined according to the feature map information, including: determining the occurrence probability of each feature parameter in each feature map according to the feature map information; for a feature map, determining the two-dimensional information entropy of the feature map according to the occurrence probability of each feature parameter in the feature map.

[0010] According to one embodiment of the present invention, the occurrence probability of each feature parameter in each feature map is determined based on the feature map information, including: for each feature map, uniformly quantizing the values ​​in the feature map to obtain a quantized feature map; forming a neighborhood combination of each feature parameter in the quantized feature map and the mean of its adjacent feature parameters; and determining the occurrence probability of each feature parameter based on the feature parameter and the neighborhood combination.

[0011] According to the second aspect of the present invention, a machine learning model compression device is also provided, which includes: an acquisition module for acquiring original model data of the model to be compressed, the original model data including feature map information of the intermediate layer of the model to be compressed; a two-dimensional information entropy determination module for determining the two-dimensional information entropy of each feature map of the intermediate layer according to the feature map information; and a cropping module for cropping the model to be compressed according to the two-dimensional information entropy to obtain compressed model data.

[0012] According to one embodiment of the present invention, the cropping module includes: a cropping quantity determination submodule, used to obtain the cropping quantity of the feature map of each intermediate layer; a cropping submodule, used to crop each intermediate layer of the model to be compressed in sequence according to the cropping quantity of the feature map, in the order from the input unit layer to the output unit layer of the intermediate layer.

[0013] According to one embodiment of the present invention, the two-dimensional information entropy determination module includes: a probability determination submodule, which is used to determine the probability of occurrence of each feature parameter in each feature map based on the feature map information; an information entropy determination submodule, which is used to determine the two-dimensional information entropy of a feature map based on the probability of occurrence of each feature parameter in the feature map.

[0014] According to the third aspect of the present invention, a device is also provided, comprising at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; and the processor is used to call program instructions in the memory to execute the above-mentioned machine learning model compression method.

[0015] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, which includes a set of computer-executable instructions, which are used to execute any of the above-mentioned machine learning model compression methods when the instructions are executed.

[0016] The machine learning model compression method, device and equipment of the embodiment of the present invention determine the two-dimensional information entropy of each feature map of the middle layer according to the feature map information of the middle layer in the original model data of the model to be compressed, and cut the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data. Thus, the importance of the feature map is reasonably evaluated by using the two-dimensional information entropy, and the machine learning model is compressed by cutting the feature map with smaller two-dimensional information entropy. On the basis of retaining the calculation accuracy of the machine learning model, the model storage space is significantly reduced, and the computing resources are saved, so that the machine learning model can be deployed to more devices, which greatly increases the application scope of the machine learning model and effectively improves the operation speed of the device.

[0017] It should be understood that the teachings of the present invention are not required to achieve all of the beneficial effects described above, but specific technical solutions can achieve specific technical effects, and other embodiments of the present invention can also achieve beneficial effects not mentioned above. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:

[0019] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0020] Figure 1 A schematic diagram of the implementation process of the machine learning model compression method according to an embodiment of the present invention is shown;

[0021] Figure 2 A schematic diagram of the implementation process of an application example of the machine learning model compression method according to an embodiment of the present invention is shown;

[0022] Figure 3 A schematic diagram of the implementation process of the device according to the embodiment of the present invention is shown;

[0023] Figure 4 A schematic diagram of the structure of the device according to the embodiment of the present invention is shown. DETAILED DESCRIPTION

[0024] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present invention more thorough and complete, and to fully convey the scope of the present invention to those skilled in the art.

[0025] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0026] Figure 1 A schematic diagram of the implementation process of the machine learning model compression method according to an embodiment of the present invention is shown.

[0027] refer to Figure 1 The machine learning model compression method of the embodiment of the present invention at least includes the following operation flow: operation 101, obtaining the original model data of the model to be compressed, the original model data including the feature map information of the middle layer of the model to be compressed; operation 102, determining the two-dimensional information entropy of each feature map of the middle layer according to the feature map information; operation 103, cropping the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data.

[0028] In operation 101, original model data of a model to be compressed is obtained, where the original model data includes feature map information of an intermediate layer of the model to be compressed.

[0029] For example, the model to be compressed is a classic neural network model, which has an input layer, an intermediate layer and an output layer. The original model data refers to the data of the feature graphs contained in each layer of the neural network model. The feature graph data of the intermediate layer is relatively large, and is the object to be compressed in the embodiment of the present invention. Therefore, when obtaining the original model data of the model to be compressed, at least the feature graph information of the intermediate layer of the model to be compressed must be obtained.

[0030] Operation 102: determining the two-dimensional information entropy of each feature map of the middle layer according to the feature map information.

[0031] Two-dimensional information entropy is a commonly used concept in images. In the relevant expressions of images, the entropy of an image is a statistical form of characteristics. It reflects the average amount of information in the image and represents the aggregation characteristics of the grayscale distribution of the image, but it cannot reflect the spatial characteristics of the grayscale distribution of the image. In order to characterize this spatial characteristic, a feature quantity that can reflect the spatial characteristics of the grayscale distribution is introduced on the basis of the one-dimensional entropy to form the two-dimensional entropy of the image.

[0032] The two-dimensional information entropy of an image reflects the spatial characteristics of the grayscale distribution of the image, highlighting the grayscale information of the pixel position in the image and the comprehensive characteristics of the grayscale distribution in the pixel neighborhood. The larger the two-dimensional information entropy, the more uniform and rich the grayscale jump distribution of the pixels in the image and their adjacent pixels is, and the more information the image contains. In the embodiment of the present invention, this feature is utilized to apply the two-dimensional information entropy to the cropping of the intermediate feature map of the neural network.

[0033] In one embodiment of the present invention, the following operating steps are used to determine the two-dimensional information entropy of each feature map in the middle layer according to the feature map information: determine the occurrence probability of each feature parameter in each feature map according to the feature map information; for a feature map, determine the two-dimensional information entropy of the feature map according to the occurrence probability of each feature parameter in the feature map.

[0034] For example, for a feature map, according to the occurrence probability of each feature parameter in the feature map, the following formula (1) is used to determine the two-dimensional information entropy of the feature map:

[0035]

[0036] Wherein, H represents the two-dimensional information entropy of the feature map;

[0037] I represents the maximum value of the characteristic parameter in the characteristic graph, 0≤i≤I;

[0038] J represents the maximum value of the mean values ​​of adjacent feature parameters of each feature parameter in the feature graph, 0≤j≤J;

[0039] P ij Represents the occurrence probability of feature parameters.

[0040] In one embodiment of the present invention, the occurrence probability of each feature parameter in each feature map is determined based on the feature map information, including: for each feature map, the values ​​in the feature map are uniformly quantized to obtain a quantized feature map; each feature parameter in the quantized feature map and the mean of its adjacent feature parameters form a neighborhood combination; based on the feature parameters and the neighborhood combination, the occurrence probability of each feature parameter is determined.

[0041] For example, for the feature graph of a machine learning model, such as a neural network model, the value of the feature graph is a two-dimensional array, including multiple values. Uniform quantization can be understood as normalization processing, which can round multiple values ​​in the feature graph to obtain multiple integer values. Or the values ​​in a certain range in the feature graph are recorded as the same value, for example, the values ​​in the range of 0 to 4 in the feature graph are uniformly recorded as 2, and the values ​​of 5 to 8 are uniformly recorded as 6... The specific value range can be set according to actual needs. In this way, the values ​​in the two-dimensional array of the feature graph are normalized, which greatly reduces the amount of calculation in the model compression process and effectively improves the efficiency of pruning the model to be compressed.

[0042] Take the values ​​in the feature map as a two-dimensional array. For each feature parameter in the feature map obtained after uniform quantization, take the average value of the values ​​of the adjacent parameters of the feature parameter in the upper, lower, left and right directions as the mean value of its adjacent feature parameters. For example: if a feature parameter is located in the second row and third column, then the feature parameter in the first row and third column is the feature parameter above it. Similarly, four feature parameters in the upper, lower, left and right directions can be obtained. For feature parameters in special positions of the feature map, one or two of the adjacent parameters such as above, below, left or right may be missing. For example: for the feature parameter in the first row and first column, there are no other feature parameters above and to the left. For the feature parameter in the second row and last column, there are no other feature parameters to the right. For the feature parameters in these special positions, the average value of the adjacent parameters they have is taken as the mean value of their adjacent parameters. Each feature parameter and the mean value of its adjacent parameters form a neighborhood combination.

[0043] According to the combination of feature parameters and neighborhood, the occurrence probability of each feature parameter is determined using the following formula (2):

[0044] P ij =f(i,j) / N 2 (2)

[0045] Among them, P ij Represents the occurrence probability of feature parameters;

[0046] f(i, j) represents the number of neighborhood combinations (i, j) in the feature graph;

[0047] N represents the total number of neighborhood combinations in the feature map;

[0048] 0≤i≤I, I represents the maximum value of the characteristic parameter in the characteristic graph;

[0049] 0≤j≤J, J represents the maximum value of the means of adjacent feature parameters of each feature parameter in the feature graph.

[0050] In operation 103, the model to be compressed is trimmed according to the two-dimensional information entropy to obtain compressed model data.

[0051] In one embodiment of the present invention, the following operating steps are used to crop the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data: obtain the number of feature map croppings for each intermediate layer; according to the number of feature map croppings, crop each intermediate layer of the model to be compressed in turn in the order from the input unit layer to the output unit layer of the intermediate layer.

[0052] For example, the model to be compressed is a neural network model with R intermediate layers, the first layer is the input unit layer of the intermediate layer, the Rth layer is the output unit layer of the intermediate layer, the number of feature map clippings of the first layer is p1, and the number of feature map clippings of the Rth layer is p r . The number of feature maps cropped for each layer can be the same or different, and the present invention does not limit this. According to the number of feature maps cropped, each intermediate layer of the model to be compressed is cropped in sequence from the 1st layer to the Rth layer, wherein R represents the number of intermediate layers of the model to be compressed, the rth layer is the input of the (r+1)th layer, R and r are both positive integers, r∈[1, R-1], and the number of feature maps of the rth intermediate layer is M r .

[0053] In one embodiment of the present invention, the cropping ratio of each intermediate layer and the corresponding total number of feature maps are obtained; and the cropping number of feature maps of the corresponding intermediate layer is determined according to each cropping ratio and the corresponding total number of feature maps. Thus, the cropping number of feature maps of each intermediate layer is obtained.

[0054] For example, if the cropping ratio of the rth intermediate layer is q r And the total number of feature maps is M r , then the number of feature maps that need to be cropped in the rth intermediate layer can be obtained using the following formula (3):

[0055] p r =q r ×M r (3).

[0056] In one embodiment of the present invention, the following operations are used to sequentially crop each intermediate layer of the compression model in the order from the input unit layer to the output unit layer of the intermediate layer: for each intermediate layer, the feature map to be cropped is determined according to the corresponding feature map cropping quantity in the order of the value of the two-dimensional information entropy of each feature map in the intermediate layer from small to large; the parameter value of the feature map to be cropped is deleted or set to zero to obtain the feature map of the cropped intermediate layer; the feature map of the cropped intermediate layer is input to the next intermediate layer to obtain the feature map of the next intermediate layer; each intermediate layer is cropped in accordance with the above steps in sequence until the cropping of all intermediate layers is completed.

[0057] For example, the model to be compressed is a neural network model with R intermediate layers. The number of feature maps to be cropped in the rth intermediate layer is p. r According to the order of the two-dimensional information entropy value of each feature map in the r-th intermediate layer of the model from small to large, the M in the r-th intermediate layer r feature maps are sorted and the top p in the sorting are determined r The feature map corresponding to the two-dimensional information entropy is deleted or set to zero to obtain the feature map of the rth intermediate layer after cropping. The feature map of the rth intermediate layer after cropping is input to the (r+1)th intermediate layer to obtain the feature map of the (r+1)th intermediate layer. The (r+1)th intermediate layer is cropped according to the above steps until the cropping of the Rth intermediate layer is completed.

[0058] Figure 2 A flowchart showing a specific application example of the machine learning model compression method according to an embodiment of the present invention is shown.

[0059] refer to Figure 2 , a specific application example of the machine learning model compression method of an embodiment of the present invention, the model to be compressed has R intermediate layers, namely Layer1, Layer2...LayerR, and correspondingly, the number of feature maps of each intermediate layer is M1, M2...M R The cropping ratio of each layer feature map is q1, q2...q R , the number of feature maps that need to be cropped in each intermediate layer are p1, p2, ..., p R Among them, p1, p2, ... p R The above formula (3) can be used to obtain M1, M2, ..., M R The values ​​of can be the same or different, q1, q2, ... q R The values ​​of can be the same or different, accordingly, p1, p2, ... R The values ​​can be the same or different.

[0060] The training data Train data is used as the model input layer and input into the middle layer of the model to be compressed to obtain M1 feature maps of the first middle layer Layer1. The two-dimensional information entropy of the M1 feature maps is calculated respectively to obtain M1 two-dimensional information entropy values. The M1 two-dimensional information entropy values ​​are sorted from small to large, and the first p1 values ​​are selected, and the parameters in the feature maps corresponding to these p1 two-dimensional information entropies are set to zero.

[0061] Among them, the specific implementation process of "calculating the two-dimensional information entropy of M1 feature maps" is the same as Figure 1 The specific implementation process of operation 102 in the illustrated embodiment is similar and will not be repeated here.

[0062] The specific implementation process of "sorting the values ​​of M1 two-dimensional information entropy from small to large, selecting the first p1 values, and setting the parameters in the feature map corresponding to these p1 two-dimensional information entropy to zero" is similar to Figure 1 The specific implementation process of operation 103 in the illustrated embodiment is similar and will not be repeated here.

[0063] In this way, the pruned first intermediate layer Pruned Layer1 is obtained, and Pruned Layer1 is input into L and input into the second intermediate layer to obtain M2 feature maps of Layer2, and then the two-dimensional information entropy of the M2 feature maps is calculated respectively to obtain M2 two-dimensional information entropy values, and the M2 two-dimensional information entropy values ​​are sorted from small to large, and the first p2 values ​​are selected, and the parameters in the feature maps corresponding to these p2 two-dimensional information entropies are set to zero.

[0064] The R intermediate layers are processed in sequence until the PrunedLayer(R-1) obtained after the (R-1)th intermediate layer is pruned is input into the Rth intermediate layer to obtain the M of LayerR. R feature maps, and then calculate M R The two-dimensional information entropy of the feature map is obtained R The value of two-dimensional information entropy, and M R The values ​​of the two-dimensional information entropy are sorted from small to large, and the first p are selected R value, this p R The parameters in the feature map corresponding to the two-dimensional information entropy are set to zero, completing the cropping of the middle layer of the Rth layer. And input to the output layer output of the model.

[0065] The machine learning model compression method, device and equipment of the embodiment of the present invention determine the two-dimensional information entropy of each feature map of the middle layer according to the feature map information of the middle layer in the original model data of the model to be compressed, and cut the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data. Thus, the importance of the feature map is reasonably evaluated by using the two-dimensional information entropy, and the machine learning model is compressed by cutting the feature map with smaller two-dimensional information entropy. On the basis of retaining the calculation accuracy of the machine learning model, the model storage space is significantly reduced, and the computing resources are saved, so that the machine learning model can be deployed to more devices, which greatly increases the application scope of the machine learning model and effectively improves the operation speed of the device.

[0066] Similarly, based on the above machine learning model compression method, an embodiment of the present invention also provides a computer-readable storage medium, which stores a program. When the program is executed by a processor, the processor performs at least the following operation steps: Operation 101, obtaining the original model data of the model to be compressed, the original model data including the feature map information of the middle layer of the model to be compressed; Operation 102, determining the two-dimensional information entropy of each feature map of the middle layer according to the feature map information; Operation 103, cropping the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data.

[0067] Further, based on the above machine learning model compression method, the embodiment of the present invention also provides a machine learning model compression device, such as Figure 3 The device 30 includes: an acquisition module 301, used to obtain the original model data of the model to be compressed, the original model data includes the feature map information of the middle layer of the model to be compressed; a two-dimensional information entropy determination module 302, used to determine the two-dimensional information entropy of each feature map of the middle layer according to the feature map information; a cropping module 303, used to crop the model to be compressed according to the two-dimensional information entropy to obtain the compressed model data.

[0068] In one embodiment of the present invention, the cropping module 303 includes: a cropping quantity determination submodule, used to obtain the cropping quantity of the feature map of each intermediate layer; a cropping submodule, used to crop each intermediate layer of the compression model in sequence according to the feature map cropping quantity, in the order from the input unit layer to the output unit layer of the intermediate layer.

[0069] In one embodiment of the present invention, the two-dimensional information entropy determination module 302 includes: a probability determination submodule, which is used to determine the probability of occurrence of each feature parameter in each feature map based on the feature map information; an information entropy determination submodule, which is used to determine the two-dimensional information entropy of a feature map based on the probability of occurrence of each feature parameter in the feature map.

[0070] Further, based on the above machine learning model compression method, an embodiment of the present invention also provides a device, such as Figure 4 The device 40 includes at least one processor 401, and at least one memory 402 and a bus 403 connected to the processor 401; wherein the processor 401 and the memory 402 communicate with each other through the bus 403; the processor 403 is used to call the program instructions in the memory 402 to execute the above-mentioned machine learning model compression method.

[0071] It should be noted here that: the above description of the embodiment of the machine learning model compression device and equipment is different from the above Figures 1 to 2 The description of the method embodiment shown is similar, with the same Figures 1 to 2 The method embodiment shown in the figure has similar beneficial effects, so it will not be described in detail. For technical details not disclosed in the embodiments of the machine learning model compression device and equipment of the present invention, please refer to the aforementioned Figures 1 to 2 The description of the method embodiment shown in the figure can be understood, and in order to save space, it will not be repeated.

[0072] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0073] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0074] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0075] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0076] Those skilled in the art will appreciate that all or part of the steps of the above method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a computer-readable storage medium, which, when executed, executes the steps of the above method embodiments; and the aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), magnetic disks or optical disks.

[0077] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0078] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A machine learning model compression method, the method comprising: Acquire original model data of the model to be compressed, wherein the original model data includes feature map information of an intermediate layer of the model to be compressed; Determine the two-dimensional information entropy of each feature map of the intermediate layer according to the feature map information; According to the two-dimensional information entropy, the model to be compressed is trimmed to obtain compressed model data; Among them, the cropping of the model to be compressed includes: obtaining the number of feature map cropping of each intermediate layer; and according to the number of feature map cropping, cropping each intermediate layer of the model to be compressed in sequence from the input unit layer to the output unit layer of the intermediate layer.

2. The method according to claim 1, wherein each intermediate layer of the model to be compressed is pruned in sequence in the order from the input unit layer to the output unit layer of the intermediate layer, comprising: For each of the intermediate layers, according to the value of the two-dimensional information entropy of each feature map in the intermediate layer from small to large, according to the corresponding feature map cropping quantity, determining the feature map to be cropped; Delete or set the parameter value of the feature map to be cropped to zero to obtain the feature map of the cropped middle layer; Inputting the cropped feature map of the intermediate layer to the next intermediate layer to obtain a feature map of the next intermediate layer; Each of the intermediate layers is cut in turn until all the intermediate layers are cut.

3. According to the method of claim 1, obtaining the number of feature map clippings of each intermediate layer comprises: Obtaining the cropping ratio of each intermediate layer and the corresponding total number of feature maps; According to each of the cropping ratios and the corresponding total number of feature maps, the number of feature maps to be cropped at the corresponding intermediate layer is determined.

4. The method according to claim 1, determining the two-dimensional information entropy of each feature map of the intermediate layer according to the feature map information, comprising: Determine the occurrence probability of each feature parameter in each feature map according to the feature map information; For each feature map, the two-dimensional information entropy of the feature map is determined according to the occurrence probability of each feature parameter in the feature map.

5. The method according to claim 4, determining the occurrence probability of each feature parameter in each feature map according to the feature map information, comprising: For each feature map, the values ​​in the feature map are uniformly quantized to obtain a quantized feature map; Combining each feature parameter in the quantized feature graph with the mean of its adjacent feature parameters into a neighborhood combination; The occurrence probability of each feature parameter is determined according to the feature parameter and the neighborhood combination.

6. A machine learning model compression device, the device comprising: An acquisition module, used to acquire original model data of the model to be compressed, wherein the original model data includes feature map information of the middle layer of the model to be compressed; A two-dimensional information entropy determination module, used to determine the two-dimensional information entropy of each feature map of the intermediate layer according to the feature map information; A clipping module, used for clipping the model to be compressed according to the two-dimensional information entropy to obtain compressed model data; Among them, the cropping module includes: a cropping quantity determination submodule, used to obtain the cropping quantity of the feature map of each intermediate layer; a cropping submodule, used to crop each intermediate layer of the model to be compressed in sequence according to the cropping quantity of the feature map, in the order from the input unit layer to the output unit layer of the intermediate layer.

7. The device according to claim 6, characterized in that The two-dimensional information entropy determination module includes: A probability determination submodule, used to determine the occurrence probability of each feature parameter in each feature map according to the feature map information; The information entropy determination submodule is used to determine the two-dimensional information entropy of each feature map according to the occurrence probability of each feature parameter in the feature map.

8. A device comprising at least one processor, and at least one memory and a bus connected to the processor; wherein: The processor and the memory communicate with each other via the bus; The processor is used to call program instructions in the memory to execute the machine learning model compression method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Deep neural network model compression method and device

    CN110059823A

  • Structured network model compression acceleration method based on multistage pruning

    CN110619385A