A dynamic fair federated learning method and device based on reinforcement learning

By using reinforcement learning to dynamically adjust client weights in federated learning, the convergence stability problem caused by uneven data distribution is solved, the cost of parameter tuning is reduced, and dynamic fairness quantification and model convergence acceleration are achieved.

CN117273119BActive Publication Date: 2024-09-13BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311076328.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-24
Publication Date
2024-09-13
Estimated Expiration
2043-08-24

AI Technical Summary

Technical Problem

Existing federated learning methods lead to convergence stability problems when dealing with uneven distribution of data from different clients, and it is difficult to determine parameters when using α-fairness fairness quantitative indicators. They rely on data sets and environments, have high requirements for parameter adjustment, and lack dynamic adaptability. .

Method used

Adopting a dynamic fair federated learning method based on reinforcement learning, each client uploads local data scale and training loss in a round of federated training to construct a reinforcement learning state space, select execution actions based on the state, calculate aggregate weights, and use experience replay to optimize fairness Dynamically adjust the mechanism to maximize the accuracy of the global federated model.

Benefits of technology

It achieves fair federated learning with privacy protection and small communication computing overhead, dynamically quantifies federated aggregation weights, reduces the dependence of parameters on the data set, and improves the model convergence speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117273119B
    Figure CN117273119B
Patent Text Reader

Abstract

The present invention provides a dynamic fair federated learning method and device based on reinforcement learning. In a round of federated training, each client trains the model sent by the server according to its own local data, generates a local model, and calculates the local training loss of the local model; uploads the local model, local training loss and local data scale to the server for aggregation; in the aggregation stage, the local training loss is used as the reinforcement learning state input, the execution action is selected according to the state and the current strategy, the aggregation weight is calculated according to the execution action and the local scale ratio, and the round of federated aggregation is completed based on the aggregation weight; the reward value is set according to the current global federated model accuracy to optimize reinforcement learning; multiple rounds of federated training are repeated until the final global federated model is obtained. The method provided by the present invention can use each local training loss as a fairness measure on the basis of protecting privacy and low communication overhead, optimize the federated aggregation process, and realize fair federated learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning technology, and in particular to a dynamic fair federated learning method and device based on reinforcement learning. Background Art

[0002] The effect of deep learning models is highly correlated with the quality and quantity of data. Models can learn useful knowledge from high-quality, representative data centers. However, high-quality data is usually held by many companies, organizations, and devices. Due to factors such as privacy, regulations, and interests, these data cannot flow freely among all parties and are difficult to centralize to train models. Federated learning can learn the implicit knowledge in the data of each client in a multi-party collaborative manner without leaving the local data, and jointly train an effective model. The core problem of federated learning is the non-independent and identically distributed problem. Existing methods mainly focus on the differences in the distribution of training data of each client.

[0003] At present, the classic federated learning algorithm aggregates the models of different participating clients by calculating the weighted average based on the local training data scale, and then obtains the global federated model. Due to the heterogeneity of data scale and distribution on different clients in the federated environment, minimizing the total loss in the global federated model will disproportionately affect the model performance of some clients, especially leading to the loss of consistency of results between clients. Although the global federated model has a high average accuracy on the test set, the accuracy of the model on a single device cannot be guaranteed.

[0004] Reinforcement learning is a technique that learns a strategy based on feedback through the interaction between an intelligent agent and the environment. This strategy can be represented as a set of parameters. This strategy represented by parameters can be iteratively trained through federated learning.

[0005] In the existing technology, some studies focus on analyzing the gradient conflicts sent back by clients to adjust the fairness problem during federated aggregation, such as AFL, FedFV, etc. However, these methods use randomly selected clients for federated aggregation optimization in each round of federated communication. During the aggregation stage, the local data on different clients is unevenly distributed, resulting in the gradient variance on each client being much larger than the weighted average from multiple selected clients, which leads to potential convergence stability problems.

