Model training method and device, equipment and medium

By dynamically adjusting the learning rate and gradient information, the problem of model training time and low accuracy caused by fixed learning rate in traditional methods is solved, and a more efficient and accurate model training process is achieved.

CN119227836AInactive Publication Date: 2024-12-31WUHAN DAMENG DATABASE

Patent Information

Application Number
CN202411363321.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-31
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When traditional database integrated machine learning methods deal with large-scale data sets and non-stationary data sets, the fixed learning rate makes the model training time-consuming and unable to adapt to data changes in time, resulting in low model accuracy and efficiency.

Method used

By obtaining model requirements information, create the model to be trained, the initial parameter auxiliary table and the initial training state table, dynamically adjust the learning rate based on the loss function and gradient information, until the training end condition is met, and the adaptive training of the model is realized.

Benefits of technology

It improves the accuracy and efficiency of model training, enhances the stability and adaptability to outliers and noises, and enables the model to converge to the optimal solution faster and more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119227836A_ABST
    Figure CN119227836A_ABST
Patent Text Reader

Abstract

The invention discloses a model training method and device, equipment and a medium, and the method comprises the steps: obtaining model demand information, and creating a to-be-trained model, an initial parameter auxiliary table and an initial training state table based on the model demand information; training the to-be-trained model according to a preset data set, the initial parameter auxiliary table and the initial training state table, and determining a current loss function and a deviation parameter of the training; updating the initial training state table based on the deviation parameter to obtain a next training state table; according to the current loss function, determining dynamic gradient information and combining with a preset fluctuation threshold to update the initial parameter auxiliary table; and performing iterative training on the to-be-trained model according to the next training state table and the next parameter auxiliary table until a training ending condition is met, and obtaining a final training model. The training process is recorded in the table, the parameter dynamic gradient information and the change condition of the loss function are determined for dynamic adjustment, the parameters are adjusted in a self-adaptive mode, and the training speed and the model accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a model training method, device, equipment and medium. Background Art

[0002] Gradient descent is a commonly used optimization algorithm in machine learning. The principle is to achieve the optimization algorithm of updating model parameters by minimizing the loss function. In the traditional method, the learning rate specified by the user determines the step size of each parameter update. In each iteration, the gradient of the loss function for each parameter is calculated, and the gradient is propagated to the input layer by back propagation to guide the parameter update process of gradient descent to reduce the value of the loss function.

[0003] Nowadays, when manufacturers use traditional methods to process large-scale data sets and non-stationary data sets, they add the learning rate as a fixed hyperparameter value to the training initialization parameters, and the step size of each iteration is also fixed.

[0004] Therefore, traditional database-integrated machine learning methods are usually time-consuming and unable to adapt to changes in training data in a timely manner when processing large-scale and non-stationary data sets. Due to the fixed learning rate, offline parameter update, and offline data set batch processing of traditional methods, the learning rate of the initialization parameters may not be applicable to the original data set or subsequent incremental data. Machine learning cannot adjust model parameters and adapt to data changes in real time, resulting in low accuracy and efficiency of the final trained model in these cases. Summary of the invention

[0005] The present invention provides a model training method, device, equipment and medium to achieve dynamic adjustment of the learning rate, thereby improving the accuracy and efficiency of model training.

[0006] According to a first aspect of the present invention, a model training method is provided, comprising:

[0007] Obtain model requirement information, and create a model to be trained, an initial parameter auxiliary table, and an initial training status table based on the model requirement information;

[0008] Train the model to be trained according to the preset data set, the initial parameter auxiliary table and the initial training state table, and determine the current loss function and deviation parameters of this training;

[0009] Update the initial training state table based on the deviation parameter to obtain a next training state table;

[0010] According to the current loss function, dynamic gradient information is determined and combined with a preset fluctuation threshold to update the initial parameter auxiliary table to obtain a next parameter auxiliary table;

[0011] The model to be trained is iteratively trained according to the next training state table and the next parameter auxiliary table until a training end condition is met to obtain a final training model.

[0012] According to a second aspect of the present invention, there is provided a model training device, comprising:

[0013] A table construction module is used to obtain model requirement information and create a model to be trained, an initial parameter auxiliary table and an initial training status table based on the model requirement information;

[0014] A parameter determination module is used to train the model to be trained according to a preset data set, the initial parameter auxiliary table and the initial training state table, and determine the current loss function and deviation parameters of this training;

