Neural network compression method and device, computer readable medium, and electronic device

By configuring the parameters to be executed for the neural network and performing quantized perceptual training and progressive pruning, the problem of long training time in neural network compression is solved, achieving efficient model compression and accuracy improvement on terminal devices.

CN114565080BActive Publication Date: 2025-11-21GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210192398.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-28
Publication Date
2025-11-21
Estimated Expiration
2042-02-28

AI Technical Summary

Technical Problem

Existing neural network compression methods suffer from high training time overhead and long model processing time, making it difficult to efficiently compress models, especially on terminal devices with limited computing power.

Method used

By configuring the parameters to be executed for the original model, including model pruning parameters and training termination conditions, inserting pseudo-quantization nodes and statistically analyzing quantization parameters, quantization-aware training is performed, and pruning is gradually carried out according to the pruning frequency until the training termination condition is reached.

Benefits of technology

This effectively avoids the additional training overhead required to obtain the pruned kernel index, shortens the pruning and quantization time, reduces the accuracy loss after model pruning, and improves model accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114565080B_ABST
    Figure CN114565080B_ABST
Patent Text Reader

Abstract

The present disclosure specifically relates to the field of computer technology, and specifically relates to a neural network compression method and device, a computer readable medium and a processor. The method comprises: in response to a trigger operation, configuring to be executed parameters for an original model; wherein the to-be-executed parameters comprise model pruning parameters and a training termination condition; inserting a pseudo quantization node into the original model, and counting corresponding quantization parameters; performing quantization-aware training on the original model with the inserted pseudo quantization node based on the quantization parameters; and performing pruning processing on the original model that has undergone n rounds of quantization-aware training according to a pruning frequency in the pruning parameters, until the original model reaches a preset training termination condition; wherein n is a positive integer. The present scheme can shorten the time cost of pruning and quantization, and improve the model accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, specifically to a neural network compression method, a neural network compression device, a computer-readable medium, and a processor. Background Technology

[0002] With the rapid development of artificial intelligence, neural networks have been widely adopted and applied in many fields, such as speech recognition, image recognition, and data analysis. However, as the performance of neural networks improves, the number of parameters and computational load of the models also increases, resulting in neural networks being characterized by high computational and memory consumption. When running neural networks on terminals with limited computing power, it is necessary to compress the neural network models. Existing neural network compression methods suffer from drawbacks such as high training time overhead and long model processing time.

[0003] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0004] This disclosure provides a neural network compression method, a neural network compression device, a computer-readable medium, and a processor that can reduce the time overhead of model training.

[0005] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0006] According to a first aspect of this disclosure, a neural network compression method is provided, comprising:

[0007] In response to a triggering operation, configure the parameters to be executed for the original model; wherein, the parameters to be executed include model pruning parameters and training termination conditions;

[0008] Pseudo-quantization nodes are inserted into the original model, and the corresponding quantization parameters are statistically analyzed.

[0009] Based on the quantization parameters, the original model with inserted pseudo-quantization nodes is subjected to quantization-aware training.

[0010] The original model, which has undergone n rounds of quantization-perception training, is pruned according to the pruning frequency in the pruning parameters until the original model reaches the preset training termination condition; where n is a positive integer.

[0011] According to a second aspect of this disclosure, a neural network compression apparatus is provided, comprising:

[0012] The parameter configuration module is used to configure the parameters to be executed for the original model in response to a trigger operation; wherein, the parameters to be executed include model pruning parameters and training termination conditions;

[0013] The quantization parameter statistics module is used to insert pseudo-quantization nodes into the original model and to count the corresponding quantization parameters.

[0014] The quantization-aware training module is used to perform quantization-aware training on the original model with inserted pseudo-quantization nodes based on the quantization parameters.

[0015] The pruning execution module is used to prune the original model that has undergone n rounds of quantization-aware training according to the pruning frequency in the pruning parameters, until the original model reaches the preset training termination condition; where n is a positive integer.

[0016] According to a third aspect of this disclosure, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the neural network compression method described above.

[0017] According to a fourth aspect of this disclosure, an electronic device is provided, comprising:

[0018] Processor; and

[0019] Memory for storing the executable instructions of the processor;

[0020] The processor is configured to implement the neural network compression method described above by executing the executable instructions.