[0006] Another part of the research work is to borrow fairness indicators, such as using indicators such as loss and accuracy on each client to quantify the fairness of federated aggregation, and adjusting the aggregation weight from the perspective of fair distribution to achieve fair learning. For example, q-FFL borrows the idea of ​​resource allocation, allocates fairness as a resource, adjusts a larger proportion of weights for clients with higher loss values ​​during training to achieve uniform distribution during federated aggregation, and also proposes an algorithm similar to FedAvg, q-FedAvg, to solve its proposed goal, and uses the estimated Lipschitz constant to avoid adjusting the learning rate of different q. α-FedAvg borrows the fairness metric calculation method to integrate it into the fairness quantification of the federated model system, and uses the gradient approximation algorithm to solve the federated aggregation weight, thereby achieving a balance between fairness and effectiveness of the federated learning system. PG-FFL measures the performance of the global federated model on each client by introducing the Gini coefficient, and uses reinforcement learning to take the accuracy and fairness of the model as the optimization goal, transforms the problem of solving the optimal model into a Markov decision problem, and integrates it into federated learning in the form of a fairness adjustment plug-in. DRFL integrates α-fairness and combines loss bias with client selection strategy to dynamically allocate weights to each client and promote fair federated learning. However, this type of method is difficult to determine parameters when using the α-fairness fairness quantification indicator, and it depends on the data set and federated environment, which has high requirements for parameter adjustment; and because federated learning requires accuracy and fairness to be adjusted in each round, this type of method lacks dynamic adaptability once the indicator calculation method is determined. Summary of the invention

[0007] In view of this, the embodiments of the present invention provide a dynamic fair federated learning method and device based on reinforcement learning to eliminate or improve one or more defects existing in the prior art, and solve the convergence stability problem caused by the uneven distribution of local data of different clients in the prior art, the difficulty in determining parameters when using the α-fairness fairness quantization indicator, the dependence on the data set and the federated environment, the high requirements for parameter adjustment, and the lack of dynamic adaptability.

[0008] On the one hand, the present invention provides a dynamic fair federated learning method based on reinforcement learning, characterized in that the method comprises the following steps:

[0009] In a round of federated training, each client trains the model sent by the server based on its own local data to generate a local model; calculates the local training loss of the local model;

[0010] Each client uploads the local data scale, the local model and the local training loss to the server, performs federation aggregation based on a fair dynamic adjustment mechanism, and obtains a preliminary global federated model;

[0011] The fair dynamic adjustment mechanism constructs a state space of reinforcement learning according to the local training loss of each client, selects a corresponding execution action according to the state and the strategy; calculates the proportion of the local data scale of each client; and determines the aggregation weight of each client according to the proportion of the local data scale and the execution action;

[0012] The fair dynamic adjustment mechanism is trained by using an experience replay method, a reward value is set according to the accuracy of the preliminary global federated model, and the fair dynamic adjustment mechanism is optimized with the goal of maximizing the reward value;

[0013] Based on the above steps, multiple rounds of federated training are performed until the preset performance requirements are met to obtain the final global federated model.

[0014] In some embodiments of the present invention, the local training loss of the local model is calculated as follows:

[0015]

[0016] Among them, F k (ω t+1 ) represents the global federated model ω obtained from the t+1th round of federated training t+1 The local training loss on client k, k∈[1,m]; p k represents the proportion of local data size of client k; q t-1 It represents the execution action selected according to the state in the fair dynamic adjustment mechanism in the t-1th round of federated training.

[0017] In some embodiments of the present invention, the fairness dynamic adjustment mechanism constructs the state space of reinforcement learning according to the local training loss of each client, and the calculation formula is:

[0018] S t ={F 1 (ω t ),F 2 (ω t ),...,F m (ω t )};

[0019] Among them, S t represents the reinforcement learning state space in the fair dynamic adjustment mechanism described in the tth round of federated training; F m (ω t ) represents the global federated model ω obtained by the tth round of federated training t The local training loss on client m.

[0020] In some embodiments of the present invention, the aggregation weight of each client is determined according to the local data scale ratio and the execution action, and the calculation formula is:

[0021]

[0022] Among them, W k represents the aggregate weight of client k, k∈[1,m]; p k represents the proportion of local data size of client k; q t-1 represents the execution action selected according to the state in the fair dynamic adjustment mechanism in the t-1th round of federated training; ω t Represents the global federated model obtained after the tth round of federated training.