[0015] A first updating module, configured to update the initial training state table based on the deviation parameter to obtain a next training state table;

[0016] A second updating module is used to determine the dynamic gradient information according to the current loss function and update the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain a next parameter auxiliary table;

[0017] The model determination module is used to iteratively train the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain a final training model.

[0018] According to a third aspect of the present invention, there is provided an electronic device, the electronic device comprising:

[0019] at least one processor; and

[0020] a memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the model training method described in any embodiment of the present invention.

[0022] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the model training method of any embodiment of the present invention when executed by a processor.

[0023] The technical solution of the embodiment of the present invention obtains model requirement information, and creates a model to be trained, an initial parameter auxiliary table and an initial training state table based on the model requirement information; trains the model to be trained according to a preset data set, an initial parameter auxiliary table and an initial training state table, and determines the current loss function and deviation parameter of this training; updates the initial training state table based on the deviation parameter to obtain the next training state table; determines the dynamic gradient information according to the current loss function and updates the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain the next parameter auxiliary table; iteratively trains the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain the final training model. By recording the training process in a table, the model training situation can be observed more intuitively, and the parameters can be dynamically adjusted by determining the changes in the dynamic gradient information of the parameters and the loss function, and the parameters can be adaptively adjusted, so as to converge to the optimal solution more efficiently, thereby improving the training speed. The dynamic gradient also has strong stability and adaptability to outliers and noise, so that the model can maintain good accuracy and reliability without being seriously affected by these interference factors, thereby improving the accuracy of the model.

[0024] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0026] Figure 1 is a flowchart of a model training method provided according to Embodiment 1 of the present invention;

[0027] Figure 2 is a flow chart of a model training method provided according to Embodiment 2 of the present invention;

[0028] Figure 3 is a structural schematic diagram of a model training device provided according to Embodiment 3 of the present invention;

[0029] Figure 4 It is a schematic diagram of the structure of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme 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 only 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0032] Embodiment 1

[0033] Figure 1 A flowchart of a model training method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where a database performs model training. The method can be performed by a model training device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device. The method can be performed in a server of the database.

[0034] like Figure 1 As shown, the method includes:

[0035] S110, obtaining model requirement information, and creating a model to be trained, an initial parameter auxiliary table, and an initial training status table based on the model requirement information.

[0036] In this embodiment, the model requirement information can be understood as the requirements for setting the characteristics and goals of the data on which the training model is based, such as defining scenarios and business requirements. The model to be trained can be understood as a model adapted to the model requirements. The initial parameter auxiliary table can be understood as a table for recording the initial parameters required for the training model. The initial training state table can be understood as a table for recording the initialization of the training state.

[0037] Specifically, the processor of the database server can receive the set model requirement information, and the processor can create a model to be trained based on the model requirement information. For example, the processor can select a suitable machine learning model (such as a random forest, support vector machine, linear regression, logistic regression, etc., which includes a gradient descent algorithm) according to the business requirements and data features in the model requirement information, and create an initial parameter auxiliary table for recording the parameters of the model to be trained and an initial training state table for the results of each training. Among them, an initial parameter auxiliary table matching each model to be trained can be pre-set, and the initial parameter auxiliary table has initial parameter values.

[0038] S120, training the model to be trained according to the preset data set, the initial parameter auxiliary table and the initial training state table, and determining the current loss function and deviation parameters of this training.

[0039] In this embodiment, the preset data set can be understood as a pre-set set for model training, which can be a large-scale data set or a non-stationary data set. It can be in the form of pre-import, or it can be input together with the model requirement information, or by selecting and extracting the table data already stored in the database. For example, the processor can import the data set into the database, or use a database query language (such as SQL language) to select and extract specific table data (for example, using operators such as WHERE clauses or JOIN connections to filter and connect tables in the database to obtain the required data). The processor can divide the data into different data subsets such as training sets, validation sets, and test sets according to the characteristics and goals of the data to meet the needs of subsequent machine learning tasks.

[0040] In this embodiment, the current loss function can be understood as a parameter used to characterize the difference between the predicted value and the true value of the model to be trained, and is used to guide the training and optimization of the model. The deviation parameter can be understood as a parameter used to characterize the effect of the model to be trained, for example, it can include a loss rate and an error value.

