Federal learning model training method and system based on distributed system
Through the SAC algorithm, the scheduling strategy is calculated and the training tasks and computing resources are dynamically allocated, which solves the problem of insufficient computing power of edge computing nodes, improves the efficiency of federated learning and model accuracy, and avoids the tendency of global models.
Patent Information
- Application Number
- CN202510030516.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-01-08
AI Technical Summary
In a distributed collaborative computing environment, edge computing nodes cannot independently process complex deep learning models due to insufficient computing power, resulting in low federated learning training efficiency, and global model features tend to nodes with strong computing resources, wasting data resources of weak computing nodes.
The scheduling strategy of user nodes is calculated through the SAC algorithm, training tasks and computing resources are dynamically allocated, user nodes are divided to allocate federated models for training, and local model parameters are aggregated to form a global model to ensure the accuracy of the global model and the reduction of the overall system delay.
It effectively improves the efficiency of model training in a distributed environment, ensures the accuracy of the global federated model, makes full use of local data resources, and avoids the tendency of the global model.
Smart Images

Figure CN120106178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed machine learning and edge computing, and more specifically, to a federated learning model training method and system based on a distributed system. Background Art
[0002] In an actual distributed collaborative computing environment, due to the significant differences in computing power and local data volume among devices, edge computing nodes such as user terminal devices often face the problem of having a large amount of local training data but insufficient computing power, and are unable to independently process complex deep learning models. The overall federated learning training is often affected by these weak computing nodes. In traditional federated learning, the system will allow these user nodes to perform more rounds of training locally before uploading model updates, and may even exclude weak computing nodes during the user selection phase to accelerate the convergence of the overall training. User nodes with stronger computing resources can upload updates more frequently. This practice will cause the final federated learning global model features to be biased towards the data set features of those user nodes that frequently upload model updates, thereby wasting a large amount of valuable weak computing node data resources, and ultimately affecting the generalization performance of the global model.
[0003] In edge computing environments, spectrum resources used for communication and computing node computing power used for task offloading are often limited. Especially when faced with large-scale node collaboration and real-time communication needs, the above resource allocation strategy directly determines the offloading efficiency of computing tasks and the overall performance of the system. In local dynamic computing task offloading, each user node may undertake tasks of different scales at different times, and the demand for spectrum resources and computing power resources will also change continuously. In the case of limited bandwidth, unreasonable and static resource allocation strategies are likely to cause nodes to compete for spectrum resources and computing power resources, resulting in communication blockage between nodes, increased task execution delays, decreased communication efficiency, and even the inability to complete tasks, thereby reducing the training speed and performance bottlenecks of the entire system. Summary of the invention
[0004] In order to overcome at least one of the defects of the prior art described above, the present invention provides a federated learning model training method and system based on a distributed system.
[0005] The present invention aims to solve the above technical problems at least to a certain extent.
[0006] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0007] A federated learning model training method based on a distributed system includes the following steps:
[0008] S1: Build a federated model with the goal of minimizing the total latency of federated model training and setting objective functions and constraints.
[0009] S2: Calculate the scheduling strategy of the user node through the SAC algorithm;
[0010] S3: The scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model;
[0011] S4: the divided user node uploads the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model;
[0012] S5: The edge server uploads the aggregated local federation model to the central server, and the central server aggregates the parameters of the local federation model to obtain a trained global federation model.
[0013] Further, in step S1, the objective function and constraint conditions include:
[0014]
[0015] Constraint function: ∑ k∈K ∑ m∈M B m (t)≤B max
[0016] ∑ k∈K ∑ m∈M E m (t)≤E max
[0017]
[0018] Among them, ∑ k∈K ∑ m∈M B m (t) is the sum of spectrum resources of all user nodes at time t, B k (t) is the spectrum resource of the kth edge server at the tth time, B max is the maximum available spectrum resource, T k is the training delay of the kth edge server, a k is the action performed by the kth edge server, B k is the spectrum resource of the kth edge server, ∑ k∈K ∑ m∈M E m (t)
[0019] is the energy consumption generated by the kth edge server allocated to the mth user node during the training process at time t, E max is the maximum available training energy consumption, F(w m , d m ) is the federation model W m In the sample data d m The accuracy on D m is the total sample data, F min is the federated model accuracy threshold, is the communication rate threshold from the edge server to the user node, r k,m is the communication rate of the kth edge server at time t, and K is the number of edge servers.
[0020] Further, calculating the energy consumption of the kth edge server during the training process at the tth time includes:
[0021] The training energy consumption E includes the federated model training energy consumption E train And the transmission energy consumption E of the federation model trans :
[0022]
[0023] in, is the computing energy consumed by the mth user node in training at the tth time, is the task offloading energy consumption generated from offloading from the mth user node to the jth user node, is the transmission energy consumption from the mth user node to the jth user node at time t, is the transmission energy consumption of the mth user node at the tth time, The ratio of the mth user node offloading the rth task to the jth user node.
[0024] Further, calculating the communication rate between the mth user node and the kth edge server includes:
[0025] r k,m (t) = B m (t)log 2 (1+T k,m (t))
[0026] Among them, B m (t) is the spectrum resource of the mth user node at the tth time, T k,m (t) is the signal-to-noise ratio between the mth user node and the kth edge server at time t, r k,m (t) is the communication rate between the mth user node and the kth edge server at the tth moment.
[0027] Further, step S2, calculating the scheduling strategy of the user node by using the SAC algorithm, includes:
[0028]
[0029] πbes t is the optimal scheduling strategy, which includes calculating the task offloading ratio, is the expectation of the scheduling strategy, is the soft Q function of action a and state s, and π(a|s) is the policy entropy of action a and state s.
[0030] Further, in step S3, the scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model, including:
[0031] S3.1: The scheduling strategy divides the user node into a first node and a second node;
[0032] S3.2: Divide the federation model into a client model and a server model according to the first node and the second node, assign the client model to the first node, and assign the server model to the second node;
[0033] S3.3: The first node calculates the intermediate output data h based on the training data and the parameters of the customer model i =W client (x i ;w client )
[0034] h i is the intermediate output data, W client () is the customer model, x i is the training data;
[0035] S3.4: The second node calculates the server model output data using the intermediate output data and the parameters of the server model.
[0036]
[0037] Output data for the server model, W server () is the server model.
[0038] Furthermore, after step S3, the method further includes calculating the parameters of the client model and the parameters of the server model according to the output data of the server model, including:
[0039] S3.5: Calculate the loss function based on the server model output data;
[0040] S3.5: Calculate the gradient of the loss function with respect to the parameters of the server model according to the loss function, and update the parameters of the server model according to the gradient of the loss function with respect to the parameters of the server model
[0041]
[0042] are the parameters of the server model trained in the t+1th round, is the parameter of the server model for the tth round of training, η is the learning rate of the federated model gradient, is the gradient of the loss function with respect to the parameters of the server model in the tth round of training;
[0043] S3.6: Calculate the gradient of the loss function with respect to the parameters of the client model based on the loss function, and update the parameters of the client model based on the gradient of the loss function with respect to the parameters of the client model
[0044]
[0045] η m is the learning rate of the federated model gradient, are the parameters of the customer model trained in the t+1th round, are the parameters of the customer model trained in round t, is the gradient of the loss function with respect to the parameters of the customer model;
[0046] S3.7: Merge the updated parameters of the client model and the server model and send them to the edge server.
[0047] Further, in step S4, the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model, including:
[0048] Aggregate the parameters of the local federation model through the edge server to obtain the aggregated local federation model
[0049]
[0050] F m () is the loss function, is the federation model parameter of the mth user node in the tth round, is the federation model parameter of the mth user node in the t+1th round, is the federation model of the edge server in round t+1, d m is the data volume of the mth user node, d edge is the data volume of the edge server, is the federation model parameter of the edge server in round t+1;
[0051] Further, in step S5, the central server aggregates the parameters of the local federated model to obtain a trained global federated model, including:
[0052]
[0053] is the model parameter of the central server in the t+1th round, is the global federation model parameter of the kth edge server in the t+1th round.
[0054] A distributed system-based federated learning model training system, applied to the federated learning model training method, includes:
[0055] The model building module is used to build a federated model, with the goal of minimizing the total latency of federated model training, and setting objective functions and constraints;
[0056] SAC algorithm module, used to calculate the scheduling strategy of user nodes through SAC algorithm;
[0057] A federated model training module, which is used for dividing user nodes by the scheduling strategy, assigning the federated model to the divided user nodes, and the divided user nodes train the federated model through local training data to obtain a local federated model;
[0058] A local federation model aggregation module is used for the divided user nodes to upload the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model;
[0059] The global federated model module is used for the edge server to upload the aggregated local federated model to the central server, and the central server aggregates the parameters of the local federated model to obtain a trained global federated model.
[0060] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0061] The present invention calculates the scheduling strategy of user nodes through the SAC algorithm; the scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model; the central server aggregates the parameters of the local federation model to obtain a trained global federation model;
[0062] The present invention provides a federated learning model training method based on a distributed system. First, the scheduling strategy of the user node is calculated by the SAC algorithm, and the training tasks and scheduling computing resources are dynamically allocated through the scheduling strategy. While reducing the overall system delay, the accuracy of the global federated model is ensured, and the efficiency of model training in a distributed environment is effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 This is a schematic diagram of the federated learning model training method of the present invention;
[0064] Figure 2 This is a scene diagram based on the dynamic federated split learning architecture described in this embodiment;
[0065] Figure 3 This is a structural diagram of a dynamic resource allocation decision algorithm based on the SAC algorithm described in this embodiment;
[0066] Figure 4 Schematic diagram of the federated learning model training system described in the present invention. DETAILED DESCRIPTION
[0067] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;
[0068] In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product;
[0069] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0070] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0071] Example 1
[0072] A federated learning model training method based on distributed systems, such as Figure 1 and Figure 2 As shown, the following steps are included:
[0073] S1: Build a federated model with the goal of minimizing the total latency of federated model training and setting objective functions and constraints.
[0074] S2: Calculate the scheduling strategy of the user node through the SAC algorithm;
[0075] S3: The scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model;
[0076] S4: the divided user node uploads the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model;
[0077] S5: The edge server uploads the aggregated local federation model to the central server, and the central server aggregates the parameters of the local federation model to obtain a trained global federation model.
[0078] In the specific implementation process, the present invention calculates the scheduling strategy of user nodes through the SAC algorithm, dynamically allocates training tasks and schedules computing resources through the scheduling strategy, ensures the accuracy of the global federated model while reducing the overall system delay, and effectively improves the efficiency of model training in a distributed environment; secondly, the local federated models are aggregated into a global federated model, and the local data resources are fully utilized through the model segmentation mechanism of parallel updating and split learning of the federated model to avoid the bias of the global model.
[0079] Example 2
[0080] This embodiment further discloses the following contents based on the embodiment 1:
[0081] Step S1, the objective function and constraints include:
[0082]
[0083] Constraint function: ∑ k∈K ∑ m∈M B m (t)≤B max
[0084] ∑ k∈K ∑ m∈M E m (t)≤E max
[0085]
[0086] Among them, ∑ k∈K ∑ m∈M B m (t) is the sum of spectrum resources of all user nodes at time t, B k (t) is the spectrum resource of the kth edge server at the tth time, B max is the maximum available spectrum resource, T k is the training delay of the kth edge server, a k is the action performed by the kth edge server, B k is the spectrum resource of the kth edge server, ∑ k∈K ∑ m∈M Em (t)
[0087] is the energy consumption generated by the kth edge server allocated to the mth user node during the training process at time t, E max is the maximum available training energy consumption, F(w m , d m ) is the federation model W m In the sample data d m The accuracy on D m is the total sample data, F min is the federated model accuracy threshold, is the communication rate threshold from the edge server to the user node, r k,m is the communication rate of the kth edge server at time t, and K is the number of edge servers.
[0088] In the specific implementation process, since the spectrum resources in the system are limited, the edge server k allocates appropriate spectrum resources to its selected user node for uploading the local model, ∑ k∈K ∑ m∈M B m (t)≤B max Represents, ensuring that the sum of spectrum resources allocated to each user in each round of federated training does not exceed the maximum available spectrum resource B at the current moment max ;∑ k∈K ∑ m∈ M E m (t)≤E max It means that the sum of the training energy consumption of each user in each round of federated training shall not exceed the maximum available training energy consumption E at the current moment. max ; F(w m , d m )≥F min It means that the accuracy of the model assigned to the user node by the federated segmentation network on the user node sample data cannot be lower than the threshold; It represents that the transmission rate between the edge server and the user nodes and computing nodes cannot be lower than the threshold.
[0089] This embodiment takes the overall delay rather than the local delay as the optimization target, so that multiple edge servers work together to optimize the performance of the overall system. The optimized independent variables are the spectrum resources and computing task ratios allocated by different edge servers to the user nodes participating in the federated training.
[0090] Example 3
[0091] This embodiment further discloses the following contents based on Embodiments 1 and 2:
[0092] Calculating the energy consumption of the kth edge server during the training process at the tth time includes:
[0093] The training energy consumption E includes the federated model training energy consumption E train And the transmission energy consumption E of the federation model trans :
[0094]
[0095] in, is the computing energy consumed by the mth user node in training at the tth time, is the task offloading energy consumption generated from offloading from the mth user node to the jth user node, is the transmission energy consumption from the mth user node to the jth user node at time t, is the transmission energy consumption of the mth user node at the tth time, The ratio of the mth user node offloading the rth task to the jth user node.
[0096] Calculating the communication rate between the mth user node and the kth edge server, including:
[0097] r k,m (t) = B m (t)log 2 (1+T k,m (t))
[0098] Among them, B m (t) is the spectrum resource of the mth user node at the tth time, T k,m (t) is the signal-to-noise ratio between the mth user node and the kth edge server at time t, r k,m (t) is the communication rate between the mth user node and the kth edge server at the tth moment.
[0099] In the specific implementation process, the delay T caused by local model training within the edge server range is composed of the transmission delay T Trans and processing delay T Com Joint decision. In this implementation, the edge server acts as a transmission intermediary between the central server and the user nodes. It is not only responsible for maintaining and managing the user nodes connected to it, but also for managing the segmentation and aggregation of the local training models of the user nodes. It also plays the role of a communication bridge, providing base station services for user nodes within the coverage area, dynamically allocating bandwidth to each user node, ensuring efficient data transmission and task offloading during node federated learning, optimizing transmission efficiency, and reducing communication latency.
[0100] According to Shannon's theorem, the transmission rate R of the communication link between edge server k and user node m is k,m (t) is expressed as:
[0101] R k,m (t) = B m (t)log 2 (1+τ k,m (t))
[0102] Set the maximum allocatable bandwidth in the scene to B max , B m (t) is the bandwidth allocated by edge server k to user node m at time t, T k,m (t) is the signal-to-noise ratio between user node m and base station k. User m transmits model parameters to edge server base station k in the rth round of federated training iteration. The transmission delay for:
[0103]
[0104] Assume that the FLOPs required for local training of user node m is Calculate the CPU frequency on a given user node In the case of , the local training delay of user node m in response to a single federated training task request is:
[0105]
[0106] For a single federated training task of user node m that needs to offload tasks, the actual delay of a complete round of computing tasks is for:
[0107]
[0108] It indicates that the task is offloaded to the specified computing node j for processing ratio. This means that the computing task will be processed on user node m. This means that the calculation task will be The proportion of offloading to non-local node j.
[0109] Total delay T k It is expressed as:
[0110]
[0111] The power consumption per unit time when training locally on a given user node m Then the computing energy consumed by user node m in a single FL training is It is expressed as:
[0112]
[0113] The local complete model training of user node m is split by the edge server and offloaded to computing node j. Then the offloaded task energy consumption is
[0114]
[0115] Given the transmission power of user node m In the case of , user node m updates the locally trained model The energy consumed in the process of uploading to edge server k is:
[0116]
[0117] The user node m whose computing task is offloaded will also generate task offloading energy consumption when exchanging intermediate data with computing node j during local training:
[0118]
[0119] h i It is the intermediate information output by the segmentation model, and its transmission size is much smaller than the parameters of the overall model Analyzing the overall training process, the energy consumption E generated by federated training is mainly divided into model training energy consumption E train And the model transmission energy consumption E trans Two parts
[0120]
[0121] Example 4
[0122] This embodiment further discloses the following contents based on Embodiments 1, 2 and 3:
[0123] Step S2, calculating the scheduling strategy of the user node by using the SAC algorithm, including:
[0124]
[0125] π best is the optimal scheduling strategy, which includes calculating the task offloading ratio, is the expectation of the scheduling strategy, is the soft Q function of action a and state s, and π(a|s) is the policy entropy of action a and state s.
[0126] Because the user node's demand for the above spectrum resource allocation is time-varying, and the static allocation strategy will only reduce the overall training performance and performance ceiling of the system. This embodiment introduces the SAC reinforcement learning algorithm. The SAC reinforcement learning algorithm agent dynamically adjusts the proportion of task offloading and the allocation of spectrum resources by sensing the real-time resource requests of each node, making the overall resource allocation strategy more efficient and flexible. The SAC algorithm emphasizes that the edge server conducts more strategy exploration and development to ensure that the best resource scheduling decisions can be made in diversified and non-deterministic scenarios. This patent effectively avoids competition for spectrum resources and solves the communication bottleneck problem, ensuring low latency and high accuracy of edge servers during global model training under limited bandwidth.
[0127] In the specific implementation process, Figure 3 As shown, the SAC algorithm models the optimization problem by defining a Markov process quintuple The execution body of the Markov process is each edge server, which dynamically adjusts the user list U of the edge server k∈K k The offloading ratio α of the computationally constrained node m within m And allocate appropriate spectrum resources B to it m The process:
[0128]
[0129] The edge server group K continuously monitors the system status and builds the complete state space S of the system, that is, the state information of a single edge server k A set of D k is the total amount of data for training tasks in the edge server k region, is the total training delay of the user nodes in the region in the last round, is the total transmission delay of the user nodes in the previous round in the region. In the initial stage of this embodiment, each user node sends its resource status information s m ∈s k Upload to the edge server, the edge server integrates the status information of all nodes and transmits s k Given to the SAC agent. The SAC agent is based on the input state vector s k Perceived environment, the state vector contains the edge server and the user nodes U in its responsible area k status information.
[0130] SAC agent in s k All possible actions a according to the action strategy π in the state k =(α k ,B k) constitutes the action space A of the SAC agent. The SAC agent selects action a based on the maximum entropy strategy. k ∈A, the purpose of introducing the maximum entropy strategy is to measure the randomness of the current system resource allocation strategy π. Therefore, the value goal of the SAC agent is to maximize the cumulative reward R and maintain sufficient randomness of the allocation strategy π to encourage the edge server k to explore more possible allocation strategies and avoid the model training falling into the local optimal strategy. Action a k It is obtained through the SAC policy network formula, including:
[0131]
[0132] Where π(s k ) is the state-based policy network output, ∈ is Gaussian noise, which is used to increase the randomness of the policy and ensure that the SAC agent representing the edge server cluster conducts sufficient exploration. k After that, the edge server k is based on the allocation ratio list α k The corresponding user node task offloading ratio α m ∈α k Give user node m a segmentation model and delegate training task W m,client , and the computationally intensive tasks W m,server Offload to a more powerful computing node j for processing, thereby alleviating the problem of insufficient local computing resources and minimizing training delays In terms of spectrum resources, edge server k takes action a as k The allocation strategy B k Give the user node list U in the region k Allocate spectrum resources B m , ensuring efficient and timely communication between edge servers and user nodes to minimize transmission delays
[0133] In obtaining the action a output by the SAC agent k After that, the edge server follows a k The corresponding action is executed to obtain the new state s of the system environment feedback. k ′, the value measurement of this state is determined by the SAC agent value function R, that is, the value function R is the edge server k in s k Take action a in state k and transfer to the new state s k ′, expressed as r k (s k ,a k ). In this network, the instant reward obtained by edge server k at time t is the overall total delay T in the edge server k area.k (t) and the strategy entropy of the current action strategy sum:
[0134]
[0135] SAC reinforcement learning uses policy entropy To measure the uncertainty of the probability distribution of different actions selected by the current strategy π in a given state, the strategy is encouraged to select a variety of actions a with a higher probability in each state s, thereby increasing the possibility of strategy exploration, and using λ to adjust the contribution of the balance reward and entropy term. Therefore, the Q function of the SAC network is based on the soft return G t (i.e. cumulative reward r i and policy entropy The soft Q function of the sum:
[0136]
[0137] Where γ is the discount factor, indicating the importance of future rewards; V t+1 is the value function, which means that in state s t The expected return on investment.
[0138] The present invention also discloses a method for improving the scheduling strategy. In this embodiment, the edge server k will execute the state s before and after each execution. t s t+1 、Action a t and reward information t The experience replay pool that stores the experience replay mechanism The SAC agent periodically replays the experience from the pool The strategy is updated by sampling in order to optimize the policy network Actor and the evaluation network Critic, and finally learn the optimal allocation strategy π best In the policy network Actor, the edge server k should maximize the soft benefit J π As the network update target, use α π Control the effect of the entropy term on the total reward to ensure a balance between exploration and exploitation, specifically:
[0139]
[0140] Each time the edge server k interacts with the user node, the SAC agent uses the experience replay pool The evaluation network Critic is trained, and the goal of iterative update is to minimize the loss function J Q To update the soft Q function:
[0141]
[0142] The SAC agent continuously optimizes the quality of its scheduling strategy by alternating between strategy evaluation and strategy improvement. The SAC algorithm gradually iterates and converges to the optimal allocation strategy.
[0143]
[0144] The maximum entropy property of the SAC algorithm enables the agent to make flexible resource allocation decisions in complex dynamic environments. The agent based on the SAC reinforcement learning algorithm continuously perceives the state s in the coverage area of the edge server k. k , thereby continuously adjusting and optimizing the user node list U k Calculation of unloading ratio α k and spectrum resource allocation B k The ultimate goal is to minimize the overall task completion time T of the system k and maintain the balance between exploration and development within the system through a reward mechanism.
[0145] Example 5
[0146] This embodiment, based on Embodiments 1, 2, 3 and 4, continues to disclose the following contents:
[0147] Step S3, the scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model, including:
[0148] S3.1: The scheduling strategy divides the user node into a first node and a second node;
[0149] S3.2: Divide the federation model into a client model and a server model according to the first node and the second node, assign the client model to the first node, and assign the server model to the second node;
[0150] In the local edge server of the federated split hybrid framework, in order to solve the limitation of limited computing resources of some local user nodes during training and reduce the computing burden of user nodes, we need to offload the training computing tasks of nodes with insufficient computing resources, so that those user nodes with rich data but limited computing resources can offload the heavier computing burden to other more powerful nodes for processing, thereby making full use of the data resources D of each node without dragging down the overall training efficiency.
[0151] The user node m∈U in the local communication range of the edge server k is responsible for k A single training task can be regarded as a complete federated model W in the scenario. m Training, and in this process the user node j∈U that is not selected to participate in the federated training kTogether with all other idle user nodes, they form the computing power network node list C of edge server k. k Assume that the user node m selected to participate in FL training has a complete federated model W m , when the total number of training rounds is E and the number of samples in the training set is d n During the training process, the total amount of calculation of user node m is expressed as:
[0152]
[0153] ρ w is the computational constant of the federated model, which is determined by the structural type of the federated model W; G one sample W n Processing a single sample (x i ,y i ) The amount of computation required, that is, the L-layer federated model W m The amount of computation per layer G l The sum of the total number of training rounds E and the number of samples in the training set d n In order to reduce the training computation of user node m without affecting the model training accuracy, edge server k dynamically uses split learning to split the complete training model W of user node m. m , to solve the problem of heterogeneity of distributed devices.
[0154] The edge server k is based on the computing power of the user node m. Generate unloading coefficient α m dynamically transform the complete local model W m Split into user node part W client And the server part W server , the customer model W assigned to user node m client ∈W m is the complete user node model W m The first l∈L layers of the offloading task determine the offloading coefficient α m is defined as:
[0155]
[0156] S3.3: The first node calculates the intermediate output data based on the training data and the parameters of the customer model
[0157] h i =W client (x i ;w client )
[0158] h i is the intermediate output data, W client () is the customer model, x iis the training data;
[0159] S3.4: The second node calculates the server model output data using the intermediate output data and the parameters of the server model.
[0160]
[0161] Output data for the server model, W server () is the server model.
[0162] In the specific implementation process, considering the local data D of the node of the unloaded model n To address privacy issues, the task offloading process of split learning does not directly transfer local training data D n , but only sends the uninstalled node model W to the uninstalled node client Corresponding server model W server and intermediate data h i , where the customer model W client The main function is to perform local data D n Perform feature extraction, server model W server According to the customer model W client The output results are processed and the output results of the entire complete federated model W are obtained. By using the federated split learning architecture with divisible training tasks, the local training data of each node can be fully utilized and protected, thereby significantly improving the generalization performance of the global model and maximizing the data value of all nodes.
[0163] In the specific implementation process, the federated model is fixedly divided through split learning, and the part with small training computation is assigned to the resource-constrained nodes, while the part with large computation is handed over to the nodes with stronger computing resources or edge servers for processing, thereby reducing the pressure on resource-constrained nodes.
[0164] Adaptively offload computing tasks based on the device resources of user devices and computing nodes to balance the computing load of nodes within the scene. Dynamic computing task offloading has stronger adaptability when dealing with device heterogeneity and network status fluctuations, thereby maximizing the utilization of computing resources within the scene.
[0165] After step S3, the method further includes calculating the parameters of the client model and the parameters of the server model according to the output data of the server model, including:
[0166] S3.5: Calculate the loss function based on the server model output data;
[0167] S3.5: Calculate the gradient of the loss function with respect to the parameters of the server model according to the loss function, and update the parameters of the server model according to the gradient of the loss function with respect to the parameters of the server model
[0168]
[0169] are the parameters of the server model trained in the t+1th round, is the parameter of the server model for the tth round of training, η is the learning rate of the federated model gradient, is the gradient of the loss function with respect to the parameters of the server model in the tth round of training;
[0170] In the specific implementation process, the local user node receives the customer model W sent by the edge server. client Then start FL training. With user node model W client User node m will transfer local data x i Type W client The feature extraction layer generates intermediate output data h i =W client (x i ;w client ), the computing network list C of edge server k within the communication range k Find an idle computing node j∈C with matching computing power k After that, the server part W server Transmitted to computing node j, computing node j that receives the computing offload task uses the corresponding server model W server Calculate the final output of the model Calculate node j according to the true label y i And the model output Calculating the loss function By back-propagating, we can find the loss function for the computation node j model W server Parameter w server Gradient And update the computing node j model W server Partial parameters
[0171] Computation node j calculates the loss function for the intermediate output h i Gradient Then pass it to the user node for back propagation:
[0172]
[0173] User node m receives the gradient from edge server k, which is passed back from computing node j. Then continue to model W for user node m client Partial parameter w clientPerform back propagation to calculate the gradient of the loss function to the user node parameters And update it:
[0174] S3.6: Calculate the gradient of the loss function with respect to the parameters of the client model based on the loss function, and update the parameters of the client model based on the gradient of the loss function with respect to the parameters of the client model
[0175]
[0176] η m is the learning rate of the federated model gradient, are the parameters of the customer model trained in the t+1th round, are the parameters of the customer model trained in round t, is the gradient of the loss function with respect to the parameters of the customer model;
[0177] In the specific implementation process, computing node j does not know the specific local training data D of user node m to be unloaded. m The intermediate result of this process is not the real data but the gradient of the partial complete model, so it is difficult for malicious nodes to reversely deduce the real data x i .
[0178] Split learning is introduced in the edge local areas of the architecture as a method to improve the model training participation of these heterogeneous user nodes. Combining the advantages of both federated learning and split learning, it improves the efficiency of model training while solving problems such as data privacy, limited computing resources and communication overhead.
[0179] S3.7: Merge the updated parameters of the client model and the server model and send them to the edge server.
[0180] In the specific implementation process, the computing node j can unload the specific local training data D of the user node m without knowing it. m The intermediate result of this process is not the real data but the gradient of the partial complete model, so it cannot be reversed by malicious nodes to deduce the real data x i .
[0181] Step S4, the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model, including:
[0182] Aggregate the parameters of the local federation model through the edge server to obtain the aggregated local federation model
[0183]
[0184] F m () is the loss function, is the federation model parameter of the mth user node in the tth round, is the federation model parameter of the mth user node in the t+1th round, is the federation model of the edge server in round t+1, d m is the data volume of the mth user node, d edge is the data volume of the edge server, is the federation model parameter of the edge server in round t+1;
[0185] After the local training of user node m is completed, each user node participating in the training will The edge servers perform a weighted average aggregation of updates from all user nodes in their region to generate new global model parameters.
[0186] Step S5, the central server aggregates the parameters of the local federated model to obtain a trained global federated model, including:
[0187]
[0188] is the model parameter of the central server in the t+1th round, is the global federation model parameter of the kth edge server in the t+1th round.
[0189] Local model of edge server in round t After aggregation, send model parameters to the cloud server Participate in global aggregation. The cloud server receives the edge server model parameters Use federated average aggregation to form new global model parameters
[0190] Example 6
[0191] This embodiment, based on Embodiments 1, 2, 3, 4 and 5, continues to disclose the following contents:
[0192] A split learning model training system based on distributed systems, such as Figure 4 As shown, the split learning model training method applied to the split learning model includes:
[0193] The model building module is used to build a federated model, with the goal of minimizing the total latency of federated model training, and setting objective functions and constraints;
[0194] SAC algorithm module, used to calculate the scheduling strategy of user nodes through SAC algorithm;
[0195] A federated model training module, which is used for dividing user nodes by the scheduling strategy, assigning the federated model to the divided user nodes, and the divided user nodes train the federated model through local training data to obtain a local federated model;
[0196] A local federation model aggregation module is used for the divided user nodes to upload the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model;
[0197] The global federated model module is used for the edge server to upload the aggregated local federated model to the central server, and the central server aggregates the parameters of the local federated model to obtain a trained global federated model.
[0198] Example 7
[0199] This embodiment, based on Embodiments 1, 2, 3, 4, 5 and 7, continues to disclose the following contents:
[0200] In the specific implementation process, federated learning is used to train a global model as a collaborative computing task for the entire architecture. The goal of federated learning is for each node to train a global machine learning model W based on the data of each IoT device without transmitting the original training data to the cloud. The purpose of model training is to find parameters w for the global model W that minimize the global loss function.
[0201]
[0202] Assume that there are K edge servers and M user nodes deployed in the scenario, and each edge server k has a unique user list U k , the training task distribution and communication functions of the user nodes in the user list are provided by the edge server; k Each user node m∈U in the list k Have local datasets where d m Represents the amount of data in user node m. Each user node uses its local data set D locally. m For the local model W m To perform training, the user node updates its model parameters w m , the goal is to minimize the user model W m The loss function F(w m ), the model parameter update formula is:
[0203]
[0204] User Model W m There are model accuracy constraints Where F(w m ,d m ) is the user model W m In the local dataset D of user node m m Sample d m The accuracy of the loss function is not less than the model accuracy threshold F min , thus ensuring the model W of user nodes in the federated segmented network m Able to maintain high accuracy.
[0205] The same or similar reference numerals correspond to the same or similar components;
[0206] The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent;
[0207] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A federated learning model training method based on a distributed system, characterized in that: The following steps are involved: S1: Build a federated model with the goal of minimizing the total latency of federated model training and setting objective functions and constraints. S2: Calculate the scheduling strategy of the user node through the SAC algorithm; S3: The scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model; S4: the divided user node uploads the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model; S5: The edge server uploads the aggregated local federation model to the central server, and the central server aggregates the parameters of the local federation model to obtain a trained global federation model.
2. The method for training a federated learning model based on a distributed system according to claim 1, characterized in that: Step S1, the objective function and constraints include: Constraint function:∑ k∈K ∑ m∈M B m (t)≤B max ∑ k∈K ∑ m∈M E m (t)≤E max Among them, ∑ k∈K ∑ m∈M B m (t) is the sum of spectrum resources of all user nodes at time t, B k (t) is the spectrum resource of the kth edge server at the tth time, B max is the maximum available spectrum resource, T k is the training delay of the kth edge server, a k is the action performed by the kth edge server, B k is the spectrum resource of the kth edge server, ∑ k∈K ∑ m∈M E m (t) is the energy consumption generated by the kth edge server allocated to the mth user node during the training process at time t, E max is the maximum available training energy consumption, F(w m ,d m ) is the federation model W m In the sample data d m The accuracy on D m is the total sample data, F min is the federated model accuracy threshold, is the communication rate threshold from the edge server to the user node, r k,m is the communication rate of the kth edge server at time t, and K is the number of edge servers.
3. The method for training a federated learning model based on a distributed system according to claim 2, characterized in that: Calculating the energy consumption of the kth edge server during the training process at the tth time includes: The training energy consumption E includes the federated model training energy consumption E train And the transmission energy consumption E of the federation model trans : in, is the computing energy consumed by the mth user node in training at the tth time, is the task offloading energy consumption generated from offloading from the mth user node to the jth user node, is the transmission energy consumption from the mth user node to the jth user node at time t, is the transmission energy consumption of the mth user node at the tth time, The ratio of the mth user node offloading the rth task to the jth user node.
4. The method for training a federated learning model based on a distributed system according to claim 2, characterized in that: Calculating the communication rate between the mth user node and the kth edge server, comprising: r k,m (t)=B m (t)log2(1+τ k,m (t)) Among them, B m (t) is the spectrum resource of the mth user node at the tth time, τ k,m (t) is the signal-to-noise ratio between the mth user node and the kth edge server at time t, r k,m (t) is the communication rate between the mth user node and the kth edge server at the tth moment.
5. The method for training a federated learning model based on a distributed system according to claim 1, characterized in that: Step S2, calculating the scheduling strategy of the user node by using the SAC algorithm, including: π best is the optimal scheduling strategy, which includes calculating the task offloading ratio, is the expectation of the scheduling strategy, is the soft Q function of action a and state s, and π(a|s) is the policy entropy of action a and state s.
6. The method for training a federated learning model based on a distributed system according to claim 5, characterized in that: Step S3, the scheduling strategy divides the user nodes, assigns the federation model to the divided user nodes, and the divided user nodes train the federation model through local training data to obtain a local federation model, including: S3.1: The scheduling strategy divides the user node into a first node and a second node; S3.2: Divide the federation model into a client model and a server model according to the first node and the second node, assign the client model to the first node, and assign the server model to the second node; S3.3: The first node calculates the intermediate output data based on the training data and the parameters of the customer model h i =W client (x i ;w client ) h i is the intermediate output data, W client () is the customer model, x i is the training data; S3.4: The second node calculates the server model output data using the intermediate output data and the parameters of the server model. Output data for the server model, W server () is the server model.
7. The method for training a federated learning model based on a distributed system according to claim 6, characterized in that: After step S3, the method further includes calculating the parameters of the client model and the parameters of the server model according to the output data of the server model, including: S3.5: Calculate the loss function based on the server model output data; S3.5: Calculate the gradient of the loss function with respect to the parameters of the server model according to the loss function, and update the parameters of the server model according to the gradient of the loss function with respect to the parameters of the server model are the parameters of the server model trained in the t+1th round, is the parameter of the server model for the tth round of training, η is the learning rate of the federated model gradient, is the gradient of the loss function with respect to the parameters of the server model in the tth round of training; S3.6: Calculate the gradient of the loss function with respect to the parameters of the client model based on the loss function, and update the parameters of the client model based on the gradient of the loss function with respect to the parameters of the client model η m is the learning rate of the federated model gradient, are the parameters of the customer model trained in the t+1th round, are the parameters of the customer model trained in round t, is the gradient of the loss function with respect to the parameters of the customer model; S3.7: Merge the updated parameters of the client model and the server model and send them to the edge server.
8. The method for training a federated learning model based on a distributed system according to claim 1, characterized in that: Step S4, the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model, including: Aggregate the parameters of the local federation model through the edge server to obtain the aggregated local federation model F m () is the loss function, is the federation model parameter of the mth user node in the tth round, is the federation model parameter of the mth user node in the t+1th round, is the federation model of the edge server in round t+1, d m is the data volume of the mth user node, d edge is the data volume of the edge server, is the federation model parameter of the edge server in round t+1.
9. The method for training a federated learning model based on a distributed system according to claim 8, characterized in that: Step S5, the central server aggregates the parameters of the local federated model to obtain a trained global federated model, including: is the model parameter of the central server in the t+1th round, is the global federation model parameter of the kth edge server in the t+1th round.
10. A federated learning model training system based on a distributed system, characterized in that: The method for training a federated learning model as claimed in any one of claims 1 to 9 comprises: The model building module is used to build a federated model, with the goal of minimizing the total latency of federated model training, and setting objective functions and constraints; SAC algorithm module, used to calculate the scheduling strategy of user nodes through SAC algorithm; A federated model training module, which is used for dividing user nodes by the scheduling strategy, assigning the federated model to the divided user nodes, and the divided user nodes train the federated model through local training data to obtain a local federated model; A local federation model aggregation module is used for the divided user nodes to upload the local federation model to the edge server, and the edge server aggregates the parameters of the local federation model to obtain an aggregated local federation model; The global federated model module is used for the edge server to upload the aggregated local federated model to the central server, and the central server aggregates the parameters of the local federated model to obtain a trained global federated model.
Citation Information
Patent Citations
Data unbalanced distribution-oriented energy-saving federal learning method
CN118133984A
Energy industry intelligent algorithm optimization method based on federal learning
CN119249363A
Internet of vehicles task unloading method based on federated learning
CN119277450A
Agent policy learning method with privacy protection in mobile edge computing
WO2024254892A1