Pruning and quantization training-based autonomous driving model compression method and device
Patent Information
- Application Number
- CN202211574926.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2042-12-08
AI Technical Summary
[0003]本发明提供一种基于剪枝和量化训练的自动驾驶模型压缩方法及装置,用以解决相关技术中使用先模型剪枝再模型量化的方法进行模型压缩时,剪枝后模型不适合做量化处理,量化精度损失严重,整个模型压缩效果不佳,对硬件的存储空间、计算资源要求高,模型的推理时间长,不满足自动驾驶实时控制需求的缺陷
[0040]本发明提供的一种基于剪枝和量化训练的自动驾驶模型压缩方法及装置,通过根据量化损失筛选出待剪枝自动驾驶预训练网络模型中的待剪枝项;根据待剪枝项计算当前模型剪枝率;在当前模型剪枝率达到预设剪枝目标时,按照筛选出的待剪枝项对待剪枝自动驾驶预训练网络模型进行剪枝;对剪枝后模型进行微调操作,输出自动驾驶压缩模型,根据量化损失筛选出待剪枝项可以在剪枝时考虑对量化操作带来的影响,因此剪枝后的模型对量化更友好,减少量化时的精度损失,提升模型压缩效果,满足部署耗时需求,并且,减小硬件的存储空间,不需要昂贵的计算资源,降低模型推理时间,满足自动驾驶实时控制需求。
Smart Images