[0041] Specifically, the processor can query and select a preset data set that best matches the model requirement information in the database. The initial parameter values ​​are loaded into the memory through the initial parameter auxiliary table as the initial state of the model to be trained. After the model to be trained is initialized, the initialized model to be trained can be trained through the preset data set, and the current loss function is calculated for the predicted value obtained by this training through the preset loss function algorithm (such as the mean square error loss function or other loss function). The deviation parameter is determined by comparing the predicted value with the actual label in the preset data set.

[0042] Exemplarily, taking a specific parameter auxiliary table as an example, the contents contained in the parameter auxiliary table are displayed, as shown in Table 1, which includes.

[0043] Table 1: Parameter auxiliary table

[0044]

[0045]

[0046] In the table, the leftmost column is the parameters for model training, the second column is the corresponding parameter values, the third column is the time when the parameters were created, and the fourth column is the update time corresponding to the current parameter values.

[0047] S130: Update the initial training state table based on the deviation parameter to obtain the next training state table.

[0048] In this embodiment, the next training state table can be understood as a training state table after recording the results of this training.

[0049] Specifically, the processor may update the initial training state table based on the number of training times, end time, and deviation parameters of this training, record the result of this training, and obtain the next training state table.

[0050] Exemplarily, the initial training status table includes a number column, a deviation parameter column, a training time column and a training status column. The number column records each training and the cumulative number of training times. The deviation parameter column records the deviation parameter of each training. The training status column records the success or failure of each training. By recording the results of each training in the form of a table, you can more intuitively see the training process and the changes in model accuracy. The deviation parameter can be represented by a loss function or an error value. This training corresponds to the first training, then the number column is 1, the loss function corresponds to 0.123, the deviation parameter column is 0.123, the end time of the training is 00:01:30, the loss function of this training does not reach the loss threshold, the training fails, and the training status is Failure False.

[0051] S140. According to the current loss function, determine the dynamic gradient information and update the initial parameter auxiliary table in combination with the preset fluctuation threshold to obtain the next parameter auxiliary table.

[0052] In this embodiment, the preset fluctuation threshold can be understood as a threshold for judging the fluctuation of the loss function, and different preset fluctuation thresholds can be set for each model to be trained. The preset fluctuation threshold can be determined by the specific model characteristics, performance and convergence. For example, in the current machine learning using pytorch gradient clipping, it is necessary to set the maximum threshold of the gradient norm (L2 norm, a parameter used to limit gradient explosion), and the preset fluctuation threshold is proportional to the complexity of the model. The next parameter auxiliary table can be understood as an auxiliary table for recording the updated parameters obtained after this training. Dynamic gradient information can be understood as information determined by comprehensively analyzing the gradient changes corresponding to the historical loss function, for example, it can include the first-order momentum and second-order momentum of the gradient.

[0053] Specifically, the processor can determine the learning rate based on the current loss function, update the parameters used by the model to be trained this time through the learning rate and the preset fluctuation threshold, determine the new parameters and update the initial parameter auxiliary table to obtain the next parameter auxiliary table.

[0054] S150, iteratively train the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain the final training model.

[0055] In this embodiment, the training end condition can be understood as a condition for stopping training, such as a final threshold of a deviation parameter, a maximum training time, or a maximum number of iterations, etc. The final training model can be understood as a model that meets the model requirements after training.

[0056] Specifically, the processor can determine whether to end training based on the next training status table. If not, the training model is set according to the updated parameters corresponding to the next parameter auxiliary table, and the gradient is calculated by backpropagation, and returns to step 120 for iterative training until the training end conditions are met to obtain the final training model.

[0057] The technical solution of the embodiment of the present invention obtains model requirement information, and creates a model to be trained, an initial parameter auxiliary table and an initial training state table based on the model requirement information; trains the model to be trained according to a preset data set, an initial parameter auxiliary table and an initial training state table, and determines the current loss function and deviation parameter of this training; updates the initial training state table based on the deviation parameter to obtain the next training state table; determines the dynamic gradient information according to the current loss function and updates the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain the next parameter auxiliary table; iteratively trains the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain the final training model. By recording the training process in a table, the model training situation can be observed more intuitively, and the parameters can be dynamically adjusted by determining the changes in the dynamic gradient information of the parameters and the loss function, and the parameters can be adaptively adjusted, so as to converge to the optimal solution more efficiently, thereby improving the training speed. The dynamic gradient also has strong stability and adaptability to outliers and noise, so that the model can maintain good accuracy and reliability without being seriously affected by these interference factors, thereby improving the accuracy of the model.