[0021] One embodiment of the neural network compression method disclosed herein pre-configures corresponding execution parameters for the original model, specifying pruning parameters and training termination conditions within these parameters. This allows the original model to be pruned during quantization-aware training using statistical information stored in quantization nodes and the execution parameters. This effectively avoids the additional training overhead required to obtain the pruning kernel index, thus shortening the time cost of pruning and quantization. Furthermore, by progressively pruning, the accuracy loss after pruning is reduced, improving model accuracy.

[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0023] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0024] Figure 1 The illustration schematically shows a neural network compression method according to an exemplary embodiment of the present disclosure;

[0025] Figure 2 This diagram schematically illustrates a method for configuring parameters to be executed in an exemplary embodiment of the present disclosure;

[0026] Figure 3 The illustration schematically shows a method for quantitative perception training in an exemplary embodiment of the present disclosure;

[0027] Figure 4 The diagram illustrates a pruning method according to an exemplary embodiment of the present disclosure.

[0028] Figure 5 This schematic diagram illustrates the composition of a neural network compression device according to an exemplary embodiment of the present disclosure;

[0029] Figure 6 This schematic diagram illustrates the composition of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0030] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0031] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0032] In related technologies, neural networks, with their excellent data fitting capabilities, have been widely used in fields such as image classification, speech recognition, and data analysis. However, due to the inherent limitations of neural networks, such as high computational load and memory consumption, when deployed on edge devices with limited computing power, it is usually necessary to compress the neural network model through pruning and quantization techniques. However, some technical solutions require separate sparse training and quantization training; or, in other solutions, the model needs to be retrained after each round of pruning and quantization. This results in high training time overhead and makes it difficult to guarantee model accuracy.

[0033] To address the shortcomings and deficiencies of the existing technology described above, this example embodiment provides a neural network compression method. (Reference) Figure 1 As shown, the neural network compression method described above may include:

[0034] Step S11: In response to the triggering operation, configure the parameters to be executed for the original model; wherein, the parameters to be executed include model pruning parameters and training termination conditions;

[0035] Step S12: Insert pseudo-quantization nodes into the original model and count the corresponding quantization parameters;

[0036] Step S13: Perform quantization-aware training on the original model with inserted pseudo-quantization nodes based on the quantization parameters.

[0037] Step S14: Prune the original model that has undergone n rounds of quantization perception training according to the pruning frequency in the pruning parameters until the original model reaches the preset training termination condition; where n is a positive integer.

[0038] The neural network compression method provided in this example implementation pre-configures corresponding execution parameters for the original model, specifying pruning parameters and training termination conditions within these parameters. On one hand, this allows the original model to be pruned during quantization-aware training using statistical information stored in quantization nodes and the execution parameters. This effectively avoids the additional training overhead required to obtain the pruning kernel index, shortening the time cost of pruning and quantization. On the other hand, by performing gradual pruning at a preset pruning frequency, it reduces the accuracy loss after pruning and improves model accuracy.

[0039] The following will describe in more detail the steps of the neural network compression method in this exemplary embodiment, with reference to the accompanying drawings and embodiments.

[0040] Step S11: In response to the triggering operation, configure the parameters to be executed for the original model; wherein, the parameters to be executed include model pruning parameters and training termination conditions;

[0041] In this example embodiment, the instruction processing method described above can be applied to a terminal device. The original model described above can be a convolutional neural network model or a deep neural network model used in applications such as image recognition, image classification, text recognition, or natural language processing.

[0042] In some exemplary embodiments, the above method may further include: pre-training the original model to obtain the original model trained to convergence; wherein the original model is a floating-point model corresponding to the target task.

[0043] For example, taking a deep neural network model for text recognition, the original model can run on the terminal device. Furthermore, the original model can be trained to convergence on the server side using a dataset. For example, the original model could be an FP32 model. After the original model is trained to convergence on the server side, it can be distributed to the terminal device for real-time text recognition of speech data. On the terminal device side, the original model can be compressed. The terminal device can be a smartphone, tablet, or other smart terminal device.

[0044] In this example implementation, refer to Figure 2 The above step S11 may include:

[0045] Step S111: In response to the triggering operation, create a parameter configuration task for the original model;

[0046] Step S112: Execute the parameter configuration task to obtain the basic information corresponding to the original model; wherein, the basic information includes any one or more of the following: application scenario, task type, available computing power, and accuracy lower limit;

