Model training method and device based on weight uncertainty, equipment, medium and program product
Through the model training method based on weight uncertainty, the problem of poor generalization ability of traditional neural networks in uncertainty tasks is solved, and the results uncertainty description is introduced without changing the hardware, which improves the generalization of the model The ability to refine and process efficiency reduces resource consumption.
Patent Information
- Application Number
- CN202411858583.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-01-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When traditional neural network models face high uncertainty tasks, it is difficult to evaluate the credibility of predictions, resulting in poor overfitting and generalization capabilities. Traditional regularization strategies cannot effectively introduce uncertainty descriptions of results, resulting in resources High cost.
Through a model training method based on weight uncertainty, the sample data and target number are obtained, the model is built and the current distribution of weight parameters is set, the weight parameter value is determined based on the distribution when inputting sample data, and sent it to the distributed computing framework. Get gradient updates, update distribution until the training is over. The entire process does not require hardware adjustments to reduce resource consumption.
It realizes that without changing the distributed computing framework, introduces the uncertainty description of the result, improves the generalization ability and processing efficiency of the model, and reduces resource consumption.
Smart Images

Figure CN119323244A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model training method, apparatus, computer equipment, computer-readable storage medium, and computer program product based on weight uncertainty. Background Art
[0002] In the practice of modern machine learning, especially deep learning, traditional neural network models, such as feedforward neural networks, have achieved remarkable results in many tasks, but they still continue to face the problem of overfitting and difficulty in evaluating the uncertainty in training data, that is, they perform well on training data but have poor generalization ability on unseen data. In addition, when faced with tasks with high uncertainty, these models are often unable to accurately evaluate the credibility of predictions, resulting in overconfidence in classification and regression results, causing the models to perform poorly in complex tasks such as medical diagnosis, and often incur large decision costs.
[0003] To alleviate these problems, neural networks often use some traditional regularization strategies to solve the above-mentioned overfitting problem. However, when solving the above-mentioned overfitting problem, traditional regularization strategies still cannot make the network output a description of the uncertainty of the results, and the strategies that can introduce the description of the uncertainty of the results in traditional technologies usually require hardware changes, such as modifying the distributed computing framework, which results in the need for a lot of manpower and material resources. Summary of the invention
[0004] Based on this, it is necessary to provide a model training method, device, computer equipment, computer-readable storage medium and computer program product based on weight uncertainty, which can introduce result uncertainty description, improve processing efficiency and reduce resource consumption in response to the above technical problems.
[0005] In a first aspect, the present application provides a model training method based on weight uncertainty, the method comprising:
[0006] Obtain sample data and target quantity;
[0007] Constructing a model and setting the current distribution corresponding to each weight parameter in the model;
[0008] When the number of sample data input to the model is less than the target number, determining a current weight parameter value corresponding to the current sample data based on the current distribution;
[0009] Send the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient;
[0010] When the number of sample data input to the model is equal to the target number, the current distribution of each weight parameter is updated based on the updated weight parameter value, and the updated current distribution is used as the current distribution, and the current weight parameter value corresponding to the current sample data is determined based on the current distribution until the training is completed.
[0011] In one embodiment, sending the current weight parameter value and the current sample data to a distributed computing framework to obtain updated weight parameter values returned by gradients includes:
[0012] The current weight parameter value and the current sample data are sent to a distributed computing framework, so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtains an updated weight parameter value by gradient feedback based on the model output result and the current sample data.
[0013] In one embodiment, the method for determining the end of the training includes:
[0014] Generate a loss function value based on the model output result and the current sample data;
[0015] On the premise that the loss function value meets the preset requirements, the training is judged to be completed.
[0016] In one embodiment, determining a current weight parameter value corresponding to the current sample data based on the current distribution includes:
[0017] The current distribution is sampled by a target sampling method to obtain a current weight parameter value corresponding to the current sample data.
[0018] In one embodiment, the obtaining of each sample data includes:
[0019] Determine the data scenarios corresponding to cost-sensitive data;
[0020] Initial data corresponding to the data scenario is acquired, and the initial data is preprocessed to obtain sample data.
[0021] In one embodiment, the method further comprises:
[0022] Calculating the correlation between the sample data and the target classification through a feature selection algorithm;
[0023] The sample data is screened based on the correlation.
[0024] In a second aspect, the present application also provides a model training device based on weight uncertainty, the device comprising:
[0025] A sample data acquisition module is used to obtain each sample data and target quantity;
[0026] A model building module, used to build a model and set the current distribution corresponding to each weight parameter in the model;
[0027] A current weight parameter value determination module, used to determine a current weight parameter value corresponding to the current sample data based on the current distribution when the number of sample data input to the model is less than the target number;
[0028] An updated weight parameter value determination module is used to send the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value returned by the gradient;
[0029] A training module is used to update the current distribution of each weight parameter based on each updated weight parameter value when the number of sample data input to the model is equal to the target number, and use the updated current distribution as the current distribution, and continue to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
[0030] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0031] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0032] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0033] The above-mentioned model training method, device, computer equipment, computer-readable storage medium and computer program product based on weight uncertainty obtain each sample data and the target number; construct a model and set the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determine the current weight parameter value corresponding to the current sample data based on the current distribution; send the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value of the gradient feedback; when the number of sample data input to the model is equal to the target number, update the current distribution of each weight parameter based on each updated weight parameter value, and use the updated current distribution as the current distribution, and continue to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed. During the whole process, there is no need to adjust the distributed computing framework, reducing the impact on the hardware, thereby reducing resource consumption and introducing a description of result uncertainty. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0035] FIG1 is a diagram of an application environment of a model training method based on weight uncertainty in one embodiment;
[0036] FIG2 is a schematic diagram of a flow chart of a model training method based on weight uncertainty in one embodiment;
[0037] FIG3 is a schematic diagram of different parameter states of a neural network in one embodiment;
[0038] FIG4 is a schematic flow chart of a model training method based on weight uncertainty in another embodiment;
[0039] FIG5 is a structural block diagram of a model training device based on weight uncertainty in one embodiment;
[0040] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0042] The model training method based on weight uncertainty provided in the embodiment of the present application can be applied in the application environment shown in FIG1. In which, the server 102 communicates with the distributed computing framework 104 through a network. The data storage system can store data that the distributed computing framework 104 needs to process. The data storage system can be integrated on the distributed computing framework 104, or it can be placed on the cloud or other network servers.
[0043] The server 102 can obtain each sample data and the target number; build a model and set the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determine the current weight parameter value corresponding to the current sample data based on the current distribution; send the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value returned by the gradient; when the number of sample data input to the model is equal to the target number, update the current distribution of each weight parameter based on each updated weight parameter value, and use the updated current distribution as the current distribution, and continue to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed. During the whole process, there is no need to adjust the distributed computing framework, which reduces the impact on the hardware and thus reduces the consumption of resources.
[0044] The server 102 may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The distributed computing framework 104 may be a distributed computing framework such as asynchronous SGD, which may include high-performance hardware such as several GPUs to implement model training.
[0045] In an exemplary embodiment, as shown in FIG2 , a model training method based on weight uncertainty is provided, and the method is applied to the server 102 in FIG1 as an example for explanation, including the following steps 202 to 210. Among them:
[0046] S202: Obtain sample data and target quantity.
[0047] The sample data is the data obtained by the training model. The target number is the cycle period for calculating the weight parameter values in the model. The weight parameter value in the model is updated once for each target number of sample data. The target number can be set based on experience. For example, the target number can be 100. In other embodiments, the target number can also be other values, which are not specifically limited here. One point that needs to be explained is that the setting of the target number can be based on the training efficiency of the model. For example, if you want to improve the training efficiency of the model, the target number is reduced, thereby increasing the number of updates of the weight parameters in the model. In addition, in order to ensure the accuracy of each weight parameter update, the target number also needs to be greater than the minimum threshold. The setting of the minimum threshold can be based on experience, which is not specifically limited here.
[0048] S204: Build a model and set the current distribution corresponding to each weight parameter in the model.
[0049] As shown in FIG3 , in order to efficiently introduce weight uncertainty in large-scale neural networks to enhance the generalization ability of the model and reduce the decision-making risk in cost-sensitive areas, the fixed parameter values in the model are set as distributions in this application, that is, back-propagation Bayes is used to introduce distribution representation for neural network weights through variational Bayesian learning. A probability distribution is assigned to each weight in the modeling process of the neural network system instead of a single value, and the uncertainty of the weight is incorporated into the model using the variational Bayesian inference method to form a dynamic set of weights, thereby enhancing the model's ability to express data uncertainty.
[0050] S206: When the number of sample data input to the model is less than the target number, determine the current weight parameter value corresponding to the current sample data based on the current distribution.
[0051] Among them, when the number of sample data input to the model is less than the target number, it means that the number of sample data of the model in this cycle is less than the target number. In this embodiment, a variable can be introduced to count the number of sample data input to the model in the current cycle, and the variable is reset each time it is equal to the target number, for example, corrected to 0, to facilitate the next statistics of the number of sample data input to the model.
[0052] Determining the current weight parameter value corresponding to the current sample data based on the current distribution may be a process of sampling each current distribution. For each weight parameter, the server samples the current distribution corresponding to it to obtain a unique and determined current weight parameter value.
[0053] S208: Send the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient.
[0054] The distributed computing framework originally trained the model based on fixed weight parameter values and sample data, that is, the input of the distributed computing framework was a fixed weight parameter value, sample data and model, so that the output of the model was obtained based on the fixed weight parameter value, sample data and model, and then the loss function value was generated based on the model output and the actual output in the sample data, and the gradient was returned based on the loss function value to obtain the updated weight parameter values of each weight parameter in the model.
[0055] In order to avoid the impact on the distributed computing framework in this application, the distribution of each weight parameter is sampled to obtain the weight parameter value, so that what is input into the distributed computing framework is still a value rather than a distribution. This does not require the distributed computing framework to be changed, thereby saving costs.
[0056] S210: When the number of sample data input to the model is equal to the target number, the current distribution of each weight parameter is updated based on each updated weight parameter value, and the updated current distribution is used as the current distribution, and the current weight parameter value corresponding to the current sample data is determined based on the current distribution until the training is completed.
[0057] When the number of sample data input to the model is equal to the target number, that is, the weight parameter values in the model need to be updated this time, since the sample data input to the model includes multiple, and the weight parameter values corresponding to each sample data are different, the updated weight parameter values obtained by training gradient feedback based on these weight parameter values are also different. For example, if there are 100 sample data, the number of updated weight parameter values corresponding to each weight parameter is less than or equal to 100. The current distribution of the weight parameter is generated for each updated weight parameter value corresponding to each weight parameter, and the current distribution is used to obtain the corresponding weight parameter value in the next cycle.
[0058] It must be noted that, when the number of sample data input to the model is equal to the target number, the present application will also reset the number of sample data input to the model, for example, to 0, in order to start the next cycle.
[0059] One point that needs to be explained is that the condition for the end of training can be that the number of sample data reaches a preset number, or it can be determined based on the loss function, for example, the change in the value of the loss function is less than a first threshold, or the loss function value is less than a second threshold, etc., and no specific limitation is made here.
[0060] The above-mentioned model training method based on weight uncertainty obtains each sample data and the target number; constructs a model, and sets the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determines the current weight parameter value corresponding to the current sample data based on the current distribution; sends the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value returned by the gradient; when the number of sample data input to the model is equal to the target number, updates the current distribution of each weight parameter based on each updated weight parameter value, and uses the updated current distribution as the current distribution, and continues to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed. During the entire process, there is no need to adjust the distributed computing framework, which reduces the impact on the hardware and thus reduces resource consumption.
[0061] In one of the optional embodiments, the current weight parameter value and the current sample data are sent to a distributed computing framework to obtain updated weight parameter values returned by gradients, including: sending the current weight parameter value and the current sample data to the distributed computing framework so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtaining updated weight parameter values returned by gradients based on the model output result and the current sample data.
[0062] Specifically, the current weight parameter values and the current sample data are sent to the distributed computing framework. The distributed computing framework generates the model output results based on the weight parameter values and the current sample data. The model output results and the output results corresponding to the current sample data generate the loss function value. Then, the gradient is returned based on the loss function value to obtain the updated weight parameter value.
[0063] In this way, the input of the distributed computing framework is still a weight parameter value and current sample data, so there is no need to change the structure of the distributed computing framework, which reduces the impact on hardware and reduces costs.
[0064] In one of the optional embodiments, the method for determining the end of training includes: generating a loss function value based on the model output results and the current sample data; and determining that the training is ended if the loss function value meets the preset requirements.
[0065] The loss function value is calculated by the distributed computing framework, that is, the loss function value is generated based on the model output results and the current sample data, and then it is judged based on the loss function value whether it meets the preset requirements. If so, the training is completed and the weight parameters in the model are updated.
[0066] The update of the model's weight parameters uses compression cost regularization: that is, by minimizing the compression cost, namely variational free energy (Variational Free Energy: In Bayesian inference, the difference between the posterior distribution of the model and the variational approximate distribution is measured as the optimization objective function, and the model parameters are adjusted by minimizing the difference.) to adjust the weights, achieve principled regularization, and improve the generalization performance of the model.
[0067] The weight uncertainty introduced by nonlinear regression and exploration strategy not only improves the prediction performance of nonlinear regression problems, but also promotes more effective exploration strategies through Thompson sampling method in reinforcement learning environment, which is better than traditional Algorithm. Efficient learning and optimization By implementing unbiased Monte Carlo gradient estimation, Bayesian learning can be efficiently performed in large-scale neural networks. At the same time, mixed proportion priors and diagonal Gaussian posteriors are combined to simplify optimization problems and avoid numerical instability. Scalability and parallelism Because the algorithm is based on the classic gradient update mode, it can be seamlessly integrated into distributed computing frameworks such as asynchronous SGD, which is convenient for acceleration on high-performance hardware such as GPUs to meet large-scale data processing needs.
[0068] In one of the optional embodiments, determining a current weight parameter value corresponding to current sample data based on the current distribution includes: sampling the current distribution by a target sampling method to obtain a current weight parameter value corresponding to the current sample data.
[0069] Among them, the target sampling method may include the Thompson sampling method (Thompson Sampling is an algorithm inspired by Bayesian inference, which is used for decision-making in the multi-armed bandit problem. It determines the next action by sampling from the posterior distribution to achieve a trade-off between exploration and utilization.), in other embodiments, the target sampling method may also be other methods, which are not specifically limited here.
[0070] By sampling the current distribution corresponding to each weight parameter in a target sampling manner, the weight parameter value corresponding to each weight parameter can be obtained. In this way, what is input into the distributed computing framework is still a weight parameter value, not a distribution. There is no need to change the distributed computing framework, thus reducing costs.
[0071] In each of the above embodiments, back-propagation Bayes is used to introduce distribution representation for neural network weights through variational Bayesian learning, minimizing the compressed variational free energy cost, thereby not only optimizing the generalization performance of the model by introducing uncertainty in weight distribution, but also providing more robust predictions when facing scenarios with scarce data or high uncertainty. This method is committed to realizing the automatic exploration-utilization trade-off of the model, and guiding the exploration strategy by using weight uncertainty, thereby improving exploration efficiency, enhancing generalization ability and flexibility without sacrificing model accuracy.
[0072] In one of the optional embodiments, obtaining each sample data includes: determining a data scenario corresponding to the cost-sensitive data; obtaining initial data corresponding to the data scenario, and preprocessing the initial data to obtain the sample data.
[0073] Cost-sensitive data can include data from different fields, such as the medical field, network security field, and financial transaction field, so first determine the data scenario, and then obtain the initial data corresponding to the data scenario. Taking the medical field as an example, the patient's electronic health record (EHR) can be obtained, including age, gender, weight, blood pressure, blood sugar level, cholesterol index, family medical history, living habits (such as smoking, drinking frequency), etc. Preprocessing means cleaning and standardizing the data, and processing missing values and outliers.
[0074] In one of the optional embodiments, the method further includes: calculating the correlation between the sample data and the target classification through a feature selection algorithm; and screening the sample data based on the correlation.
[0075] The feature selection algorithm may include methods based on correlation analysis, recursive feature elimination, etc., and no specific limitation is made here. Through the feature selection algorithm, features that are highly correlated with the occurrence of the disease can be identified, reducing the dimension while ensuring the predictive ability of the model.
[0076] As shown in FIG4 , after the above processing, the obtained sample data can be used for model training.
[0077] To this end, a model is constructed, which can be a deep feedforward neural network architecture, including multiple layers of fully connected layers, possible convolutional layers or recurrent layers (for sequence data such as genetic sequences), where the weight parameters are all modeled with uncertainty using the variational Bayesian method. The output layer is designed as a binary or multi-classification problem, depending on the type of disease. For example, if it is a binary classification, the output layer includes yes or no, and if it is a multi-classification, the output layer can include multiple dimensions, each of which represents the probability of a disease.
[0078] Bayesian optimization training: The model is trained using the back-propagation Bayesian framework, and the weight parameters are updated through an iterative process. In each iteration, different weight configurations are sampled, the expected value of the loss function is calculated, and then the updated weight parameter value is obtained based on the gradient information. In each cycle, that is, after the number of sample data input into the model reaches the target number, the distribution of weight parameters in the module is updated based on each updated weight parameter value to obtain the current distribution, ensuring the optimization of the weight distribution of the entire network. After the model training is completed based on the loss function, the trained model is obtained, which can be used for subsequent individualized risk assessment.
[0079] Individualized risk assessment includes: for each patient, multiple model instances are extracted from the posterior weight distribution (that is, the weight distribution of each weight parameter in the trained model) through Thompson sampling (that is, Thompson sampling is performed multiple times to obtain a combination of weight parameter values for each processing of the data to be processed (such as patient data), one model instance corresponds to a group of combinations, and multiple model instances are obtained in this application, so that the patient data is processed multiple times), and each instance is predicted and the results are summarized, where each instance corresponds to an output, which can be a binary classification or a multi-classification, and each output is processed to obtain a probability distribution rather than a single prediction value, which reflects the model's uncertainty estimate of the patient's risk of illness. Taking binary classification as an example, each instance corresponds to an output, which is the probability of illness, and then the outputs corresponding to multiple instances are processed to obtain the distribution of outputs, that is, the distribution of probabilities.
[0080] Doctors can develop personalized intervention measures and monitoring plans based on the probability distribution of the predicted results and the patient's specific situation, and provide more refined management recommendations, especially for patients whose predicted risks are in the marginal range.
[0081] In addition, it should be noted that the model output of this application is a probability value, which provides a reference for doctors to diagnose and treat more accurately. The implementing subject is a computer and other devices, and the implementation object is the collected sample data. There is no need for doctors to participate in the whole process, and all steps are processed by computers and other devices.
[0082] In the above embodiment, by introducing variational distribution to approximate the true posterior distribution of weights, using variational free energy as the optimization target, the uncertainty quantification of weights is effectively realized in large-scale neural networks, which is the key to improving the generalization ability of the model. The unbiased Monte Carlo gradient estimation method is adopted, so that the Bayesian neural network can be efficiently executed in actual calculations, and the feasibility and speed of training can be maintained even in deep learning models with a large number of parameters. In the prediction and decision-making process, by performing Thompson sampling from the posterior distribution, the exploration and utilization behavior of the model is adaptively adjusted, the strategy selection in scenarios such as medical decision-making is optimized, and the flexibility and accuracy of decision-making are improved. The designed algorithm is compatible with the existing distributed computing framework, can make full use of hardware acceleration resources such as GPU, is suitable for processing large-scale medical data sets, and accelerates model training and reasoning processes.
[0083] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0084] Based on the same inventive concept, the embodiment of the present application also provides a model training device based on weight uncertainty for implementing the model training method based on weight uncertainty involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more embodiments of the model training device based on weight uncertainty provided below can refer to the limitations of the model training method based on weight uncertainty above, and will not be repeated here.
[0085] In an exemplary embodiment, as shown in FIG5 , a model training device based on weight uncertainty is provided, comprising: a sample data acquisition module 501, a model construction module 502, a current weight parameter value determination module 503, an updated weight parameter value determination module 504 and a training module 505, wherein:
[0086] The sample data acquisition module 501 is used to acquire each sample data and target quantity;
[0087] A model building module 502 is used to build a model and set the current distribution corresponding to each weight parameter in the model;
[0088] A current weight parameter value determination module 503 is used to determine a current weight parameter value corresponding to the current sample data based on the current distribution when the number of sample data input to the model is less than the target number;
[0089] An updated weight parameter value determination module 504 is used to send the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient;
[0090] Training module 505 is used to update the current distribution of each weight parameter based on each updated weight parameter value when the number of sample data input to the model is equal to the target number, and use the updated current distribution as the current distribution, and continue to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
[0091] In one of the optional embodiments, the above-mentioned updated weight parameter value determination module 504 is specifically used to send the current weight parameter value and the current sample data to the distributed computing framework, so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtains an updated weight parameter value for gradient feedback based on the model output result and the current sample data.
[0092] In one of the optional embodiments, the above-mentioned training module 505 is specifically used to generate a loss function value based on the model output result and the current sample data; and the training is judged to be completed on the premise that the loss function value meets the preset requirements.
[0093] In one of the optional embodiments, the training module 505 is specifically used to sample the current distribution through a target sampling method to obtain a current weight parameter value corresponding to the current sample data.
[0094] In one of the optional embodiments, the sample data acquisition module 501 is specifically used to determine a data scenario corresponding to the cost-sensitive data; acquire initial data corresponding to the data scenario, and pre-process the initial data to obtain sample data.
[0095] In one of the optional embodiments, the sample data acquisition module 501 is specifically used to calculate the correlation between the sample data and the target classification through a feature selection algorithm; and screen the sample data based on the correlation.
[0096] Each module in the above-mentioned model training device based on weight uncertainty can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0097] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store sample data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model training method based on weight uncertainty is implemented.
[0098] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0099] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining each sample data and a target number; constructing a model, and setting the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determining the current weight parameter value corresponding to the current sample data based on the current distribution; sending the current weight parameter value and the current sample data to a distributed computing framework to obtain each updated weight parameter value returned by the gradient; when the number of sample data input to the model is equal to the target number, updating the current distribution of each weight parameter based on each updated weight parameter value, and using the updated current distribution as the current distribution, and continuing to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
[0100] In one embodiment, when a processor executes a computer program, the current weight parameter value and the current sample data are sent to a distributed computing framework to obtain updated weight parameter values returned by gradients, including: sending the current weight parameter value and the current sample data to the distributed computing framework so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtaining updated weight parameter values returned by gradients based on the model output result and the current sample data.
[0101] In one embodiment, the method for determining the end of training involved in the processor executing the computer program includes: generating a loss function value based on the model output result and the current sample data; and determining the end of training on the premise that the loss function value meets the preset requirements.
[0102] In one embodiment, the determination of the current weight parameter value corresponding to the current sample data based on the current distribution implemented by the processor when executing the computer program includes: sampling the current distribution through a target sampling method to obtain the current weight parameter value corresponding to the current sample data.
[0103] In one embodiment, the acquisition of each sample data implemented when the processor executes the computer program includes: determining a data scenario corresponding to the cost-sensitive data; acquiring initial data corresponding to the data scenario, and preprocessing the initial data to obtain the sample data.
[0104] In one embodiment, when the processor executes the computer program, the following steps are also implemented: calculating the correlation between the sample data and the target classification through a feature selection algorithm; and screening the sample data based on the correlation.
[0105] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining each sample data and a target number; constructing a model, and setting the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determining the current weight parameter value corresponding to the current sample data based on the current distribution; sending the current weight parameter value and the current sample data to a distributed computing framework to obtain each updated weight parameter value returned by the gradient; when the number of sample data input to the model is equal to the target number, updating the current distribution of each weight parameter based on each updated weight parameter value, and using the updated current distribution as the current distribution, and continuing to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
[0106] In one embodiment, the computer program implemented when executed by the processor sends the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient, including: sending the current weight parameter value and the current sample data to the distributed computing framework so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtaining the updated weight parameter value returned by the gradient based on the model output result and the current sample data.
[0107] In one embodiment, the method for determining the end of training involved in executing a computer program by a processor includes: generating a loss function value based on a model output result and current sample data; and determining the end of training on the premise that the loss function value meets preset requirements.
[0108] In one embodiment, the computer program executed by the processor determines the current weight parameter value corresponding to the current sample data based on the current distribution, including: sampling the current distribution through a target sampling method to obtain the current weight parameter value corresponding to the current sample data.
[0109] In one embodiment, the acquisition of each sample data implemented when the computer program is executed by the processor includes: determining a data scenario corresponding to the cost-sensitive data; acquiring initial data corresponding to the data scenario, and preprocessing the initial data to obtain the sample data.
[0110] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: calculating the correlation between the sample data and the target classification through a feature selection algorithm; and screening the sample data based on the correlation.
[0111] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: obtaining each sample data and a target number; constructing a model, and setting the current distribution corresponding to each weight parameter in the model; when the number of sample data input to the model is less than the target number, determining the current weight parameter value corresponding to the current sample data based on the current distribution; sending the current weight parameter value and the current sample data to a distributed computing framework to obtain each updated weight parameter value returned by the gradient; when the number of sample data input to the model is equal to the target number, updating the current distribution of each weight parameter based on each updated weight parameter value, and using the updated current distribution as the current distribution, and continuing to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
[0112] In one embodiment, the computer program implemented when executed by the processor sends the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient, including: sending the current weight parameter value and the current sample data to the distributed computing framework so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtaining the updated weight parameter value returned by the gradient based on the model output result and the current sample data.
[0113] In one embodiment, the method for determining the end of training involved in executing a computer program by a processor includes: generating a loss function value based on a model output result and current sample data; and determining the end of training on the premise that the loss function value meets preset requirements.
[0114] In one embodiment, the computer program executed by the processor determines the current weight parameter value corresponding to the current sample data based on the current distribution, including: sampling the current distribution through a target sampling method to obtain the current weight parameter value corresponding to the current sample data.
[0115] In one embodiment, the acquisition of each sample data implemented when the computer program is executed by the processor includes: determining a data scenario corresponding to the cost-sensitive data; acquiring initial data corresponding to the data scenario, and preprocessing the initial data to obtain the sample data.
[0116] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: calculating the correlation between the sample data and the target classification through a feature selection algorithm; and screening the sample data based on the correlation.
[0117] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0118] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0119] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0120] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A model training method based on weight uncertainty, characterized in that: The method comprises: Obtain sample data and target quantity; Constructing a model and setting the current distribution corresponding to each weight parameter in the model; When the number of sample data input to the model is less than the target number, determining a current weight parameter value corresponding to the current sample data based on the current distribution; Send the current weight parameter value and the current sample data to the distributed computing framework to obtain the updated weight parameter values returned by the gradient; When the number of sample data input to the model is equal to the target number, the current distribution of each weight parameter is updated based on the updated weight parameter value, and the updated current distribution is used as the current distribution, and the current weight parameter value corresponding to the current sample data is determined based on the current distribution until the training is completed.
2. The method according to claim 1, characterized in that The sending of the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value returned by the gradient includes: The current weight parameter value and the current sample data are sent to a distributed computing framework, so that the distributed computing framework generates a model output result based on the weight parameter value and the current sample data, and obtains an updated weight parameter value by gradient feedback based on the model output result and the current sample data.
3. The method according to claim 2, characterized in that The method for determining the end of the training includes: Generate a loss function value based on the model output result and the current sample data; On the premise that the loss function value meets the preset requirements, the training is judged to be completed.
4. The method according to any one of claims 1 to 3, characterized in that: The determining a current weight parameter value corresponding to the current sample data based on the current distribution includes: The current distribution is sampled by a target sampling method to obtain a current weight parameter value corresponding to the current sample data.
5. The method according to any one of claims 1 to 3, characterized in that: The obtaining of each sample data comprises: Determine the data scenarios corresponding to cost-sensitive data; Initial data corresponding to the data scenario is acquired, and the initial data is preprocessed to obtain sample data.
6. The method according to claim 5, characterized in that The method further comprises: Calculating the correlation between the sample data and the target classification through a feature selection algorithm; The sample data is screened based on the correlation.
7. A model training device based on weight uncertainty, characterized in that: The device comprises: A sample data acquisition module is used to obtain each sample data and target quantity; A model building module, used to build a model and set the current distribution corresponding to each weight parameter in the model; A current weight parameter value determination module, used to determine a current weight parameter value corresponding to the current sample data based on the current distribution when the number of sample data input to the model is less than the target number; An updated weight parameter value determination module is used to send the current weight parameter value and the current sample data to the distributed computing framework to obtain each updated weight parameter value returned by the gradient; A training module is used to update the current distribution of each weight parameter based on each updated weight parameter value when the number of sample data input to the model is equal to the target number, and use the updated current distribution as the current distribution, and continue to determine the current weight parameter value corresponding to the current sample data based on the current distribution until the training is completed.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.