[0058] As a first optional embodiment of the first embodiment, based on the above embodiment, it also includes:

[0059] Receive an SQL modification statement; and modify corresponding parameter values ​​in a next parameter auxiliary table or an initial parameter auxiliary table based on the SQL modification statement.

[0060] In this embodiment, the Structured Query Language (SQL) modification statement can be understood as a statement used to modify model training parameters.

[0061] It can be known that the name of the parameter auxiliary table and training status table of the model to be trained can be provided to the user. The user can query the next training status table through the corresponding query statement to see the training status of each training of the model to be trained at the current and historical moments. The parameter auxiliary table can also be queried through the corresponding query statement to see the parameters currently used for model training. The user can modify the parameters by entering SQL modification statements.

[0062] Specifically, the processor can receive an SQL modification statement and find the corresponding parameter auxiliary table based on the table name in the SQL modification statement, such as the initial parameter auxiliary table before training and the next parameter auxiliary table during training. The processor can modify the corresponding parameter value in the next parameter auxiliary table or the initial parameter auxiliary table based on the value in the SQL modification statement, so that the model to be trained can perform prediction according to the set parameters during the next iterative training.

[0063] As a second optional embodiment of the first embodiment, after iteratively training the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met and the final training model is obtained, it also includes:

[0064] The final training model and the corresponding model data are serialized and saved, and a model calling function of the serialized final training model is established; the performance indicators of the final training model are monitored, and when the performance indicators do not meet the preset accuracy conditions, the final training model is trained again.

[0065] In this embodiment, the model call function can be understood as a function generated for calling the final training model. Model data can be understood as metadata related to the recognition and use of the model, such as model type (algorithm), feature data, real-time hyperparameter information and performance indicators. Performance indicators can be understood as indicators used to reflect the accuracy of the final training model, such as accuracy, recall rate and F1 score. The preset accuracy condition can be understood as a threshold condition for judging the accuracy of the model.

[0066] Specifically, the processor can serialize the final training model and the corresponding model data into a byte stream and save it in the database, which can be achieved through a specific type in the database (such as BLOB or BYTEA, etc.). And establish a model call function for the serialized final training model, so that the user can retrieve the serialized model byte stream from the database through the model call function and deserialize it into a model object that can be used for prediction, and then use the deserialized model object to perform real-time prediction and inference on the new data, and build the prediction results and return them to the customer and record the log. In the subsequent prediction process, the processor can determine the performance indicators of the final training model in real time based on each prediction result and the subsequent true value, and monitor the performance indicators of the final training model. The processor can compare the performance indicators with the preset accurate conditions, and retrain the final training model when the performance indicators do not meet the preset accurate conditions.

[0067] The disclosed embodiment, through such a setting, saves the model in a serialized form in the database while ensuring the data security of the data set, and also provides technical means such as data desensitization and encryption for the model and algorithm to reduce the risk of data leakage. These metadata can provide the functions of version control, audit tracking and model life cycle management of the model, making the management of the model more comprehensive and traceable. By concentrating the management and update of the model on the database server, centralized management is achieved, the maintenance process is simplified and management efficiency is improved. At the same time, real-time updates and rapid deployment can be achieved, reducing the time and workload of updates, so that new functions and improvements can be quickly deployed to the database application.

[0068] Embodiment 2

[0069] Figure 2 This is a flow chart of a model training method provided in the second embodiment of the present invention. This embodiment is a further refinement of the above embodiment. Figure 2 As shown, the method includes:

[0070] S201. Obtain model requirement information, and create a model to be trained, an initial parameter auxiliary table, and an initial training status table based on the model requirement information.

[0071] S202. Configure the model to be trained according to the initial parameter values ​​in the initial parameter auxiliary table to obtain the configured model to be trained.

[0072] In this embodiment, the initial parameter value can be understood as a parameter value used to initialize the parameters in the model to be trained.