[0023] In some embodiments of the present invention, the corresponding execution action is selected according to the state according to the strategy to obtain the probability of the T-step trajectory, which is calculated as follows:

[0024]

[0025] Where P(τ|π) represents the probability of the T-step trajectory; τ represents the decision sequence; π represents the strategy; ρ 0 represents the initial state distribution; s 0 represents the initial state; P(s t+1 |s t ,a t ) indicates that the agent performs action a t From the state t Transfer to state s t+1 probability.

[0026] In some embodiments of the present invention, the fairness dynamic adjustment mechanism is trained to find the best strategy to maximize the long-term reward expectation, and the calculation formula is:

[0027] π * =arg π maxJ(π);

[0028] in,

[0029] J(π)=∫ τ P(τ|π)R(τ)=E τ~π [R(π)];

[0030] Among them, π * represents the optimal strategy; π represents the strategy; J(π) represents the long-term reward expectation; τ represents the decision sequence; P(τ|π) represents the probability of the T-step trajectory; R(τ) represents the reward function.

[0031] In some embodiments of the present invention, in the fair dynamic adjustment mechanism, the agent is trained by strategy optimization, and the strategy is updated by gradient optimization, and the calculation formula is:

[0032]

[0033] Where θ represents the learnable agent parameters; J(π θ ) represents the long-term reward expectation; τ represents the decision sequence; π 0 represents the initial strategy; s t Indicates status; a t represents the execution action; R(τ) represents the reward function.

[0034] In some embodiments of the present invention, a reward value is set according to the accuracy of the preliminary global federated model, and the reward value calculation formula is:

[0035]

[0036] Among them, r t-1 represents the reward value of the t-1 round of federated training; a t Represents the current preliminary global federation model ω t Performance on the test set; F m (ω t ) represents the global federated model ω obtained by the tth round of federated training t The local training loss on client m.

[0037] In some embodiments of the present invention, calculating the local training loss of the local model further includes:

[0038] The client selects a batch size of local data to predict the local model, and constructs a loss function between the prediction result and the true label to obtain the local training loss.

[0039] On the other hand, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the methods mentioned above.

[0040] The beneficial effects of the present invention are at least:

[0041] The present invention provides a dynamic fair federated learning method and device based on reinforcement learning. In a round of federated training, each client trains the model sent by the server according to its own local data, generates a local model, and calculates the local training loss of the local model; uploads the local model, local training loss and local data scale to the server for aggregation; in the aggregation stage, the local training loss is used as the reinforcement learning state input, the execution action is selected according to the state and the current strategy, the aggregation weight is calculated according to the execution action and the local scale ratio, and the round of federated aggregation is completed based on the aggregation weight; the reward value is set according to the current global federated model accuracy to optimize reinforcement learning; multiple rounds of federated training are repeated until the final global federated model is obtained. The method provided by the present invention can use the local training loss of each client participating in the calculation of the global federated model as a fairness measure on the basis of protecting privacy and low communication computing overhead, optimize the federated aggregation process, and realize fair federated learning. Furthermore, based on a fair dynamic adjustment mechanism, the local training loss on each client in the federated learning is used as the state of the intelligent body, and the federated aggregation weight is dynamically adjusted according to the execution action of the intelligent body, so as to solve the problem of dynamic quantification of fairness in the federated learning process. Furthermore, by analyzing the α-fairness fairness measurement method and the training method of federated learning, the dependence of parameters on data sets is reduced, while the cost of the optimal reinforcement learning strategy is reduced, thereby accelerating model convergence.

[0042] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.

[0043] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:

[0045] Figure 1 The figure is a schematic diagram of the steps of a dynamic fair federated learning method based on reinforcement learning in one embodiment of the present invention.

[0046] Figure 2 Schematic diagram of the structure of a dynamic fair federated learning method based on reinforcement learning in one embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0048] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.

[0049] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.

[0050] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection with an intermediate.

[0051] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.

[0052] It should be emphasized here that the step marks mentioned below are not intended to limit the order of the steps, but it should be understood that the steps can be executed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be executed simultaneously.

