A federated learning model training method and system based on distributed system
By dynamically allocating resources through the SAC algorithm and split learning mechanism, the problems of insufficient data utilization and improper resource allocation of weak computing nodes in distributed environments are solved, the efficiency and accuracy of model training are improved, and the system performance is optimized.
Patent Information
- Application Number
- CN202510030516.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-01-08
AI Technical Summary
In a distributed collaborative computing environment, the data resources of weak computing nodes are not fully utilized, resulting in the global model characteristics being biased towards strong computing nodes, and the static allocation of spectrum resources and computing resources leads to communication congestion and low training efficiency.
The SAC algorithm is used to calculate the scheduling strategy of user nodes, dynamically allocate training tasks and computing resources, adopt a split learning mechanism, assign the federated model to different nodes for training, and aggregate parameters between edge servers and central servers to optimize spectrum resources and energy consumption constraints.
It improves the training efficiency and accuracy of the global federated model, reduces system latency, fully utilizes the data resources of each node, and avoids resource competition and communication bottlenecks.
Smart Images

Figure CN120106178B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields 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 actual distributed collaborative computing environments, due to significant differences in computing power and local data volume among devices, edge computing nodes, such as user terminals, often face the challenge of possessing large amounts of local training data but insufficient computing power. This makes them unable to independently process complex deep learning models, and overall federated learning training is often affected by these weak computing nodes. In traditional federated learning, the system requires these user nodes to perform additional rounds of local training before uploading model updates. Weak computing nodes may even be excluded during the user selection phase to accelerate the convergence of overall training. User nodes with greater computing resources, on the other hand, can upload updates more frequently. This practice causes the final federated learning global model features to be biased towards the dataset characteristics of user nodes that frequently upload model updates, thereby wasting valuable data resources from weak computing nodes and ultimately affecting the generalization performance of the global model.
[0003] In edge computing environments, spectrum resources for communication and computing node computing power for task offloading are often limited. Especially when facing large-scale node collaboration and real-time communication requirements, the allocation strategy for these resources directly determines the efficiency of computing task offloading and the overall performance of the system. In localized dynamic computing task offloading, each user node may undertake tasks of varying sizes at different times, resulting in constantly changing demands for spectrum and computing resources. Given limited bandwidth, unreasonable, static resource allocation strategies can easily lead to competition among nodes for spectrum and computing resources, resulting in communication congestion between nodes, increased task execution delays, decreased communication efficiency, and even the inability to complete tasks, which in turn reduces the training speed and performance bottlenecks of the entire system. Summary of the Invention
[0004] In order to overcome at least one of the above-mentioned defects of the prior art, 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 solutions of the present invention are 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, setting the objective function 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 using 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] Furthermore, in step S1, the objective function and constraints 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 time t, 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 accuracy threshold of the federated model, 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 k-th edge server during the training process at the t-th time includes:
[0021] Training energy consumption E includes federated model training energy consumption E train And the transmission energy consumption E of the federated model trans :
[0022]
[0023] in, is the computational energy consumed by the mth user node in training at time t, is the task offloading energy consumption generated 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 time t, The ratio of the rth task offloaded to the jth user node by the mth 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)log2(1+T k,m (t))
[0026] Among them, B m (t) is the spectrum resource of the mth user node at time t, 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 time t.
[0027] Furthermore, in step S2, the scheduling strategy of the user node is calculated using the SAC algorithm, including:
[0028]
[0029] πbes t is the optimal scheduling strategy, which includes calculating the task offloading ratio, is the expectation of the scheduling policy, 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] Furthermore, 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 using 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 federated 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 parameters of the client model and parameters of the server model based on the server model output data, 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 based on the loss function, and update the parameters of the server model based on 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 trained in round t;
[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] Furthermore, 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] Furthermore, in step S5, the central server aggregates the parameters of the local federated models to obtain a trained global federated model, including:
[0052]
[0053] is the model parameter of the central server in the t+1 round, is the global federation model parameter of the kth edge server in round t+1.
[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, set the objective function and constraints with the goal of minimizing the total latency of federated model training;
[0056] SAC algorithm module, used to calculate the scheduling strategy of user nodes through SAC algorithm;
[0057] A federated model training module is used to divide user nodes according to the scheduling strategy, assign the federated model to the divided user nodes, and train the federated model on the divided user nodes using 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 beneficial effects of the technical solution of the present invention are:
[0061] The present invention calculates a scheduling strategy for user nodes using a SAC algorithm; the scheduling strategy divides the user nodes, assigns a federation model to the divided user nodes, and the divided user nodes train the federation model using 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 user nodes is calculated through the SAC algorithm. Training tasks and scheduling computing resources are dynamically allocated through the scheduling strategy. While reducing the overall system latency, the accuracy of the global federated model is ensured, effectively improving the efficiency of model training in a distributed environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 Schematic diagram of the federated learning model training method according to 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 the 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 accompanying drawings are for illustrative purposes only and are not to be construed as limiting this patent;
[0068] In order to better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size;
[0069] It is understandable to those skilled in the art that some well-known structures and descriptions thereof may be omitted in the drawings.
[0070] The technical solution of the present invention is further described below with reference to 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, setting the objective function 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 using 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] During 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 through the model segmentation mechanism of parallel updating and split learning of the federated model, its local data resources are fully utilized to avoid the bias of the global model.
[0079] Example 2
[0080] This embodiment, based on the first embodiment, further discloses the following contents:
[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 time t, 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 accuracy threshold of the federated model, 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 Representative, to ensure 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 Representative, to ensure that the sum of the training energy consumption of each user in each round of federated training does 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 ensures that the transmission rate between the edge server and the user nodes and computing nodes cannot be lower than the threshold.
[0089] This embodiment optimizes overall latency rather than local latency, enabling multiple edge servers to collaborate and optimize overall system performance. The independent variables for optimization are the spectrum resources and computing task ratios allocated by different edge servers to user nodes participating in federated training.
[0090] Example 3
[0091] This embodiment, based on Embodiments 1 and 2, further discloses the following contents:
[0092] Calculating the energy consumption of the k-th edge server during the training process at the t-th time includes:
[0093] Training energy consumption E includes federated model training energy consumption E train And the transmission energy consumption E of the federated model trans :
[0094]
[0095] in, is the computational energy consumed by the mth user node in training at time t, is the task offloading energy consumption generated 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 time t, The ratio of the rth task offloaded to the jth user node by the mth 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)log2(1+T k,m (t))
[0098] Among them, B m (t) is the spectrum resource of the mth user node at time t, 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 time t.
[0099] In the specific implementation process, the delay T generated 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 responsible not only for maintaining and managing the user nodes connected to it, but also for managing the segmentation and aggregation of the user nodes' local training models. It also serves as a communication bridge, providing base station services for user nodes within its coverage area and dynamically allocating bandwidth to each user node. This ensures efficient data transmission and task offloading during node federated learning, optimizes transmission efficiency, and reduces communication latency.
[0100] According to Shannon's theorem, the transmission rate R of the communication link between the edge server k and the user node m is k,m (t) is expressed as:
[0101] R k,m (t) = B m (t)log2(1+τ k,m (t))
[0102] Set the maximum allocable 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. Transmission delay for:
[0103]
[0104] Assume that the FLOPs required for local training of user node m is CPU calculation frequency on a given user node In the case of , the local training delay of user node m in responding 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] Indicates the processing ratio of the task to be offloaded to the specified computing node j, This means that the computing task will be processed on user node m. This means that the calculation task will be The proportion of processing offloaded to non-local node j.
[0109] Total delay T k Expressed as:
[0110]
[0111] The power consumption per unit time during local training of a given user node m The computational energy consumed by user node m in a single FL training 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. 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 the local training process:
[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 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 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 policy, 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, a 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 optimal resource scheduling decisions can be made in diverse 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 conditions.
[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 computation-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 the SAC agent. The SAC agent is given the state vector s according to the input 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 while maintaining 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 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 group 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 k Allocation strategy B in k Give the user node list U in the area 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 ′, which is the immediate reward obtained, represented by r k (s k ,a k ). In this network, the immediate reward obtained by edge server k at time t is the total delay T in the edge server k area.k (t) and the policy entropy of the current action strategy sum:
[0134]
[0135] SAC reinforcement learning uses policy entropy To measure the uncertainty of the probability distribution of the current strategy π in a given state to select different actions, it encourages the strategy 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, which indicates the importance of future rewards; V t+1 Is the value function, which means that in state s t The expected return.
[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 Experience replay pool stored in 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 iteratively converges to the optimal allocation strategy.
[0143]
[0144] The maximum entropy characteristic 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 within the coverage area of the edge server k. k , thereby continuously adjusting and optimizing the user node list U k Calculation of the 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 of exploration and development within the system through a reward mechanism.
[0145] Example 5
[0146] This embodiment, based on Embodiments 1, 2, 3, and 4, further discloses 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 using 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 federated 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 fully utilizing 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 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 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 computational workload of user node m while not 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 the unloading coefficient αm dynamically by converting 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 For 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 where the model is unloaded, 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 separable 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 node, while the part with large computation is handed over to the node with stronger computing resources or edge server for processing, thereby reducing the pressure on the resource-constrained node.
[0164] Computing tasks are adaptively offloaded based on the device resources of user devices and computing nodes, balancing the computing load across nodes within the scenario. Dynamic computing task offloading is more adaptable to device heterogeneity and network status fluctuations, thereby maximizing the utilization of computing resources within the scenario.
[0165] After step S3, the method further includes calculating parameters of the client model and 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 based on the loss function, and update the parameters of the server model based on 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 trained in round t;
[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 store local data x i Enter W client The feature extraction layer generates intermediate output data h i =W client (x i ;w client ), the computing power 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 model output Calculating the loss function By back-propagation, the loss function is calculated for the computing 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 passed back from computing node j from edge server k Then continue to model W for user node m client Partial parameter w clientPerform back propagation to calculate the gradient of the loss function with respect 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, the computing node j does not know the specific local training data D of the 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 model training efficiency 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 the specific local training data D of the user node m. 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] In 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 set its local model parameters The edge servers perform a weighted average aggregation of updates from all user nodes in their region to generate new global model parameters.
[0186] In step S5, the central server aggregates the parameters of the local federated models to obtain a trained global federated model, including:
[0187]
[0188] is the model parameter of the central server in the t+1 round, is the global federation model parameter of the kth edge server in round t+1.
[0189] Local model of edge server in round t After aggregation is completed, the model parameters are sent to the cloud server Participate in global aggregation. The cloud server receives the edge server model parameters Use federated averaging to aggregate and form new global model parameters
[0190] Example 6
[0191] This embodiment, based on Embodiments 1, 2, 3, 4, and 5, further discloses 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 includes:
[0193] The model building module is used to build a federated model, set the objective function and constraints with the goal of minimizing the total latency of federated model training;
[0194] SAC algorithm module, used to calculate the scheduling strategy of user nodes through SAC algorithm;
[0195] A federated model training module is used to divide user nodes according to the scheduling strategy, assign the federated model to the divided user nodes, and train the federated model on the divided user nodes using 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, further discloses 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 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 the parameters w for the global model W so that the global loss function is minimized.
[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, communication and other functions of user nodes in the user list are provided by the edge server; k Each user node m∈U in the list k All have local datasets where d m Represents the amount of data for user node m. Each user node uses its local dataset D locally. m For the local model W m To train, 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 lower 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 for illustrative purposes only and should not be construed as limiting this patent;
[0207] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A federated learning model training method based on a distributed system, characterized in that: Includes the following steps Steps: S1: Build a federated model with the goal of minimizing the total latency of federated model training and setting the objective function and constraints; wherein 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 time t, B max is the maximum available spectrum resource, T k is the kth edge The server's training delay, a k is the action performed by the kth edge server, B k is the frequency of the kth edge server Spectrum resources, ∑ k∈K ∑ m∈M E m (t) is the energy consumption generated by the k-th edge server allocated to the m-th 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 accuracy threshold of the federated model, 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; S2: Calculate the scheduling strategy of the user node through the SAC algorithm, including: π best is the optimal scheduling strategy, which includes calculating the task offloading ratio, For scheduling Strategic expectations, is the soft Q function of action a and state s, π(a|s) is the policy entropy of action a and state s; S3: The scheduling strategy divides the user nodes and assigns the federated model to the divided user nodes. The divided user nodes train the federation model using 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 distributed system-based federated learning model training method according to claim 1, characterized in that: Calculating the energy consumption of the k-th edge server during the training process at the t-th time includes: Training energy consumption E includes federated model training energy consumption E train And the transmission energy consumption E of the federated model trans : in, is the computational energy consumed by the mth user node in training at time t, is the task offloading energy consumption generated 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 time t, The ratio of the rth task offloaded to the jth user node by the mth user node.
3. The distributed system-based federated learning model training method according to claim 1, 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 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 time t.
4. The distributed system-based federated learning model training method according to claim 1, 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 using 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 federated 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.
5. The distributed system-based federated learning model training method according to claim 4, characterized in that: After step S3, the method further includes calculating parameters of the client model and 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 based on the loss function, and update the parameters of the server model based on 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 round t 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 trained in round t; 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.
6. The distributed system-based federated learning model training method according to claim 1, characterized in that: In 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.
7. The distributed system-based federated learning model training method according to claim 6, characterized in that: In step S5, the central server aggregates the parameters of the local federated models to obtain a trained global federated model, including: is the model parameter of the central server in the t+1 round, is the global federation model parameter of the kth edge server in round t+1.
8. A federated learning model training system based on a distributed system, characterized in that: The method for training a federated learning model according to any one of claims 1 to 7 comprises: The model construction module is used to build a federated model, set an objective function and constraints with the goal of minimizing the total latency of federated model training; wherein 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 time t, 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 k-th edge server allocated to the m-th 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 accuracy threshold of the federated model, 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; The SAC algorithm module is used to calculate the scheduling policy of user nodes using the SAC algorithm, including: π best is the optimal scheduling strategy, which includes calculating the task offloading ratio, is the expectation of the scheduling policy, is the soft Q function of action a and state s, π(a|s) is the policy entropy of action a and state s; A federated model training module is used to divide user nodes according to the scheduling strategy, assign the federated model to the divided user nodes, and train the federated model on the divided user nodes using 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