[0073] Specifically, the processor can extract the initial parameter values ​​for training the model to be trained from the preset parameter auxiliary table, and configure the model to be trained by the initial parameter values, so that the model to be trained is trained according to the initial parameter values ​​to obtain the configured model to be trained. In the training process, these parameters can be adjusted by back propagation, so that the model can gradually learn the appropriate weights and bias values.

[0074] S203: Input the training data subset in the preset data set into the configured model to be trained to obtain a prediction result.

[0075] In this embodiment, the training data subset can be understood as a data subset used to input the model. The prediction result can be understood as the output result of the current training of the model to be trained.

[0076] Specifically, the processor may input a subset of training data in a preset data set into the configured model to be trained to obtain a prediction result based on the training data.

[0077] S204: Determine the current loss function and deviation parameters of this training according to the verification subset and prediction results in the preset data set.

[0078] In this embodiment, the validation subset can be understood as a set used to verify the prediction results, for example, a set corresponding to the training data after actual labels are added.

[0079] Specifically, the processor predefines a loss function, calculates the actual label and prediction result of the verification subset in the preset data set through the predefined loss function, obtains the current loss function, and calculates the deviation parameter based on the actual result and the prediction result.

[0080] S205: Obtain the number of training times for this training and the end timestamp when the training ends.

[0081] In this embodiment, the number of training times can be understood as the cumulative number of trainings. The end timestamp can be understood as the time when the training ends.

[0082] Specifically, the processor may obtain the number of training times corresponding to the current training and the corresponding end timestamp when the current training ends.

[0083] S206: Determine whether the training end condition is met according to the number of training times, the end timestamp and the deviation parameter, and determine the training status identifier.

[0084] In this embodiment, the training status flag is used to indicate whether the training is finished, and can be False or True, for example.

[0085] Specifically, the processor can compare the number of training times with the preset maximum number of training times, compare the end timestamp with the preset maximum training duration, and compare the deviation parameter with the deviation threshold. If one of them meets the training end condition, the training success (such as True) is used as the training status identifier, otherwise, the training failure (False) is used as the training status identifier.

[0086] S207: Based on a preset structured query language SQL update statement, the initial training state table is updated by the number of training times, the end timestamp, the deviation parameter and the training state identifier to obtain a next training state table.

[0087] In this embodiment, the preset SQL update statement can be understood as a statement used to update a table.

[0088] Specifically, the processor can set the number of training times, end timestamp, deviation parameters and training status identifier based on the preset SQL update statement, and add the new number of training times and corresponding training status values ​​to the initial training status table through the preset SQL update statement to obtain the next training status table.

[0089] Exemplarily, the training status table is presented with a specific example.

[0090] Table 2: Training status table:

[0091]

[0092]

[0093] In Table 2, the leftmost column is the number of training times, the second column is the deviation parameter of each training model (taking the LOSS parameter as an example), the third column is the end time of each training, and the fourth column is the training status, which indicates whether each training is successful. The table is updated after each training so that users can see the training status in real time. The deviation parameter can be used to more intuitively see the changes in the model effect, and the model parameters can be adjusted during the training process.

[0094] S208. Query the current parameter value in the initial parameter auxiliary table based on a preset SQL query statement.

[0095] In this embodiment, the current parameter value can be understood as the parameter value used in this training.

[0096] Specifically, the processor can search the initial parameter auxiliary table corresponding to the model to be trained in the database based on a preset SQL query statement, and query the current parameter values ​​used in this training.

[0097] S209. Determine the current gradient value and the corresponding dynamic gradient information according to the current loss function, where the dynamic gradient information includes the first-order momentum and the second-order momentum.

[0098] In this embodiment, the current gradient value can be understood as an indication of model changes to guide the update of model parameters. The first-order momentum can be understood as an estimate of the first-order moment of the gradient, which represents the mean or moving average of the gradient, and is used to indicate the direction of the gradient and to estimate the valuation of random variables. The second-order momentum can be understood as an estimate of the second-order moment of the gradient, which represents the variance of the gradient or the mean of the second-order derivative, and is used to indicate the change of the gradient.

[0099] Specifically, the processor can calculate the current gradient value of the current loss function outputted by the training model through the back-propagation algorithm, and determine the first-order momentum and second-order momentum corresponding to the current gradient value through the first-order momentum algorithm and the second-order momentum algorithm.

[0100] S210: Determine a next learning rate according to the first-order momentum and the second-order momentum.

[0101] In this embodiment, the next learning rate can be understood as a step size for updating parameters.

