Data sharing system based on hierarchical federal learning
Through the hierarchical federated learning system and subspace tracking algorithm, the problem of high communication overhead of geographically dispersed devices in traditional federated learning is solved, stable synchronization of model parameters is achieved, and the efficiency and reliability of the data sharing system are improved.
Patent Information
- Application Number
- CN202410611581.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2024-09-17
AI Technical Summary
The traditional data sharing method based on federated learning has high communication overhead when multiple devices or nodes are geographically dispersed, and when a large number of artificial intelligence models are trained, it is difficult to ensure the stability of model parameter synchronization.
A hierarchical federated learning system is used to synchronize model parameters of global and edge iteration rounds through the hierarchical structure of cloud servers, cloud-side edge devices, and roadside edge devices. The subspace tracking algorithm is used for gradient reconstruction and aggregation to reduce communication overhead and ensure the stability of model parameter synchronization.
It effectively reduces communication overhead, ensures stable synchronization of model parameters in the case of multi-channel edge devices, and improves the efficiency and reliability of the data sharing system.
Smart Images

Figure CN118656202A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data sharing system based on hierarchical federated learning. Background Art
[0002] To meet the needs of traffic flow control and violation identification, artificial intelligence models can be deployed on urban roads. However, as urban traffic conditions become increasingly complex, more road data needs to be shared to train artificial intelligence models in order to better improve the level of intelligence in urban traffic. Since urban road data has a large amount of data and involves a lot of private data, directly uploading all road data to the cloud for sharing will result in huge resource consumption and may also cause the leakage of private data.
[0003] Federated learning is a distributed machine learning method that achieves local data processing and centralized model training by jointly training models on multiple devices or nodes. Although traditional data sharing methods based on federated learning can achieve data sharing while protecting data privacy, there are still certain problems in training artificial intelligence models based on traditional data sharing methods based on federated learning. On the one hand, since multiple devices or nodes may be geographically dispersed in different cities and regions, the communication overhead during model training is usually large. On the other hand, when the number of artificial intelligence models that need to be trained is large, the single-layer communication structure used in traditional data sharing methods based on federated learning is difficult to ensure the stability of model parameter synchronization. Summary of the invention
[0004] The present invention provides a data sharing system based on hierarchical federated learning, which is used to solve the problems in the prior art that multiple devices or nodes may be geographically dispersed in different cities and regions, the communication overhead in the model training process is usually large, and when the number of artificial intelligence models to be trained is large, the single-layer communication structure used in the traditional federated learning method is difficult to ensure the stability of model parameter synchronization, thereby reducing the communication overhead and ensuring the stability of model parameter synchronization.
[0005] The present invention provides a data sharing system based on hierarchical federated learning, comprising: a cloud server, a plurality of cloud-side edge devices and a plurality of roadside edge devices, wherein the plurality of roadside edge devices are distributed in a plurality of edge areas, each of the edge areas comprises at least one roadside edge device, and the cloud-side edge device corresponds to at least one edge area;
[0006] The cloud server is used to determine and issue the global model parameters corresponding to each global iteration round, and the cloud server is also used to determine the global model parameters corresponding to the last global iteration round as the target global model parameters; wherein the global model parameters corresponding to the next global iteration round are determined based on the global model parameters corresponding to the previous global iteration round and the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round;
[0007] In each global iteration round, for each of the cloud-side edge devices, the cloud-side edge device is used to send the edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area, and upload the edge aggregation gradient corresponding to the last edge iteration round to the cloud server; wherein, for each of the global iteration rounds, the edge model parameters corresponding to the first edge iteration round in the global iteration round are the global model parameters corresponding to the global iteration round; the edge model parameters corresponding to the next edge iteration round are determined based on the edge model parameters corresponding to the previous edge iteration round and the edge aggregation gradient corresponding to the previous edge iteration round; for each of the edge iteration rounds, the edge aggregation gradient corresponding to the edge iteration round is determined based on the regional aggregation gradient corresponding to the edge iteration round and the cloud-side local data volume corresponding to the cloud-side edge device;
[0008] In each edge iteration round, for each edge area, the roadside edge device in the edge area is used to iteratively train the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device; at least one of the roadside edge devices in the edge area is used to determine the regional aggregation gradient corresponding to the edge area based on the corresponding gradient value at the end of the iterative training of each roadside edge device in the edge area.
[0009] According to a data sharing system based on hierarchical federated learning provided by the present invention, the cloud server is specifically used for:
[0010] For each of the global iteration rounds, when the global iteration round is the first global iteration round, randomly determining a global model parameter corresponding to the first global iteration round;
[0011] When the global iteration round is not the first global iteration round, the global aggregation gradient corresponding to the previous global iteration round is determined based on the edge aggregation gradient uploaded by each cloud-side edge device in the previous global iteration round, and the global model parameters corresponding to the global iteration round are determined based on the global aggregation gradient corresponding to the previous global iteration round and the global model parameters corresponding to the previous global iteration round.
[0012] According to a data sharing system based on hierarchical federated learning provided by the present invention, the edge aggregation gradient uploaded by each cloud-side edge device in the previous global iteration round is used to determine the global aggregation gradient corresponding to the previous global iteration round, including:
[0013] The subspace tracking algorithm is used to reconstruct the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round to obtain the reconstructed edge aggregation gradients;
[0014] Aggregation processing is performed on each of the reconstructed edge aggregation gradients to determine a global aggregation gradient corresponding to the previous global iteration round.
[0015] According to a data sharing system based on hierarchical federated learning provided by the present invention, the cloud-side edge device is specifically used for:
[0016] In each global iteration round, for each edge iteration round in the global iteration round, a subspace tracking algorithm is used to reconstruct the corresponding regional aggregate gradients of the edge iteration round;
[0017] Aggregation processing is performed on each reconstructed regional aggregation gradient to determine the edge aggregation gradient corresponding to the edge iteration round.
[0018] According to a data sharing system based on hierarchical federated learning provided by the present invention, the roadside edge device is specifically used for:
[0019] In each edge iteration round, the following iterative training steps are performed:
[0020] S1. Performing initial training on the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device to obtain an initial sparse gradient of an initial training round;
[0021] S2, determining an initial regional aggregate gradient, wherein the initial regional aggregate gradient is determined based on an initial sparse gradient and local data corresponding to the roadside edge device in the current training round, and initial reconstruction gradients and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and initial reconstruction gradients corresponding to the remaining roadside edge devices are determined based on initial sparse gradients corresponding to the remaining roadside edge devices;
[0022] S3. Update the edge model parameters sent by the corresponding cloud-side edge device based on the initial regional aggregation gradient to obtain updated parameters;
[0023] S4. Retrain the local model based on the local data and the updated parameters to obtain a sparse gradient of the current training round;
[0024] S5, determining an aggregate gradient in the training area, wherein the aggregate gradient in the training area is determined based on the sparse gradient and local data corresponding to the roadside edge device in the current training round, and the reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradient corresponding to the remaining roadside edge devices is determined based on the sparse gradient corresponding to the remaining roadside edge devices;
[0025] S6. Update the update parameter based on the aggregated gradient of the training area to obtain a new update parameter;
[0026] S7. Repeat steps S4 to S7 using the new update parameter as the update parameter until the number of iterative training reaches a preset number.
[0027] According to a data sharing system based on hierarchical federated learning provided by the present invention, the local model is retrained based on the local data and the updated parameters to obtain a sparse gradient of the current training round, including:
[0028] The local model is updated based on the update parameters to obtain an updated local model, the local data is input into the updated local model for training, and a current model function output by the updated local model is obtained;
[0029] Determine a training gradient for a current training round based on the current model function;
[0030] The training gradient of the current training round is updated based on the residual gradient of the previous training round to obtain the updated gradient of the current training round;
[0031] Performing sparse processing on the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round;
[0032] The residual gradient of the current training round is the sum of the residual gradient of the previous training round and the sparse value of the current training round.
[0033] According to a data sharing system based on hierarchical federated learning provided by the present invention, the sparse processing of the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round includes:
[0034] Sort the updated gradient values in the updated gradient of the current training round according to their absolute values;
[0035] Selecting an updated gradient value of a target gradient value quantity from the sorting in descending order;
[0036] Determining the sparse gradient of the current training round based on the selected update gradient value, and determining the sparse value of the current training round based on the remaining update gradient values in the sorting;
[0037] The target gradient value quantity is determined based on the number of rounds of the current training round and the preset number of rounds.
[0038] According to a data sharing system based on hierarchical federated learning provided by the present invention, the roadside edge device is further used for:
[0039] Obtain compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area;
[0040] The subspace tracking algorithm is used to reconstruct the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradients corresponding to the remaining roadside edge devices in the corresponding edge area are obtained.
[0041] According to a data sharing system based on hierarchical federated learning provided by the present invention, the remaining roadside edge devices are specifically used for:
[0042] The sparse gradient of the current training round is compressed to obtain the compressed gradient of the current training round.
[0043] According to a data sharing system based on hierarchical federated learning provided by the present invention, compressing the sparse gradient of the current training round to obtain the compressed gradient of the current training round includes:
[0044] Compressing the sparse gradient of the current training round based on the target compression matrix to obtain the compressed gradient of the current training round;
[0045] The target compression matrix is determined based on the number of rounds of the current training round and the preset number of rounds.
[0046] The present invention provides a data sharing system based on hierarchical federated learning, which includes: a cloud server, multiple cloud-side edge devices and multiple roadside edge devices, wherein the multiple roadside edge devices are distributed in multiple edge areas, each edge area includes at least one roadside edge device, and the cloud-side edge device corresponds to at least one edge area. In each global iteration round, for each cloud-side edge device, the cloud-side edge device is used to send edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area, and upload the edge aggregation gradient corresponding to the last edge iteration round to the cloud server. In the technical solution of the present invention, the cloud server shares data with the roadside edge device through the cloud-side edge device. When the roadside edge devices are geographically dispersed in different areas of the city, since the cloud server connects the roadside edge devices in multiple different areas through multiple cloud-side edge devices, compared with the prior art in which the cloud server directly shares model parameters with each roadside edge device, the communication overhead can be reduced. In addition, when the number of roadside edge devices is large, that is, the number of local models corresponding to each roadside edge device is large, since the cloud server synchronizes model parameters with each roadside edge device through each cloud-side edge device, the longer distance data synchronization from the cloud server to the roadside edge device is converted into two shorter distance data synchronizations from the cloud server to the cloud-side edge device and then to the roadside edge device, thereby ensuring the stability of the model parameter synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 is a structural diagram of a data sharing system based on hierarchical federated learning provided by an embodiment of the present invention;
[0049] Figure 2 It is a flowchart of the roadside edge device performing iterative training steps provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] In view of the above problems in the prior art, the present invention provides a data sharing system based on hierarchical federated learning. Figure 1 is a schematic diagram of the structure of a data sharing system based on hierarchical federated learning provided by an embodiment of the present invention. Figure 1 As shown, the data sharing system based on hierarchical federated learning includes: a cloud server, multiple cloud-side edge devices and multiple roadside edge devices, wherein the multiple roadside edge devices are distributed in multiple edge areas, each of the edge areas includes at least one roadside edge device, and the cloud-side edge device corresponds to at least one edge area;
[0052] The cloud server is used to determine and issue the global model parameters corresponding to each global iteration round, and the cloud server is also used to determine the global model parameters corresponding to the last global iteration round as the target global model parameters; wherein the global model parameters corresponding to the next global iteration round are determined based on the global model parameters corresponding to the previous global iteration round and the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round;
[0053] In each global iteration round, for each of the cloud-side edge devices, the cloud-side edge device is used to send the edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area, and upload the edge aggregation gradient corresponding to the last edge iteration round to the cloud server; wherein, for each of the global iteration rounds, the edge model parameters corresponding to the first edge iteration round in the global iteration round are the global model parameters corresponding to the global iteration round; the edge model parameters corresponding to the next edge iteration round are determined based on the edge model parameters corresponding to the previous edge iteration round and the edge aggregation gradient corresponding to the previous edge iteration round; for each of the edge iteration rounds, the edge aggregation gradient corresponding to the edge iteration round is determined based on the regional aggregation gradient corresponding to the edge iteration round and the cloud-side local data volume corresponding to the cloud-side edge device;
[0054] In each edge iteration round, for each edge area, the roadside edge device in the edge area is used to iteratively train the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device; at least one of the roadside edge devices in the edge area is used to determine the regional aggregation gradient corresponding to the edge area based on the corresponding gradient value at the end of the iterative training of each roadside edge device in the edge area.
[0055] Specifically, the data sharing system based on hierarchical federated learning includes: a cloud server, multiple cloud-side edge devices and multiple roadside edge devices. The multiple roadside edge devices are distributed in multiple edge areas, each edge area includes at least one roadside edge device, and each cloud-side edge device corresponds to at least one edge area.
[0056] Exemplarily, the cloud server may be a smart intersection cloud server pre-established based on a cloud data center and a traffic command center. Each roadside edge device may obtain one or more intersection data such as traffic road camera data, traffic road radar data, and traffic road environment collector data as local data.
[0057] Furthermore, the cloud server can be used to determine the global model parameters corresponding to each global iteration round and send the global model parameters corresponding to each global iteration round to each cloud-side edge device. The cloud server can also be used to determine the global model parameters corresponding to the last global iteration round as the target global model parameters, which are the model parameters determined for the model by the data sharing system based on hierarchical federated learning. For example, the global model parameters corresponding to the first global iteration round are w 1 , the global model parameter corresponding to the last global iteration round is w H , we can use w H Determined as the target global model parameters, H represents the number of the last global iteration round, which can be preset. During the entire global iteration process, the global model parameters corresponding to the next global iteration round are determined based on the global model parameters corresponding to the previous global iteration round and the edge aggregation gradients uploaded by each cloud-side edge device in the previous global iteration round, that is, w h+1 Based on w h and the edge aggregation gradient uploaded by each cloud-side edge device in the global iteration round h, where the edge aggregation gradient can be a compressed edge aggregation gradient.
[0058] Furthermore, in each global iteration round, for each cloud-side edge device, the cloud-side edge device i can be used to send the edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area. (h represents the round number of the global iteration round, t represents the round number of the edge iteration round, and i represents the number of the cloud-side edge device). The cloud-side edge device can send edge model parameters to each roadside edge device in each corresponding edge area, or send edge model parameters to the representative roadside edge device in each corresponding edge area. The representative roadside edge device can receive edge model parameters on behalf of other roadside edge devices in the edge area, and can send the received edge model parameters to other roadside edge devices in the edge area step by step. The representative roadside edge device of an edge area can be determined based on the data propagation rate or bit error rate of each roadside edge device in the edge area. The cloud-side edge device i can also compress the edge aggregation gradient corresponding to the last edge iteration round and upload it to the cloud server. Among them, for each global iteration round, the edge model parameters corresponding to the first edge iteration round in the global iteration round are the global model parameters corresponding to the global iteration round, that is, In the entire edge iteration process, the edge model parameters corresponding to the next edge iteration round can be determined based on the edge model parameters corresponding to the previous edge iteration round and the edge aggregation gradient corresponding to the previous edge iteration round, that is, Based on and the edge aggregation gradient corresponding to edge iteration round t. For each edge iteration round, the edge aggregation gradient corresponding to edge iteration round t is determined based on the regional aggregation gradient corresponding to edge iteration round t and the cloud-side local data volume corresponding to the cloud-side edge device. The cloud-side local data volume is the sum of the regional local data volumes of each edge region corresponding to the cloud-side edge device. It should be noted that each global iteration round includes a complete edge iteration process, which includes multiple edge iteration rounds.
[0059] Furthermore, in each edge iteration round, for each edge region, the roadside edge device k in edge region j is used to generate edge model parameters based on the local data corresponding to the roadside edge device k and the edge model parameters sent by the cloud-side edge device corresponding to the roadside edge device k. Iteratively train the local model in the roadside edge device k. At the end of the entire edge iteration process, at least one roadside edge device in the edge area is used to determine the regional aggregation gradient corresponding to the edge area based on the corresponding gradient value at the end of the iterative training of each roadside edge device in the edge area. It is easy to understand that the regional aggregation gradient corresponding to the edge area can be determined by one roadside edge device in the edge area, or it can be determined by multiple roadside edge devices in the edge area. In the case where multiple roadside edge devices determine the regional aggregation gradient corresponding to the edge area based on the corresponding gradient value at the end of the iterative training of each roadside edge device in the edge area, even if one of the roadside edge devices fails, it does not affect the determination of the regional aggregation gradient corresponding to the edge area.
[0060] The present invention provides a data sharing system based on hierarchical federated learning, which includes: a cloud server, multiple cloud-side edge devices and multiple roadside edge devices. Multiple roadside edge devices are distributed in multiple edge areas, each edge area includes at least one roadside edge device, and the cloud-side edge device corresponds to at least one edge area. In each global iteration round, for each cloud-side edge device, the cloud-side edge device is used to send edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area, and upload the edge aggregation gradient corresponding to the last edge iteration round to the cloud server. In the technical solution of the present invention, the cloud server shares data with the roadside edge device through the cloud-side edge device. When the roadside edge devices are geographically dispersed in different areas of the city, since the cloud server connects the roadside edge devices in multiple different areas through multiple cloud-side edge devices, compared with the prior art in which the cloud server directly shares model parameters with each roadside edge device, the communication overhead can be reduced. In addition, when the number of roadside edge devices is large, that is, the number of local models corresponding to each roadside edge device is large, since the cloud server synchronizes model parameters with each roadside edge device through each cloud-side edge device, the longer distance data synchronization from the cloud server to the roadside edge device is converted into two shorter distance data synchronizations from the cloud server to the cloud-side edge device and then to the roadside edge device, thereby ensuring the stability of the model parameter synchronization.
[0061] In one embodiment, the cloud server is specifically used for:
[0062] For each of the global iteration rounds, when the global iteration round is the first global iteration round, randomly determining a global model parameter corresponding to the first global iteration round;
[0063] When the global iteration round is not the first global iteration round, the global aggregation gradient corresponding to the previous global iteration round is determined based on the edge aggregation gradient uploaded by each cloud-side edge device in the previous global iteration round, and the global model parameters corresponding to the global iteration round are determined based on the global aggregation gradient corresponding to the previous global iteration round and the global model parameters corresponding to the previous global iteration round.
[0064] Specifically, the cloud server can be used to: for each global iteration round, when the global iteration round is the first global iteration round, randomly determine the global model parameter corresponding to the first global iteration round, that is, w 1It can be the initial parameter of the model determined randomly. When the global iteration round is not the first global iteration round, that is, when h≠1, the cloud server can determine the global aggregation gradient of the previous global iteration round based on the edge aggregation gradient uploaded by each cloud-side edge device in the previous global iteration round (the edge aggregation gradient can be a compressed edge aggregation gradient), and determine the global model parameters corresponding to the global iteration round based on the global aggregation gradient and the global model parameters corresponding to the previous global iteration round.
[0065] For example, when the last global iteration round is h, the global model parameter w corresponding to the global iteration round h+1 is h+1 It can be determined by the following formula:
[0066] w h+1 =w h -ηg h
[0067] Among them, η represents the preset learning rate, g h represents the global aggregate gradient of global iteration round h.
[0068] In the above embodiment, the cloud server is specifically used to determine the global model parameters corresponding to each global iteration round, which lays the foundation for sending the global model parameters to each cloud-side edge device.
[0069] In one embodiment, determining the global aggregation gradient corresponding to the previous global iteration round based on the edge aggregation gradient uploaded by each of the cloud-side edge devices in the previous global iteration round includes:
[0070] The subspace tracking algorithm is used to reconstruct the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round to obtain the reconstructed edge aggregation gradients;
[0071] Aggregation processing is performed on each of the reconstructed edge aggregation gradients to determine a global aggregation gradient corresponding to the previous global iteration round.
[0072] Specifically, the Subspace Pursuit (SP) algorithm can be used to compress the edge aggregation gradient uploaded by the cloud-side edge device i in the previous global iteration round h, and then the compressed edge aggregation gradient can be (T represents the number of rounds of the last edge iteration round, which can be preset) to perform reconstruction processing to obtain the reconstructed edge aggregation gradient And the gradient of the reconstructed edge can be aggregated Perform aggregation processing to determine the global aggregation gradient g corresponding to the previous global iteration round h h , the global aggregate gradient g corresponding to the previous global iteration round hh It can be determined by the following formula:
[0073]
[0074] Among them, |D i | represents the amount of local data on the cloud side corresponding to the cloud-side edge device i, and I represents the total number of cloud-side edge devices.
[0075] In the above embodiment, the subspace tracking algorithm is used to reconstruct the edge aggregation gradients uploaded by each cloud-side edge device in the previous global iteration round, obtain the reconstructed edge aggregation gradients, aggregate the reconstructed edge aggregation gradients, and determine the global aggregation gradient corresponding to the previous global iteration round, which lays the foundation for determining the global model parameters corresponding to the global iteration round.
[0076] In one embodiment, the cloud-side edge device is specifically used for:
[0077] In each global iteration round, for each edge iteration round in the global iteration round, a subspace tracking algorithm is used to reconstruct the corresponding regional aggregate gradients of the edge iteration round;
[0078] Aggregation processing is performed on each reconstructed regional aggregation gradient to determine the edge aggregation gradient corresponding to the edge iteration round.
[0079] Specifically, the cloud-side edge device i can be used to: in each global iteration round, for each edge iteration round t in the global iteration round, the subspace tracking algorithm can be used to aggregate the gradients of each compressed region corresponding to the edge iteration round t (L represents the total number of iterative training of the local model, i.e. the preset number of times) to reconstruct the model, and the gradient of each reconstructed region can be aggregated Perform aggregation processing to determine the edge aggregation gradient corresponding to edge iteration round t The edge aggregation gradient It can be determined by the following formula:
[0080]
[0081] Where J represents the number of edge regions corresponding to the cloud-side edge device i, |D i,j | represents the amount of local data in edge region j corresponding to edge device i on the cloud side. It should be noted that
[0082] That is, the amount of local data on the cloud side corresponding to the cloud-side edge device i is the sum of the amount of regional local data on the edge regions corresponding to the cloud-side edge device i.
[0083] In the above embodiment, the cloud-side edge device is specifically used to determine the edge aggregation gradient corresponding to each edge iteration round, which lays the foundation for sending the edge aggregation gradient to each road-side edge device.
[0084] In one embodiment, Figure 2 2 is a flow chart of the iterative training steps performed by the roadside edge device provided in an embodiment of the present invention. As shown in FIG. 2 , the roadside edge device k is specifically used for:
[0085] In each edge iteration round, the following iterative training steps S1 to S7 are performed:
[0086] S1. Perform initial training on the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device to obtain an initial sparse gradient of an initial training round.
[0087] Specifically, the local model of the roadside edge device k is initially trained based on the local data corresponding to the roadside edge device k and the edge model parameters sent by the cloud-side edge device corresponding to the roadside edge device k, and the initial sparse gradient of the initial training round is obtained.
[0088] S2. Determine an initial regional aggregate gradient, where the initial regional aggregate gradient is determined based on the initial sparse gradient and local data corresponding to the roadside edge device in the current training round, and the initial reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and the initial reconstructed gradient corresponding to the remaining roadside edge devices is determined based on the initial sparse gradient corresponding to the remaining roadside edge devices.
[0089] Specifically, the initial regional aggregation gradient can be obtained The initial regional aggregated gradient is determined based on the initial sparse gradient and local data corresponding to the roadside edge device k in the current training round, and the initial reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area j. For the remaining roadside edge devices, the initial reconstructed gradient corresponding to the roadside edge device is determined based on the initial sparse gradient corresponding to the roadside edge device.
[0090] S3. Update the edge model parameters sent by the corresponding cloud-side edge device based on the initial regional aggregation gradient to obtain updated parameters.
[0091] Specifically, the edge model parameters sent by the cloud-side edge device i corresponding to the roadside edge device k can be updated based on the initial regional aggregation gradient to obtain the updated parameters Update Parameters It can be determined by the following formula:
[0092]
[0093] in, is the edge model parameter sent by the cloud-side edge device in edge iteration round t.
[0094] S4. Retrain the local model based on the local data and the updated parameters to obtain a sparse gradient of a current training round.
[0095] In one embodiment, the retraining of the local model based on the local data and the updated parameters to obtain the sparse gradient of the current training round includes:
[0096] The local model is updated based on the update parameters to obtain an updated local model, the local data is input into the updated local model for training, and a current model function output by the updated local model is obtained;
[0097] Determine a training gradient for a current training round based on the current model function;
[0098] The training gradient of the current training round is updated based on the residual gradient of the previous training round to obtain the updated gradient of the current training round;
[0099] Performing sparse processing on the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round;
[0100] The residual gradient of the current training round is the sum of the residual gradient of the previous training round and the sparse value of the current training round.
[0101] Specifically, the update parameters can be based on (It is easy to understand that when step S4 is executed for the first time, l=2) The local model is updated to obtain an updated local model, and the updated local model uses the update parameters as its model parameters. i,j,k Input the updated local model to train the local model, and you can get the model function output by the updated local model, and then you can determine the training gradient of the current training round l based on the model function. We can further use the residual gradient of the previous training round Training gradients for the current training round Update and obtain the updated gradient of the current training round The updated gradient It can be determined by the following formula:
[0102]
[0103] It is easy to understand that the initial residual gradient of the initial training round can be determined to be 0.
[0104] Furthermore, the updated gradient of the current training round can be Perform sparse processing to obtain the sparse gradient of the current training round The residual gradient of the current training round is the sum of the residual gradient of the previous training round and the sparse value of the current training round.
[0105] In the above embodiment, the local model is retrained based on local data and updated parameters to obtain the sparse gradient of the current training round, which lays a foundation for determining the aggregated gradient of the training area.
[0106] In one embodiment, the step of performing sparse processing on the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round includes:
[0107] Sort the updated gradient values in the updated gradient of the current training round according to their absolute values;
[0108] Selecting an updated gradient value of a target gradient value quantity from the sorting in descending order;
[0109] Determining the sparse gradient of the current training round based on the selected update gradient value, and determining the sparse value of the current training round based on the remaining update gradient values in the sorting;
[0110] The target gradient value quantity is determined based on the number of rounds of the current training round and the preset number of rounds.
[0111] Specifically, the updated gradient values in the updated gradient of the current training round can be sorted according to the absolute value, and the target gradient value quantity Q can be selected from the sorting in descending order. l The updated gradient value of the current training round is determined based on the selected updated gradient value. And determine the sparse value of the current training round based on the remaining updated gradient values in the sort, where the number of target gradient values Q l It can be determined by the following formula:
[0112]
[0113] Among them, L represents the preset number of times, Q min Indicates the minimum number of target gradient values, Q max Indicates the maximum number of target gradient values, Q min and Q max Both can be pre-set.
[0114] In the above embodiment, the updated gradient values in the updated gradient of the current training round are sorted according to the absolute value, and the updated gradient values of the target gradient value quantity are selected from the sorting in descending order, and the sparse gradient of the current training round is determined based on the selected updated gradient value, and the sparse value of the current training round is determined based on the remaining updated gradient values in the sorting, which lays a foundation for the subsequent determination of the aggregated gradient of the training area. In addition, Q is adjusted in each iteration round. l The value of can further affect the sparse gradient, which can enable the model parameters to converge quickly in the early stage of the training phase during the iterative training of the local model and save communication overhead in the later stage of the training phase.
[0115] S5. Determine an aggregate gradient in the training area, where the aggregate gradient in the training area is determined based on the sparse gradient and local data corresponding to the roadside edge device in the current training round, and the reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradient corresponding to the remaining roadside edge devices is determined based on the sparse gradient corresponding to the remaining roadside edge devices.
[0116] Specifically, the training area aggregate gradient can be determined, and the training area aggregate gradient is determined based on the sparse gradient and local data corresponding to the roadside edge device in the current training round, and the reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area. It can be determined by the following formula:
[0117]
[0118] in, represents the set of other roadside edge devices in edge area j corresponding to roadside edge device k, and b represents The number of the edge devices on each side of the road, D i,j,k represents the local data corresponding to the roadside edge device k, |D i,j,k | represents the local data volume of the local data corresponding to the roadside edge device k, represents the reconstruction gradient corresponding to each roadside edge device in edge region j except roadside edge device k. It is easy to understand that the sum of the local data volume corresponding to each roadside edge device in an edge region is the local data volume of the edge region. The reconstruction gradient corresponding to roadside edge device b is the sparse gradient corresponding to the roadside edge device b Sure.
[0119] S6. Update the update parameter based on the aggregated gradient of the training area to obtain a new update parameter.
[0120] Specifically, the gradient can be aggregated based on the training area To update the parameters Update and obtain new update parameters The new update parameter It can be determined by the following formula:
[0121]
[0122] S7. Repeat steps S4 to S7 using the new update parameter as the update parameter until the number of iterative training reaches a preset number.
[0123] Specifically, the new update parameter is used as the update parameter to repeat step S4 to step S7 until the number of iterative training reaches a preset number L. The preset number can be pre-set as needed. It should be noted that each edge iteration round includes a complete iterative training process, and the iterative training process includes multiple iterative training rounds.
[0124] In one embodiment, the roadside edge device is further used for:
[0125] Obtain compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area;
[0126] The subspace tracking algorithm is used to reconstruct the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradients corresponding to the remaining roadside edge devices in the corresponding edge area are obtained.
[0127] Specifically, the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area can be obtained. For example, for roadside edge device k, the compression gradients corresponding to the remaining roadside edge devices except roadside edge device k in edge area j corresponding to roadside edge device k can be obtained. b means The number of the edge devices on each side of the road, Represents the set of other roadside edge devices in edge area j corresponding to roadside edge device k.
[0128] The subspace tracking algorithm can be further used to reconstruct the compression gradients corresponding to the remaining roadside edge devices in the edge area corresponding to the roadside edge device k Get the reconstruction gradients corresponding to the remaining roadside edge devices in edge area j
[0129] In the above embodiment, the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area are obtained, and the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area are reconstructed using the subspace tracking algorithm to obtain the reconstructed gradients corresponding to the remaining roadside edge devices in the corresponding edge area, which lays a foundation for determining the aggregated gradient of the training area.
[0130] In one embodiment, the remaining roadside edge devices are respectively used to:
[0131] The sparse gradient of the current training round is compressed to obtain the compressed gradient of the current training round.
[0132] Specifically, the remaining road-side edge devices b can be used to: Perform compression processing to obtain the compressed gradient of the current training round
[0133] In one embodiment, compressing the sparse gradient of the current training round to obtain the compressed gradient of the current training round includes:
[0134] Compressing the sparse gradient of the current training round based on the target compression matrix to obtain the compressed gradient of the current training round;
[0135] The target compression matrix is determined based on the number of rounds of the current training round and the preset number of rounds.
[0136] Specifically, the sparse gradient of the current training round can be compressed based on the target compression matrix A to obtain the compressed gradient of the current training round Compressed Gradient It can be determined by the following formula:
[0137]
[0138] Among them, the target compression matrix represents a matrix set, N l represents the number of rows in the matrix in training round l, M represents the number of columns in the matrix, the value of M is preset, and N l It can be determined by the following formula:
[0139] N l =M×ζ l
[0140]
[0141] Among them, l represents the compression ratio, ζ min Indicates the preset minimum compression rate, ζmax Indicates the preset maximum compression ratio.
[0142] In the above embodiment, N is adjusted in each iteration round. l The value of can then adjust the target compression matrix, which can make the model parameters converge quickly in the early stage of the training phase during the iterative training of the local model and save communication overhead in the later stage of the training phase.
[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data sharing system based on hierarchical federated learning, characterized in that: include: A cloud server, a plurality of cloud-side edge devices and a plurality of roadside edge devices, wherein the plurality of roadside edge devices are distributed in a plurality of edge areas, each of the edge areas includes at least one roadside edge device, and the cloud-side edge device corresponds to at least one edge area; The cloud server is used to determine and issue the global model parameters corresponding to each global iteration round, and the cloud server is also used to determine the global model parameters corresponding to the last global iteration round as the target global model parameters; wherein the global model parameters corresponding to the next global iteration round are determined based on the global model parameters corresponding to the previous global iteration round and the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round; In each global iteration round, for each of the cloud-side edge devices, the cloud-side edge device is used to send the edge model parameters corresponding to each edge iteration round to the roadside edge device in the corresponding edge area, and upload the edge aggregation gradient corresponding to the last edge iteration round to the cloud server; wherein, for each of the global iteration rounds, the edge model parameters corresponding to the first edge iteration round in the global iteration round are the global model parameters corresponding to the global iteration round; the edge model parameters corresponding to the next edge iteration round are determined based on the edge model parameters corresponding to the previous edge iteration round and the edge aggregation gradient corresponding to the previous edge iteration round; for each of the edge iteration rounds, the edge aggregation gradient corresponding to the edge iteration round is determined based on the regional aggregation gradient corresponding to the edge iteration round and the cloud-side local data volume corresponding to the cloud-side edge device; In each edge iteration round, for each edge area, the roadside edge device in the edge area is used to iteratively train the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device; at least one of the roadside edge devices in the edge area is used to determine the regional aggregation gradient corresponding to the edge area based on the corresponding gradient value at the end of the iterative training of each roadside edge device in the edge area.
2. The data sharing system based on hierarchical federated learning according to claim 1, characterized in that: The cloud server is specifically used for: For each of the global iteration rounds, when the global iteration round is the first global iteration round, randomly determining a global model parameter corresponding to the first global iteration round; When the global iteration round is not the first global iteration round, the global aggregation gradient corresponding to the previous global iteration round is determined based on the edge aggregation gradient uploaded by each cloud-side edge device in the previous global iteration round, and the global model parameters corresponding to the global iteration round are determined based on the global aggregation gradient corresponding to the previous global iteration round and the global model parameters corresponding to the previous global iteration round.
3. The data sharing system based on hierarchical federated learning according to claim 2 is characterized in that: The determining the global aggregation gradient corresponding to the previous global iteration round based on the edge aggregation gradient uploaded by each of the cloud-side edge devices in the previous global iteration round includes: The subspace tracking algorithm is used to reconstruct the edge aggregation gradients uploaded by each of the cloud-side edge devices in the previous global iteration round to obtain the reconstructed edge aggregation gradients; Aggregation processing is performed on each of the reconstructed edge aggregation gradients to determine a global aggregation gradient corresponding to the previous global iteration round.
4. The data sharing system based on hierarchical federated learning according to claim 1, characterized in that: The cloud-side edge device is specifically used for: In each global iteration round, for each edge iteration round in the global iteration round, a subspace tracking algorithm is used to reconstruct the corresponding regional aggregate gradients of the edge iteration round; Aggregation processing is performed on each reconstructed regional aggregation gradient to determine the edge aggregation gradient corresponding to the edge iteration round.
5. The data sharing system based on hierarchical federated learning according to claim 1, characterized in that: The roadside edge device is specifically used for: In each edge iteration round, the following iterative training steps are performed: S1. Performing initial training on the local model based on the corresponding local data and the edge model parameters sent by the corresponding cloud-side edge device to obtain an initial sparse gradient of an initial training round; S2, determining an initial regional aggregate gradient, wherein the initial regional aggregate gradient is determined based on an initial sparse gradient and local data corresponding to the roadside edge device in the current training round, and initial reconstruction gradients and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and initial reconstruction gradients corresponding to the remaining roadside edge devices are determined based on initial sparse gradients corresponding to the remaining roadside edge devices; S3. Update the edge model parameters sent by the corresponding cloud-side edge device based on the initial regional aggregation gradient to obtain updated parameters; S4. Retrain the local model based on the local data and the updated parameters to obtain a sparse gradient of the current training round; S5, determining an aggregate gradient in the training area, wherein the aggregate gradient in the training area is determined based on the sparse gradient and local data corresponding to the roadside edge device in the current training round, and the reconstructed gradient and local data corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradient corresponding to the remaining roadside edge devices is determined based on the sparse gradient corresponding to the remaining roadside edge devices; S6. Update the update parameter based on the aggregated gradient of the training area to obtain a new update parameter; S7. Repeat steps S4 to S7 using the new update parameter as the update parameter until the number of iterative training reaches a preset number.
6. The data sharing system based on hierarchical federated learning according to claim 5, characterized in that: The retraining of the local model based on the local data and the updated parameters to obtain a sparse gradient of a current training round includes: The local model is updated based on the update parameters to obtain an updated local model, the local data is input into the updated local model for training, and a current model function output by the updated local model is obtained; Determine a training gradient for a current training round based on the current model function; The training gradient of the current training round is updated based on the residual gradient of the previous training round to obtain the updated gradient of the current training round; Performing sparse processing on the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round; The residual gradient of the current training round is the sum of the residual gradient of the previous training round and the sparse value of the current training round.
7. The data sharing system based on hierarchical federated learning according to claim 6, characterized in that: The step of performing sparse processing on the updated gradient of the current training round to obtain the sparse gradient and sparse value of the current training round includes: Sort the updated gradient values in the updated gradient of the current training round according to their absolute values; Selecting an updated gradient value of a target gradient value quantity from the sorting in descending order; Determining the sparse gradient of the current training round based on the selected update gradient value, and determining the sparse value of the current training round based on the remaining update gradient values in the sorting; The target gradient value quantity is determined based on the number of rounds of the current training round and the preset number of rounds.
8. The data sharing system based on hierarchical federated learning according to claim 5, characterized in that: The roadside edge device is also specifically used for: Obtain compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area; The subspace tracking algorithm is used to reconstruct the compression gradients corresponding to the remaining roadside edge devices in the corresponding edge area, and the reconstructed gradients corresponding to the remaining roadside edge devices in the corresponding edge area are obtained.
9. The data sharing system based on hierarchical federated learning according to claim 8, characterized in that: The remaining roadside edge devices are specifically used for: The sparse gradient of the current training round is compressed to obtain the compressed gradient of the current training round.
10. The data sharing system based on hierarchical federated learning according to claim 9, characterized in that: The compressing the sparse gradient of the current training round to obtain the compressed gradient of the current training round includes: Compressing the sparse gradient of the current training round based on the target compression matrix to obtain the compressed gradient of the current training round; The target compression matrix is determined based on the number of rounds of the current training round and the preset number of rounds.
Citation Information
Cited By
Distributed model training method and system based on training and compression layering
CN121031719A