[0053] In order to solve the problems of convergence stability caused by uneven distribution of local data of different clients in the prior art, the difficulty in determining parameters when using the α-fairness fairness quantization indicator, the dependence on data sets and federated environments, the high requirements for parameter adjustment, and the lack of dynamic adaptability, the present invention provides a dynamic fair federated learning method based on reinforcement learning, such as Figure 1 As shown, the method includes the following steps S101 to S104:

[0054] Step S101: In a round of federated training, each client trains the model sent by the server according to its own local data to generate a local model; and calculates the local training loss of the local model.

[0055] Step S102: Each client uploads the local data scale, local model and local training loss to the server, performs federation aggregation based on a fair dynamic adjustment mechanism, and obtains a preliminary global federated model.

[0056] Among them, the fair dynamic adjustment mechanism uses the local training loss of each client as the state space of reinforcement learning, selects the corresponding execution action according to the state and the strategy; calculates the local data scale ratio of each client; and determines the aggregation weight of each client based on the local data scale ratio and the execution action.

[0057] Step S103: Use the experience replay method to train the fair dynamic adjustment mechanism, set the reward value according to the accurate value of the preliminary global federated model, maximize the reward value as the goal, and optimize the fair dynamic adjustment mechanism.

[0058] Step S104: Based on the above steps, multiple rounds of federated training are performed until the preset performance requirements are met to obtain the final global federated model.

[0059] like Figure 2 As shown in the figure, it is a structural diagram of the dynamic fair federated learning method based on reinforcement learning, the upper side is the fair dynamic adjustment mechanism, and the lower side is the federated learning.

[0060] In step S101, in any round of federated training, the server randomly selects the clients to participate in this training, and broadcasts the preliminary global federated model and training parameters obtained in the previous round of training to the selected clients. If it is the first round of federated training, the initial model and initial parameters are broadcast to the selected clients.

[0061] Each client constructs a training set for training based on local data, that is, uses local data to train the model sent by the server to generate a local model.

[0062] In some embodiments, each client selects a batch size of local data to predict the local model, constructs a loss function between the prediction result and the true label, and calculates the local training loss. At the same time, a local optimization algorithm is used to update the model on the training set. Among them, the batch size refers to the number of samples selected from the local data (training set) each time. Exemplarily, the local data is divided into multiple smaller batches, and a batch size is selected to specify the number of samples in each batch. In the present invention, the batch size can be adjusted according to factors such as computing resources, memory limitations, and model performance, and is not limited in the present invention.

[0063] The method for calculating the local training loss includes the following steps:

[0064] Determine the batch size and randomly select that number of samples in the local data.

[0065] Input the sample into the local model for forward propagation to obtain the corresponding prediction result.

[0066] Compare the predicted result with the actual label and calculate the loss value, that is, construct a loss function between the predicted result and the actual label. Exemplarily, the loss function can be Mean Squared Error (MSE), Cross-Entropy Loss, etc.

[0067] The back propagation algorithm is used to update the parameters of the local model according to the loss value so that the local model can be gradually optimized and the loss can be reduced.

[0068] In some embodiments, the local training loss calculation formula of the local model is shown in formula (1):

[0069]

[0070] Among them, F k (ω t+1 ) represents the global federated model ω obtained from the t+1th round of federated training t+1 The local training loss on client k, k∈[1,m]; p k represents the proportion of local data size of client k; q t-1 It represents the execution action selected according to the state in the fair dynamic adjustment mechanism in the t-1th round of federated training.

[0071] In step S102, each client uploads the local model, local training loss, and local data scale obtained in step S101 to the server for federated aggregation.

[0072] In the present invention, a fairness dynamic adjustment mechanism based on reinforcement learning is designed. The local training loss on each client in federated learning is used as the agent state, and the federation aggregation weight is dynamically adjusted according to the output action of the agent to solve the problem of dynamic quantification of fairness in the federated learning process.

[0073] In the present invention, the design requirements of reinforcement learning for states, actions, and rewards are met by combining the situation of each round of communication iteration in federated learning. Specifically:

[0074] State: The local training loss of each client is used as the state space of reinforcement learning: In the tth round of federated training (communication), the global federated model ω t The local training loss calculated on the client constructs the state space S t , the calculation formula is shown in formula (2):