[0102] Specifically, the processor can introduce a momentum term through the first-order momentum to smooth parameter updates, update parameters in a standard gradient descent manner, and further adjust the learning rate adaptively by considering the variance of the gradient through the second-order momentum combined with the first-order momentum and the momentum coefficient, such as obtaining the next learning rate through Adam update. Momentum information can help the optimization algorithm adjust the learning rate more effectively, so as to optimize the loss function faster and more stably.

[0103] S211. Determine the next parameter value according to the current gradient value, the preset fluctuation threshold, the current parameter value and the next learning rate.

[0104] Specifically, the processor can compare the current gradient value with the preset fluctuation threshold to determine whether the loss function is stagnant or the loss function fluctuates greatly, and adjust the current parameter value for the next learning rate based on the judgment.

[0105] Further, based on the above embodiment, the next parameter value is determined according to the current gradient value, the preset fluctuation threshold, the current parameter value and the next learning rate, including:

[0106] The parameter update amount is determined according to the next learning rate and the current gradient value; if the current gradient value is less than the preset fluctuation threshold, the current parameter value is added to the parameter update amount to obtain the next parameter value; if the current gradient value is greater than or equal to the preset fluctuation threshold, the current parameter value is subtracted from the parameter update amount to obtain the next parameter value.

[0107] In this embodiment, the parameter update amount may be understood as an adjustment amount used to adjust the current parameter value.

[0108] Specifically, the processor can determine the parameter update amount according to the product of the next learning rate and the current gradient value. When the current gradient value is less than the preset fluctuation threshold, the current parameter value is added to the parameter update amount to obtain the next parameter value for the next training; when the current gradient value is greater than or equal to the preset fluctuation threshold, the current parameter value is subtracted from the parameter update amount to obtain the next parameter value.

[0109] S212: Based on a preset SQL update statement, the initial auxiliary parameter table is updated based on the next parameter value to obtain a next parameter auxiliary table.

[0110] Specifically, the processor may update the next parameter value in the initial auxiliary parameter table based on a preset SQL update statement by determining the timestamp of the next parameter value, and obtain the next parameter auxiliary table.

[0111] The technical solution of the embodiment of the present invention determines the dynamic gradient information through the current loss function obtained in each training, and adaptively adjusts the learning rate through the first-order momentum and the second-order momentum in the dynamic gradient information, so that each parameter can be updated to different degrees. This allows the amplitude of parameter updates to be dynamically adjusted according to the changes in the gradient or loss function during the training process, so as to converge to the optimal solution more efficiently. By presetting the fluctuation threshold to maintain the momentum of parameter updates, historical information can be accumulated in the gradient direction. This can reduce swings when updating parameters, especially in the presence of noise or sparse gradients. It can help to jump out of the local optimal solution and converge to the global optimal solution faster. It is applicable to various machine learning tasks and model types, and the selection of hyperparameters is relatively robust. The dynamic gradient also has strong stability and adaptability to outliers and noise, so that the model can maintain good accuracy and reliability without being seriously affected by these interference factors. By updating the parameter auxiliary table and training status table in real time, the model training process is displayed in a visual way, the controllability and observability of the model training process are achieved, and the user is provided with modification statements for parameters so that the user can provide guidance to the model, so that the model can adapt to the changing data and business needs in a timely manner based on the changes.

[0112] Embodiment 3

[0113] Figure 3 This is a schematic diagram of the structure of a model training device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device comprises:

[0114] A table construction module 31 is used to obtain model requirement information and create a model to be trained, an initial parameter auxiliary table and an initial training state table based on the model requirement information;

[0115] A parameter determination module 32 is used to train the to-be-trained model according to a preset data set, the initial parameter auxiliary table and the initial training state table, and determine the current loss function and deviation parameters of this training;

[0116] A first updating module 33, configured to update the initial training state table based on the deviation parameter to obtain a next training state table;

[0117] A second updating module 34 is used to determine the dynamic gradient information according to the current loss function and update the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain a next parameter auxiliary table;

[0118] The model determination module 35 is used to iteratively train the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain the final training model.