Figure CN116126815B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of autonomous driving technology, and in particular to an autonomous driving model compression method and apparatus based on pruning and quantization training. Background Technology
[0002] With the rapid development of autonomous driving technology and deep learning, autonomous driving models are becoming increasingly complex, resulting in more and more model parameters and models with greater complexity. Complex models place higher demands on storage space and computing resources, and also increase inference time. In autonomous driving scenarios, real-time analysis of acquired data through models and control driving based on the analysis results is crucial. Model compression technology can improve inference speed and reduce the number of model parameters and computational load, thus it is widely used in the field of autonomous driving model computation acceleration. Traditional compression methods include model quantization and model pruning, but neither pruning nor quantization achieves ideal compression results, and model deployment is time-consuming. In related technologies, a method of pruning followed by quantization is used for model compression. However, the parameter ranges of each layer in the pruned model change, with some layers having large variances in weight parameters and many outliers. Since the input condition for quantization models is small variance in weight parameters, the pruned model is unsuitable for quantization, resulting in significant loss of quantization accuracy, poor overall model compression performance, high demands on hardware storage space and computing resources, and long inference time, failing to meet the real-time control requirements of autonomous driving. Summary of the Invention
[0003] This invention provides a method and apparatus for compressing autonomous driving models based on pruning and quantization training. It addresses the shortcomings of related technologies that use the method of pruning the model first and then quantizing it for model compression. These shortcomings include the fact that the pruned model is not suitable for quantization, resulting in a serious loss of quantization accuracy, poor overall model compression effect, high requirements for hardware storage space and computing resources, long model inference time, and failure to meet the real-time control requirements of autonomous driving.
[0004] This invention provides a method for compressing autonomous driving models based on pruning and quantization training, comprising:
[0005] The terms to be pruned in the pre-trained network model of autonomous driving to be pruned are selected based on the quantized loss.
[0006] Calculate the current model pruning rate based on the items to be pruned;
[0007] When the current model pruning rate reaches the preset pruning target, the autonomous driving pre-trained network model to be pruned is pruned according to the selected items to be pruned.
[0008] Fine-tune the pruned model to output a compressed autonomous driving model.
[0009] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the quantization loss calculation method includes:
[0010] Simulated pruning is performed on the i-th channel of the j-th layer in the pre-trained network model of the autonomous driving system to be pruned.
[0011] The simulated pruning model is obtained by quantizing the j-th layer of the simulated pruning model.
[0012] Calculate the first accuracy of the pre-trained network model for autonomous driving to be pruned based on the test set, and calculate the second accuracy of the simulated pruning model based on the test set.
[0013] The difference between the first accuracy and the second accuracy is used as the quantization loss.
[0014] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the specific method of quantization includes:
[0015] Convert floating-point data in the model feature data to integer data.
[0016] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the step of filtering out the items to be pruned in the autonomous driving pre-trained network model based on the quantization loss includes:
[0017] When the current model pruning rate is less than the preset pruning target, the quantization loss of each channel in each layer of the autonomous driving pre-trained network model to be pruned is analyzed in sequence, the obtained quantization losses are sorted, and a certain channel of a certain layer corresponding to the minimum value is taken as the item to be pruned.
[0018] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the step of pruning the pre-trained network model of the autonomous driving system to be pruned according to the selected items to be pruned includes:
[0019] Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0020] The backpropagation gradient of the weight parameters is gradually approximated to 0 based on the penalty term.
[0021] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the fine-tuning operation of the pruned model includes:
[0022] Within the preset number of model training iterations, the fine-tuning loss function of the model based on the output results of the training set and the actual results is calculated at each training iteration;
[0023] The backpropagation gradient of the weight parameters of each layer of the model is calculated based on the fine-tuned loss function.
[0024] Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0025] Update the weight parameters of each layer so that the backpropagation gradient of the weight parameters of the item to be pruned gradually approaches 0.
[0026] According to the autonomous driving model compression method based on pruning and quantization training provided by the present invention, the pruning rate of the current model is the percentage decrease in the number of floating-point operations of the current model.
[0027] The present invention also provides an image recognition method in an autonomous driving scenario, comprising:
[0028] Acquire the image to be identified;
[0029] The image to be identified is input into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described above.
[0030] The present invention also provides an autonomous driving model compression device based on pruning and quantization training, comprising:
[0031] The filtering module is used to filter out items to be pruned in the pre-trained network model of autonomous driving based on the quantization loss.
[0032] The calculation module is used to calculate the current model pruning rate based on the items to be pruned;
[0033] The pruning module is used to prune the pre-trained autonomous driving network model to be pruned according to the selected items to be pruned when the current model pruning rate reaches the preset pruning target.
[0034] The fine-tuning module is used to fine-tune the pruned model and output a compressed autonomous driving model.
[0035] The present invention also provides an image recognition device for autonomous driving scenarios, comprising:
[0036] The acquisition module is used to acquire the image to be recognized;
[0037] The recognition module is used to input the image to be recognized into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described above.
[0038] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the autonomous driving model compression method based on pruning and quantization training as described above, and / or, the image recognition method in an autonomous driving scenario as described in claim 8.
[0039] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the autonomous driving model compression method based on pruning and quantization training as described in any of the preceding claims, and / or the image recognition method in an autonomous driving scenario as described in claim 8.
[0040] This invention provides a method and apparatus for compressing autonomous driving models based on pruning and quantization training. The method involves: selecting items to be pruned from a pre-trained autonomous driving network model based on quantization loss; calculating the current model pruning rate based on these items; pruning the pre-trained autonomous driving network model according to the selected items when the current pruning rate reaches a preset pruning target; fine-tuning the pruned model to output a compressed autonomous driving model. Selecting items to be pruned based on quantization loss allows consideration of the impact on quantization operations during pruning, resulting in a more quantization-friendly model, reducing accuracy loss during quantization, improving model compression, meeting deployment time requirements, reducing hardware storage space, eliminating the need for expensive computing resources, and lowering model inference time to meet real-time control requirements for autonomous driving. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is one of the flowcharts of the autonomous driving model compression method based on pruning and quantization training provided by the present invention;
[0043] Figure 2 This is the second flowchart of the autonomous driving model compression method based on pruning and quantization training provided by the present invention;
[0044] Figure 3 This is the third flowchart of the autonomous driving model compression method based on pruning and quantization training provided by the present invention;
[0045] Figure 4This is the fourth flowchart of the autonomous driving model compression method based on pruning and quantization training provided by the present invention;
[0046] Figure 5 This is a schematic diagram of the structure of the autonomous driving model compression device based on pruning and quantization training provided by the present invention;
[0047] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0049] Figure 1 A flowchart of the autonomous driving model compression method based on pruning and quantization training provided in the embodiments of the present invention is shown below. Figure 1 As shown, the autonomous driving model compression method based on pruning and quantization training provided in this embodiment of the invention includes:
[0050] Step 101: Select the items to be pruned in the pre-trained network model of autonomous driving based on the quantization loss;
[0051] In this embodiment of the invention, the autonomous driving pre-trained network model is a model trained based on training data; for example, the autonomous driving pre-trained network model is a vehicle classification model, and inputting the training data into the autonomous driving pre-trained vehicle classification network model can obtain vehicle classification results. It should be noted that this invention does not limit the specific function of the autonomous driving pre-trained network model, and those skilled in the art can select one according to actual needs.
[0052] In this embodiment of the invention, during pruning, if the variance of the weight parameter of the item to be pruned (the channel to be pruned) is small, it indicates that it is suitable for quantization, so the layer should not be pruned as much as possible, and channels in layers with larger variance of weight parameters should be pruned.
[0053] By pre-screening the items to be pruned, channels suitable for pruning can be avoided from being deleted, thus making the pruned model suitable for quantization and reducing quantization loss.
[0054] Step 102: Calculate the current pruning rate of the model based on the items to be pruned;
[0055] In this embodiment of the invention, the current model pruning rate is the percentage decrease in the number of floating-point operations (FLOPs) of the current model. The number of floating-point operations (FLOPs) of the current model can be used to measure the complexity of the algorithm / model.
[0056] Step 103: When the current model pruning rate reaches the preset pruning target, prune the pre-trained network model of the autonomous driving system to be pruned according to the selected items to be pruned.
[0057] In this embodiment of the invention, the preset pruning target is the percentage decrease threshold of the floating-point operations of the current model, such as 50% or 70%. It should be noted that this application does not limit the specific value of the pruning target, and those skilled in the art can set it according to actual needs.
[0058] Step 104: Fine-tune the pruned model and output the autonomous driving compressed model.
[0059] By pruning channels that are not suitable for quantization, the number of parameters and computational load of autonomous driving models can be reduced. The output compressed autonomous driving model can reduce hardware storage space, does not require expensive computing resources, has a short model inference time, and meets the real-time control requirements of autonomous driving.
[0060] Traditional compression methods include model quantization and model pruning. However, neither pruning nor quantization yields ideal compression results, and model deployment is time-consuming. In related technologies, a method of pruning followed by quantization is used for model compression. Because the parameter ranges of each layer in the pruned model change, some layers have large variances in their weight parameters and numerous outliers. Since the input condition for quantization is small variance in weight parameters, the pruned model becomes unsuitable for quantization, resulting in significant loss of quantization accuracy and poor overall model compression performance, failing to meet user needs.
[0061] This invention provides a method for compressing autonomous driving models based on pruning and quantization training. The method involves: selecting items to be pruned from the pre-trained autonomous driving network model based on quantization loss; calculating the current model pruning rate based on these items; pruning the pre-trained autonomous driving network model according to the selected items when the current pruning rate reaches a preset pruning target; fine-tuning the pruned model to output a compressed autonomous driving model. Selecting items to be pruned based on quantization loss takes into account the impact on quantization operations during pruning, resulting in a more quantization-friendly model, reducing accuracy loss during quantization, improving model compression performance, meeting deployment time requirements, reducing hardware storage space, eliminating the need for expensive computing resources, and lowering model inference time to meet the real-time control requirements of autonomous driving.
[0062] Based on any of the above embodiments, such as Figure 2 As shown, the quantization loss calculation method includes:
[0063] Step 201: Simulate pruning for the i-th channel of the j-th layer in the pre-trained autonomous driving network model to be pruned;
[0064] Step 202: Quantize the j-th layer of the simulated pruning model to obtain the simulated pruning model;
[0065] Quantization refers to the process of approximating the continuous values of a signal to a finite number of discrete values. It is a method of information compression. Quantization can reduce the number of bits used to store weights, allowing them to be stored in a smaller space. Weights do not need to be stored in a high-precision manner, and should not even be stored in a high-precision manner. In this embodiment of the invention, the specific method of quantization includes:
[0066] Convert floating-point data in the model feature data to integer data.
[0067] Step 203: Calculate the first accuracy of the test results output by the pre-trained network model of the autonomous driving system to be pruned based on the test set, and the second accuracy of the test results output by the simulated pruning model based on the test set. Use the difference between the first accuracy and the second accuracy as the quantization loss.
[0068] Based on any of the above embodiments, the items to be pruned in the pre-trained autonomous driving network model are selected according to the quantization loss, including:
[0069] When the current model pruning rate is less than the preset pruning target, the quantization loss of each channel in each layer of the autonomous driving pre-trained network model to be pruned is analyzed in turn. The obtained quantization losses are sorted, and a certain channel of a certain layer corresponding to the minimum value is taken as the item to be pruned.
[0070] In some embodiments of the present invention, the items to be pruned selected each time are stored and collected into the overall pruning configuration items.
[0071] Calculate the current model pruning rate based on the existing items to be pruned in the overall pruning configuration;
[0072] If the current model pruning rate does not reach the preset pruning target, the items to be pruned in the model need to be re-selected and stored in the overall pruning configuration items until the current model pruning rate reaches the preset pruning target.
[0073] Based on any of the above embodiments, such as Figure 3 As shown, the pre-trained network model for autonomous driving to be pruned is pruned according to the selected items to be pruned, including:
[0074] Step 301: Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0075] In this embodiment of the invention, the penalty term formula is: w represents the weight of the item to be pruned.
[0076] Step 302: Gradually approach 0 with the backpropagation gradient of the weight parameters according to the penalty term.
[0077] When the backpropagation gradient of the weight parameter of a channel is 0, the pruning of that channel is considered complete.
[0078] In this embodiment of the invention, by pruning the model, the deployment speed of the pruned model can be improved, thus meeting user needs.
[0079] Based on any of the above embodiments, such as Figure 4 As shown, fine-tuning operations are performed on the pruned model, including:
[0080] Step 401: Within the preset number of model training iterations, calculate the fine-tuning loss function of the model based on the output results of the training set and the actual results during each training iteration;
[0081] Step 402: Calculate the backpropagation gradient of the weight parameters of each layer of the model based on the fine-tuning loss function;
[0082] Step 403: Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0083] Step 404: Update the weight parameters of each layer so that the backpropagation gradient of the weight parameters of the item to be pruned gradually approaches 0.
[0084] In this embodiment of the invention, the model compression effect can be further improved by fine-tuning the pruned model.
[0085] The autonomous driving model compression method based on pruning and quantization training provided in this invention takes into account the impact on quantization operations during pruning. Therefore, the pruned model is more quantization-friendly, reduces the accuracy loss during quantization, and reduces the time required for model deployment.
[0086] The present invention also provides an image recognition method in an autonomous driving scenario, comprising:
[0087] Acquire the image to be identified;
[0088] The image to be identified is input into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described above.
[0089] This invention provides an image recognition method for autonomous driving scenarios. The method involves acquiring an image to be recognized, inputting the image into an autonomous driving compression model, and obtaining the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described in the above embodiments, which can improve recognition efficiency.
[0090] The autonomous driving model compression device based on pruning and quantization training provided by the present invention will be described below. The autonomous driving model compression device based on pruning and quantization training described below can be referred to in correspondence with the autonomous driving model compression method based on pruning and quantization training described above.
[0091] Figure 5 This is a schematic diagram of an autonomous driving model compression device based on pruning and quantization training provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the autonomous driving model compression device based on pruning and quantization training provided in this embodiment of the invention includes:
[0092] The filtering module 501 is used to filter out the items to be pruned in the pre-trained network model of autonomous driving based on the quantization loss.
[0093] Calculation module 502 is used to calculate the current model pruning rate based on the items to be pruned;
[0094] The pruning module 503 is used to prune the pre-trained autonomous driving network model to be pruned according to the selected items to be pruned when the current model pruning rate reaches the preset pruning target.
[0095] The fine-tuning module 504 is used to fine-tune the pruned model and output the autonomous driving compressed model.
[0096] This invention provides an autonomous driving model compression device based on pruning and quantization training. The device filters out items to be pruned from the pre-trained autonomous driving network model based on quantization loss; calculates the current model pruning rate based on these items; when the current model pruning rate reaches a preset pruning target, it prunes the pre-trained autonomous driving network model according to the filtered items; fine-tunes the pruned model, and outputs a compressed autonomous driving model. Filtering out items to be pruned based on quantization loss allows consideration of the impact on quantization operations during pruning, resulting in a more quantization-friendly model, reducing accuracy loss during quantization, improving model compression performance, and meeting deployment time requirements.
[0097] In this embodiment of the invention, the filtering module 501 is configured as follows:
[0098] When the current model pruning rate is less than the preset pruning target, the quantization loss of each channel in each layer of the autonomous driving pre-trained network model to be pruned is analyzed in turn. The obtained quantization losses are sorted, and a certain channel of a certain layer corresponding to the minimum value is taken as the item to be pruned.
[0099] Furthermore, the specific methods for calculating quantified loss include:
[0100] Simulate pruning of the i-th channel in the j-th layer of the pre-trained network model for autonomous driving to be pruned;
[0101] The simulated pruning model is obtained by quantizing the j-th layer of the simulated pruning model.
[0102] The first accuracy of the pre-trained network model for autonomous driving to be pruned, based on the test set, is calculated, and the second accuracy of the simulated pruning model, based on the test set, is output.
[0103] The difference between the first and second accuracy rates is used as the quantization loss.
[0104] Furthermore, the specific quantification methods in the screening module 501 include:
[0105] Convert floating-point data in the model feature data to integer data.
[0106] In this embodiment of the invention, the calculation module 502 is configured as follows:
[0107] The current model pruning rate is the percentage decrease in the number of floating-point operations in the current model.
[0108] In this embodiment of the invention, the pruning module 503 is configured as follows:
[0109] Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0110] The backpropagation gradient of the weight parameters is gradually approximated to 0 based on the penalty term.
[0111] In this embodiment of the invention, the fine-tuning module 504 is configured as follows:
[0112] Within the preset number of model training iterations, the fine-tuning loss function of the model based on the output results of the training set and the actual results is calculated at each training iteration;
[0113] The backpropagation gradient of the weight parameters of each layer of the model is calculated based on the fine-tuned loss function.
[0114] Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned;
[0115] Update the weight parameters of each layer so that the backpropagation gradient of the weight parameters of the item to be pruned gradually approaches 0.
[0116] The present invention provides an autonomous driving model compression device based on pruning and quantization training. The pruning process takes into account the impact on quantization operations, so the pruned model is more quantization-friendly, reduces the accuracy loss during quantization, and reduces the time required for model deployment.
[0117] The present invention also provides an image recognition device for autonomous driving scenarios, comprising:
[0118] The acquisition module is used to acquire the image to be recognized;
[0119] The recognition module is used to input the image to be recognized into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described in the above embodiments.
[0120] The present invention provides an image recognition device for autonomous driving scenarios, which acquires an image to be recognized; inputs the image to be recognized into an autonomous driving compression model to obtain an image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training described in the above embodiments, which can improve recognition efficiency.
[0121] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute an autonomous driving model compression method based on pruning and quantization training. This method includes: selecting items to be pruned in the autonomous driving pre-trained network model based on quantization loss; calculating the current model pruning rate based on the items to be pruned; pruning the autonomous driving pre-trained network model according to the selected items to be pruned when the current model pruning rate reaches a preset pruning target; fine-tuning the pruned model and outputting an autonomous driving compressed model; and executing an image recognition method in an autonomous driving scenario, which includes: acquiring an image to be recognized; inputting the image to be recognized into the autonomous driving compressed model to obtain an image recognition result, wherein the autonomous driving compressed model is obtained according to the autonomous driving model compression method based on pruning and quantization training described above.
[0122] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0123] On the other hand, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program is implemented to perform the autonomous driving model compression method based on pruning and quantization training provided by the above methods. The method includes: selecting items to be pruned in the autonomous driving pre-trained network model based on quantization loss; calculating the current model pruning rate based on the items to be pruned; pruning the autonomous driving pre-trained network model according to the selected items to be pruned when the current model pruning rate reaches a preset pruning target; fine-tuning the pruned model and outputting an autonomous driving compressed model; and executing an image recognition method in an autonomous driving scenario. The method includes: acquiring an image to be recognized; inputting the image to be recognized into the autonomous driving compressed model to obtain an image recognition result. The autonomous driving compressed model is obtained according to the autonomous driving model compression method based on pruning and quantization training described in any one of the above methods.
[0124] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0125] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for compressing autonomous driving models based on pruning and quantization training, characterized in that, include: The terms to be pruned in the pre-trained network model of autonomous driving to be pruned are selected based on the quantized loss. Calculate the current model pruning rate based on the items to be pruned; When the current model pruning rate reaches the preset pruning target, the autonomous driving pre-trained network model to be pruned is pruned according to the selected items to be pruned. Fine-tune the pruned model to output a compressed autonomous driving model. The quantization loss calculation method includes: Simulated pruning is performed on the i-th channel of the j-th layer in the pre-trained network model of the autonomous driving system to be pruned. The simulated pruning model is obtained by quantizing the j-th layer of the simulated pruning model. Calculate the first accuracy of the pre-trained network model for autonomous driving to be pruned, based on the test results output by the test set, and the second accuracy of the simulated pruning model, based on the test results output by the test set. The difference between the first accuracy and the second accuracy is used as the quantization loss; Acquire the image to be identified; The image to be identified is input into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained according to the autonomous driving model compression method based on pruning and quantization training.
2. The autonomous driving model compression method based on pruning and quantization training according to claim 1, characterized in that, The specific methods of quantification include: Convert floating-point data in the model feature data to integer data.
3. The autonomous driving model compression method based on pruning and quantization training according to claim 2, characterized in that, The step of selecting the items to be pruned in the pre-trained autonomous driving network model based on quantization loss includes: When the current model pruning rate is less than the preset pruning target, the quantization loss of each channel in each layer of the autonomous driving pre-trained network model to be pruned is analyzed in sequence. The obtained quantization losses are sorted, and the channel of a certain layer corresponding to the minimum value is selected as the item to be pruned.
4. The autonomous driving model compression method based on pruning and quantization training according to claim 1, characterized in that, The step of pruning the pre-trained autonomous driving network model according to the selected items to be pruned includes: Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned; The backpropagation gradient of the weight parameters is gradually approximated to 0 based on the penalty term.
5. The autonomous driving model compression method based on pruning and quantization training according to claim 4, characterized in that, The fine-tuning operation of the pruned model includes: Within the preset number of model training iterations, the fine-tuning loss function of the model based on the output results of the training set and the actual results is calculated at each training iteration; The backpropagation gradient of the weight parameters of each layer of the model is calculated based on the fine-tuned loss function. Add a penalty term to the backpropagation gradient of the weight parameters of the item to be pruned; Update the weight parameters of each layer so that the backpropagation gradient of the weight parameters of the item to be pruned gradually approaches 0.
6. The autonomous driving model compression method based on pruning and quantization training according to claim 1, characterized in that, The current model pruning rate is the percentage decrease in the number of floating-point operations of the current model.
7. An autonomous driving model compression device based on pruning and quantization training, characterized in that, include: The filtering module is used to filter out items to be pruned in the pre-trained network model of autonomous driving based on the quantization loss. The quantization loss calculation method includes: performing simulated pruning on the i-th channel of the j-th layer in the pre-trained autonomous driving network model to be pruned; quantizing the j-th layer of the simulated pruning model to obtain a simulated pruning model; calculating a first accuracy rate of the pre-trained autonomous driving network model to be pruned based on the test set, and a second accuracy rate of the simulated pruning model based on the test set; and using the difference between the first accuracy rate and the second accuracy rate as the quantization loss. The calculation module is used to calculate the current model pruning rate based on the items to be pruned; The pruning module is used to prune the pre-trained autonomous driving network model to be pruned according to the selected items to be pruned when the current model pruning rate reaches the preset pruning target. The fine-tuning module is used to fine-tune the pruned model and output an autonomous driving compressed model. The acquisition module is used to acquire the image to be recognized; The recognition module is used to input the image to be recognized into the autonomous driving compression model to obtain the image recognition result. The autonomous driving compression model is obtained by the autonomous driving model compression method based on pruning and quantization training according to any one of claims 1 to 6.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the autonomous driving model compression method based on pruning and quantization training as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the autonomous driving model compression method based on pruning and quantization training as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Convolutional neural network compression method based on pre-quantization and scaling coefficient pruning
CN113570055A
Classification network, and method and apparatus for implementing same
WO2022160856A1