Quantized data selection method and device, electronic equipment and storage medium
Through iterative training and data regular processing, the target floating-point model is generated, and the core training data is selected using quantitative differences and predictive indicators, the problems of insufficient quantization accuracy and time-consuming quantization training after floating-point model are solved, and more efficient quantitative training is achieved.
Patent Information
- Application Number
- CN202411460599.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-14
AI Technical Summary
The quantization accuracy after floating point model in assisted driving or autonomous driving tasks does not meet the needs, and the quantitative training based on the full data set takes a long time.
By obtaining the original floating-point model and full training data of the current training stage, iterative training and data regularization and constraint processing, the target floating-point model is obtained. Then, the core training data is selected from the full training data using quantitative difference indicators and quantitative prediction indicators for the next stage of quantitative training of the target floating-point model.
The post-quantization accuracy of floating-point models is improved, and the amount of data required for quantization training is reduced, thereby reducing the training time cost.
Smart Images

Figure CN119441869A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method, device, electronic device and storage medium for selecting quantitative data. Background Art
[0002] The original floating-point model of deep learning algorithms in the automotive industry's assisted driving and autonomous driving technologies has a large amount of computational complexity, which puts pressure on the deployment of end-side chips. The current mainstream quantization methods are mostly post-quantization methods. Although there are many methods, there are still problems such as the post-quantization accuracy of floating-point models in assisted driving or autonomous driving tasks does not meet the requirements, and the quantization training based on the full data set takes a long time. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method, device, electronic device and storage medium for selecting quantized data to solve the problem that the post-quantization accuracy of the floating-point model in assisted driving or autonomous driving tasks does not meet the requirements and the quantization training based on the full data set takes a long time.
[0004] In a first aspect, an embodiment of the present invention provides a method for selecting quantitative data, the method comprising:
[0005] Obtaining an original floating-point model and full training data of a current training phase, wherein the original floating-point model and full training data are determined according to business requirements associated with assisted driving or autonomous driving;
[0006] Iteratively training the original floating-point model using the full amount of training data, and performing data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model;
[0007] If the target floating-point model has been trained for a preset number of times in the current training phase, a quantitative difference index and a quantitative prediction index are obtained;
[0008] The core training data is selected from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
[0009] Furthermore, the obtaining of the original floating-point model and the full amount of training data in the current training phase includes:
[0010] Obtain business requirements related to assisted driving or autonomous driving;
[0011] Acquire corresponding full training data according to the business requirements, and determine data characteristics of the full training data;
[0012] A target network structure matching the business requirement and the data characteristics is obtained from multiple network structures, and the original floating-point model is built using the target network structure.
[0013] Furthermore, the iterative training of the original floating-point model using the full amount of training data and performing data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model includes:
[0014] In each iteration, the full amount of training data is input into the original floating-point model to obtain a first output result;
[0015] Calculating a first training loss of the original floating-point model based on the first output result, and updating a model parameter of the original floating-point model using the first training loss to obtain an updated original floating-point model;
[0016] Adding a range-limited loss function layer to the updated network structure of the original floating-point model, and using the range-limited loss function layer to update the first training loss to obtain an updated first training loss;
[0017] The updated original floating-point model is adjusted using the updated first training loss to obtain the target floating-point model.
[0018] Furthermore, the method of using the full amount of training data to perform quantization training on the original floating-point model, and performing data regularization constraint processing on the original floating-point model during the quantization training process to obtain a target floating-point model includes:
[0019] Adding a range-limited loss function layer to the network structure of the original floating-point model to obtain the original floating-point model after the network structure is adjusted;
[0020] In each iteration, the full amount of training data is input into the original floating-point model after the network structure is adjusted to obtain a second output result;
[0021] A second training loss of the original floating-point model is calculated based on the second output result, and the model parameters of the original floating-point model are updated using the second training loss to obtain the target floating-point model.
[0022] Furthermore, the selecting core training data from the full amount of training data using the quantitative difference index and the quantitative prediction index includes:
[0023] Obtaining a first performance score of each data sample in the full amount of training data under the quantitative difference index, and a second performance score of each data sample in the full amount of training data under the quantitative prediction index;
[0024] Calculating a comprehensive score corresponding to each data sample using the first performance score and the second performance score of the data sample;
[0025] The data samples in the full amount of training data are sorted in descending order of the comprehensive scores to obtain a data sample sequence, and a preset number of data samples are selected from the starting position of the data sample sequence as the core training data.
[0026] Furthermore, the obtaining of a first performance score of each data sample in the full amount of training data under the quantitative difference index, and a second performance score of each data sample in the full amount of training data under the quantitative prediction index, includes:
[0027] Obtain a first sample output result and a true label corresponding to each data sample, and obtain a second sample output result output by the target floating-point model based on the data sample;
[0028] Calculate a first performance score of the data sample under the quantitative difference index based on the difference between the second sample output result corresponding to each data sample and the first sample output result corresponding to the data sample;
[0029] Based on the difference between the second sample output result corresponding to each data sample and the true label corresponding to the data sample, a second performance score of the data sample under the quantitative prediction index is calculated.
[0030] Further, calculating a comprehensive score corresponding to each data sample using the first performance score and the second performance score of the data sample includes:
[0031] Obtaining a first weight corresponding to the quantitative difference index and a second weight corresponding to the quantitative prediction index;
[0032] calculating a first product between the first weight and the first performance score, and calculating a second product between the second weight and the second performance score;
[0033] The comprehensive score is obtained by summing the first product and the second product.
[0034] In a second aspect, an embodiment of the present invention provides a device for selecting quantized data, the device comprising:
[0035] An acquisition module, used to acquire an original floating-point model and full training data of a current training phase, wherein the original floating-point model and full training data are determined according to business requirements associated with assisted driving or autonomous driving;
[0036] A training module, used to perform quantization training on the original floating-point model using the full amount of training data, and perform data regularization constraint processing on the original floating-point model during the quantization training process to obtain a target floating-point model;
[0037] A processing module, configured to obtain a quantitative difference index and a quantitative prediction index if the number of training times of the target floating-point model in the current training phase reaches a preset number of times;
[0038] A selection module is used to select core training data from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
[0039] In a third aspect, an embodiment of the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0040] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method of the first aspect or any corresponding embodiment thereof.
[0041] The method provided in the embodiment of the present application first determines the original floating-point model and the full amount of training data according to the business needs associated with assisted driving or autonomous driving. When iteratively training the original floating-point model, adding data regularization constraint processing helps to optimize the model and reduce outliers in the data, thereby improving the accuracy of the model, which is conducive to solving the problem that the post-quantization accuracy of the floating-point model does not meet the requirements. When the number of training times of the target floating-point model in the current training stage reaches a preset number, a quantitative difference index and a quantitative prediction index are obtained. These two indicators are used to select core training data from the full amount of training data for the next stage of quantitative training of the target floating-point model. In this way, instead of using the full data set for quantitative training, more representative and valuable core training data are selected, the amount of training data is reduced, thereby reducing the training time cost, and solving the problem that quantitative training based on the full data set takes a long time. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 is a flowchart of a method for selecting quantitative data according to some embodiments of the present invention;
[0044] Figure 2 is a flowchart of a method for selecting quantitative data according to some embodiments of the present invention;
[0045] Figure 3 is a structural block diagram of a device for selecting quantized data according to an embodiment of the present invention;
[0046] Figure 4 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0048] According to an embodiment of the present invention, a method, device, electronic device and storage medium for selecting quantitative data are provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0049] In this embodiment, a method for selecting quantitative data is provided. Figure 1 is a flow chart of a method for selecting quantitative data according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0050] Step S101, obtaining the original floating-point model and the full amount of training data of the current training stage, wherein the original floating-point model and the full amount of training data are determined according to the business requirements associated with assisted driving or autonomous driving.
[0051] In the embodiments of this application, in the field of assisted driving or autonomous driving, specific business requirements must first be clarified. Business requirements include requirements for target detection accuracy in different scenarios, such as accurate identification and positioning of vehicles, pedestrians, traffic signs, etc.; requirements for response speed under different road conditions, such as the ability to make quick decisions in environments such as highways and urban roads; and requirements for adaptability under different weather and lighting conditions.
[0052] Determine the original floating-point model and full training data based on these business requirements. The selection of the original floating-point model can take into account the existing mature model architecture and adjust and optimize it according to the specific task. For example, if the business requirement emphasizes the detection accuracy of small targets, a model architecture with higher resolution and small receptive field may be selected. If fast inference speed is required, a lightweight model architecture may be selected.
[0053] The collection of full training data must cover a variety of possible scenarios and situations to meet business needs. This includes data collected under different weather conditions (such as sunny, rainy, snowy, etc.), data under different lighting conditions (such as day, night, dawn, dusk, etc.), data under different road conditions (such as highways, urban roads, rural roads, etc.), and data containing various types of vehicles, pedestrians, and traffic signs. By extensively collecting and organizing this data, it is ensured that the original floating-point model can learn various situations during the training process, thereby improving performance and adaptability in practical applications to meet the business needs of assisted driving or autonomous driving.
[0054] Step S102, iteratively train the original floating-point model using the full amount of training data, and perform data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model.
[0055] In an embodiment of the present application, the original floating-point model is iteratively trained using the full amount of training data, and the original floating-point model is subjected to data regularization constraint processing during the iterative training process to obtain a target floating-point model, including the following steps A1-A4:
[0056] Step A1: In each iteration, the entire training data is input into the original floating-point model to obtain the first output result.
[0057] Specifically, the full amount of training data is divided into multiple batches so that small batches can be processed during the training process to improve training efficiency. For each batch of data, it is input into the original floating-point model. The original floating-point model performs forward propagation calculations through a series of neural network layers. For example, for a convolutional neural network, the data first passes through the convolution layer for feature extraction, then increases nonlinearity through the activation function, and then may pass through the pooling layer for downsampling and other operations. Finally, the model outputs the prediction result of the input data, that is, the first output result.
[0058] Step A2: calculate the first training loss of the original floating-point model based on the first output result, and use the first training loss to update the model parameters of the original floating-point model to obtain an updated original floating-point model.
[0059] Specifically, the first output result is compared with the corresponding true label to calculate the training loss. The choice of loss function depends on the specific task. Common loss functions include mean square error (MSE), cross entropy loss, etc. For example, if it is a classification task, the cross entropy loss function can be used to calculate the difference between the class probability predicted by the model and the true class.
[0060] Use an optimization algorithm (such as stochastic gradient descent, Adam, etc.) to update the parameters of the original floating-point model according to the first training loss. Specifically, calculate the gradient of the loss function with respect to the model parameters, and then update the model parameters such as weights and biases according to the update rules of the optimization algorithm. Repeat this process multiple times until a round of iterations is completed.
[0061] Step A3, adding a range restriction loss function layer to the updated network structure of the original floating-point model, and using the range restriction loss function layer to update the first training loss to obtain an updated first training loss.
[0062] Specifically, in the updated network structure of the original floating-point model, select a suitable position to insert the range-limited loss function layer. This can be determined according to the specific structure of the model and the task requirements. For example, it can be added after the fully connected layer or after the convolutional layer. The range-limited loss function is combined with the first training loss to obtain the updated first training loss. The two loss functions can be combined in a certain proportion by weighted summation. The formula of the range-limited loss function is as follows:
[0063] L reg =∑(N+max(M|-N),0).
[0064] Step A4: Use the updated first training loss to adjust the updated original floating-point model to obtain a target floating-point model.
[0065] Specifically, the updated first training loss is used to update the parameters of the model again using the optimization algorithm. Similar to the above steps, the gradient of the updated loss function to the model parameters is calculated, and then the parameters are updated according to the update rules of the optimization algorithm. Repeat the above process and continuously adjust the parameters of the model so that the model meets the requirements of the range limit while minimizing the updated first training loss. Continue training until the model converges. The convergence criterion can be that the loss function no longer decreases significantly, or that a preset number of training rounds is reached. The final model is the target floating-point model, which meets the requirements of the range limit while maintaining a certain accuracy, and is ready for subsequent quantization training.
[0066] It should be noted that, on the one hand, by continuously iterating and using the full amount of training data, the model can fully learn the features and patterns in the data, improving the accuracy and generalization ability of the model. On the other hand, adding a range-limited loss function layer can help remove outliers, compress the data distribution range, and improve the quantization bit resolution. This can not only make the model more stable during training and reduce the adverse effects of abnormal data on the model, but also enable the model to achieve similar accuracy at lower bit quantization, preparing for subsequent quantization training.
[0067] Step S103, if the number of training times of the target floating-point model in the current training phase reaches a preset number of times, a quantization difference index and a quantization prediction index are obtained.
[0068] In the embodiment of the present application, when the target floating-point model is trained, the number of training times is continuously recorded. If the number of training times of the target floating-point model reaches a preset number in the current training phase, it is necessary to obtain a quantization difference index (usually measuring the performance difference between the quantized result and the floating-point model result) and a quantization prediction index (paying more attention to the result of the quantization prediction).
[0069] First, by using the preset calculation method and evaluation function, the quantized output results of the current target floating-point model are compared with the output results of the floating-point model to obtain the performance score of the quantization difference index, which reflects the degree of influence of the quantization operation on the model performance. At the same time, the prediction results of the quantized model are analyzed, and the performance score of the quantization prediction index is determined by considering factors such as its accuracy and reliability in different scenarios.
[0070] Step S104, selecting core training data from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
[0071] In the embodiment of the present application, first, the quantitative difference index measures the performance difference between the quantized result and the floating-point model result, while the quantitative prediction index pays more attention to the result of the quantitative prediction. When using these two indicators to select core training data from the full amount of training data, the performance of each data sample under these two indicators will be comprehensively considered. For each data point in the full amount of training data, its value under the quantitative difference index and the quantitative prediction index is calculated respectively. The data is evaluated and sorted according to these values, and those data points that perform relatively well on the two indicators are selected as core training data.
[0072] The selected core training data has better representativeness and value, and can more effectively improve the performance of the target floating-point model in the next stage of quantization training. In the subsequent quantization training, the target floating-point model will be trained mainly based on these core training data to improve training efficiency and accuracy, and converge to a better quantization model state more quickly.
[0073] The method provided in the embodiment of the present application first determines the original floating-point model and the full amount of training data according to the business needs associated with assisted driving or autonomous driving. When iteratively training the original floating-point model, adding data regularization constraint processing helps to optimize the model and reduce outliers in the data, thereby improving the accuracy of the model, which is conducive to solving the problem that the post-quantization accuracy of the floating-point model does not meet the requirements. When the number of training times of the target floating-point model in the current training stage reaches a preset number, a quantitative difference index and a quantitative prediction index are obtained. These two indicators are used to select core training data from the full amount of training data for the next stage of quantitative training of the target floating-point model. In this way, instead of using the full data set for quantitative training, more representative and valuable core training data are selected, the amount of training data is reduced, thereby reducing the training time cost, and solving the problem that quantitative training based on the full data set takes a long time.
[0074] Figure 2 is a flow chart of a method for selecting quantitative data according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0075] Step S201, obtaining the original floating-point model and the full amount of training data of the current training stage, wherein the original floating-point model and the full amount of training data are determined according to the business requirements associated with assisted driving or autonomous driving.
[0076] In the embodiment of the present application, obtaining the original floating-point model and the full amount of training data in the current training phase includes the following steps B1-B3:
[0077] Step B1: Obtain business requirements related to assisted driving or autonomous driving.
[0078] Specifically, obtain the business needs in different scenarios, such as different requirements for model performance in environments such as highways, urban roads, and rural roads. It is also necessary to consider the impact of different weather conditions (sunny, rainy, snowy, etc.) and lighting conditions (daytime, nighttime, etc.) on the system.
[0079] Determine specific performance indicators based on business needs, such as accuracy, recall, and real-time requirements. For example, for target detection tasks, it may be required to achieve a certain level of accuracy while ensuring a low false alarm rate and missed alarm rate. For path planning tasks, it may be necessary to generate a feasible path plan within a certain period of time.
[0080] Step B2: Obtain corresponding full training data according to business requirements and determine data characteristics of the full training data.
[0081] Specifically, determine the required data types based on business needs. For example: including image data (from on-board cameras), sensor data (such as lidar, millimeter-wave radar, GPS, etc.), vehicle status data (speed, acceleration, steering angle, etc.), etc. Collect a large amount of data from actual driving scenarios by collecting data at different locations, at different times, and under different weather conditions. Ensure the diversity and representativeness of the data to cover all possible situations. Organize and annotate the collected data to provide accurate label information for subsequent model training.
[0082] Analyze the data characteristics of the entire training data, including data distribution, data size, data quality, etc. For example, count the proportion of different types of data to understand whether the data is evenly distributed across different categories. You can also check the quality of the data, including whether there are problems such as noise, outliers, and missing values. For problematic data, you can clean and repair it, or take appropriate processing measures in subsequent model training. You can also analyze the correlation of the data to understand the relationship between different types of data and the impact of these relationships on model training.
[0083] Step B3, obtaining a target network structure that matches the business requirements and data characteristics from multiple network structures, and using the target network structure to build an original floating-point model.
[0084] Specifically, multiple network structures include convolutional neural networks (CNN), recurrent neural networks (RNN), long short-term memory networks (LSTM), generative adversarial networks (GAN), etc.
[0085] Analyze the characteristics and advantages of different network structures. For example, CNN is good at processing image data, RNN and LSTM are suitable for processing sequence data, GAN can be used for data generation and enhancement, etc.
[0086] According to business requirements and data characteristics, select the target network structure that matches the task. For example, if the task is image recognition, you may choose a deep convolutional neural network; if the task is time series prediction, you may choose LSTM or RNN. Consider factors such as the complexity of the network structure, computing resource requirements, and training time. Under the premise of meeting business requirements, choose a network structure that has good performance and can run efficiently in practical applications.
[0087] Use the selected target network structure to build a raw floating-point model. Building a raw floating-point model includes defining the number of network layers, the number of neurons in each layer, activation functions, connection methods, etc. Initialize the built raw floating-point model. You can use random initialization or pre-trained model initialization methods. Ensure that the model's initialization state is reasonable to avoid extreme values or unreasonable distributions.
[0088] Step S202, iteratively train the original floating-point model using the full amount of training data, and perform data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model.
[0089] In an embodiment of the present application, the original floating-point model is quantized and trained using the full amount of training data, and the original floating-point model is subjected to data regularization constraint processing during the quantization training process to obtain a target floating-point model, including the following steps C1-C3:
[0090] Step C1, adding a range-limited loss function layer to the network structure of the original floating-point model to obtain the original floating-point model after the network structure is adjusted.
[0091] Specifically, determine the specific form of the range-limited loss function. For example, when the weight or activation value of the model exceeds a certain range, a larger penalty is given. This loss function can help eliminate outliers, compress the data distribution range, and improve the quantization bit resolution. Determine the parameters in the loss function, such as the upper and lower limits of the range. These parameters can be determined through experiments or theoretical analysis.
[0092] Analyze the network structure of the original floating-point model to determine where to add the range-limited loss function layer. For example, you can add this loss function layer after the fully connected layer, after the convolutional layer, or before the output layer of the model. Use the interface provided by the deep learning framework to add the designed range-limited loss function layer to the network structure of the original floating-point model. Make sure that the loss function layer is properly connected to the rest of the model and can work properly during training.
[0093] Perform preliminary verification on the original floating-point model after adjusting the network structure to ensure that the model can run normally without errors or abnormalities. You can use a small portion of data for testing to check whether the output of the model meets expectations.
[0094] Step C2: In each iteration, the full amount of training data is input into the original floating-point model after the network structure is adjusted to obtain a second output result.
[0095] Specifically, ensure that all training data has been preprocessed. For example, image data may need to be normalized, cropped, scaled, etc. to meet the input requirements of the model. Divide the full training data into multiple batches so that small batches can be processed during training to improve training efficiency.
[0096] For each batch of data, it is input into the original floating-point model after the network structure is adjusted. The model performs forward propagation calculations through a series of neural network layers, including the newly added range-limited loss function layer. During the calculation process, the model will gradually calculate the output of each layer based on the input data and the current model parameters, and finally obtain the second output result.
[0097] Step C3, calculating the second training loss of the original floating-point model based on the second output result, and using the second training loss to update the model parameters of the original floating-point model to obtain the target floating-point model.
[0098] Specifically, the second output result is compared with the corresponding true label to calculate the training loss. The choice of loss function can be determined according to the specific task and requirements. Common loss functions include mean square error (MSE) and cross entropy loss. Since the range restriction loss function layer is added to the model, it is necessary to consider both the original loss function and the range restriction loss function when calculating the training loss. The two loss functions can be combined in a certain proportion by weighted summation.
[0099] Use an optimization algorithm (such as stochastic gradient descent, Adam, etc.) to update the parameters of the original floating-point model according to the second training loss. Specifically, calculate the gradient of the loss function to the model parameters, and then update the model parameters such as weights and biases according to the update rules of the optimization algorithm.
[0100] Repeat the above process and continuously adjust the model parameters so that the model can meet the range restriction requirements while minimizing the second training loss. Continue training until the model converges. The convergence criterion can be that the loss function no longer decreases significantly, or that the preset number of training rounds is reached. The final model is the target floating-point model, which meets the range restriction requirements while maintaining a certain accuracy, and is ready for subsequent quantization training.
[0101] It should be noted that first, a range-limited loss function layer is added to the network structure of the original floating-point model to obtain the original floating-point model after the network structure is adjusted. The advantage of doing this is that the output of the model can be constrained during the training process, outliers can be removed, and the data distribution range can be compressed, thereby improving the quantization bit resolution, so that the model can be quantized with lower bits and achieve better accuracy in the subsequent quantization process. Then, in each iteration, the full amount of training data is input into the original floating-point model after the network structure is adjusted to obtain the second output result. This ensures that the model can make full use of the full amount of data for learning, capture the data features in various situations, and improve the generalization ability of the model.
[0102] Step S203: if the number of training times of the target floating-point model in the current training phase reaches a preset number of times, a quantization difference index and a quantization prediction index are obtained.
[0103] In an embodiment of the present application, during the process of training the target floating-point model, the number of training times will be continuously recorded. If the number of training times of the target floating-point model in the current training stage reaches a preset number of times, it is necessary to start obtaining the quantization difference index and the quantization prediction index. The quantization difference index mainly measures the performance difference between the quantized result and the floating-point model result, which can reflect the specific impact of the quantization operation on the model performance. The quantization prediction index focuses more on the results of the quantization prediction, and pays attention to the prediction accuracy and reliability of the model after quantization. By obtaining these two indicators, it can provide an important basis for the subsequent selection of core training data from the full amount of training data, so as to better optimize the performance of the target floating-point model in quantization training.
[0104] Step S204, selecting core training data from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
[0105] In the embodiment of the present application, the core training data is selected from the full amount of training data using the quantitative difference index and the quantitative prediction index, including the following steps D1-D3:
[0106] Step D1, obtaining a first performance score of each data sample in the full training data under a quantitative difference index, and a second performance score of each data sample in the full training data under a quantitative prediction index.
[0107] In an embodiment of the present application, obtaining a first performance score of each data sample in the full amount of training data under a quantitative difference index, and a second performance score of each data sample in the full amount of training data under a quantitative prediction index, includes:
[0108] Step D101, obtaining a first sample output result and a true label corresponding to each data sample, and obtaining a second sample output result output by a target floating-point model based on the data sample.
[0109] Specifically, first, for each data sample in the full training data, its output results at different stages need to be determined. If the data sample was previously processed or modeled in a certain initial stage to obtain the first sample output result, and we also know the true label of the data sample. Now, when the target floating-point model is used to process this data sample, the second sample output result output by the target floating-point model will be obtained. This may involve reading the first sample output result and the true label data from the storage, as well as inputting the data sample into the target floating-point model and obtaining its output.
[0110] Step D102, based on the difference between the second sample output result corresponding to each data sample and the first sample output result corresponding to the data sample, calculate the first performance score of the data sample under the quantitative difference index.
[0111] Specifically, for each data sample, calculate its performance score under the quantitative difference index. Specifically, compare the second sample output result of the target floating-point model with the first sample output result before the data sample. This comparison can adopt different methods according to the specific task and data type, such as calculating the distance between the two, the absolute value of the difference, or other specific measurement methods. The difference value obtained by this comparison can be further converted into a performance score, which reflects the performance of the data sample under the quantitative difference index.
[0112] The calculation formula of the first performance score is as follows:
[0113]
[0114] In the formula, O ds is the first performance score under the quantitative difference index, t is the number of iterations, Output result for the second sample, Output the result for the first sample.
[0115] Step D103, based on the difference between the second sample output result corresponding to each data sample and the true label corresponding to the data sample, calculate the second performance score of the data sample under the quantitative prediction index.
[0116] Specifically, for each data sample, calculate its performance score under the quantitative prediction index. This time, compare the second sample output result of the target floating-point model with the true label corresponding to the data sample. Similarly, a metric suitable for the task can be used to calculate the difference between the two, and then calculate the second performance score of the data sample under the quantitative prediction index based on the difference value. This score reflects the degree of closeness of the prediction result of the target floating-point model for the data sample to the actual situation, and its performance under the quantitative prediction index.
[0117] The calculation formula for the second performance score is as follows:
[0118]
[0119] In the formula, O evs is the second performance score under the quantitative prediction index, t is the number of iterations, is the output result of the second sample, and y is the true label.
[0120] Step D2, using the first performance score and the second performance score of each data sample to calculate the comprehensive score corresponding to the data sample.
[0121] Specifically, the first performance score and the second performance score of each data sample are used to calculate the comprehensive score corresponding to the data sample, including: obtaining a first weight corresponding to the quantitative difference index and a second weight corresponding to the quantitative prediction index; calculating a first product between the first weight and the first performance score, and calculating a second product between the second weight and the second performance score; and summing the first product and the second product to obtain a comprehensive score.
[0122] The calculation formula of the comprehensive score is as follows:
[0123] O acs (t) = α(t) × O evs (t)+(1-α(t))×O ds (t).
[0124] In the formula, O acs (t) is the comprehensive score, O ds (t) is the first performance score, O evs (t) is the second performance score, and α(t) is the second weight corresponding to the second performance score. It should be noted that E represents the total number of training rounds (the total number of epochs). As the training progresses, t gradually increases from 0, and the value of α(t) will change with the change. In the initial stage, the t value is small, and the value of α(t) is relatively large. The main consideration is O evs (t); when t is close to E, the value of α(t) gradually decreases, and more attention is paid to O ds(t). This is to dynamically adjust the focus on different indicators at different training stages to better optimize the model.
[0125] Step D3, sorting the data samples in the full amount of training data in descending order of comprehensive scores to obtain a data sample sequence, and selecting a preset number of data samples from the starting position of the data sample sequence as core training data.
[0126] Specifically, all data samples in the full training data are sorted in descending order of comprehensive scores, thus obtaining a data sample sequence. In this sequence, data samples with high comprehensive scores are ranked in front, indicating that they perform relatively better in the two indicators. Then, starting from the starting position of this data sample sequence, a preset number of data samples are selected. This preset number can be determined based on actual needs and resource constraints. These selected data samples serve as core training data, and they will play an important role in the next stage of quantization training of the target floating-point model, because they have good performance in both quantization difference and quantization prediction, and are expected to improve the efficiency and accuracy of quantization training.
[0127] In the present embodiment, a selection device for quantitative data is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0128] This embodiment provides a device for selecting quantitative data, such as Figure 3 As shown, including:
[0129] An acquisition module 301 is used to acquire an original floating-point model and full training data of a current training phase, wherein the original floating-point model and full training data are determined according to business requirements associated with assisted driving or autonomous driving;
[0130] The training module 302 is used to perform quantization training on the original floating-point model using the full amount of training data, and perform data regularization constraint processing on the original floating-point model during the quantization training process to obtain a target floating-point model;
[0131] The processing module 303 is used to obtain a quantitative difference index and a quantitative prediction index if the number of training times of the target floating-point model in the current training phase reaches a preset number of times;
[0132] The selection module 304 is used to select core training data from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
[0133] In an embodiment of the present application, the acquisition module 301 is used to obtain business requirements related to assisted driving or autonomous driving; obtain the corresponding full training data according to the business requirements, and determine the data characteristics of the full training data; obtain a target network structure that matches the business requirements and data characteristics from multiple network structures, and use the target network structure to build an original floating-point model.
[0134] In an embodiment of the present application, the training module 302 is used to input the full amount of training data into the original floating-point model in each iteration to obtain a first output result; calculate the first training loss of the original floating-point model based on the first output result, and use the first training loss to update the model parameters of the original floating-point model to obtain an updated original floating-point model; add a range restriction loss function layer to the network structure of the updated original floating-point model, and use the range restriction loss function layer to update the first training loss to obtain an updated first training loss; use the updated first training loss to adjust the updated original floating-point model to obtain a target floating-point model.
[0135] In an embodiment of the present application, the training module 302 is used to add a range-limited loss function layer to the network structure of the original floating-point model to obtain the original floating-point model after the network structure is adjusted; in each iteration, the full amount of training data is input into the original floating-point model after the network structure is adjusted to obtain a second output result; based on the second output result, the second training loss of the original floating-point model is calculated, and the model parameters of the original floating-point model are updated using the second training loss to obtain the target floating-point model.
[0136] In an embodiment of the present application, the selection module 304 is used to obtain a first performance score of each data sample in the full training data under a quantitative difference index, and a second performance score of each data sample in the full training data under a quantitative prediction index; use the first performance score and the second performance score of each data sample to calculate the comprehensive score corresponding to the data sample; sort the data samples in the full training data in descending order of the comprehensive scores to obtain a data sample sequence, and select a preset number of data samples from the starting position of the data sample sequence as core training data.
[0137] In an embodiment of the present application, a selection module 304 is used to obtain a first sample output result and a true label corresponding to each data sample, and obtain a second sample output result based on the data sample output of the target floating-point model; based on the difference between the second sample output result corresponding to each data sample and the first sample output result corresponding to the data sample, a first performance score of the data sample under a quantitative difference index is calculated; based on the difference between the second sample output result corresponding to each data sample and the true label corresponding to the data sample, a second performance score of the data sample under a quantitative prediction index is calculated.
[0138] In an embodiment of the present application, the selection module 304 is used to obtain a first weight corresponding to the quantitative difference index and a second weight corresponding to the quantitative prediction index; calculate a first product between the first weight and the first performance score, and calculate a second product between the second weight and the second performance score; and sum the first product and the second product to obtain a comprehensive score.
[0139] See also Figure 4 , Figure 4 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 4 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.
[0140] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0141] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0142] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of a computer device based on the presentation of a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0143] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0144] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0145] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be recorded in a storage medium, or can be downloaded through a network and stored in a remote storage medium or a non-temporary machine-readable storage medium.
[0146] Computer code stored in a local storage medium, so that the methods described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0147] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for selecting quantitative data, characterized in that: The method comprises: Obtaining an original floating-point model and full training data of a current training phase, wherein the original floating-point model and full training data are determined according to business requirements associated with assisted driving or autonomous driving; Iteratively training the original floating-point model using the full amount of training data, and performing data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model; If the target floating-point model has been trained for a preset number of times in the current training phase, a quantitative difference index and a quantitative prediction index are obtained; The core training data is selected from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
2. The method according to claim 1, characterized in that The obtaining of the original floating-point model and the full amount of training data in the current training phase includes: Obtain business requirements related to assisted driving or autonomous driving; Acquire corresponding full training data according to the business requirements, and determine data characteristics of the full training data; A target network structure matching the business requirement and the data characteristics is obtained from multiple network structures, and the original floating-point model is built using the target network structure.
3. The method according to claim 1, characterized in that The iterative training of the original floating-point model using the full amount of training data, and performing data regularization constraint processing on the original floating-point model during the iterative training process to obtain a target floating-point model, includes: In each iteration, the full amount of training data is input into the original floating-point model to obtain a first output result; Calculating a first training loss of the original floating-point model based on the first output result, and updating a model parameter of the original floating-point model using the first training loss to obtain an updated original floating-point model; Adding a range-limited loss function layer to the updated network structure of the original floating-point model, and using the range-limited loss function layer to update the first training loss to obtain an updated first training loss; The updated original floating-point model is adjusted using the updated first training loss to obtain the target floating-point model.
4. The method according to claim 1, characterized in that: The method of using the full amount of training data to perform quantization training on the original floating-point model, and performing data regularization constraint processing on the original floating-point model during the quantization training process to obtain a target floating-point model includes: Adding a range-limited loss function layer to the network structure of the original floating-point model to obtain the original floating-point model after the network structure is adjusted; In each iteration, the full amount of training data is input into the original floating-point model after the network structure is adjusted to obtain a second output result; A second training loss of the original floating-point model is calculated based on the second output result, and the model parameters of the original floating-point model are updated using the second training loss to obtain the target floating-point model.
5. The method according to claim 1, characterized in that: The selecting core training data from the full amount of training data using the quantitative difference index and the quantitative prediction index includes: Obtaining a first performance score of each data sample in the full amount of training data under the quantitative difference index, and a second performance score of each data sample in the full amount of training data under the quantitative prediction index; Calculating a comprehensive score corresponding to each data sample using the first performance score and the second performance score of the data sample; The data samples in the full amount of training data are sorted in descending order of the comprehensive scores to obtain a data sample sequence, and a preset number of data samples are selected from the starting position of the data sample sequence as the core training data.
6. The method according to claim 5, characterized in that The obtaining of a first performance score of each data sample in the full amount of training data under the quantitative difference index and a second performance score of each data sample in the full amount of training data under the quantitative prediction index comprises: Obtain a first sample output result and a true label corresponding to each data sample, and obtain a second sample output result output by the target floating-point model based on the data sample; Calculate a first performance score of the data sample under the quantitative difference index based on the difference between the second sample output result corresponding to each data sample and the first sample output result corresponding to the data sample; Based on the difference between the second sample output result corresponding to each data sample and the true label corresponding to the data sample, a second performance score of the data sample under the quantitative prediction index is calculated.
7. The method according to claim 5, characterized in that Calculating a comprehensive score corresponding to each data sample using the first performance score and the second performance score of the data sample includes: Obtaining a first weight corresponding to the quantitative difference index and a second weight corresponding to the quantitative prediction index; calculating a first product between the first weight and the first performance score, and calculating a second product between the second weight and the second performance score; The comprehensive score is obtained by summing the first product and the second product.
8. A device for selecting quantitative data, characterized in that: The device comprises: An acquisition module, used to acquire an original floating-point model and full training data of a current training phase, wherein the original floating-point model and full training data are determined according to business requirements associated with assisted driving or autonomous driving; A training module, used to perform quantization training on the original floating-point model using the full amount of training data, and perform data regularization constraint processing on the original floating-point model during the quantization training process to obtain a target floating-point model; A processing module, configured to obtain a quantitative difference index and a quantitative prediction index if the number of training times of the target floating-point model in the current training phase reaches a preset number of times; A selection module is used to select core training data from the full amount of training data using the quantization difference index and the quantization prediction index, wherein the core training data is used for the next stage of quantization training of the target floating-point model.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.