[0119] The technical solution of the embodiment of the present invention obtains model requirement information, and creates a model to be trained, an initial parameter auxiliary table and an initial training state table based on the model requirement information; trains the model to be trained according to a preset data set, an initial parameter auxiliary table and an initial training state table, and determines the current loss function and deviation parameter of this training; updates the initial training state table based on the deviation parameter to obtain the next training state table; determines the dynamic gradient information according to the current loss function and updates the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain the next parameter auxiliary table; iteratively trains the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain the final training model. By recording the training process in a table, the model training situation can be observed more intuitively, and the parameters can be dynamically adjusted by determining the changes in the dynamic gradient information of the parameters and the loss function, and the parameters can be adaptively adjusted, so as to converge to the optimal solution more efficiently, thereby improving the training speed. The dynamic gradient also has strong stability and adaptability to outliers and noise, so that the model can maintain good accuracy and reliability without being seriously affected by these interference factors, thereby improving the accuracy of the model.

[0120] Furthermore, the parameter determination module 32 is specifically used for:

[0121] The model to be trained is configured according to the initial parameter values ​​in the initial parameter auxiliary table to obtain the configured model to be trained;

[0122] Inputting a training data subset in the preset data set into the configured model to be trained to obtain a prediction result;

[0123] According to the verification subset in the preset data set and the prediction result, the current loss function and deviation parameters of this training are determined.

[0124] Furthermore, the first updating module 33 is specifically used for:

[0125] Get the number of training times for this training and the end timestamp when the training ends;

[0126] Determine whether the training end condition is met according to the training number, the end timestamp and the deviation parameter, and determine the training state identifier;

[0127] Based on a preset structured query language SQL update statement, the initial training state table is updated through the training times, the end timestamp, the deviation parameter and the training state identifier to obtain a next training state table.

[0128] Furthermore, the second updating module 34 includes:

[0129] An information query unit, used to query the current parameter value in the initial parameter auxiliary table based on a preset SQL query statement;

[0130] A momentum determination unit, configured to determine a current gradient value and corresponding dynamic gradient information according to the current loss function, wherein the dynamic gradient information includes a first-order momentum and a second-order momentum;

[0131] a learning rate determining unit, configured to determine a next learning rate according to the first-order momentum and the second-order momentum;

[0132] a parameter determination unit, configured to determine a next parameter value according to the current gradient value, the preset fluctuation threshold, the current parameter value and the next learning rate;

[0133] The auxiliary table determination unit is used to update the initial auxiliary parameter table based on the next parameter value based on a preset SQL update statement to obtain a next parameter auxiliary table.

[0134] The parameter determination unit is specifically used for:

[0135] Determining a parameter update amount according to the next learning rate and the current gradient value;

[0136] If the current gradient value is less than the preset fluctuation threshold, the current parameter value is added to the parameter update amount to obtain a next parameter value;

[0137] If the current gradient value is greater than or equal to the preset fluctuation threshold, the current parameter value is subtracted from the parameter update amount to obtain a next parameter value.

[0138] Optionally, the device further includes: a parameter modification module.

[0139] The parameter modification module is specifically used for:

[0140] Receive an SQL modification statement; and modify corresponding parameter values ​​in the next parameter auxiliary table or the initial parameter auxiliary table based on the SQL modification statement.

[0141] Optionally, the device further includes: a model monitoring module.

[0142] The model monitoring module is specifically used for:

[0143] The final training model and the corresponding model data are serialized and saved, and a model calling function of the serialized final training model is established; the performance indicators of the final training model are monitored, and when the performance indicators do not meet the preset accuracy conditions, the final training model is trained again.

[0144] The model training device provided in the embodiment of the present invention can execute the model training method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0145] Embodiment 4

[0146] Figure 4 A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0147] like Figure 4 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0148] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0149] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 41 performs the various methods and processes described above, such as a model training method.

[0150] In some embodiments, the model training method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the model training method described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to perform the model training method in any other suitable manner (e.g., by means of firmware).

[0151] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0152] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0153] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0154] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0155] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0156] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0157] In one embodiment, the embodiment of the present invention also includes a computer program product, the computer program product includes a computer program, and the computer program implements the model training method of any embodiment of the present invention when executed by a processor.

[0158] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).

