Model processing method, electronic equipment, storage medium and computer program product
By optimizing the pruning and quantization of the neural network model layer by layer, and combining the target parameters and real-time performance parameters of neurons, the problem of performance degradation during model optimization is solved, and the computational accuracy and efficiency of the model are improved.
Patent Information
- Application Number
- CN202511553149.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-02-24
AI Technical Summary
In existing technologies, when optimizing neural network models, the model's performance drops significantly, affecting normal use.
By combining the target parameters, real-time performance parameters, and optimization parameters of each neuron in the neural network model, the model is pruned and quantized using a layer-by-layer optimization approach to determine the target neural network model.
The optimization process considers the model's real-time performance and the importance of neurons, avoiding a significant drop in performance and improving the model's computational accuracy and efficiency.
Smart Images

Figure CN121562701A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of model processing technology, and in particular to a model processing method, device, storage medium and computer program product. Background Technology
[0002] With the development of technology, neural network models have been widely used in mobile terminals (such as mobile phones) to achieve operations such as gesture recognition. However, the computing power, memory capacity, and battery capacity of mobile terminals are limited. This means that before deploying a neural network model on a mobile terminal, the model's size needs to be optimized to reduce its storage and computing requirements. Currently, related technologies typically prune all neurons in the neural network model according to a pre-set pruning rate to optimize the model's size. However, this method of optimizing the neural network model solely based on the pruning rate leads to a significant drop in the model's performance, thus affecting its normal use. Summary of the Invention
[0003] To address the aforementioned technical problems, this application aims to provide a model processing method, electronic device, storage medium, and computer program product, thereby resolving the issue in related technologies where the performance of neural network models significantly decreases during optimization.
[0004] To achieve the above objectives, the technical solution of this application embodiment is implemented as follows: A model processing method, the method comprising: The data to be processed is processed using a first neural network model to obtain a first output result of the first neural network model and a second output result of each neuron in each layer of the first neural network model. Based on the first output result and the second output result, the target parameters corresponding to each neuron in each layer are determined; wherein, the target parameters characterize the importance of the neuron to the first neural network model; Based on the real-time performance parameters of the first neural network model, the target parameters, and the optimization parameters corresponding to the first neural network model, the first neural network model is processed to obtain the target neural network model; wherein, the optimization parameters are used to optimize the size of the first neural network model.
[0005] In the above scheme, the step of processing the first neural network model to obtain the target neural network model based on the real-time performance parameters of the first neural network model, the target parameters, and the optimization parameters corresponding to the first neural network model includes: For the first layer of the first neural network model, a first optimization parameter is determined based on the target parameter and the target quantization threshold, and the neurons in the first layer are processed based on the first optimization parameter and the target parameter of each neuron in the first layer to obtain a second neural network model; For the i-th layer of the i-th neural network model, based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter, the i-th optimization parameter corresponding to the i-th layer is determined. Then, based on the i-th optimization parameter and the target parameter corresponding to each neuron in the i-th layer of the first neural network model, the neurons in the i-th layer are processed to obtain the (i+1)-th neural network model; where i is an integer greater than 1. The target neural network model is determined based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the target optimization function.
[0006] In the above scheme, determining the first optimization parameter based on the target parameter and the target quantization threshold includes: The first pruning parameter is determined based on the target parameter corresponding to each neuron in each layer; Based on the target parameters corresponding to each neuron in each layer and the target quantization threshold, a first quantization parameter is determined; wherein, the first optimization parameter includes the first pruning parameter and the first quantization parameter.
[0007] In the above scheme, determining the i-th optimization parameter corresponding to the i-th layer based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter includes: Based on the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer of the first neural network model, and the target quantization threshold, the i-th quantization parameter is determined; Obtain the third output result of the i-th layer of the first neural network model; The i-th neural network model is used to process the data to be processed, and the fourth output result of the i-th layer of the i-th neural network model is determined. Based on the first performance parameter, the i-th performance parameter, the third output result, the fourth output result, and the (i-1)-th pruning parameter, the i-th pruning parameter is determined; wherein, the (i-1)-th optimization parameter includes the (i-1)-th pruning parameter; the i-th optimization parameter includes the i-th quantization parameter and the i-th pruning parameter.
[0008] In the above scheme, determining the target neural network model based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the target optimization function includes: The data to be processed is processed using the (i+1)th neural network model to obtain the output result of the (i+1)th neural network model; Based on the first optimization parameter, the i-th optimization parameter, the optimization parameter corresponding to the intermediate layer, the output result of the (i+1)-th neural network model, and the target optimization function, the target value corresponding to the (i+1)-th neural network model is determined. If the target value corresponding to the (i+1)th neural network model meets the target threshold, the (i+1)th neural network model is determined to be the target neural network model.
[0009] The method in the above scheme further includes: If the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the (i+1)th optimization parameter is determined based on the first performance parameter, the (i+1)th performance parameter of the (i+1)th neural network model, the target parameter corresponding to each neuron in each layer, the target quantization threshold, and the (i)th optimization parameter, until the target value corresponding to the determined Nth neural network model meets the target threshold; where N is an integer greater than i+1; The Nth neural network model is determined to be the target neural network model.
[0010] The method in the above scheme further includes: Obtain sample data; The target loss function is determined based on the cross-entropy loss function, the regularization loss function, and the knowledge distillation loss function. Based on the sample data and the target loss function, the target neural network model is trained to obtain the trained neural network model.
[0011] An electronic device includes: a processor and a memory for storing a computer program capable of running on the processor; The processor is used to execute the steps of the above-described model processing method when running a computer program.
[0012] A storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described model processing method.
[0013] A computer program product includes a computer program that, when executed by a processor, implements the steps of the above-described model processing method.
[0014] The model processing method, electronic device, model processing apparatus, storage medium, and computer program product provided in this application embodiment can process the data to be processed using a first neural network model to obtain a first output result of the first neural network model and a second output result of each neuron in each layer of the first neural network model. Based on the first and second output results, target parameters representing the importance of each neuron to the first neural network model are determined for each neuron in each layer. Then, based on the real-time performance parameters of the first neural network model, the target parameters, and the optimization parameters corresponding to the first neural network model for optimizing the size of the first neural network model, the first neural network model is processed to obtain a target neural network model. In this way, the target parameters corresponding to each neuron in the first neural network model, the real-time performance parameters of the first neural network model, and the optimization parameters corresponding to the first neural network model can be combined to optimize the first neural network model to obtain the target neural network model. That is, the optimization process of the first neural network model simultaneously considers the real-time performance of the first neural network model, the target parameters corresponding to the neurons in the first neural network model, and the optimization parameters corresponding to the first neural network model, instead of only considering the pruning rate of the model when optimizing the neural network model as in related technologies. This solves the problem that the performance of the model will drop significantly when optimizing the neural network model in related technologies. Attached Figure Description
[0015] Figure 1 A schematic flowchart illustrating a model processing method provided in an embodiment of this application; Figure 2 A flowchart illustrating another model processing method provided in an embodiment of this application; Figure 3 A flowchart illustrating yet another model processing method provided in an embodiment of this application; Figure 4 A schematic diagram of the structure of an electronic device provided for an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a model processing device provided in an embodiment of this application. Detailed Implementation
[0016] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0017] It should be understood that the phrases "embodiments of this application" or "foreign embodiments" throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "embodiments of this application" or "in the foreign embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0018] Unless otherwise specified, any step in the embodiments of this application performed by the electronic device may be executed by the processor of the electronic device. It is also worth noting that the embodiments of this application do not limit the order in which the electronic device performs the following steps. Furthermore, the methods used to process data in different embodiments may be the same or different methods. It should also be noted that any step in the embodiments of this application can be executed independently by the electronic device; that is, when the electronic device performs any step in the following embodiments, it may not depend on the execution of other steps.
[0019] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of this application.
[0020] This application provides a method, referring to... Figure 1 As shown, the method may include the following steps: Step 101: Use the first neural network model to process the data to be processed, and obtain the first output result of the first neural network model and the second output result of each neuron in each layer of the first neural network model.
[0021] In this embodiment, the first neural network model may run on a mobile terminal (e.g., a mobile phone). In one possible implementation, the first neural network model may be a gesture recognition model, a face recognition model, or a speech recognition model, etc.
[0022] In this embodiment of the application, before the first neural network model processes the data to be processed, specific program code can be inserted at each neuron in each layer of the first neural network model to monitor the internal behavior of the model. Then, the data to be processed can be input as input parameters into the first neural network model, and the first neural network model will process the data to be processed, thereby obtaining the second output result of each neuron and the final output result of the first neural network model (i.e., the first output result).
[0023] Step 102: Based on the first output result and the second output result, determine the target parameters corresponding to each neuron in each layer.
[0024] The target parameter represents the importance of the neuron to the first neural network model.
[0025] In this embodiment, the target parameter can also characterize the contribution of each neuron to the output of the first neural network model. It should be noted that the target parameter can be represented by a matrix.
[0026] In this embodiment of the application, the influence factor corresponding to each neuron can be obtained, and the target parameters corresponding to each neuron in each layer of the first neural network model can be determined based on the influence factor corresponding to each neuron, the second output result of each neuron and the first output result of each neuron.
[0027] Step 103: Based on the real-time performance parameters, target parameters, and corresponding optimization parameters of the first neural network model, process the first neural network model to obtain the target neural network model.
[0028] The optimization parameters are used to optimize the size of the first neural network model.
[0029] In this embodiment, the optimization parameters may include pruning parameters and quantization parameters; the performance parameters may include the computational accuracy and computational complexity of the model. Specifically, the optimization parameters can be updated in real time based on the real-time performance parameters and target parameters of the first neural network model, and the first neural network model can be compressed using a layer-by-layer optimization approach based on the updated optimization parameters to obtain the target neural network model.
[0030] It should be noted that pruning parameters can refer to the pruning rate, while quantization parameters can refer to the quantization level.
[0031] The model processing method provided in this application can combine the target parameters corresponding to each neuron in the first neural network model, the real-time performance parameters of the first neural network model, and the optimization parameters corresponding to the first neural network model to optimize the first neural network model and obtain the target neural network model. That is, in the process of optimizing the first neural network model, the real-time performance of the first neural network model, the target parameters corresponding to the neurons in the first neural network model, and the optimization parameters corresponding to the first neural network model are considered simultaneously, instead of only considering the pruning rate of the model when optimizing the neural network model as in related technologies. This solves the problem that the performance of the model will drop significantly when optimizing the neural network model in related technologies.
[0032] Based on the foregoing embodiments, embodiments of this application provide a model processing method, referring to... Figure 2 As shown, the method may include the following steps: Step 201: The electronic device uses a first neural network model to process the data to be processed, and obtains the first output result of the first neural network model and the second output result of each neuron in each layer of the first neural network model.
[0033] In the embodiments of this application, the first neural network model can be a lightweight convolutional neural network model (hereinafter referred to as: MobileNet) or an efficient convolutional neural network model (hereinafter referred to as: EfficientNet). It should be noted that, as... Figure 3 As shown, the first neural network model can be obtained by training the initial neural network model.
[0034] In one feasible approach, if the first neural network model is a gesture recognition model, the gesture recognition model can be obtained as follows: A1. Obtain the gesture dataset for model training.
[0035] In this embodiment of the application, in order to ensure the robustness of the model, multiple target gesture data under different lighting, different angles and different occlusion conditions can be selected from multiple gesture data. Then, the multiple target gesture data are combined to obtain a gesture dataset.
[0036] A2. Train the initial gesture recognition model based on the gesture dataset to obtain the gesture recognition model.
[0037] In this embodiment of the application, the gesture dataset can be used as the input parameter of the initial gesture recognition model. That is, the gesture dataset can be input into the initial gesture recognition model for processing to train the initial gesture recognition model and thus obtain the gesture recognition model.
[0038] In this embodiment of the application, after training the first neural network model, the first performance parameters (also known as initial performance parameters) of the first neural network model can be calculated. These first performance parameters may include the computational accuracy and computational complexity of the first neural network before compression.
[0039] It should be noted that the calculation methods for the model's accuracy and computational complexity are existing technologies and will not be elaborated upon here.
[0040] In this embodiment, a hook mechanism can be used to insert program code into each layer of the first neural network model and at each neuron in each layer in advance. Then, the data to be processed can be input into the first neural network model as input parameters. In this way, not only can the first output result of the first neural network model and the second output result of each neuron be obtained, but also the third output result of each layer of the first neural network model can be obtained.
[0041] It should be noted that the first, second, and third output results can be stored in the cache area for later use.
[0042] Step 202: The electronic device determines the target parameters corresponding to each neuron in each layer based on the first output result and the second output result.
[0043] The target parameter represents the importance of the neuron to the first neural network model.
[0044] In this embodiment of the application, the target parameters corresponding to each neuron can be obtained by calculating the influence factor corresponding to each neuron, the second output result of each neuron and the first output result of the first neural network model according to the following formula (1).
[0045] Formula (1) in, This represents the target parameter corresponding to the nth neuron in the l-th layer. This indicates the first output result. This represents the second output of the nth neuron in the l-th layer. This represents the influencing factor corresponding to each neuron.
[0046] It should be noted that the influence factor for each neuron is pre-set, and different neurons correspond to different influence factors.
[0047] In this embodiment, the target parameter can be represented by a matrix, and the dimension of the matrix is typically 1*m. Here, m is determined based on the number of connections between the neuron and the neurons in the previous layer.
[0048] For example, if the second neuron in the first layer has connections with the four neurons in the previous layer, then the number of connections is four. Accordingly, the target parameter of the second neuron is a matrix with a dimension of 1*4.
[0049] Step 203: For the first layer of the first neural network model, the electronic device determines the first optimization parameters based on the target parameters and the target quantization threshold, and processes the neurons in the first layer based on the first optimization parameters and the target parameters of each neuron in the first layer to obtain the second neural network model.
[0050] The optimization parameters are used to optimize the size of the first neural network model.
[0051] In this embodiment, the first neural network model typically has an input layer, a hidden layer, and an output layer; the first optimization parameters may include a first pruning parameter and a first quantization parameter. The first layer can be an output layer, the last layer can be an input layer, and the hidden layers may include convolutional layers, fully connected layers, normalization layers, etc.
[0052] It should be noted that the hidden layers can be different for different first neural network models.
[0053] In this embodiment of the application, the "electronic device determines the first optimization parameter based on the target parameter and the target quantization threshold" in step 203 can be implemented through steps 203a to 203b.
[0054] Step 203a: The electronic device determines the first pruning parameters based on the target parameters corresponding to each neuron in each layer.
[0055] In this embodiment, the first pruning parameter may refer to the first pruning rate. The first pruning rate can be expressed as a percentage, for example, it could be 30% or 25%.
[0056] In one feasible approach, the eigenvalues of the matrix (i.e., the target parameters) corresponding to each neuron in each layer can be calculated first, and then the first pruning parameters can be manually set based on multiple eigenvalues.
[0057] In another feasible approach, after calculating the matrix features corresponding to each neuron in each layer, a weighted average of multiple feature values can be performed, and the resulting average value can be used as the first pruning parameter.
[0058] Step 203b: The electronic device determines the first quantization parameter based on the target parameter and target quantization threshold corresponding to each neuron in each layer.
[0059] The first optimization parameters include the first pruning parameters and the first quantization parameters.
[0060] In this embodiment, the target quantization threshold can refer to the initial bit width. The target quantization threshold may include a minimum quantization threshold (i.e., minimum bit width) and a maximum quantization threshold (i.e., maximum bit width). It should be noted that the target quantization threshold is set according to the user's actual needs.
[0061] In this embodiment of the application, the target parameters corresponding to each layer of the first neural network model can be obtained by first determining the target parameters corresponding to each neuron in each layer and then concatenating multiple target parameters.
[0062] For example, if the first layer has 3 neurons and the matrices corresponding to these 3 neurons have the same dimension (e.g., all are 2D matrices), then these 2D matrices can be directly concatenated to obtain the target parameters corresponding to the first layer. Conversely, if the matrices corresponding to these 3 neurons have different dimensions (e.g., the target parameters corresponding to the first and second neurons are 2D matrices, and the target parameters corresponding to the third neuron are 3D matrices), then it is necessary to first increase the dimension of the 2D matrices corresponding to the first and second neurons, and then concatenate the increased-dimensional matrices with the 3D matrix corresponding to the third neuron to obtain the target parameters corresponding to the first layer.
[0063] In this embodiment of the application, after obtaining the target parameters corresponding to each layer of the first neural network model, the feature values of the matrix (i.e., the target parameters) corresponding to each layer can be calculated, and multiple feature values can be compared pairwise. The layer corresponding to the matrix (i.e., the target parameters) with the largest feature value is determined as the target layer. Then, the target parameters corresponding to the first layer can be extracted from the target parameters corresponding to each layer, and the target quantization threshold, the target parameters corresponding to the first layer and the target parameters corresponding to the target layer can be calculated according to the following formula (2) to obtain the first quantization parameter (i.e., the first quantization level).
[0064] Formula (2) in, Indicates the first quantization level; This represents the maximum quantization threshold among the target quantization thresholds; This represents the minimum quantization threshold among the target quantization thresholds; This represents the target parameters corresponding to the first layer; This represents the target parameters corresponding to the target layer.
[0065] In this embodiment, after determining the first pruning parameter and the first quantization level, the eigenvalues of the target parameters (i.e., matrices) corresponding to each neuron in the first layer can be calculated first, and the eigenvalues corresponding to each neuron can be compared with the first pruning parameter. Then, the neurons with eigenvalues less than the first pruning parameter can be marked as neurons to be processed. After that, the neurons to be processed can be pruned to obtain the pruned neural network model. Furthermore, the neurons in the first layer of the pruned neural network model can be quantized according to the first quantization level to obtain the second neural network model.
[0066] In one feasible way, such as Figure 3 As shown, the neurons in the first layer can also be pruned and quantized simultaneously based on the first pruning parameters and the first quantization level to obtain the second neural network model.
[0067] In another possible approach, the neurons in the first layer of the first neural network model can be quantized according to the first quantization level, and then the neurons in the first layer of the quantized neural network model can be pruned according to the first pruning parameters to obtain the second neural network model.
[0068] Step 204: For the i-th layer of the i-th neural network model, the electronic device determines the i-th optimization parameter based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter. Based on the i-th optimization parameter and the target parameter corresponding to each neuron in the i-th layer of the first neural network model, the electronic device processes the neurons in the i-th layer to obtain the (i+1)-th neural network model.
[0069] Where i is an integer greater than 1.
[0070] In this embodiment, if i=2, then for the second layer of the second neural network model, the first optimization parameter can be adjusted according to the second performance parameter of the second neural network model obtained after compression of the first neural network model, the first performance parameter, the target parameter corresponding to each neuron in each layer, and the target quantization threshold to obtain the second optimization parameter corresponding to the second layer. Then, according to the second optimization parameter and the target parameter corresponding to each neuron in the second layer of the first neural network model, the neurons of the second layer of the second neural network model are compressed to obtain the third neural network model.
[0071] In this embodiment, if i=3, then for the third layer of the third neural network model, the second optimization parameters can be adjusted according to the third performance parameters, the first performance parameters, the target parameters, and the target quantization threshold of the third neural network model to obtain the third optimization parameters corresponding to the third layer. Then, based on the third optimization parameters and the target parameters corresponding to each neuron in the third layer of the first neural network model, the third layer of the third neural network model is compressed to obtain the fourth neural network model. The third neural network model is obtained by compressing the second neural network model.
[0072] It should be noted that the i-th optimization parameter includes the i-th pruning parameter and the i-th quantization parameter.
[0073] In this embodiment, for the i-th layer of the i-th neural network model, new optimization parameters can be determined by combining the performance parameters, first performance parameters, target parameters, and target quantization threshold of the i-th neural network model obtained after compressing the (i-1)-th neural network model. These parameters are then used to compress the neurons in the i-th layer. In other words, when compressing the neural network model, the optimization parameters for the next layer can be flexibly adjusted based on the real-time feedback from the previous layer after compressing the previous layer. This not only ensures the accuracy of the neural network model but also significantly improves its computational accuracy and efficiency.
[0074] In this embodiment of the application, the step 204, "the electronic device determines the i-th optimization parameter based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, and the target quantization threshold," can be implemented through steps 204a-204d: Step 204a: The electronic device determines the i-th quantization parameter based on the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer of the first neural network model, and the target quantization threshold.
[0075] In this embodiment of the application, the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer, and the target quantization threshold can be calculated according to the following formula (3) to obtain the i-th quantization parameter (i.e. the i-th quantization level).
[0076] Formula (3) in, This represents the i-th quantization parameter (i.e., the i-th quantization level); This represents the maximum quantization threshold among the target quantization thresholds; This represents the minimum quantization threshold among the target quantization thresholds; This represents the target parameters corresponding to the i-th layer; This represents the target parameters corresponding to the target layer.
[0077] Step 204b: The electronic device acquires the third output result of the i-th layer of the first neural network model.
[0078] In this embodiment of the application, the third output result of the i-th layer of the first neural network model can be obtained directly from the cache area.
[0079] Step 204c: The electronic device uses the i-th neural network model to process the data to be processed and determines the fourth output result of the i-th layer of the i-th neural network model.
[0080] In this embodiment of the application, the internal behavior of the model can be monitored directly through the pre-set program code in the i-th neural network model, so as to obtain the fourth output result of the i-th layer of the i-th neural network model when the data to be processed is input as an input parameter to the i-th neural network model.
[0081] It should be noted that the program code used to monitor the internal behavior of the i-th neural network model has already been set in step 201.
[0082] Step 204d: The electronic device determines the i-th pruning parameter based on the first performance parameter, the i-th performance parameter, the third output result, the fourth output result, and the (i-1)-th pruning parameter.
[0083] Among them, the (i-1)th optimization parameter includes the (i-1)th pruning parameter; the ith optimization parameter includes the ith quantization parameter and the ith pruning parameter.
[0084] In this embodiment of the application, if i=2, the first pruning parameter can be adjusted according to the first performance parameter, the second performance parameter of the second neural network model, the third output result, and the fourth output result of the i-th layer of the second neural network model to obtain the second pruning parameter.
[0085] In this embodiment, the first performance parameter includes the computational accuracy (hereinafter referred to as: first accuracy) and computational complexity (hereinafter referred to as: first complexity) of the first neural network model; the i-th performance parameter may include the i-th computational accuracy (hereinafter referred to as: i-th accuracy) and the i-th computational complexity (hereinafter referred to as: i-th complexity) of the i-th neural network model. Specifically, the amount of change between the third output result and the fourth output result can be determined first, and then the first performance parameter, the third performance parameter, the amount of change of the output result, the fourth output result and the (i-1)-th output result can be calculated according to the following formula (4) to obtain the i-th pruning parameter.
[0086] Formula (4) in, This represents the i-th pruning parameter (i.e., the i-th pruning rate); This represents the (i-1)th pruning parameter (i.e., the (i-1)th pruning rate). This represents the first complexity among the first performance parameters; This represents the i-th complexity in the i-th performance parameter; This represents the first accuracy rate among the first performance parameters; This represents the accuracy of the i-th performance parameter. Indicates the amount of change in the output result; This indicates the fourth output result; Indicates the first weighting coefficient; This represents the second weighting coefficient; This represents the learning rate factor.
[0087] It should be noted that the first weighting coefficient Second weighting coefficient and learning rate factor These are fixed values set by the user based on their actual needs.
[0088] In this embodiment, by adjusting the pruning parameters of the model based on the latest performance and changes in the model output after the last model compression, the computational accuracy of the model can be guaranteed while reducing its computational complexity. Furthermore, while ensuring model performance, dynamic optimization can be performed for different tasks and hardware environments, thereby significantly improving the model's compression ratio and computational efficiency.
[0089] Step 205: The electronic device determines the target neural network model based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the target optimization function.
[0090] In this embodiment, the target optimization function is set according to the user's actual needs. Specifically, the (i+1)th neural network model can be used to process the data to be processed to obtain the output result of the (i+1)th neural network model. Then, the target neural network model can be determined based on the output result, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, the target optimization function, and the (i+1)th neural network model.
[0091] In this embodiment of the application, step 205 can be implemented through steps 205a to 205e: Step 205a: The electronic device uses the (i+1)th neural network model to process the data to be processed, and obtains the output result of the (i+1)th neural network model.
[0092] In this embodiment of the application, the data to be processed can be input as an input parameter into the (i+1)th neural network model. Then, the (i+1)th neural network model can process the data to be processed to obtain the output result of the (i+1)th neural network model.
[0093] For example, if i=2, the data to be processed can be input into the third neural network model. Then, the third neural network model can process the data to be processed and obtain the output result of the third neural network model.
[0094] Step 205b: The electronic device determines the target value corresponding to the (i+1)th neural network model based on the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer, the output result of the (i+1)-th neural network model, and the target optimization function.
[0095] In this embodiment, the objective optimization function S can be represented by the following formula (5): Formula (5) in, This includes the first pruning parameter, the i-th pruning parameter, and the pruning parameters corresponding to the intermediate layers. This includes the first quantization parameter, the i-th quantization parameter, and the quantization parameters corresponding to the intermediate layers. This represents the output of the (i+1)th neural network model. Denotes the first regularization coefficient. Denotes the second regularization coefficient. This represents the equilibrium parameter.
[0096] For example, if i=2, then the middle layer is empty. Including the first optimization parameter and the second optimization parameter; This includes the first quantization parameter and the second quantization parameter; if i=3, then the intermediate layer is the second layer. This includes the first optimization parameter, the second optimization parameter, and the third optimization parameter; This includes the first quantization parameter, the second quantization parameter, and the third quantization parameter.
[0097] In this embodiment of the application, the first optimization parameter, the i-th optimization parameter, the optimization parameter corresponding to the intermediate layer and the output result of the i+1th neural network model can be substituted into formula (5). When performing the calculation in the formula, the first optimization parameter, the i-th optimization parameter and the optimization parameter corresponding to the intermediate layer are first added together, and then the first quantization parameter, the i-th quantization parameter and the quantization parameter corresponding to the intermediate layer are added together. After that, the target value is calculated by combining the output result of the i+1th neural network model.
[0098] It should be noted that the first regularization coefficient, the second regularization coefficient, and the balancing parameter are all preset according to the user's actual needs.
[0099] In this embodiment of the application, step 205c or steps 205d to 205e can be executed after step 205b.
[0100] Step 205c: If the target value corresponding to the (i+1)th neural network model meets the target threshold, the electronic device determines the (i+1)th neural network model as the target neural network model.
[0101] In this embodiment, the target threshold can be set according to the user's actual needs. Specifically, if the target value corresponding to the (i+1)th neural network model meets the target threshold, that is, the target value is greater than or equal to the target threshold, the compression processing of the neural network model can be stopped, and the (i+1)th neural network model can be directly determined as the target neural network model.
[0102] In another possible approach, the target value corresponding to the (i+1)th neural network model can be compared with the target values corresponding to all neural network models preceding the (i+1)th neural network model. If the target value corresponding to the (i+1)th neural network model is the smallest, then the (i+1)th neural network model can also be determined as the target neural network model. In other words, if the target value corresponding to a certain neural network model is the smallest, i.e., the target value is the minimum value of the target optimization function, then the neural network model can be determined as the target neural network model.
[0103] Step 205d: If the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the electronic device determines the (i+1)th optimization parameter based on the first performance parameter, the (i+1)th performance parameter of the (i+1)th neural network model, the target parameter corresponding to each neuron in each layer, the target quantization threshold, and the (i)th optimization parameter, until the target value corresponding to the determined Nth neural network model meets the target threshold.
[0104] Where N is an integer greater than i+1.
[0105] In this embodiment, if the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the electronic device will, according to step 204, adjust the i-th optimized parameter based on the first performance parameter, the (i+1)th performance parameter, the target parameter corresponding to each neuron in each layer, and the target quantization threshold to obtain the (i+1)th optimized parameter. Then, the neurons of the (i+1)th layer of the (i+1)th neural network model will be compressed based on the (i+1)th optimized parameter and the target parameter to obtain the (i+2)th neural network model. After that, the target value corresponding to the (i+2)th neural network model can be calculated according to steps 205a~205b. If the target value meets the target threshold, the (i+2)th neural network model can be determined as the target neural network model. If the target value still does not meet the target threshold, the process can be continuously looped according to steps 204 and 205a~205b until the target value corresponding to the determined Nth neural network model meets the target threshold, and then the loop stops.
[0106] Step 205e: The electronic device determines the Nth neural network model as the target neural network model.
[0107] In this embodiment of the application, after determining that the target value corresponding to the Nth neural network model meets the target threshold, the Nth neural network model can be determined as the target neural network model.
[0108] In other embodiments of this application, steps 206 to 208 may be performed after step 205.
[0109] Step 206: The electronic device acquires sample data.
[0110] In this embodiment of the application, the sample data may be data used to train the target neural network model.
[0111] Step 207: The electronic device determines the target loss function based on the cross-entropy loss function, the regularization loss function, and the knowledge distillation loss function.
[0112] In this embodiment of the application, the regularization loss function can be: ,in, This can refer to the original loss function, where R represents the regularization term. Specifically, the regularization term R can be represented by the following formula (6): Formula (6) in, and Represents the regularization coefficient. This represents the entropy term.
[0113] In this embodiment of the application, if the cross-entropy loss function is used This indicates that the knowledge distillation loss function is used... In other words, the objective loss function is... It can be represented by the following formula (7): Formula (7) in, This represents the first weight corresponding to the cross-entropy loss function. This represents the second weight corresponding to the regularization loss function. This represents the third weight corresponding to the knowledge distillation loss function. It should be noted that the sum of the first, second, and third weights is 1.
[0114] Step 208: The electronic device trains the target neural network model based on the sample data and the target loss function to obtain the trained neural network model.
[0115] In the embodiments of this application, such as Figure 3 As shown, sample data can be used as input parameters into the target neural network model. That is, the target neural network model is used to process the sample data to obtain processed data. Then, the difference between the processed data and the real data can be calculated through the target loss function, and the parameters of the target neural network model are updated according to the difference until the difference determined by the target loss function meets the requirements. In this way, the trained neural network model can be obtained.
[0116] In one feasible approach, the parameters of the target neural network model (e.g., learning rate, regularization coefficient) can be adjusted using a Bayesian optimization function to improve the model's recognition performance in real-world scenarios. It should be noted that the optimization objective of the model's parameters is... ,in, The set of parameters to be optimized. This represents the computational cost of the target neural network model.
[0117] In this embodiment, by introducing a regularization term into the target loss function, the distribution of model parameters can be optimized, thereby avoiding overfitting caused by compressing the neural network model. This allows for improved robustness and generalization ability of the target neural network model even with a high compression ratio.
[0118] It should be noted that the descriptions of the same steps and contents as in other embodiments in this embodiment can be found in the descriptions in other embodiments, and will not be repeated here.
[0119] The model processing method provided in this application can combine the target parameters corresponding to each neuron in the first neural network model, the real-time performance parameters of the first neural network model, and the optimization parameters corresponding to the first neural network model to optimize the first neural network model and obtain the target neural network model. That is, in the process of optimizing the first neural network model, the real-time performance of the first neural network model, the target parameters corresponding to the neurons in the first neural network model, and the optimization parameters corresponding to the first neural network model are considered simultaneously, instead of only considering the pruning rate of the model when optimizing the neural network model as in related technologies. This solves the problem that the performance of the model will drop significantly when optimizing the neural network model in related technologies.
[0120] Based on the foregoing embodiments, embodiments of this application provide an electronic device that can be applied to... Figure 1 and Figure 2 In the model processing method provided in the corresponding embodiment, refer to Figure 4 As shown, the electronic device 3 may include: a processor 31, a memory 32, and a communication bus 33, wherein: Communication bus 33 is used to realize the communication connection between processor 31 and memory 32; The processor 31 is used to execute the model processing program in the memory 32 to perform the following steps: The data to be processed is processed using a first neural network model to obtain the first output result of the first neural network model and the second output result of each neuron in each layer of the first neural network model; Based on the first and second output results, the target parameters corresponding to each neuron in each layer are determined; wherein, the target parameters characterize the importance of the neuron to the first neural network model; Based on the real-time performance parameters, target parameters, and corresponding optimization parameters of the first neural network model, the first neural network model is processed to obtain the target neural network model; wherein, the optimization parameters are used to optimize the size of the first neural network model.
[0121] In other embodiments of this application, the processor 31 is used to execute the model processing program in the memory 32 based on the real-time performance parameters, target parameters, and optimization parameters corresponding to the first neural network model, to process the first neural network model to obtain the target neural network model, thereby implementing the following steps: For the first layer of the first neural network model, the first optimization parameters are determined based on the target parameters and the target quantization threshold. Then, the neurons in the first layer are processed based on the first optimization parameters and the target parameters of each neuron in the first layer to obtain the second neural network model. For the i-th layer of the i-th neural network model, based on the first performance parameters of the first neural network model, the i-th performance parameters of the i-th neural network model, the target parameters, the target quantization threshold, and the (i-1)-th optimization parameters, the i-th optimization parameters corresponding to the i-th layer are determined. Then, based on the i-th optimization parameters and the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the neurons in the i-th layer are processed to obtain the (i+1)-th neural network model; where i is an integer greater than 1. The target neural network model is determined based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the objective optimization function.
[0122] In other embodiments of this application, processor 31 is used to execute the model processing program in memory 32 to determine first optimization parameters based on target parameters and target quantization threshold, in order to implement the following steps: The first pruning parameter is determined based on the target parameter corresponding to each neuron in each layer; Based on the target parameters and target quantization threshold corresponding to each neuron in each layer, the first quantization parameter is determined; wherein, the first optimization parameter includes the first pruning parameter and the first quantization parameter.
[0123] In other embodiments of this application, the processor 31 is used to execute the model processing program in the memory 32 based on the first performance parameters of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter, to determine the i-th optimization parameter corresponding to the i-th layer, in order to implement the following steps: Based on the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer of the first neural network model, and the target quantization threshold, the i-th quantization parameter is determined; Obtain the third output result of the i-th layer of the first neural network model; The i-th neural network model is used to process the data to be processed, and the fourth output result of the i-th layer of the i-th neural network model is determined. Based on the first performance parameter, the i-th performance parameter, the third output result, the fourth output result, and the (i-1)-th pruning parameter, the i-th pruning parameter is determined; wherein, the (i-1)-th optimization parameter includes the (i-1)-th pruning parameter; the i-th optimization parameter includes the i-th quantization parameter and the i-th pruning parameter.
[0124] In other embodiments of this application, the processor 31 is used to execute the model processing program in the memory 32 to determine the target neural network model based on the (i+1)th neural network model, the first optimization parameters, the i-th optimization parameters, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the target optimization function, so as to implement the following steps: The (i+1)th neural network model is used to process the data to be processed, and the output result of the (i+1)th neural network model is obtained. Based on the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer, the output result of the (i+1)-th neural network model and the objective optimization function, the target value corresponding to the (i+1)-th neural network model is determined. If the target value corresponding to the (i+1)th neural network model meets the target threshold, the (i+1)th neural network model is determined to be the target neural network model.
[0125] In other embodiments of this application, processor 31 is used to execute a model processing program in memory 32 to perform the following steps: If the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the (i+1)th optimization parameter is determined based on the first performance parameter, the (i+1)th performance parameter of the (i+1)th neural network model, the target parameter corresponding to each neuron in each layer, the target quantization threshold, and the (i)th optimization parameter, until the target value corresponding to the determined Nth neural network model meets the target threshold; where N is an integer greater than i+1; The Nth neural network model is determined as the target neural network model.
[0126] In other embodiments of this application, processor 31 is used to execute a model processing program in memory 32 to perform the following steps: Obtain sample data; The target loss function is determined based on the cross-entropy loss function, the regularization loss function, and the knowledge distillation loss function. Based on sample data and the target loss function, the target neural network model is trained to obtain the trained neural network model.
[0127] It should be noted that a detailed description of the steps performed by the processor can be found in [reference needed]. Figure 1 and Figure 2 The model processing methods provided in the corresponding embodiments will not be described in detail here.
[0128] The electronic device provided in the embodiments of this application can optimize the first neural network model by combining the target parameters corresponding to each neuron in the first neural network model, the real-time performance parameters of the first neural network model, and the optimization parameters corresponding to the first neural network model, to obtain the target neural network model. That is, in the process of optimizing the first neural network model, the real-time performance of the first neural network model, the target parameters corresponding to the neurons in the first neural network model, and the optimization parameters corresponding to the first neural network model are considered simultaneously, instead of only considering the pruning rate of the model when optimizing the neural network model as in related technologies. This solves the problem that the performance of the model will drop significantly when optimizing the neural network model in related technologies.
[0129] Based on the foregoing embodiments, embodiments of this application provide a model processing apparatus that can be applied to... Figure 1 and Figure 2 In the model processing method provided in the corresponding embodiment, refer to Figure 5 As shown, the model processing device 4 may include: a first processing unit 41, a determining unit 42, and a second processing unit 43, wherein: The first processing unit 41 is used to process the data to be processed using the first neural network model to obtain the first output result of the first neural network model and the second output result of each neuron in each layer of the first neural network model. The determining unit 42 is used to determine the target parameters corresponding to each neuron in each layer based on the first output result and the second output result; wherein, the target parameters characterize the importance of the neuron to the first neural network model; The second processing unit 43 is used to process the first neural network model based on the real-time performance parameters, target parameters, and optimization parameters corresponding to the first neural network model to obtain the target neural network model; wherein, the optimization parameters are used to optimize the size of the first neural network model.
[0130] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: For the first layer of the first neural network model, the first optimization parameters are determined based on the target parameters and the target quantization threshold. Then, the neurons in the first layer are processed based on the first optimization parameters and the target parameters of each neuron in the first layer to obtain the second neural network model. For the i-th layer of the i-th neural network model, based on the first performance parameters of the first neural network model, the i-th performance parameters of the i-th neural network model, the target parameters, the target quantization threshold, and the (i-1)-th optimization parameters, the i-th optimization parameters corresponding to the i-th layer are determined. Then, based on the i-th optimization parameters and the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the neurons in the i-th layer are processed to obtain the (i+1)-th neural network model; where i is an integer greater than 1. The target neural network model is determined based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the objective optimization function.
[0131] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: The first pruning parameter is determined based on the target parameter corresponding to each neuron in each layer; Based on the target parameters and target quantization threshold corresponding to each neuron in each layer, the first quantization parameter is determined; wherein, the first optimization parameter includes the first pruning parameter and the first quantization parameter.
[0132] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: Based on the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer of the first neural network model, and the target quantization threshold, the i-th quantization parameter is determined; Obtain the third output result of the i-th layer of the first neural network model; The i-th neural network model is used to process the data to be processed, and the fourth output result of the i-th layer of the i-th neural network model is determined. Based on the first performance parameter, the i-th performance parameter, the third output result, the fourth output result, and the (i-1)-th pruning parameter, the i-th pruning parameter is determined; wherein, the (i-1)-th optimization parameter includes the (i-1)-th pruning parameter; the i-th optimization parameter includes the i-th quantization parameter and the i-th pruning parameter.
[0133] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: The (i+1)th neural network model is used to process the data to be processed, and the output result of the (i+1)th neural network model is obtained. Based on the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer, the output result of the (i+1)-th neural network model and the objective optimization function, the target value corresponding to the (i+1)-th neural network model is determined. If the target value corresponding to the (i+1)th neural network model meets the target threshold, the (i+1)th neural network model is determined to be the target neural network model.
[0134] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: If the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the (i+1)th optimization parameter is determined based on the first performance parameter, the (i+1)th performance parameter of the (i+1)th neural network model, the target parameter corresponding to each neuron in each layer, the target quantization threshold, and the (i)th optimization parameter, until the target value corresponding to the determined Nth neural network model meets the target threshold; where N is an integer greater than i+1; The Nth neural network model is determined as the target neural network model.
[0135] In other embodiments of this application, the second processing unit 43 is further configured to perform the following steps: Obtain sample data; The target loss function is determined based on the cross-entropy loss function, the regularization loss function, and the knowledge distillation loss function. Based on sample data and the target loss function, the target neural network model is trained to obtain the trained neural network model.
[0136] It should be noted that the specific implementation process of the steps performed by each unit in the embodiments of this application can be referred to Figure 1 and Figure 2 The implementation process of the model processing method provided in the corresponding embodiment will not be described in detail here.
[0137] The model processing apparatus provided in the embodiments of this application can combine the target parameters corresponding to each neuron in the first neural network model, the real-time performance parameters of the first neural network model, and the optimization parameters corresponding to the first neural network model to optimize the first neural network model and obtain the target neural network model. That is, in the process of optimizing the first neural network model, the real-time performance of the first neural network model, the target parameters corresponding to the neurons in the first neural network model, and the optimization parameters corresponding to the first neural network model are considered simultaneously, instead of only considering the pruning rate of the model when optimizing the neural network model as in related technologies. This solves the problem that the performance of the model will drop significantly when optimizing the neural network model in related technologies.
[0138] Based on the foregoing embodiments, embodiments of this application provide a storage medium storing a computer program thereon, which is implemented when executed by a processor. Figure 1 and 2 The steps of the model processing method provided in the corresponding embodiment.
[0139] Based on the foregoing embodiments, embodiments of this application provide a computer program product, which includes a computer program that, when executed by a processor, implements... Figure 1 and 2 The steps of the model processing method provided in the corresponding embodiment.
[0140] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0141] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0142] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0143] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A model processing method, characterized in that, The method includes: The data to be processed is processed using a first neural network model to obtain a first output result of the first neural network model and a second output result of each neuron in each layer of the first neural network model. Based on the first output result and the second output result, the target parameters corresponding to each neuron in each layer are determined; wherein, the target parameters characterize the importance of the neuron to the first neural network model; Based on the real-time performance parameters of the first neural network model, the target parameters, and the optimization parameters corresponding to the first neural network model, the first neural network model is processed to obtain the target neural network model; wherein, the optimization parameters are used to optimize the size of the first neural network model.
2. The method according to claim 1, characterized in that, The step of processing the first neural network model to obtain the target neural network model based on the real-time performance parameters of the first neural network model, the target parameters, and the optimization parameters corresponding to the first neural network model includes: For the first layer of the first neural network model, a first optimization parameter is determined based on the target parameter and the target quantization threshold, and the neurons in the first layer are processed based on the first optimization parameter and the target parameter of each neuron in the first layer to obtain a second neural network model; For the i-th layer of the i-th neural network model, based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter, the i-th optimization parameter corresponding to the i-th layer is determined. Then, based on the i-th optimization parameter and the target parameter corresponding to each neuron in the i-th layer of the first neural network model, the neurons in the i-th layer are processed to obtain the (i+1)-th neural network model; where i is an integer greater than 1. The target neural network model is determined based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layer between the first layer and the i-th layer, and the target optimization function.
3. The method according to claim 2, characterized in that, The step of determining the first optimization parameter based on the target parameter and the target quantization threshold includes: The first pruning parameter is determined based on the target parameter corresponding to each neuron in each layer; Based on the target parameters corresponding to each neuron in each layer and the target quantization threshold, a first quantization parameter is determined; wherein, the first optimization parameter includes the first pruning parameter and the first quantization parameter.
4. The method according to claim 2, characterized in that, The determination of the i-th optimization parameter corresponding to the i-th layer based on the first performance parameter of the first neural network model, the i-th performance parameter of the i-th neural network model, the target parameter, the target quantization threshold, and the (i-1)-th optimization parameter includes: Based on the target parameters corresponding to each neuron in the i-th layer of the first neural network model, the target parameters corresponding to each neuron in the target layer of the first neural network model, and the target quantization threshold, the i-th quantization parameter is determined; Obtain the third output result of the i-th layer of the first neural network model; The i-th neural network model is used to process the data to be processed, and the fourth output result of the i-th layer of the i-th neural network model is determined. Based on the first performance parameter, the i-th performance parameter, the third output result, the fourth output result, and the (i-1)-th pruning parameter, the i-th pruning parameter is determined; wherein, the (i-1)-th optimization parameter includes the (i-1)-th pruning parameter; the i-th optimization parameter includes the i-th quantization parameter and the i-th pruning parameter.
5. The method according to claim 2, characterized in that, The step of determining the target neural network model based on the (i+1)th neural network model, the first optimization parameter, the i-th optimization parameter, the optimization parameters corresponding to the intermediate layers between the first layer and the i-th layer, and the objective optimization function includes: The data to be processed is processed using the (i+1)th neural network model to obtain the output result of the (i+1)th neural network model; Based on the first optimization parameter, the i-th optimization parameter, the optimization parameter corresponding to the intermediate layer, the output result of the (i+1)-th neural network model, and the target optimization function, the target value corresponding to the (i+1)-th neural network model is determined. If the target value corresponding to the (i+1)th neural network model meets the target threshold, the (i+1)th neural network model is determined to be the target neural network model.
6. The method according to claim 5, characterized in that, The method further includes: If the target value corresponding to the (i+1)th neural network model does not meet the target threshold, the (i+1)th optimization parameter is determined based on the first performance parameter, the (i+1)th performance parameter of the (i+1)th neural network model, the target parameter corresponding to each neuron in each layer, the target quantization threshold, and the (i)th optimization parameter, until the target value corresponding to the determined Nth neural network model meets the target threshold; where N is an integer greater than i+1; The Nth neural network model is determined to be the target neural network model.
7. The method according to claim 1, characterized in that, The method further includes: Obtain sample data; The target loss function is determined based on the cross-entropy loss function, the regularization loss function, and the knowledge distillation loss function. Based on the sample data and the target loss function, the target neural network model is trained to obtain the trained neural network model.
8. An electronic device, characterized in that, include: Processor and memory used to store computer programs that can run on the processor; When the processor is used to run a computer program, it executes the steps of the method according to any one of claims 1 to 7.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.