[0047] Step S113: Configure the parameters to be executed for the original model based on the basic information.

[0048] For example, after receiving the trained raw model from the server, the terminal device can trigger a parameter configuration task for the raw model. For instance, a parameter configuration form can be pre-loaded onto the terminal device. This form can include basic information categories such as application scenario, terminal device type, task type, computing power, and accuracy requirements, as well as the execution parameters configured based on these basic information categories. The task type can refer to a real-time task or an offline task. The execution parameters include model pruning parameters and training termination conditions. Model pruning parameters can include any one or more of the following: pruning ratio, quantization bits, inference latency, and model size. Different pruning ratios, pruning frequencies, and inference latency parameters can be configured under different terminal devices, different model application scenarios, and different terminal computing power conditions. For example, different pruning ratios can be configured in text recognition and image recognition application scenarios. Or, different model sizes and pruning frequencies can be configured under different terminal computing power conditions; and so on. For example, for real-time tasks deployed on mobile phones, the quantization bit count can be configured to be 8, the inference latency to be 10-20ms, and the model size to be 3-5MB.

[0049] Once the parameters to be executed are determined, the terminal can perform quantitative perceptual training on the original model based on these parameters.

[0050] In step S12, pseudo-quantization nodes are inserted into the original model, and the corresponding quantization parameters are statistically analyzed.

[0051] In this example implementation, a per-channel quantization algorithm can be used to embed pseudo-quantized nodes in each convolutional layer of the original model's convolutional network structure, and to statistically analyze the parameters required for quantization. Specifically, the statistically analyzed quantization parameters can include the min_val and max_val corresponding to various parameters counted on a kernel-by-kernel basis, as well as the min_val and max_val of the feature map as a whole. For example, this could include the maximum and minimum values ​​of the convolutional kernels of each convolutional layer in the neural network; the maximum and minimum values ​​in the feature map, and so on.

[0052] In step S13, the original model with inserted pseudo-quantized nodes is subjected to quantization-aware training based on the quantization parameters.

[0053] In this example implementation, refer to Figure 3 As shown, step S13 above may include:

[0054] Step S131: Perform pseudo-quantization calculation using statistical quantization parameters to achieve forward propagation of the original model;

[0055] Step S132: Calculate the loss based on the preset loss function of the original model, and update the model parameters of the original model according to the loss.

[0056] Specifically, after statistically quantizing the parameters, the original model can be trained using quantization awareness. During the forward propagation process, pseudo-quantization is performed using the statistical minimum and maximum values, the loss is calculated based on the loss function, and the model parameters are updated via backpropagation.

[0057] In step S14, the original model that has undergone n rounds of quantization perception training is pruned according to the pruning frequency in the pruning parameters until the original model reaches the preset training termination condition; where n is a positive integer.

[0058] In this example implementation, refer to Figure 4 As shown, step S14 above may include:

[0059] Step S141: When completing the nth round of quantization perception training, calculate the reference values ​​of each quantization parameter for the current original model; wherein, the reference values ​​of the quantization parameters are determined based on the maximum and minimum values ​​of the quantization parameters.

[0060] Step S142: Sort the quantization parameters based on the reference value, and prune the quantization parameters with the smallest reference value according to a preset pruning ratio.

[0061] Specifically, based on the pruning frequency configured in the parameters to be executed, after completing n rounds of training, the reference value for each kernel can be calculated using the following formula:

[0062] s = 2max_val - min_val

[0063] Where max_val represents the maximum value and min_val represents the minimum value.

[0064] After calculation, this reference value can be used to represent the importance of the parameters. Based on the configured pruning ratio, the current original model is pruned, removing kernels with smaller calculation results. It is then determined whether the preset termination condition has been met. If not, this step is repeated to prune again until the preset termination condition is reached, and the quantized trained model is output.

[0065] The neural network compression method provided in this disclosure pre-configures the parameters to be executed and prunes the model using statistical information stored in the quantization nodes during the perceptual quantization process. This avoids the additional training overhead required to obtain the pruning kernel index, thus shortening the time cost of pruning and quantization. Furthermore, by controlling the pruning frequency, the model is gradually pruned during quantization training, removing a fixed proportion of parameters each time, reducing the accuracy loss after pruning and improving the accuracy of pruning quantization. This solution shortens the time cycle for deploying intelligent algorithms on the edge and, to a certain extent, ensures the accuracy of the model after pruning and quantization.