[0159] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0160] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A model training method, characterized in that: include: Obtain model requirement information, and create a model to be trained, an initial parameter auxiliary table, and an initial training status table based on the model requirement information; Train the model to be trained according to the preset data set, the initial parameter auxiliary table and the initial training state table, and determine the current loss function and deviation parameters of this training; Update the initial training state table based on the deviation parameter to obtain a next training state table; According to the current loss function, dynamic gradient information is determined and combined with a preset fluctuation threshold to update the initial parameter auxiliary table to obtain a next parameter auxiliary table; The model to be trained is iteratively trained according to the next training state table and the next parameter auxiliary table until a training end condition is met to obtain a final training model.

2. The method according to claim 1, characterized in that: The training of the to-be-trained model according to the preset data set, the initial parameter auxiliary table and the initial training state table to determine the current loss function and deviation parameters of this training includes: The model to be trained is configured according to the initial parameter values ​​in the initial parameter auxiliary table to obtain the configured model to be trained; Inputting a training data subset in the preset data set into the configured model to be trained to obtain a prediction result; According to the verification subset in the preset data set and the prediction result, the current loss function and deviation parameters of this training are determined.

3. The method according to claim 1, characterized in that The updating of the initial training state table based on the deviation parameter to obtain a next training state table includes: Get the number of training times for this training and the end timestamp when the training ends; Determine whether the training end condition is met according to the training number, the end timestamp and the deviation parameter, and determine the training state identifier; Based on a preset structured query language SQL update statement, the initial training state table is updated through the training times, the end timestamp, the deviation parameter and the training state identifier to obtain a next training state table.

4. The method according to claim 1, characterized in that: The method of determining the dynamic gradient information according to the current loss function and updating the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain a next parameter auxiliary table includes: Query the current parameter value in the initial parameter auxiliary table based on a preset SQL query statement; Determine a current gradient value and corresponding dynamic gradient information according to the current loss function, wherein the dynamic gradient information includes a first-order momentum and a second-order momentum; Determining a next learning rate according to the first-order momentum and the second-order momentum; Determine a next parameter value according to the current gradient value, the preset fluctuation threshold, the current parameter value and the next learning rate; The initial auxiliary parameter table is updated based on the next parameter value based on a preset SQL update statement to obtain a next parameter auxiliary table.

5. The method according to claim 4, characterized in that The determining the next parameter value according to the current gradient value, the preset fluctuation threshold, the current parameter value and the next learning rate includes: Determining a parameter update amount according to the next learning rate and the current gradient value; If the current gradient value is less than the preset fluctuation threshold, the current parameter value is added to the parameter update amount to obtain a next parameter value; If the current gradient value is greater than or equal to the preset fluctuation threshold, the current parameter value is subtracted from the parameter update amount to obtain a next parameter value.

6. The method according to claim 1, characterized in that Also includes: Receive SQL modification statements; The corresponding parameter values ​​in the next parameter auxiliary table or the initial parameter auxiliary table are modified based on the SQL modification statement.

7. The method according to claim 1, characterized in that After the model to be trained is iteratively trained according to the next training state table and the next parameter auxiliary table until a training end condition is met and a final training model is obtained, the method further includes: Serializing and saving the final training model and the corresponding model data, and establishing a model calling function of the serialized final training model; The performance index of the final training model is monitored, and when the performance index does not meet the preset accuracy condition, the final training model is trained again.

8. A model training device, characterized in that: include: A table construction module is used to obtain model requirement information and create a model to be trained, an initial parameter auxiliary table and an initial training status table based on the model requirement information; A parameter determination module is used to train the model to be trained according to a preset data set, the initial parameter auxiliary table and the initial training state table, and determine the current loss function and deviation parameters of this training; A first updating module, configured to update the initial training state table based on the deviation parameter to obtain a next training state table; A second updating module is used to determine the dynamic gradient information according to the current loss function and update the initial parameter auxiliary table in combination with a preset fluctuation threshold to obtain a next parameter auxiliary table; The model determination module is used to iteratively train the model to be trained according to the next training state table and the next parameter auxiliary table until the training end condition is met to obtain a final training model.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the model training method described in any one of claims 1-7.

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 processor to implement the model training method described in any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • Machine learning model training method and device, machine learning model data processing method and device and medium

    CN116542341A

Cited By

  • Model training method and device, equipment, storage medium and program product

    CN120409741A

  • Model training method, device, equipment, storage medium and program product

    CN120409741B

  • Power virtual energy storage control method based on multi-energy complementation

    CN120855429A

  • Battery bumping damage early warning method and system

    CN121385674A