Model training method, control device and computer-readable storage medium
By creating a second linear model from a pre-trained first linear model and performing feature filling in the vehicle driving risk assessment model, the problem of mismatched feature fields from different vehicle data sources is solved, enabling rapid model migration and performance evaluation with higher feature dimensions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 北京宏瓴科技发展有限公司
- Filing Date
- 2023-07-03
- Publication Date
- 2026-05-26
AI Technical Summary
In vehicle driving risk assessment models, there is a problem of mismatched feature fields from different vehicle data sources, which makes model migration difficult and time-consuming, and discarding feature fields will affect the assessment results.
By acquiring a pre-trained first linear model, a second linear model is created based on it. The first dataset is then padded with features to match the number of feature fields in the second dataset. The second linear model is then trained, and the model is transferred to the padded dataset for training. Different learning rates are frozen and set to optimize the training process.
It enables rapid model migration, improves the performance of feature dimensions in vehicle driving risk assessment, and can effectively evaluate vehicle data sources with more feature fields.
Smart Images

Figure CN116701942B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning technology, specifically providing a model training method, a control device, and a computer-readable storage medium. Background Technology
[0002] When building a model to assess vehicle driving risk, there are often situations where different vehicles have different data sources. For example, vehicle A might have data with 30 feature fields, while vehicle B might have data with 30+20 feature fields. This would result in a linear model M1 trained on the data from vehicle A having 30 input feature fields. If you need to use the M1 model to predict the driving risk score for vehicle B, there are two methods:
[0003] 1. Retraining a model M2 with 50 input feature fields presents a problem: in practice, there is often not enough data to support retraining M2, and even if there is enough data, the training process is very time-consuming.
[0004] 2. Discard the 20 extra feature fields for vehicle B. Here's another issue: the discarded feature fields could actually improve the model's evaluation performance.
[0005] Therefore, how to quickly transfer models while also more effectively assessing vehicle driving risks is a problem that needs to be solved in this field. Summary of the Invention
[0006] To overcome the above-mentioned shortcomings, this invention is proposed to provide a solution, or at least a partial solution, to the problem of how to ensure the evaluation effect of the model while ensuring rapid model transfer.
[0007] In a first aspect, the present invention provides a model training method, the method comprising:
[0008] Obtain the first trained linear model; wherein the first linear model is trained based on the first dataset, the number of feature fields of the first dataset is G, and the feature dimension of the first linear model is G;
[0009] Based on the first linear model, a second linear model is created; wherein the second linear model has an input feature dimension of N, and G is less than N;
[0010] The first dataset is padded with features so that the number of feature fields in the first dataset is N;
[0011] The second linear model is trained using the first and second datasets after feature padding to obtain a trained second linear model; wherein the number of feature fields in the second dataset is N.
[0012] In one technical solution of the above model training method, the step of creating a second linear model based on the first linear model includes:
[0013] The model parameters of the trained first linear model are loaded into the second linear model, wherein the loaded model parameters are G-dimensional;
[0014] The model parameters of the unloaded NG dimension in the second linear model are assigned values to achieve the creation of the second linear model.
[0015] In one technical solution of the above model training method, before training the second linear model on the first and second datasets after feature filling, the method further includes:
[0016] Freeze the G-dimensional model parameters loaded from the first linear model in the second linear model.
[0017] In one technical solution of the above model training method, before training the second linear model on the first and second datasets after feature filling, the method further includes:
[0018] Set a first learning rate for the G-dimensional model parameters loaded from the first linear model in the second linear model;
[0019] Set a second learning rate for the NG-dimensional model parameters that are assigned values in the second linear model;
[0020] Wherein, the first learning rate is less than the second learning rate.
[0021] In one technical solution of the above model training method, the second linear model is trained using the first and second datasets after feature filling, including:
[0022] The second dataset is preprocessed;
[0023] The second linear model is trained using the first dataset after feature filling and the second dataset after preprocessing.
[0024] When the convergence condition is met, training ends to obtain a well-trained second linear model.
[0025] In one technical solution of the above model training method, training the second linear model using the first dataset after feature filling and the preprocessed second dataset includes:
[0026] For each iteration of the training, the first dataset after feature filling and the second dataset after preprocessing are input into the second linear model to obtain the model prediction result for the current iteration;
[0027] Based on the model's prediction results, obtain the loss for the current iteration;
[0028] Based on the backpropagation of the loss from the current iteration, the model parameters of the second linear model are optimized to achieve the training of the second linear model.
[0029] In one technical solution of the above model training method, the preprocessing of the second dataset includes:
[0030] Perform data cleaning on the second dataset;
[0031] Feature engineering is performed on the cleaned second dataset to achieve preprocessing of the second dataset.
[0032] In one technical solution of the above model training method, the first linear model and the second linear model are vehicle driving risk assessment models;
[0033] The first dataset and the second dataset were obtained from data sources collected from different vehicles.
[0034] In a second aspect, a control device is provided, comprising at least one processor and at least one storage device, the storage device being adapted to store a plurality of program codes, the program codes being adapted to be loaded and run by the processor to perform the model training method described in any of the above-described technical solutions.
[0035] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored therein, the program codes being adapted to be loaded and run by a processor to perform the model training method described in any of the above-described technical solutions.
[0036] The present invention comprises one or more of the following technical solutions:
[0037] Beneficial effects:
[0038] In implementing the technical solution of this invention, a trained first linear model is obtained, and a second linear model is created based on the first linear model, wherein the feature dimension of the second linear model is greater than that of the first linear model. After feature imputation on the first dataset used to train the first linear model, the second linear model is trained using the imputed first dataset and the second dataset, thereby obtaining a trained second linear model, wherein the number of feature fields in the second dataset is the same as the feature dimension of the second linear model.
[0039] Through the above configuration, this invention enables rapid transfer from a first linear model to a second linear model. Furthermore, since the second linear model is trained on both the padded first and second datasets, it utilizes a dataset with a greater number of feature fields, achieving higher performance across more feature dimensions. For example, in vehicle driving risk assessment, it can evaluate vehicle data sources with a higher number of feature fields. Attached Figure Description
[0040] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Wherein:
[0041] Figure 1 This is a schematic diagram of the main steps of a model training method according to an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the main steps of a real-number model training method according to an embodiment of the present invention. Detailed Implementation
[0043] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0044] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.
[0045] In one application scenario of this invention, when building a vehicle driving risk model, different vehicles often have different data sources. For example, vehicle A's data may contain 30 feature fields, while vehicle B's data may contain 30+20 feature fields. This means that a linear model trained on vehicle A's data cannot fully utilize all the data collected from vehicle B.
[0046] See appendix Figure 1 , Figure 1 This is a schematic flowchart illustrating the main steps of a model training method according to an embodiment of the present invention. Figure 1 As shown, the model training method in this embodiment of the invention mainly includes the following steps S101-S104.
[0047] Step S101: Obtain the trained first linear model; wherein, the first linear model is trained based on the first dataset, the number of feature fields of the first dataset is G, and the feature dimension of the first linear model is G.
[0048] In this embodiment, a first linear model can be obtained by training based on a first dataset. The number of feature fields in the first dataset is G, and the feature dimension of the first linear model is G. Wherein, G is a positive integer.
[0049] In one implementation, the first dataset can be a dataset built from a data source based on vehicle data collection.
[0050] For example, vehicle A has data collected from a data source containing G feature fields. The number of feature fields in the first dataset constructed based on the data source collected from vehicle A is G, and the feature dimension of the first linear model trained based on the first dataset is also G.
[0051] In one implementation, the first linear model can be a vehicle driving risk assessment model used to evaluate the driving risk of vehicles corresponding to the first dataset.
[0052] Step S102: Based on the first linear model, create a second linear model; wherein the second linear model has an input feature dimension of N, and G is less than N.
[0053] In this embodiment, a second linear model can be created based on the first linear model, wherein the feature dimension of the second linear model is greater than that of the first linear model. Here, N is a positive integer.
[0054] In one implementation, the second linear model can be a vehicle driving risk assessment model used to evaluate the driving risk of vehicles corresponding to the second dataset.
[0055] Step S103: Perform feature padding on the first dataset so that the number of feature fields in the first dataset is N.
[0056] In this embodiment, the first dataset can be filled with features so that the number of feature fields in the first dataset reaches N.
[0057] In one implementation, the first dataset can be padded with zeros to make the number of feature fields in the first dataset reach N. For example, if the first dataset has 30 feature fields and the second linear model has a feature dimension of 50, then the feature fields of the first dataset can be padded with zeros to make the number of feature fields in the first dataset reach 50.
[0058] Step S104: Apply the first and second datasets after feature filling to train the second linear model to obtain the trained second linear model; wherein, the number of feature fields in the second dataset is N.
[0059] In this embodiment, the second linear model can be trained using the first and second datasets after feature padding, thereby obtaining a trained second linear model. The number of feature fields in both the first and second datasets after feature padding is N.
[0060] In one implementation, the second dataset can be a dataset built from a data source based on vehicle data collection.
[0061] For example, if vehicle B's data source consists of data with N feature fields, the number of feature fields in the second dataset constructed based on the data source from vehicle B is also N. The feature dimension of the second linear model trained on the first and second datasets after feature padding is also N. This second linear model can quickly transfer the performance of the first linear model. Furthermore, training on the first and second datasets after feature padding allows the second linear model to effectively evaluate the data source information from vehicle B while maintaining the performance of the first linear model.
[0062] Based on steps S101-S104 above, this embodiment of the invention obtains a trained first linear model, and creates a second linear model based on the first linear model, wherein the feature dimension of the second linear model is greater than that of the first linear model. After feature padding of the first dataset used to train the first linear model, the second linear model is trained using the padded first and second datasets, thereby obtaining a trained second linear model, wherein the number of feature fields in the second dataset is the same as the feature dimension of the second linear model. Through the above configuration, this embodiment of the invention can quickly transfer from the first linear model to obtain the second linear model. Furthermore, since the second linear model is obtained by training on the padded first and second datasets, it uses a dataset with a larger number of feature fields for training, achieving higher feature dimension performance. For example, in vehicle driving risk assessment, it can evaluate vehicle data sources with a higher number of feature fields.
[0063] The following provides a further explanation of steps S103 and S104.
[0064] In one embodiment of the present invention, step S103 may further include steps S1031 and S1032:
[0065] Step S1031: Load the model parameters of the trained first linear model into the second linear model, wherein the loaded model parameters are G-dimensional.
[0066] Step S1032: Assign values to the unloaded NG-dimensional model parameters in the second linear model to create the second linear model.
[0067] In this embodiment, the G-dimensional model parameters of the trained first linear model can be loaded into the second linear model, and the unloaded NG-dimensional model parameters in the second linear model can be assigned values, thereby creating the second linear model. This allows the second linear model to achieve the performance of the first linear model.
[0068] In one implementation, the unloaded NG-dimensional model parameters in the second linear model can be assigned values through random initialization.
[0069] In one implementation, other assignment methods can be selected to assign values to the unloaded NG-dimensional model parameters in the second linear model, depending on the actual application requirements.
[0070] In one embodiment, prior to step S104, the invention further includes the following step S105:
[0071] Step S105: Freeze the G-dimensional model parameters loaded from the first linear model in the second linear model.
[0072] In this embodiment, since the first linear model is already trained, the G-dimensional model parameters loaded from the first linear model can be frozen before training the second linear model. That is, the gradient of the G-dimensional model parameters loaded from the first linear model can be set to 0, and these G-dimensional model parameters will not be updated during the training of the second linear model. This effectively reduces the training time of the second linear model.
[0073] In another embodiment, prior to step S104, the present invention further includes steps S106 and S107:
[0074] Step S106: Set the first learning rate for the G-dimensional model parameters loaded from the first linear model in the second linear model.
[0075] Step S107: Set a second learning rate for the NG-dimensional model parameters to be assigned in the second linear model; wherein the first learning rate is less than the second learning rate.
[0076] In this embodiment, since the first linear model has already been trained, before training the second linear model, a smaller learning rate (first learning rate) can be set for the G-dimensional model parameters loaded from the first linear model, and a larger learning rate (second learning rate) can be set for the NG-dimensional model parameters to be assigned values. This can effectively reduce the training time of the model during the training of the second linear model.
[0077] In one embodiment of the present invention, step S104 may further include steps S1041 to S1043:
[0078] Step S1041: Preprocess the second dataset.
[0079] In this embodiment, step S1041 may further include the following steps S10411 and S10412:
[0080] Step S10411: Perform data cleaning on the second dataset.
[0081] Step S10412: Perform feature engineering on the cleaned second dataset to achieve preprocessing of the second dataset.
[0082] In this embodiment, the second dataset can be cleaned to remove false positives and other data. Then, feature engineering is performed on the cleaned second dataset, involving data processing, feature extraction, feature construction, and feature selection to obtain model input data suitable for the second linear model.
[0083] Step S1042: Apply the first dataset after feature filling and the second dataset after preprocessing to train the second linear model.
[0084] In this embodiment, step S1042 may further include steps S10421 to S10423:
[0085] Step S10421: For each iteration of training, input the first dataset after feature filling and the second dataset after preprocessing into the second linear model to obtain the model prediction result of the current iteration.
[0086] Step S10422: Obtain the loss for the current iteration based on the model prediction results.
[0087] Step S10423: Backpropagate the loss from the current iteration to optimize the model parameters of the second linear model in order to train the second linear model.
[0088] In this embodiment, in each iteration of the training of the second linear model, the first dataset after feature filling and the second dataset after preprocessing can be input into the second linear model to obtain the model prediction result of the current iteration. The loss of the current iteration is calculated based on the model prediction result, and the model parameters of the second linear model are updated according to the backpropagation of the loss, thereby realizing the training of the second linear model.
[0089] Step S1043: When the convergence condition is met, end the training to obtain the trained second linear model.
[0090] In this implementation, it can be determined whether the model meets the convergence condition. If the convergence condition is met, the training can be terminated, thereby obtaining the trained second linear model.
[0091] In one implementation, the convergence condition can be that the loss of the iteration is less than a preset loss threshold.
[0092] In one implementation, the convergence condition can be that the number of iterations has reached a preset threshold.
[0093] In one implementation, the convergence condition is that the change in weight between two iterations is less than a preset change threshold.
[0094] It should be noted that those skilled in the art can set the values of the loss threshold, the number of times threshold, and the change threshold according to the needs of actual applications, and these are within the protection scope of this invention.
[0095] In one implementation, see Appendix Figure 2 , Figure 2 This is a schematic flowchart illustrating the main steps of a real-number model training method according to an embodiment of the present invention. Figure 2 As shown, the model training method may include: obtaining data A (first dataset) and data B (second dataset) from a vehicle trip database; filling features in data A to complete the training of model M1 (first linear model) (e.g., input feature dimension 30); cleaning data B and performing feature engineering; creating model M (second linear model) (e.g., input feature dimension 50); loading model M1 parameters into the parameter part of model M, and randomly initializing the remaining parameters; training the model and calculating the loss; backpropagating to optimize the model; determining whether the model training is complete; if not, continuing to execute the "training model and calculating loss" step; if yes, saving the model.
[0096] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.
[0097] Those skilled in the art will understand that all or part of the processes in the method of the above embodiment of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.
[0098] Furthermore, the present invention also provides a control device. In one embodiment of the control device according to the present invention, the control device includes a processor and a storage device. The storage device can be configured to store a program for executing the model training method of the above-described method embodiments, and the processor can be configured to execute the program in the storage device. The program includes, but is not limited to, the program for executing the model training method of the above-described method embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The control device can be a control device device comprising various electronic devices.
[0099] In embodiments of the present invention, the control device may be a control device device comprising various electronic devices. In some possible implementations, the control device may include multiple storage devices and multiple processors. The program executing the model training method of the above method embodiments can be divided into multiple subroutines, each subroutine can be loaded and run by a processor to execute different steps of the model training method of the above method embodiments. Specifically, each subroutine can be stored in different storage devices, and each processor can be configured to execute programs in one or more storage devices to jointly implement the model training method of the above method embodiments, that is, each processor executes different steps of the model training method of the above method embodiments to jointly implement the model training method of the above method embodiments.
[0100] The aforementioned multiple processors can be processors deployed on the same device. For example, the aforementioned control device can be a high-performance device composed of multiple processors, and the aforementioned multiple processors can be processors configured on that high-performance device. Alternatively, the aforementioned multiple processors can also be processors deployed on different devices. For example, the aforementioned control device can be a server cluster, and the aforementioned multiple processors can be processors on different servers within the server cluster.
[0101] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program for performing the model training method of the above-described method embodiments, the program being loaded and run by a processor to implement the above-described model training method. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device comprising various electronic devices; optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.
[0102] Furthermore, it should be understood that since the various modules are only provided to illustrate the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the processor's software, a part of its hardware, or a combination of software and hardware. Therefore, the number of modules shown in the figures is merely illustrative.
[0103] Those skilled in the art will understand that the various modules in the device can be adaptively split or combined. Such splitting or combining of specific modules will not cause the technical solution to deviate from the principles of the present invention; therefore, the technical solutions after splitting or combining will fall within the protection scope of the present invention.
[0104] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A method for assessing vehicle driving risks, characterized in that, The method includes: Obtain a trained first linear model; wherein the first linear model is trained based on a first dataset, the first dataset is a dataset established based on data sources collected from vehicles, the number of feature fields of the first dataset is G, and the first linear model is a vehicle driving risk assessment model used to evaluate the driving risk of the vehicles corresponding to the first dataset; the feature dimension of the first linear model is G. Based on the first linear model, a second linear model is created; wherein, the second linear model is a vehicle driving risk assessment model used to evaluate the driving risk of vehicles corresponding to the second dataset; the input feature dimension of the second linear model is N, and G is less than N; The first dataset is padded with features so that the number of feature fields in the first dataset is N; The second linear model is trained using the first and second datasets after feature imputation to obtain a trained second linear model; wherein, the second dataset is a dataset established based on data sources collected from vehicles; the number of feature fields in the second dataset is N; The trained second linear model is used to assess vehicle driving risks.
2. The vehicle driving risk assessment method according to claim 1, characterized in that, The step of creating a second linear model based on the first linear model includes: The model parameters of the trained first linear model are loaded into the second linear model, wherein the loaded model parameters are G-dimensional; The model parameters of the unloaded NG dimension in the second linear model are assigned values to achieve the creation of the second linear model.
3. The vehicle driving risk assessment method according to claim 2, characterized in that, Before training the second linear model on the first and second datasets after feature padding, the method further includes: Freeze the G-dimensional model parameters loaded from the first linear model in the second linear model.
4. The vehicle driving risk assessment method according to claim 2, characterized in that, Before training the second linear model on the first and second datasets after feature padding, the method further includes: Set a first learning rate for the G-dimensional model parameters loaded from the first linear model in the second linear model; Set a second learning rate for the NG-dimensional model parameters that are assigned values in the second linear model; Wherein, the first learning rate is less than the second learning rate.
5. The vehicle driving risk assessment method according to claim 1, characterized in that, The first and second datasets, after feature filling, are used to train the second linear model, including: The second dataset is preprocessed; The second linear model is trained using the first dataset after feature filling and the second dataset after preprocessing. When the convergence condition is met, training ends to obtain a well-trained second linear model.
6. The vehicle driving risk assessment method according to claim 5, characterized in that, The second linear model is trained using the first dataset after feature filling and the second dataset after preprocessing, including: For each iteration of the training, the first dataset after feature filling and the second dataset after preprocessing are input into the second linear model to obtain the model prediction result for the current iteration; Based on the model's prediction results, obtain the loss for the current iteration; Based on the backpropagation of the loss from the current iteration, the model parameters of the second linear model are optimized to achieve the training of the second linear model.
7. The vehicle driving risk assessment method according to claim 5, characterized in that, The preprocessing of the second dataset includes: Perform data cleaning on the second dataset; Feature engineering is performed on the cleaned second dataset to achieve preprocessing of the second dataset.
8. The vehicle driving risk assessment method according to any one of claims 1 to 7, characterized in that, The first linear model and the second linear model are vehicle driving risk assessment models; The first dataset and the second dataset were obtained from data sources collected from different vehicles.
9. A control device comprising at least one processor and at least one storage device, said storage device being adapted to store a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by the processor to perform the vehicle driving risk assessment method according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by a processor to perform the vehicle driving risk assessment method according to any one of claims 1 to 8.