[0075] S t ={F 1 (ω t ), F 2 (ω t ), …, F m(ω t )}; (2)

[0076] Among them, S t represents the reinforcement learning state space in the fair dynamic adjustment mechanism of federated training in the tth round; F m (ω t ) represents the global federated model ω obtained by the tth round of federated training t The local training loss on client m.

[0077] Action: In each round of federated training (communication), when the state is updated, the agent needs to select the corresponding execution action based on the current state, that is, determine the current execution action based on the loss calculated by the current participating training client, so as to achieve fairness among the participating computing clients during dynamic evaluation aggregation during the federated training process.

[0078] Reward: Reward is used to balance fairness and accuracy in the federated learning process and optimize the federated global model to achieve the best results. In some embodiments, the calculation formula of the reward value is shown in formula (3):

[0079]

[0080] Among them, r t-1 represents the reward value of the t-1 round of federated training; a t Represents the current preliminary global federation model ω t Performance on the test set, encouraging the model to achieve optimal and fair performance; F m (ω t ) represents the global federated model ω obtained by the tth round of federated training t The local training loss on client m.

[0081] In the present invention, a parameter sensitivity strategy based on α-faimess is introduced. In formula (3), a t (Performance) is the accuracy of the prediction results of the global federated model on the client test set. The accuracy is used as a balance metric, and the weights during federated aggregation are modified according to fairness quantification, giving more weight to clients with greater training losses during local updates.

[0082] While building the reinforcement learning framework, the local data scale ratio is calculated based on the uploaded local data scale to obtain the traditional federated aggregation weight.

[0083] In some embodiments, the local data scale ratio is calculated as shown in formula (4):

[0084]

[0085] Among them, p irepresents the proportion of local data size of client i; D i and D j Represent the local data size of clients i and j respectively, i, j∈[1,m].

[0086] The aggregation weight of each client is determined according to the proportion of local data size and execution action. The calculation formula is shown in formula (5):

[0087]

[0088] Among them, W k represents the aggregate weight of client k, k∈[1,m]; p k represents the proportion of local data size of client k; q t-1 represents the execution action selected according to the state in the fair dynamic adjustment mechanism in the t-1th round of federated training; ω t Represents the global federated model obtained after the tth round of federated training.

[0089] Based on the above description, in the aggregation stage, the aggregation weight of each client is adjusted using a fair dynamic adjustment mechanism to achieve federated aggregation and obtain a global federated model.

[0090] In step S103, the present invention takes into account that in federated learning training, since a certain proportion of clients are randomly selected in each round to participate in the update, and the performance of the model on each client during aggregation needs to be considered, the optimal weight distribution is non-differentiable. The weight distribution problem of different local models in the global federated model is modeled as a deep reinforcement learning problem to solve the problem of balancing client accuracy and fairness in the federated aggregation stage.

[0091] The difference between reinforcement learning and supervised learning is that it does not rely on the feedback information given by the label, nor does it need to explicitly correct suboptimal operations. On the contrary, the focus of reinforcement learning is to find a balance between exploring unknown areas and developing current knowledge. The agent running on the server selects the corresponding execution action based on the state (i.e., the local training loss sent back by each client) and the current strategy, and can obtain the probability of the T-step trajectory, as shown in formula (6):

[0092]

[0093] Among them, P(τ|π) represents the probability of T-step trajectory; τ represents the decision sequence; π represents the strategy; ρ 0 represents the initial state distribution; s 0 represents the initial state; P(s t+1 |s t , a t ) indicates that the agent performs action a t From the state tTransfer to state s t+1 probability.

[0094] The goal of deep reinforcement learning is to find an optimal strategy that maximizes the expected long-term reward. The calculation formula is shown in formula (7):

[0095] π * =arg π maxJ(π); (7)

[0096] The calculation formula of J(π) is shown in formula (8):

[0097] J(π)=∫ τ P(τ|π)R(τ)=E τ~π [R(τ)]; (8)

[0098] In formula (7) and formula (8), π * represents the optimal strategy; π represents the strategy; J(π) represents the long-term reward expectation; τ represents the decision sequence; P(τ|π) represents the probability of the T-step trajectory; R(τ) represents the reward function, which is used to evaluate the quality of the agent's strategy.