[0066] It should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may, for example, be executed synchronously or asynchronously in multiple modules.

[0067] Further reference Figure 5 As shown, this example embodiment also provides a neural network compression device 50, including: a parameter configuration module 501, a quantization parameter statistics module 502, a quantization perception training module 503, and a pruning execution module 504. Wherein,

[0068] The parameter configuration module 501 can be used to configure parameters to be executed for the original model in response to a trigger operation; wherein, the parameters to be executed include model pruning parameters and training termination conditions.

[0069] The quantization parameter statistics module 502 can be used to insert pseudo-quantization nodes into the original model and count the corresponding quantization parameters.

[0070] The quantization-aware training module 503 can be used to perform quantization-aware training on the original model with inserted pseudo-quantization nodes based on the quantization parameters.

[0071] The pruning execution module 504 can be used to prune the original model that has undergone n rounds of quantization perception training according to the pruning frequency in the pruning parameters, until the original model reaches the preset training termination condition; where n is a positive integer.

[0072] In some exemplary embodiments, the apparatus further includes a model pre-training module.

[0073] The model pre-training module can be used to pre-train the original model to obtain the original model trained to convergence; wherein, the original model is a floating-point model corresponding to the target task.

[0074] In some exemplary embodiments, the parameter configuration module 501 to be executed may include: creating a parameter configuration task for the original model in response to a trigger operation; executing the parameter configuration task to obtain basic information corresponding to the original model; wherein, the basic information includes any one or more of the following: application scenario, task type, available computing power, and accuracy lower limit; and configuring the parameters to be executed for the original model based on the basic information.

[0075] In some exemplary embodiments, the model pruning parameters include any one or more of the following: pruning ratio, number of quantization bits, inference latency, and model size.

[0076] In some exemplary embodiments, the quantization parameters statistically include: the maximum and minimum values ​​of the target parameters in kernel units, and the maximum and minimum values ​​of the feature map.

[0077] In some exemplary embodiments, the quantization-aware training module 503 may include: performing pseudo-quantization operations using statistical quantization parameters to achieve forward propagation of the original model; calculating loss based on a preset loss function of the original model; and updating the model parameters of the original model according to the loss.

[0078] In some exemplary embodiments, the pruning execution module 504 may include, upon completing the nth round of quantization-aware training, calculating reference values ​​for each quantization parameter of the current original model; wherein the reference values ​​of the quantization parameters are determined based on the maximum and minimum values ​​of the quantization parameters; sorting the quantization parameters based on the reference values; and pruning the quantization parameters with the smallest reference values ​​according to a preset pruning ratio.

[0079] The specific details of each module in the aforementioned neural network compression device 50 have been described in detail in the corresponding neural network compression method, so they will not be repeated here.

[0080] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0081] Figure 6 A schematic diagram of an electronic device suitable for implementing embodiments of the present invention is shown.

[0082] It should be noted that, Figure 6The illustrated electronic device 1000 is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.

[0083] like Figure 6 As shown, the electronic device 1000 includes a Central Processing Unit (CPU) 1001, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 1002 or programs loaded from Storage Unit 1008 into Random Access Memory (RAM) 1003. The RAM 1003 also stores various programs and data required for system operation. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An Input / Output (I / O) interface 1005 is also connected to the bus 1004.

[0084] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to I / O interface 1005 as needed. Removable media 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1010 as needed so that computer programs read from them can be installed into storage section 1008 as needed.

[0085] In particular, according to embodiments of the present invention, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1009, and / or installed from removable medium 1011. When the computer program is executed by central processing unit (CPU) 1001, it performs various functions defined in the system of this application.

[0086] Specifically, the aforementioned electronic devices can be smart mobile terminal devices such as mobile phones, tablets, or laptops. Alternatively, the aforementioned electronic devices can also be smart terminal devices such as desktop computers.

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

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

[0089] The units described in the embodiments of the present invention can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0090] It should be noted that, as another aspect, this application also provides a computer-readable medium, which may be included in an electronic device or may exist independently without being assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by an electronic device, cause the electronic device to perform the methods described in the following embodiments. For example, the electronic device may perform... Figure 1 The steps shown.

