Federated learning model training method, device, non-volatile storage medium and electronic device
By alternately training the global model and local model in the multi-task federated learning model, the problems of client inequality and computational redundancy are solved, the fairness and robustness of model performance are improved, and the use of computing resources is reduced.
Patent Information
- Application Number
- CN202310912918.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2043-07-24
AI Technical Summary
During the training process, the multi-task federated learning model has problems such as client inequality and computational redundancy, which leads to the performance of the model in some local nodes after training that cannot meet user needs, and the training process occupies too much computing resources.
By determining the local model corresponding to the global model and each first node, and performing multiple rounds of training on the global model and the local model through each first node, the global model and local model are alternately trained to ensure the fairness of each terminal device during the federated learning model training process.
By alternately training of global models and local models, the problems of client inequality and computational redundancy of multi-task federated learning models during training are solved, which improves the fairness and robustness of model performance and reduces the computing resources required during training.
Smart Images

Figure CN116720592B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and specifically, to a federated learning model training method, device, non-volatile storage medium and electronic device. Background Art
[0002] In existing federated learning algorithms, a multi-task federated learning model is usually used to avoid model heterogeneity problems during training. However, the multi-task federated learning model has problems such as client inequality and computational redundancy during training, resulting in the local model performance of some nodes failing to meet user requirements after training is completed, and the computing power required during training is too much.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a federated learning model training method, device, non-volatile storage medium and electronic device to at least solve the technical problems in the related art that the multi-task federated learning model has client inequality and computational redundancy during the training process, resulting in the model performance of some local nodes after the training is completed not meeting user requirements, and the training process occupies too many computing resources.
[0005] According to one aspect of an embodiment of the present application, a method for training a federated learning model is provided, including: determining a global model and a local model corresponding to each first node, wherein the local model is stored in the corresponding first node; performing multiple rounds of training on the global model and the local model through each first node, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the training of the global model is completed, the local model is trained; obtaining a target global model obtained after multiple rounds of training and a target local model corresponding to each first node, wherein the test indicators of the target local model corresponding to each first node are within a preset test indicator value range.
[0006] Optionally, after the training is completed, the step of performing multiple rounds of training on the global model and the local model through each first node includes: in each training round, before training the global model, performing multiple corrected gradient descents on the local model according to the global correction coefficient; after multiple corrected gradient descents, determining the local correction coefficient corresponding to the first node according to the global correction coefficient and the corrected local model; and updating the global correction coefficient according to the local correction coefficient.
[0007] Optionally, the first node includes multiple second nodes and a scheduler, and the scheduler is used to allocate and schedule the second nodes, wherein the divergence value corresponding to the first node is within a preset divergence value range.
[0008] Optionally, before the step of determining the global model and the local models corresponding to each first node, the federated learning model training method also includes: instructing the scheduler to perform local iterative training on the local model corresponding to the scheduler based on the data corresponding to each second node until the second nodes are relatively balanced, wherein the relative balance between the second nodes includes that the load difference between any two second nodes is within an allowable range and the contributions of any two second nodes to the local model are balanced.
[0009] Optionally, before the step of determining the global model and the local models corresponding to each first node, the federated learning model training method also includes: determining outlier nodes from all second nodes; calculating the standard normal distribution score of each outlier node, and determining the majority class outlier nodes and the minority class outlier nodes according to the standard normal distribution score, wherein the standard normal distribution score of the majority class outlier node is greater than a first score threshold, the standard normal distribution score of the minority class outlier node is less than a second score threshold, and the first score threshold is greater than the second score threshold; downsampling the data in the majority class outlier nodes, and expanding the data in the minority class outlier nodes, wherein the expansion processing includes displacement processing, rotation processing and shearing processing of the data in the minority class outlier nodes.
[0010] Optionally, before the step of performing multiple rounds of training on the global model and the local model through each first node, the federated learning model training method also includes: determining a global optimization target and a local optimization target corresponding to each first node, wherein the global optimization target is used to train the global model and the local optimization target is used to train the local model; determining an optimization target control parameter of the local optimization target, wherein the optimization target control parameter is used to determine the similarity between the local optimization target and the global optimization target, and the larger the target control parameter, the greater the similarity between the local optimization target and the global optimization target.
[0011] Optionally, the step of performing multiple rounds of training on the global model and the local model through each first node includes: determining a target regularization term based on an optimization target control parameter, wherein the target regularization term is used to adjust the local optimization target so that the local optimization target is close to the global optimization target; using the target regularization term to adjust the local optimization target, and using the adjusted local optimization target to train the local model.
[0012] According to another aspect of an embodiment of the present application, a federated learning model training device is also provided, including: a first processing module, used to determine a global model and a local model corresponding to each first node, wherein the local model is stored in the corresponding first node; a second processing module, used to perform multiple rounds of training on the global model and the local model through each first node, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the training of the global model is completed, the local model is trained; a third processing module, used to obtain a target global model obtained after multiple rounds of training and a target local model corresponding to each first node, wherein the test indicators of the target local model corresponding to each first node are within a preset test indicator value range.
[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, in which a program is stored, wherein when the program is running, a device where the non-volatile storage medium is located is controlled to execute a federated learning model training method.
[0014] According to another aspect of an embodiment of the present application, an electronic device is also provided, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the federated learning model training method is executed when the program is running.
[0015] In an embodiment of the present application, a global model and a local model corresponding to each first node are determined, wherein the local model is stored in the corresponding first node; multiple rounds of training are performed on the global model and the local model through each first node, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the global model training is completed, the local model is trained; the target global model obtained after multiple rounds of training and the target local model corresponding to each first node are obtained, wherein the test indicators of the target local model corresponding to each first node are within the preset test indicator value range, and the global model and the local model are alternately trained to achieve the technical effect of ensuring the fairness of each terminal device during the training process of the federated learning model, thereby solving the technical problems of client inequality and computational redundancy in the training process of the multi-task federated learning model in the related technology, which leads to the model performance of some local nodes after the training does not meet user requirements, and the training process occupies too many computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1is a structural schematic diagram of a computer terminal provided according to an embodiment of the present application;
[0018] Figure 2 It is a flowchart of a federated learning model training method provided according to an embodiment of the present application;
[0019] Figure 3 It is a flowchart of a training process using gradient correction provided according to the relevant technology;
[0020] Figure 4 It is a flowchart of a training process using gradient correction provided in an embodiment of the present application;
[0021] Figure 5 It is a structural diagram of a federated learning model training device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0025] Federated learning model: The federated learning model is a machine learning method that aims to solve the problems of data privacy and security during model training. In traditional machine learning methods, data sets are usually stored in a central location and trained by a single entity or organization. In the federated learning model, data sets are stored in a distributed manner on multiple local devices or edge devices, and the model training process is performed on the local device, using only local data for training. There is no need to pass data to the central server. Only the updated parameters of the model will be transmitted to the central server.
[0026] Non-IID data scenario: refers to the situation where the samples in the data set are unevenly distributed or not independent and identically distributed. In this scenario, the distribution of different samples may be significantly different, such as the number of samples in some categories far exceeds that of other categories, or the distribution of different sample features is significantly different.
[0027] With the continuous increase of network access devices, the rapid growth of data volume and users' requirements for data privacy, the federated learning model has gradually become a mainstream model training method because it does not expose the device's own data and is only trained through parameter aggregation. Moreover, as an emerging multi-party machine learning framework, the federated learning model is expected to become the core solution for many complex multi-party machine learning scenarios when the current centralized cloud computing brings many problems such as privacy issues of participants and network limitations caused by massive data. At present, the major research challenges of federated learning include data heterogeneity, transmission efficiency, attack resistance, service valuation and user selection.
[0028] However, the federated learning model still has the following problems:
[0029] First, the training process of the federated learning model itself requires a large amount of computing resources and network resources. Therefore, in large-scale multi-party computing scenarios involving multiple clients, it is necessary to orchestrate and schedule the clients to reduce network pressure and save transmission costs through compression and encoding.
[0030] Second, although federated learning does not directly expose the data of edge nodes, it may also obtain information on the edge based on the transmission of parameters such as gradient data. Therefore, there is a risk of privacy leakage during the training process of the federated learning model. In addition, edge nodes are vulnerable to attacks, and there may be malicious participants who disrupt the learning process of the model.
[0031] Third, the data heterogeneity of the federated learning model is natural. The clients involved in the calculation are often mobile smart devices or IoT devices, and there are often large differences in the data scale, feature distribution, etc. of their training data. This will make it difficult to improve the accuracy of the global model, and then lead to problems such as model heterogeneity, which seriously affects the performance of the federated learning model finally trained.
[0032] Specifically, since each local device involved in the training process only records the relevant activity data of its owner, the data in different local devices often have different data sizes, data features, and target category distributions, resulting in the data distribution of any local device not being able to represent the overall data distribution. In addition, due to the defects in the aggregation method of the federated learning model itself, that is, the local data generated across local devices has inherent heterogeneity, the accuracy loss caused by data heterogeneity cannot be avoided during the training process of the federated learning model. For example, in the Non-IID data scenario, due to the class imbalance, distribution imbalance, or scale imbalance of the data set, the performance of the model finally trained cannot meet user needs.
[0033] In order to solve the problem of data heterogeneity, related technologies provide methods such as transfer learning, active learning, multi-task learning, client clustering, and data enhancement. Among them, multi-task learning refers to avoiding the problem of model heterogeneity by maintaining multiple independent models. However, multi-task federated learning has problems such as client inequality and computational redundancy.
[0034] In order to solve the problems of client inequality, computational redundancy, etc. in the above-mentioned multi-task federated learning model, relevant solutions are provided in the embodiments of the present application, which are described in detail below.
[0035] According to an embodiment of the present application, a method embodiment of a federated learning model training method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0036] The method embodiments provided in the embodiments of the present application can be executed by controlling the server remotely or by wired communication through a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a federated learning model training method. Figure 1As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0037] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the federated learning model training method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned federated learning model training method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0039] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0040] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0041] In the above operating environment, the present application embodiment provides a federated learning model training method, such as Figure 2 As shown, the method comprises the following steps:
[0042] Step S202, determining the global model and the local model corresponding to each first node, wherein the local model is stored in the corresponding first node;
[0043] In the technical solution provided in step S202, the first node includes multiple second nodes and a scheduler, and the scheduler is used to allocate and schedule the second nodes, wherein the divergence value corresponding to the first node is within a preset divergence value range.
[0044] Specifically, in the multi-task federated learning model, since each scheduler (i.e., the first node) will schedule several edge nodes (i.e., the second node), each scheduler and the several edge computing nodes it is responsible for scheduling jointly maintain a local model. In addition, during the training process, the scheduler can first control the corresponding edge node to perform internal iterations to achieve a local balance of the internal nodes, and then participate in the federated average as a unit of the scheduler.
[0045] When determining the edge nodes corresponding to the scheduler, it should be ensured that the number of edge nodes assigned to the scheduler does not exceed the upper limit of the scheduler's capacity, where the scheduler's capacity can be set by the developer. In order to achieve the maximum degree of local balance, the data distribution of each edge node corresponding to the scheduler should be as close to uniform distribution as possible. In addition, the scheduler can determine whether the data corresponding to the scheduler is close to uniform distribution by traversing KLD (Kullback-Leibler Divergence) calculations on each edge node and determining whether the calculation result is within a preset value range.
[0046] As an optional implementation method, before the step of determining the global model and the local models corresponding to each first node, the federated learning model training method also includes: instructing the scheduler to perform local iterative training on the local model corresponding to the scheduler based on the data corresponding to each second node until the second nodes are relatively balanced, wherein the relative balance between the second nodes includes that the load difference between any two second nodes is within an allowable range, and the contribution of any two second nodes to the local model is balanced.
[0047] In some embodiments of the present application, in order to ensure the training effect and alleviate the problem of global imbalance, before the step of determining the global model and the local model corresponding to each first node, the data in the edge node can be preprocessed, including the following steps: determining the outlier nodes from all the second nodes; calculating the standard normal distribution score of each outlier node, and determining the majority class outlier nodes and the minority class outlier nodes according to the standard normal distribution score, wherein the standard normal distribution score of the majority class outlier node is greater than the first score threshold, the standard normal distribution score of the minority class outlier node is less than the second score threshold, and the first score threshold is greater than the second score threshold; downsampling the data in the majority class outlier nodes, and expanding the data in the minority class outlier nodes, wherein the expansion processing includes displacement processing, rotation processing and shearing processing of the data in the minority class outlier nodes.
[0048] Specifically, a variant of the outlier detection algorithm based on the Z-score can be used to determine the outlier nodes in the edge nodes, determine the type of the outlier nodes, and perform data enhancement or downsampling on the data in the outlier nodes according to the type of the outlier nodes. The server that executes the federated learning model training method provided in the present application can first collect the distribution of sample data from the client, calculate the Z-score of the node based on the distribution, and then compare the Z-score of each node with the preset first score threshold τ d and the second score threshold τ a The comparison is performed, and the majority class outlier nodes and minority class outlier nodes are determined based on the comparison results. For the majority class outlier nodes, downsampling can be used to reduce the data size. For the minority class outlier nodes, new data can be obtained by randomly shifting, rotating, and shearing the original data to increase the data size. The specific degree of increasing or decreasing the data size can be measured by the parameter R. ad To measure, R ad The data ratio to be increased or decreased based on the current data size of the node.
[0049] By using the scheduler to manage multiple edge nodes and performing multi-task federated learning in units of schedulers, the statistical heterogeneity problem that may be stored in conventional federated learning can be effectively alleviated, and the computational redundancy during training and the low contribution of nodes with a small number of samples to training can be reduced. Specifically, when performing matrix optimization in units of schedulers, the amount of computation in each round can be significantly reduced.
[0050] Step S204, performing multiple rounds of training on the global model and the local model through each first node, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the global model training is completed, the local model is trained;
[0051] By adopting the method of alternating training of global models and local models provided by the present application, the fairness and robustness of the training process can be improved at the same time. Among them, fairness refers to the consistency of performance of the trained model across devices, and the test LOSS of all client devices (edge nodes) can be used as a standard to measure fairness. Robustness refers to the ability to resist attacks launched by malicious nodes during the training phase, which can be reflected by the test performance of benign nodes. The federated learning model training method in the related art usually adopts a method in which each client device independently optimizes the local model. Although robustness can be guaranteed, it performs poorly in terms of fairness. Even if the training results of the client are aggregated through node scheduling, the problem of poor performance of the model in some clients cannot be avoided.
[0052] In the technical solution provided in step S204, before the step of performing multiple rounds of training on the global model and the local model through each first node, the federated learning model training method also includes: determining a global optimization target and a local optimization target corresponding to each first node, wherein the global optimization target is used to train the global model, and the local optimization target is used to train the local model; determining an optimization target control parameter of the local optimization target, wherein the optimization target control parameter is used to determine the similarity between the local optimization target and the global optimization target, and the larger the target control parameter, the greater the similarity between the local optimization target and the global optimization target.
[0053] As an optional implementation, the step of performing multiple rounds of training on the global model and the local model through each first node includes: determining a target regularization term based on an optimization target control parameter, wherein the target regularization term is used to adjust the local optimization target so that the local optimization target is close to the global optimization target; using the target regularization term to adjust the local optimization target, and using the adjusted local optimization target to train the local model.
[0054] Specifically, it is assumed that the global optimization goal of the federated learning process can be expressed as follows:
[0055] min w G(F1(w),…F K (w))
[0056] In the above formula, G() is the function of aggregating local objective functions, w is the global optimization target model, F is the local target of each device, min w Indicates that the training objective is the convergence of the result of the aggregation function of the local objective function. K is the total number of devices, which can also be regarded as the number of schedulers in the multi-task federated learning process based on node scheduling.
[0057] Since the data distribution in different clients is different, for any node k, the optimization target of node k can be expressed as the following formula:
[0058]
[0059] In the above formula, D(k) represents all the data of node K, f k Represents a single data x under the optimization target of the model corresponding to node k k The loss calculation, x k Represents any data in the data set, ":=" represents a copy operation, and E represents x k The corresponding error.
[0060] When node k optimizes an independent local model, the optimization objective can be expressed as follows:
[0061]
[0062] where v k is the target model of node k, which is the independent local model mentioned above.
[0063] As an optional implementation method, the following regularization term can be added during the training of the local model, so that the local optimization target can approach the global optimization target:
[0064]
[0065]
[0066] The meaning of each parameter in the above regularization term can be found in other formulas in the previous article. Parameter λ is the optimization target control parameter. When λ is equal to 0, node K trains the local model, that is, the training target of the local model is quite different from the training target of the global model. When λ tends to infinity, the target of node k will be infinitely close to the global optimization target.
[0067] As an optional implementation method, after determining the above optimization target, the model training process provided in the embodiment of the present application is as follows:
[0068] The first step is to initialize the parameters, including initializing K, T, s, λ, η, ω0, {v k}, k∈[K] and other parameters;
[0069] In the second step, during the tth round of training, the server selects several nodes S t , and send the global model ω to these nodes t .
[0070] After receiving the global model, the node first trains and updates the aggregation model according to the federated aggregation algorithm, which can be expressed by the following formula:
[0071]
[0072] In the above formula Indicates the model and its parameters after training and updating, UPDATE_GLOBAL() indicates the training process, w t is the model parameter of the global model ωt, Represents the objective function during training.
[0073] After the global model training is completed, the node will also train and update the local model, which can be expressed by the following formula:
[0074]
[0075] The above formula represents the gradient descent training operation performed on the local model with the h() function as the optimization target, and η represents the learning rate.
[0076] In the technical solution provided in step S204, the steps of performing multiple rounds of training on the global model and the local model through each first node include: in each training round, before training the global model, performing multiple corrected gradient descents on the local model according to the global correction coefficient; after the multiple corrected gradient descents, determining the local correction coefficient corresponding to the first node according to the global correction coefficient and the corrected local model; and updating the global correction coefficient according to the local correction coefficient.
[0077] Specifically, in the process of federated learning, communication efficiency is one of the important challenges that affect the training effect. In the multi-task federated learning scenario, due to the complexity of relational matrix optimization, the fitting efficiency of federated learning will be further reduced, and some models cannot be fitted in the case of non-alternating optimization. In related technologies such as the FedAVG algorithm, the specific training process of a training is as follows: Figure 3As shown, the node performs multiple local gradient descent updates in one round. However, this method in the related art will cause the problem of reduced model accuracy when facing Non-IID data. In order to solve this problem, the SCAFFOLD algorithm provided by the present application can be used to add optimization of another correction parameter when the node performs local gradient descent, and use the correction parameter to control the node gradient to always descend in a relatively correct direction. In this way, in each training round, the node will locally update the node correction parameter after updating the global model and the local model, and then perform model aggregation of each node and update of the global correction parameter.
[0078] As an optional implementation method, the update rule of the correction parameter can be expressed by the following formula:
[0079]
[0080] In the above formula, gi() is a function for calculating the gradient of the node model parameters. i is the correction parameter of the i-th node, K is the number of times the entire data set is calculated in local training, x is the global model, and y i is the local model of node i, η l is the learning rate for local updates.
[0081] Each node can adaptively select parameter optimization solutions based on the training task characteristics of the local model. After the node completes the local correction parameter correction, the server can update the global correction parameter. Specifically, the server will first perform federated averaging on each node participating in the training. The specific formula is as follows:
[0082]
[0083] In the above formula, η g represents the learning rate during global update, represents the set of all nodes, and x represents the global model.
[0084] The server can then update the global correction parameters and prepare for the next local gradient correction. The specific formula is as follows:
[0085]
[0086] As an optional implementation, the present application also provides a method as follows: Figure 4 The process of gradient descent correction during federated learning model training shown in FIG. 1 includes the following steps:
[0087] First, input the global correction coefficient c of the scheduler model xt. For scheduler t, yt←xt, that is, update the model in the scheduler, and then perform K times of corrected gradient descent on yt.
[0088] yt←yt-ηl(gt(yt)-ct+c)
[0089] Then update the local correction coefficient And update the global correction coefficient
[0090]
[0091] In the above formula, M is the total number of schedulers, and c is the global correction coefficient. The above formula can be expressed by the local correction coefficient c of each scheduler. t A weighted average is performed to update the global correction coefficient.
[0092] Finally, the optimized scheduler model parameters are sent to perform local and global updates of the federated learning model.
[0093] Specifically, from Figure 4 It can be seen that when the extraction and correction method provided in this application is used to train the federated learning model, the scheduler receives the global model x i Update local model y i , then the local model y i Using local data and local correction factor c i And the global coefficient c to perform gradient correction and update y i , and then get the new local correction coefficient These parameters are sent to the global server. The server obtains the local correction coefficients and models of each scheduler, performs weighted average to obtain the global correction coefficient and global model, and then enters the next step of alternating optimization.
[0094] Step S206, obtaining the target global model obtained after multiple rounds of training and the target local model corresponding to each first node, wherein the test index of the target local model corresponding to each first node is within a preset test index value range.
[0095] By adopting a method of determining a global model and a local model corresponding to each first node, wherein the local model is stored in the corresponding first node; performing multiple rounds of training on the global model and the local model through each first node, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the global model training is completed, the local model is trained; obtaining a target global model obtained after multiple rounds of training and a target local model corresponding to each first node, wherein the test indicators of the target local model corresponding to each first node are within the preset test indicator value range, and by alternately training the global model and the local model, the technical effect of ensuring the fairness of each terminal device during the training process of the federated learning model is achieved, thereby solving the technical problems of client inequality and computational redundancy in the training process of the multi-task federated learning model in the related technology, which leads to the model performance of some local nodes failing to meet user requirements after the training, and the training process occupies too many computing resources.
[0096] In addition, by adopting the alternating optimization strategy provided by the present application, under the premise of reducing redundant calculations of multi-task learning through node scheduling, it is possible to alternately optimize in the generalization strategy and the personalized strategy, while improving the fairness of the client and the performance of the overall model. Moreover, by adopting the gradient descent correction method provided by the present application, the number of rounds required for model fitting can be effectively reduced by gradient descent, and the accuracy of the personalized model can be improved while improving the fitting rate.
[0097] In summary, the federated learning model training method provided in this application can effectively reduce the computing resources required in the training process and ensure that the performance of the final model on each terminal device participating in the training process has little difference.
[0098] The present application embodiment provides a federated learning model training device, Figure 5 is a schematic diagram of the structure of the device, such as Figure 5 As shown, the device includes: a first processing module 50, used to determine the global model and the local model corresponding to each first node, wherein the local model is stored in the corresponding first node; a second processing module 52, used to perform multiple rounds of training on the global model and the local model through each first node, wherein in each training round, the first node will use the data corresponding to the first node to train the global model, and after the global model training is completed, the local model is trained; a third processing module 54, used to obtain the target global model obtained after multiple rounds of training and the target local model corresponding to each first node, wherein the test indicators of the target local model corresponding to each first node are within the preset test indicator value range.
[0099] In some embodiments of the present application, the first node includes multiple second nodes and a scheduler, and the scheduler is used to allocate and schedule the second nodes, wherein the divergence value corresponding to the first node is within a preset divergence value range.
[0100] In some embodiments of the present application, before the step of determining the global model and the local models corresponding to each first node, the first processing module 50 is also used to: instruct the scheduler to perform local iterative training on the local model corresponding to the scheduler based on the data corresponding to each second node until the second nodes are relatively balanced, wherein the relative balance between the second nodes includes that the load difference between any two second nodes is within an allowable range, and the contribution of any two second nodes to the local model is balanced.
[0101] In some embodiments of the present application, before the step of determining the global model and the local models corresponding to each first node, the first processing module 50 is further used to: determine the outlier nodes from all the second nodes; calculate the standard normal distribution score of each outlier node, and determine the majority class outlier nodes and the minority class outlier nodes according to the standard normal distribution score, wherein the standard normal distribution score of the majority class outlier node is greater than the first score threshold, the standard normal distribution score of the minority class outlier node is less than the second score threshold, and the first score threshold is greater than the second score threshold; downsample the data in the majority class outlier nodes, and expand the data in the minority class outlier nodes, wherein the expansion processing includes displacement processing, rotation processing and shearing processing of the data in the minority class outlier nodes.
[0102] In some embodiments of the present application, the steps of the second processing module 52 performing multiple rounds of training on the global model and the local model through each first node include: in each training round, before training the global model, performing multiple corrected gradient descents on the local model according to the global correction coefficient; after multiple corrected gradient descents, determining the local correction coefficient corresponding to the first node according to the global correction coefficient and the corrected local model; and updating the global correction coefficient according to the local correction coefficient.
[0103] In some embodiments of the present application, before the step of performing multiple rounds of training on the global model and the local model through each first node, the second processing module 52 is also used to: determine the global optimization target and the local optimization target corresponding to each first node, wherein the global optimization target is used to train the global model and the local optimization target is used to train the local model; determine the optimization target control parameter of the local optimization target, wherein the optimization target control parameter is used to determine the similarity between the local optimization target and the global optimization target, and the larger the target control parameter, the greater the similarity between the local optimization target and the global optimization target.
[0104] In some embodiments of the present application, the second processing module 52 performs multiple rounds of training on the global model and the local model through each first node, including: determining a target regularization term based on an optimization target control parameter, wherein the target regularization term is used to adjust the local optimization target so that the local optimization target is close to the global optimization target; using the target regularization term to adjust the local optimization target, and using the adjusted local optimization target to train the local model.
[0105] It should be noted that the various modules in the above-mentioned federated learning model training device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0106] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0107] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0108] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0109] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0110] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0111] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0112] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for training a federated learning model, characterized in that: include: Determine a global model and a local model corresponding to each first node, wherein the local model is stored in the corresponding first node; Performing multiple rounds of training on the global model and the local model through each of the first nodes, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the training of the global model is completed, the local model is trained; The target global model obtained after the multiple rounds of training and the target local model corresponding to each of the first nodes are obtained, wherein the test indicators of the target local model corresponding to each of the first nodes are within the preset test indicator value range.
2. The federated learning model training method according to claim 1, characterized in that: After the training is completed, the step of performing multiple rounds of training on the global model and the local model through each of the first nodes includes: In each training round, before training the global model, the local model is subjected to multiple correction gradient descents according to the global correction coefficient; After the multiple modified gradient descents, determining a local correction coefficient corresponding to the first node according to the global correction coefficient and the modified local model; The global correction coefficient is updated according to the local correction coefficient.
3. The federated learning model training method according to claim 1, characterized in that: The first node includes multiple second nodes and a scheduler, and the scheduler is used to allocate and schedule the second nodes, wherein the divergence value corresponding to the first node is within a preset divergence value range.
4. The federated learning model training method according to claim 3, characterized in that: Before the step of determining the global model and the local models corresponding to each first node, the federated learning model training method further includes: Instruct the scheduler to perform local iterative training on the local model corresponding to the scheduler according to the data corresponding to each of the second nodes until the second nodes are relatively balanced, wherein the relative balance between the second nodes includes that the load difference between any two of the second nodes is within an allowable range and the contributions of any two of the second nodes to the local model are balanced.
5. The method for training a federated learning model according to claim 3, characterized in that: Before the step of determining the global model and the local models corresponding to each first node, the federated learning model training method further includes: determining an outlier node from among all the second nodes; Calculating the standard normal distribution score of each of the outlier nodes, and determining the majority class outlier nodes and the minority class outlier nodes according to the standard normal distribution score, wherein the standard normal distribution score of the majority class outlier nodes is greater than a first score threshold, the standard normal distribution score of the minority class outlier nodes is less than a second score threshold, and the first score threshold is greater than the second score threshold; The data in the majority class outlier nodes are downsampled, and the data in the minority class outlier nodes are expanded, wherein the expansion processing includes displacement processing, rotation processing and shearing processing of the data in the minority class outlier nodes.
6. The federated learning model training method according to claim 1, characterized in that: Before the step of performing multiple rounds of training on the global model and the local model through each of the first nodes, the federated learning model training method further includes: Determine a global optimization target and a local optimization target corresponding to each of the first nodes, wherein the global optimization target is used to train the global model, and the local optimization target is used to train the local model; Determine an optimization target control parameter of the local optimization target, wherein the optimization target control parameter is used to determine the similarity between the local optimization target and the global optimization target, and the larger the optimization target control parameter is, the greater the similarity between the local optimization target and the global optimization target is.
7. The method for training a federated learning model according to claim 6, characterized in that: The step of performing multiple rounds of training on the global model and the local model through each of the first nodes comprises: Determining a target regularization term according to the optimization target control parameter, wherein the target regularization term is used to adjust the local optimization target so that the local optimization target is close to the global optimization target; The target regularization term is used to adjust the local optimization target, and the adjusted local optimization target is used to train the local model.
8. A federated learning model training device, characterized in that: include: A first processing module, configured to determine a global model and a local model corresponding to each first node, wherein the local model is stored in the corresponding first node; A second processing module is used to perform multiple rounds of training on the global model and the local model through each of the first nodes, wherein in each training round, the first node uses the data corresponding to the first node to train the global model, and after the training of the global model is completed, the local model is trained; The third processing module is used to obtain the target global model obtained after performing the multiple rounds of training and the target local model corresponding to each of the first nodes, wherein the test indicators of the target local model corresponding to each of the first nodes are within the preset test indicator value range.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the federated learning model training method described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program, when running, executes the federated learning model training method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Model training method under federated learning network and related equipment thereof
CN111814985A
Federal model training method and device, electronic equipment and storage medium
CN113011602A