[0099] In some embodiments, considering that the state needs to be changed after each round of communication during the federated learning training process, and that reinforcement learning needs to be relied upon to set the weights for the next round of federated aggregation for each client, a strategy optimization method is used to train the agent, and a gradient optimization method is used to update the strategy. The calculation formula is shown in formula (9):

[0100]

[0101] Where θ represents the learnable agent parameters; J(π θ ) represents the long-term reward expectation; τ represents the decision sequence; π 0 represents the initial strategy; s t Indicates status; a t represents the execution action; R(τ) represents the reward function.

[0102] In step S104, based on steps S101 to S103 (i.e., one round of federated training steps), multiple rounds of federated training are performed until the preset performance requirements are met, thereby obtaining a final global federated model.

[0103] Based on the above description, during the reinforcement federation training process, the server is responsible for selecting clients to participate in the training of federated learning and maintaining the optimization of the reinforcement learning agent strategy to achieve fair aggregation. The fair dynamic adjustment mechanism based on reinforcement learning uses the local training loss of the current global federated model on each client to construct the state space, selects the corresponding execution action according to the current optimal strategy, and determines the weight of each client model during federation aggregation based on the proportion of local data scale and execution action, so as to give greater penalties to clients with high losses and adjust the situation in which the proportion of the traditional federated aggregation is small due to the small data scale in the aggregation stage. The client updates the global federated model based on the local data, and uses the performance (accuracy) of the global federated model on the local data to provide a basis for the server to measure fairness.

[0104] The dynamic fair federated learning method based on reinforcement learning provided by the present invention is applicable to a variety of application scenarios. The present invention is further described below in conjunction with a specific embodiment.

[0105] This specific embodiment provides a method for detecting public safety emergencies, comprising the following steps:

[0106] The data to be detected is obtained, where the data to be detected includes text information about public safety emergencies on a social platform.

[0107] The data to be detected is input into the public safety emergency detection model trained by the dynamic fair federated learning method based on reinforcement learning provided by the present invention, and the public safety emergency corresponding to each text information in the data to be detected is obtained to achieve classification.

[0108] The training method of the public safety emergency detection model includes the following steps:

[0109] In a round of federated training, each client trains the model sent by the server based on its own local data, generates a local model, and calculates the local training loss of the local model. The local data includes text information about public safety emergencies on various social platforms with actual labels, ensuring the privacy of data on each platform.

[0110] Each client uploads the local data scale, local model and local training loss to the server, performs federation aggregation based on a fair dynamic adjustment mechanism, and obtains a preliminary global federated model.

[0111] The reinforcement learning in the fair dynamic adjustment mechanism is trained and optimized according to the training method described above; and multiple rounds of federated training are performed until the preset performance requirements are met to obtain the final global federated model, which is used as a public safety emergency detection model.

[0112] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a dynamic fair federated learning method based on reinforcement learning.

[0113] Corresponding to the above method, the present invention also provides a device, which includes a computer device, the computer device includes a processor and a memory, the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the steps of the method described above.

[0114] The embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the aforementioned edge computing server deployment method are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.

[0115] In summary, the present invention provides a dynamic and fair federated learning method and device based on reinforcement learning. In a round of federated training, each client trains the model sent by the server according to its own local data, generates a local model, and calculates the local training loss of the local model; uploads the local model, local training loss and local data scale to the server for aggregation; in the aggregation stage, the local training loss is used as the reinforcement learning state input, the execution action is selected according to the state and the current strategy, the aggregation weight is calculated according to the execution action and the local scale ratio, and the round of federated aggregation is completed based on the aggregation weight; the reward value is set according to the current global federated model accuracy to optimize reinforcement learning; multiple rounds of federated training are repeated until the final global federated model is obtained. The method provided by the present invention can use the local training loss of each client participating in the calculation of the global federated model as a fairness measure on the basis of protecting privacy and low communication computing overhead, optimize the federated aggregation process, and realize fair federated learning. Furthermore, based on the fair dynamic adjustment mechanism, the local training loss on each client in the federated learning is used as the state of the intelligent body, and the federated aggregation weight is dynamically adjusted according to the execution action of the intelligent body to solve the problem of dynamic quantification of fairness in the federated learning process. Furthermore, by analyzing the α-fairness fairness measurement method and the training method of federated learning, the dependence of parameters on data sets is reduced, while the cost of the optimal reinforcement learning strategy is reduced, thereby accelerating model convergence.