[0091] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0092] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0093] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A neural network compression method, characterized in that, The method includes: In response to a triggering operation, the original model is configured with parameters to be executed; wherein, the parameters to be executed include model pruning parameters and training termination conditions; the original model is used for image recognition, image classification, text recognition, or a convolutional neural network model or a deep neural network model in natural language processing application scenarios; Pseudo-quantization nodes are inserted into the original model, and the corresponding quantization parameters are statistically analyzed. The statistically analyzed quantization parameters include the maximum and minimum values ​​of the target parameters in kernel units, and the maximum and minimum values ​​of the feature maps. Based on the quantization parameters, the original model with inserted pseudo-quantization nodes is subjected to quantization-aware training; the original model that has undergone n rounds of quantization-aware training is pruned according to the pruning frequency in the pruning parameters until the original model reaches the preset training termination condition; where n is a positive integer; the pruning of the original model that has undergone n rounds of quantization-aware training according to the pruning frequency in the pruning parameters includes: when completing the nth round of quantization-aware training, calculating reference values ​​for each quantization parameter of the current original model; where the reference values ​​of the quantization parameters are determined based on the maximum and minimum values ​​of the quantization parameters; sorting the quantization parameters based on the reference values, and pruning the quantization parameter with the smallest reference value according to a preset pruning ratio; the configuration of the parameters to be executed for the original model in response to the trigger operation includes: In response to the triggering operation, a parameter configuration task is created for the original model; Execute the parameter configuration task to obtain the basic information corresponding to the original model; wherein, the basic information includes any one or more of the following: application scenario, task type, available computing power, and accuracy lower limit; Configure the parameters to be executed for the original model based on the basic information.

2. The neural network compression method according to claim 1, characterized in that, The method further includes: The original model is pre-trained to obtain a converged original model; wherein the original model is a floating-point model corresponding to the target task.

3. The neural network compression method according to claim 1, characterized in that, The model pruning parameters include any one or more of the following: pruning ratio, number of quantization bits, inference latency, and model size.

4. The neural network compression method according to claim 1, characterized in that, The step of performing quantization-aware training on the original model with inserted pseudo-quantization nodes based on the quantization parameters includes: Pseudo-quantization is performed using statistical quantization parameters to achieve forward propagation of the original model; The loss is calculated based on the preset loss function of the original model, and the model parameters of the original model are updated according to the loss.

5. A neural network compression device, characterized in that, The device includes: The parameter configuration module is used to configure the parameters to be executed for the original model in response to the trigger operation; wherein, the parameters to be executed include model pruning parameters and training termination conditions; the original model is a convolutional neural network model or a deep neural network model in image recognition, image classification, text recognition, or natural language processing application scenarios. The quantization parameter statistics module is used to insert pseudo-quantization nodes into the original model and count the corresponding quantization parameters; wherein, the counted quantization parameters include: the maximum and minimum values ​​of the target parameters in kernel units, and the maximum and minimum values ​​of the feature maps; The quantization-aware training module is used to perform quantization-aware training on the original model with inserted pseudo-quantization nodes based on the quantization parameters. A pruning execution module is used to prune the original model that has undergone n rounds of quantization-aware training according to the pruning frequency in the pruning parameters, until the original model reaches the preset training termination condition; where n is a positive integer; the pruning of the original model that has undergone n rounds of quantization-aware training according to the pruning frequency in the pruning parameters is configured as follows: when completing the nth round of quantization-aware training, a reference value for each quantization parameter is calculated for the current original model; wherein the reference value of the quantization parameter is determined based on the maximum and minimum values ​​of the quantization parameter; the quantization parameters are sorted based on the reference value, and the quantization parameter with the smallest reference value is selected for pruning according to a preset pruning ratio; The response to the triggering operation is configured as follows: The parameters to be executed for the original model configuration are set as follows: In response to the triggering operation, a parameter configuration task is created for the original model; Execute the parameter configuration task to obtain the basic information corresponding to the original model; wherein, the basic information includes any one or more of the following: application scenario, task type, available computing power, and accuracy lower limit; Configure the parameters to be executed for the original model based on the basic information.

6. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the neural network compression method as described in any one of claims 1 to 4.

7. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the neural network compression method of any one of claims 1 to 4 by executing the executable instructions.

Citation Information

Patent Citations

  • Neural network model compression method and device

    CN111582471A

  • Quantitative perception training method and device of neural network, and electronic equipment

    CN113762061A