[0116] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.

[0117] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0118] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.

[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A dynamic and fair federated learning method based on reinforcement learning, characterized in that: The method comprises the following steps: In a round of federated training, each client trains the model sent by the server according to its own local data to generate a local model; calculates the local training loss of the local model; the local data includes text information about public safety emergencies on various social platforms with actual labels; Each client uploads the local data scale, the local model and the local training loss to the server, performs federation aggregation based on a fair dynamic adjustment mechanism, and obtains a preliminary global federated model; Among them, the local training loss calculation formula of the local model is: ; Indicates +1 round of federated training to obtain the global federated model On the client side The local training loss is ; Represents the client The proportion of local data size; Indicates - 1 round of federated training to execute actions selected according to the state in the fair dynamic adjustment mechanism; The fair dynamic adjustment mechanism constructs the state space of reinforcement learning according to the local training loss of each client, selects the corresponding execution action according to the state and the strategy; calculates the local data scale ratio of each client; determines the aggregation weight of each client according to the local data scale ratio and the execution action; the calculation formula of the aggregation weight is: ; Represents the client The aggregation weight of ; Represents the client The proportion of local data size; Indicates - 1 round of federated training to execute actions selected according to the state in the fair dynamic adjustment mechanism; Indicates The global federated model obtained by rounds of federated training; The fair dynamic adjustment mechanism is trained by using an experience replay method, a reward value is set according to the accuracy of the preliminary global federated model, and the fair dynamic adjustment mechanism is optimized with the goal of maximizing the reward value; Based on the above steps, multiple rounds of federated training are performed until the preset performance requirements are met to obtain the final global federated model.

2. The dynamic fair federated learning method based on reinforcement learning according to claim 1, characterized in that: The fair dynamic adjustment mechanism constructs the state space of reinforcement learning according to the local training loss of each client, and the calculation formula is: ; in, Indicates Reinforcement learning state space in the fair dynamic adjustment mechanism described in round federated training; Indicates The global federated model obtained by rounds of federated training On the client side The local training loss.

3. The dynamic fair federated learning method based on reinforcement learning according to claim 1, characterized in that: According to the state, the corresponding execution action is selected according to the strategy to obtain the probability of the T-step trajectory. The calculation formula is: ; in, represents the probability of the T-step trajectory; represents a decision sequence; represents said strategy; represents the initial state distribution; Indicates the initial state; Indicates that the agent performs actions according to From the status Transfer to state probability.

4. The dynamic fair federated learning method based on reinforcement learning according to claim 3 is characterized in that: The fair dynamic adjustment mechanism is trained to find the best strategy to maximize the expected long-term reward, calculated as: ; in, ; in, represents the optimal strategy; represents said strategy; Indicates long-term reward expectations; represents a decision sequence; represents the probability of the T-step trajectory; represents the reward function.

5. The dynamic fair federated learning method based on reinforcement learning according to claim 1, characterized in that: In the fair dynamic adjustment mechanism, the agent is trained by strategy optimization, and the strategy is updated by gradient optimization. The calculation formula is: ; in, represents the learnable agent parameters; Indicates long-term reward expectations; represents a decision sequence; represents the initial strategy; Indicates status; Indicates the execution of an action; represents the reward function.

6. The dynamic fair federated learning method based on reinforcement learning according to claim 1, characterized in that: The reward value is set according to the accuracy of the preliminary global federated model, and the reward value calculation formula is: ; in, express The reward value of a round of federation training; Represents the current preliminary global federation model Performance on the test set; Indicates The global federated model obtained by rounds of federated training On the client side The local training loss.

7. The dynamic fair federated learning method based on reinforcement learning according to claim 1, characterized in that: Calculating the local training loss of the local model further includes: The client selects a batch size of local data to predict the local model, and constructs a loss function between the prediction result and the true label to obtain the local training loss.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.