A hierarchical federated learning method based on dynamic clusters in Internet of Vehicles
By adopting dynamic cluster construction and hierarchical federated learning methods in the Internet of Vehicles, combining synchronous and asynchronous federated learning, the problem of low training efficiency in the Internet of Vehicles is solved, more efficient model training and resource utilization are achieved, and the convergence speed and communication efficiency of the global model are improved.
Patent Information
- Application Number
- CN202311645432.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-04
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-12-04
AI Technical Summary
Existing federated learning methods for Internet of Vehicles do not fully consider dynamics and heterogeneity, resulting in low training efficiency and difficulty in effectively utilizing computing resources on the road.
A hierarchical aggregation scheme combining dynamic cluster construction with synchronous federated learning within a vehicle cluster and asynchronous federated learning between vehicle clusters is adopted. Model parameters are updated within the vehicle cluster through synchronous federated learning, and asynchronous aggregation is performed at the edge server to form a global model.
It improves the efficiency of federated learning in Internet of Vehicles and the convergence speed of the global model, reduces communication delay and resource consumption, and is superior to traditional FL solutions.
Smart Images

Figure CN117750324B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of federated learning in Internet of Vehicles (IoV), and in particular to a hierarchical federated learning method based on dynamic clustering in IoV. Background Art
[0002] With the rapid development of the Internet of Vehicles (IoV), vehicles have evolved into mobile intelligent data centers, generating a wealth of valuable information about traffic conditions, driver behavior, and road infrastructure. Using this rich data for effective machine learning to construct high-quality data analysis models can drive advances in road safety, traffic management, and autonomous driving. However, leveraging this potential while addressing the privacy and security of vehicle user data remains a major challenge. Federated Learning (FL), a novel machine learning paradigm that allows for collaborative model training across distributed and privacy-sensitive IoV resources, has emerged as a promising solution.
[0003] Considerable research has been conducted on federated learning solutions for various applications in the Internet of Vehicles (IoV). Lu et al. proposed a blockchain-enabled federated learning framework for secure and reliable data sharing in large-scale vehicle networks. Xie et al. introduced the Spike neural network model, a more suitable training model for IoV, within a federated learning framework for effective traffic sign recognition in autonomous vehicles. To learn and cache popular content that best meets vehicle user requirements in roadside units (RSUs) to support real-time vehicle applications, Wu et al. designed a vehicle-edge computing collaborative cache based on asynchronous FL. Shinde et al. integrated ground-based IoV and airborne networks to establish a three-dimensional distributed FL platform, reducing the overall FL process cost through appropriate network layer selection. However, most of these works directly apply classic FL to the IoV, failing to consider the dynamic nature of the IoV and the heterogeneity of vehicles to improve the efficiency of FL training within the vehicle itself. Summary of the Invention
[0004] The present invention provides a hierarchical federated learning method based on dynamic clusters in the Internet of Vehicles (IoV). It combines synchronous federated learning within a vehicle cluster and asynchronous federated learning between vehicle clusters, fully considering the dynamic and heterogeneous characteristics of the IoV scenario, completing federated learning training more efficiently and making full use of computing resources on the road.
[0005] The present invention is achieved through the following technical solutions:
[0006] A hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles is implemented between a base station including a server, several vehicles, and a C-V2X communication network, including:
[0007] S1. Dynamically construct several vehicles into several vehicle clusters;
[0008] S2. Performing synchronous federated learning on each vehicle in the vehicle cluster, thereby updating the cluster model after independent synchronous aggregation, and then calculating the cluster model loss function;
[0009] S3. Whenever the edge server receives one of the cluster models, it immediately performs global aggregation to update the global model after asynchronous aggregation. When the edge server receives multiple cluster models at the same time, it performs global aggregation in sequence according to the received cluster models.
[0010] S4, calculating a global loss function of the global model, and establishing an objective function according to the global loss function;
[0011] S5. Determine whether the objective function has reached the optimal solution or whether the number of rounds of global aggregation of the global model in S3 has reached the specified number of iterations. If so, the entire hierarchical federated learning process ends. Otherwise, jump to S6.
[0012] S6. After the cluster head in the vehicle cluster completes uploading the cluster model to the edge server, the cluster head determines whether the cluster member vehicles in the vehicle cluster are still within the effective communication range. If so, the edge server sends the updated global model to the original vehicle cluster and then jumps to S2. Otherwise, the vehicle cluster is disbanded, jumps to S1 to build a new vehicle cluster, and the edge server sends the updated global model to the new vehicle cluster and then jumps to S2.
[0013] As an optimization, two vehicles communicate through the V2V link; the vehicle and the base station communicate through the V2I link.
[0014] As an optimization, the specific process of dynamically constructing several vehicle clusters is as follows:
[0015] S1.1. Let each vehicle be within the communication range of R c Inner multicast a message containing the vehicle coordinates (x0, y0), the vehicle moving speed cv0, and the calculation frequency cf0;
[0016] S1.2. Each vehicle simultaneously monitors and records messages received from neighboring vehicles, calculates the effective connection time for direct communication with neighboring vehicles based on the received messages, and then sorts the neighboring vehicles based on the effective connection time to generate a neighbor vehicle sequence for the corresponding sending vehicle. A sending vehicle and its corresponding neighbor vehicle sequence form a candidate cluster.
[0017] S1.3. Each vehicle is used as the cluster head of its own candidate cluster, and the maximum computing resource (CCR) that can be utilized within the effective connection time is calculated. The CCR of each vehicle is then obtained and sent to the corresponding neighboring vehicles.
[0018] S1.4. Each vehicle receives the CCR from a neighboring vehicle and compares the CCR of the neighboring vehicle with its own CCR;
[0019] S1.5. Sort all CCRs from largest to smallest to obtain a CCR sequence;
[0020] S1.6. Find the vehicle with the highest ranked CCR as the cluster head, and use this vehicle and its corresponding neighboring vehicles as the cluster strategy to form a cluster. The CCR of the vehicle that has already been the cluster head is no longer included in the CCR sequence.
[0021] S1.7. Determine whether there are any CCRs in the CCR sequence. If so, jump to S1.8; otherwise, jump to S1.10.
[0022] S1.8. Find the vehicle with the first CCR in the CCR sequence and determine whether the vehicle is considered a clustered vehicle. If so, remove the CCR of the vehicle from the CCR sequence, recalculate the CCRs of all remaining vehicles that have not formed a cluster, and then jump to S1.5. Otherwise, jump to S1.9.
[0023] S1.9. Determine whether the neighboring vehicles of the vehicle are considered as established cluster vehicles. If so, recalculate the CCR and jump to S1.5. Otherwise, jump to S1.6.
[0024] S1.10. Form several clusters.
[0025] As an optimization, the calculation formula of the maximum computing resource CCR is:
[0026]
[0027] Among them, ct i is the shortest effective communication time between the i-th neighbor vehicle and the cluster head, cf0 is the calculation frequency of the cluster head sending messages, cf j is the calculated frequency of sending messages to the jth neighbor vehicle, is the sum of the calculated frequencies of the i-th to I-th neighbor vehicles, and I is the total number of neighbor vehicles of the cluster head;
[0028]
[0029] Among them, (x i ,y i) is the coordinate of the i-th neighbor vehicle, R c is the broadcast communication range of the cluster head, cv i is the moving speed of the i-th neighbor vehicle, cv0 is the moving speed of the cluster head, and (x0, y0) is the coordinate of the cluster head.
[0030] As an optimization, the specific steps of S2 are:
[0031] S2.1. Each cluster head receives an initial model from an edge server and distributes the initial model to each cluster member in its respective cluster;
[0032] S2.2. For cluster c z Each cluster member vehicle v zm , perform multiple stochastic gradient descents on the vehicle local dataset to independently update the parameters of the initial model, z∈[1,Z], Z is the total number of clusters, m∈[1,M], M is the total number of vehicles in a cluster, v zm represents the mth vehicle in the zth cluster model;
[0033] Specifically: vehicle v zm According to its data set right Perform training by calculating the local gradient descent The training process is as follows:
[0034]
[0035] is the model parameter of the m-th cluster member vehicle in the z-th cluster after training and update, is the model of the m-th vehicle in the z-th cluster before update, η>0, is the local learning rate;
[0036] S2.3. Cluster model aggregation: In the same cluster, each cluster member vehicle sends the updated model parameters to the cluster head for normalization and averaging to obtain the cluster model parameters. Specifically:
[0037]
[0038] Among them, w z (t+1) represents the updated model parameters of the zth cluster, w z (t) represents the model parameters before the update of the z-th cluster, represents the relative sample size, Represents vehicle v zm Cumulative local progress achieved, Indicates vehicle v zm In cluster c zThe number of local iterations within the effective connection time, where E is the iteration period, B is the mini-batch size, |D z | represents the sum of the training data samples of all cluster member vehicles in the zth cluster, represents the mth vehicle v zm Model parameters before training.
[0039] As an optimization, the local loss function is specifically expressed as:
[0040]
[0041] in, represents the local loss function of the mth vehicle in the zth cluster, l(w,ξ) is the prediction loss of the parameter vector w for the sample ξ, is the number of training samples of the m-th vehicle in the z-th cluster;
[0042] The model loss function of the cluster is specifically:
[0043]
[0044] For cluster c z The training sample size in .
[0045] As an optimization, in S3, the expression of the global model is updated as follows:
[0046] w(t+1)=(1-α δ )w(t)+α δ w z (t+1);
[0047] Among them, α δ is the weight corresponding to the cluster model when the global model is aggregated, w(t) is the parameter of the global model before the update at the edge server, w(t+1) is the parameter of the global model after the update at the edge server, and w z (t+1) is the parameter of the cluster model of the zth cluster.
[0048] As an optimization, the weight α of the cluster model δ It is determined according to the staleness of the cluster model. The specific formula is:
[0049]
[0050] Among them, α∈(0,1) is the weight of each initial cluster model, δ represents the staleness of the cluster model, and b≥0 represents the staleness threshold.
[0051] As an optimization, the global loss function is specifically:
[0052]
[0053] in, is the global sample size involved in training, F z (w) is cluster c z The model loss function at .
[0054] The objective function is expressed as:
[0055] w * =argminG(w).
[0056] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0057] This paper improves the efficiency of FL in the dynamic and heterogeneous Internet of Vehicles. By first dynamically clustering vehicles on the road, and then combining synchronous federated learning within a vehicle cluster with asynchronous federated learning between vehicle clusters, a hierarchical aggregation scheme is proposed. Simulation results show that this paper outperforms typical FL schemes in terms of global model convergence speed and communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0059] Figure 1 Schematic diagram of the system structure of hierarchical federated learning based on dynamic clustering of the present invention;
[0060] Figure 2 The relationship between model accuracy and loss value and time for different algorithms on the MNIST dataset;
[0061] Figure 3 The relationship between model accuracy and loss value and time for different algorithms under the FashionMNIST dataset;
[0062] Figure 4 The communication resource consumption diagram of different algorithms to achieve the same model accuracy. DETAILED DESCRIPTION
[0063] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with examples and drawings. The exemplary embodiments of the present invention and their descriptions are only used to explain the present invention and are not intended to limit the present invention.
[0064] The embodiment 1 provides a hierarchical federated learning method based on dynamic clusters in vehicle networking, and the main content of the application is that a hierarchical federated learning scheme based on dynamic clusters in vehicle networking is provided, which combines synchronous federated learning in vehicle clusters and asynchronous federated learning between vehicle clusters. The application fully considers the dynamic and heterogeneous characteristics of the vehicle networking scene, more efficiently completes the federated learning training and fully utilizes the computing resources on the road. The scheme framework provided by the application is hierarchical FL based on vehicle clusters in vehicle networking. Synchronous aggregation is performed in each cluster to obtain a cluster model, and asynchronous aggregation is performed between clusters to obtain a global model.
[0065] Specifically, as shown in the figure, Figure 1 the specific implementation of the application is realized between a base station containing a server, a plurality of vehicles and a C-V2X (cellular vehicle-to-everything) communication network. In the system, two vehicles communicate through a V2V (vehicle-to-vehicle) link; the vehicle and the base station communicate through a V2I (vehicle-to-infrastructure) link.
[0066] According to the C-V2X technical standard, the vehicle can perform connectionless multicast communication, that is, a distance-based dynamic multicast communication. It is assumed that the vehicle has set a fixed range R c of connectionless broadcast communication (which can be flexibly adjusted according to the density of vehicles on the road and the number of lanes), and the vehicles in the range are recorded as neighbor vehicles N={1,···,I}. Let (x i ,y i ) be the position coordinates of vehicle i, cv i be the moving speed, cf i be the calculation frequency of the vehicle training capability. For simplicity, it is considered that all vehicles move in the same direction and maintain uniform speed.
[0067] The specific method comprises:
[0068] S1, a plurality of vehicles are dynamically constructed into a plurality of vehicle clusters; if there is a vehicle that is not in the cluster, the vehicle does not exist as a separate cluster and does not participate in federated learning training.
[0069] The specific process of dynamically constructing a plurality of vehicle clusters is:
[0070] S1.1, let each vehicle multicast a sending message containing vehicle coordinates (x0, y0), vehicle moving speed cv0 and calculation frequency cf0 within a communication range R c ;
[0071] S1.2. Each vehicle simultaneously monitors and records messages received from neighboring vehicles. Based on the received messages, each vehicle calculates the effective connection time for direct communication with the neighboring vehicles. The neighboring vehicles are then sorted by the effective connection time to generate a neighbor vehicle sequence for the corresponding vehicle (arranged in ascending order of effective communication time). A vehicle and its corresponding neighbor vehicle sequence form a candidate cluster.
[0072] S1.3. Each vehicle is used as the cluster head of its own candidate cluster, and the maximum computing resource (CCR) that can be utilized within the effective connection time is calculated. The CCR of each vehicle is then obtained and sent to the corresponding neighboring vehicles.
[0073] CCR is the cluster computing resource (CCR) of a vehicle, which is defined as the maximum computing resource that can be used by the cluster built if the vehicle acts as the cluster head within the effective connection time.
[0074] Specifically, the calculation formula of the maximum computing resource CCR is:
[0075]
[0076] Among them, ct i is the shortest effective connection time between the i-th neighbor vehicle and the cluster head, cf0 is the calculation frequency of the cluster head, cf j is the calculation frequency of the jth neighbor vehicle, I is the total number of neighbor vehicles of the cluster head, is the calculated frequency sum of the i-th to i-th neighbor vehicles;
[0077]
[0078] (x i ,y i ) is the coordinate of the i-th neighbor vehicle, R c The communication distance for cluster heads to send messages, cv i is the moving speed of the i-th neighbor vehicle, cv0 is the moving speed of the cluster head, and (x0, y0) is the coordinate of the cluster head;
[0079] Since the vehicle can obtain the calculation frequency of neighbor vehicles and the connection time with neighbor vehicles from the received broadcast information, all neighbor vehicles are sorted from small to large according to the connection time, and the CCR value is calculated. The CCR value is calculated from 1-I, 2-I in sequence, and the maximum value is taken as the CCR of the vehicle. The reason for this calculation is that the computing resource contribution value of the cluster depends on the vehicle with the shortest effective connection time, but the vehicle with the shortest effective connection time may be abandoned, and the CCR value will be larger. Therefore, the neighbor vehicle member set corresponding to the largest CCR value will be obtained {n i ,···,n I} as a cluster strategy.
[0080] Each vehicle calculates its CCR value based on its neighbor list and obtains the calculated value i (i.e., the i-th neighbor vehicle). This gives the corresponding neighbor vehicle member set {i, ···, I} as the clustering strategy. The vehicle then multicasts its CCR value and the clustering strategy (after calculating the CCR value, the vehicle broadcasts the CCR value to neighbor vehicles and compares the CCR values). This is shown in Table 1.
[0081] Table 1 Neighbor vehicle sequence
[0082]
[0083] S1.4. Each vehicle receives the CCR from a neighboring vehicle and compares the CCR of the neighboring vehicle with its own CCR;
[0084] S1.5. Sort all CCRs from largest to smallest to obtain a CCR sequence;
[0085] S1.6. Find the vehicle with the highest ranked CCR as the cluster head, and use this vehicle and its corresponding neighboring vehicles as the cluster strategy to form a cluster. The CCR of the vehicle that has already been the cluster head is no longer included in the CCR sequence.
[0086] S1.7. Determine whether there are any CCRs in the CCR sequence. If so, jump to S1.8; otherwise, jump to S1.10.
[0087] S1.8. Find the vehicle with the first CCR in the CCR sequence and determine whether the vehicle is considered a clustered vehicle. If so, remove the CCR of the vehicle from the CCR sequence, recalculate the CCRs of all remaining vehicles that have not formed a cluster, and then jump to S1.5. Otherwise, jump to S1.9.
[0088] S1.9. Determine whether the neighboring vehicles of the vehicle are considered as established cluster vehicles. If so, recalculate the CCR and jump to S1.5. Otherwise, jump to S1.6.
[0089] S1.10. Form several clusters.
[0090] Select the set with the maximum value in turn. If the vehicles in the set with the maximum value have been classified into a cluster, update the vehicle neighbor sequence and calculate the CCR, or remove the vehicle from the cluster head candidate list. That is, if a vehicle is a neighbor vehicle of multiple cluster heads, assign this vehicle to the cluster head with the largest CCR value. Other cluster heads that include the vehicle as a cluster member will delete the vehicle from their neighbor lists, update the neighbor sequence, and recalculate the CCR value.
[0091] When executing a clustering strategy, there are two situations where updates are required: 1. The vehicle acting as a cluster head is already a member of the global cluster; 2. The vehicle's neighbor list contains vehicles that are already members of the global cluster. In the first case, the vehicle acting as a cluster head must be removed from the candidate cluster head list. In the second case, the vehicle acting as a cluster head must re-update the vehicle neighbor list to obtain a new CCR value.
[0092] When no cluster is formed, each vehicle calculates the CCR value to become a candidate cluster head. The vehicle in "Vehicles executing this strategy update their respective neighbor vehicle sequences" refers to the candidate cluster head vehicle. As a mobile resource provider on the road, vehicles have strong computing and communication capabilities. The overhead of the above process steps is acceptable, and the delay can be controlled at the millisecond level. Even in scenarios with many lanes and high vehicle density, by flexibly setting the communication range R c , and can also complete the entire cluster construction process well.
[0093] Next, we introduce a hierarchical aggregation scheme based on vehicle clustering. For FL training objectives, directly finding the optimal global model parameter w is nearly impossible. Each participating vehicle needs to perform stochastic gradient descent (SGD) on each local update to gradually approach the optimal solution. Therefore, this paper proposes a hierarchical aggregation scheme to efficiently aggregate local updates from vehicles, fully accounting for the heterogeneity of vehicle datasets and computing power.
[0094] S2. Performing synchronous federated learning on the vehicles in each vehicle cluster, thereby independently updating the first model parameters of each cluster model, and then calculating the cluster model loss function in each cluster;
[0095] The specific steps are:
[0096] S2.1. Each cluster head receives an initial model from an edge server and distributes the initial model to each cluster member vehicle in its respective cluster;
[0097] The model here refers to a neural network model, such as CNN, LSTM, etc. This model is trained to complete classification tasks, etc.
[0098] Assume that after the vehicles on the road have undergone cluster construction, there are some clusters C = {c1,···,c Z}, Z is the total number of clusters, and some unselected vehicles. Each cluster head receives the initial model from the edge server and distributes it to CMs for local training. z The cluster members within ∈C are represented as V z ={v z1 ,···,v zM}, M is the total number of vehicles in a cluster.
[0099] S2.2. Vehicle local training: for cluster c z Each cluster member vehicle v zm , perform multiple stochastic gradient descents on the vehicle local dataset to independently update the parameters of the initial model, z∈[1,Z], Z is the total number of clusters, m∈[1,M], M is the total number of vehicles in a cluster, v zm represents the mth vehicle in the zth cluster model;
[0100] Specifically: vehicle v zm According to its data set right Perform training by calculating the local gradient descent The training process is as follows:
[0101]
[0102] is the updated model parameter of the m-th vehicle in the z-th cluster after training, that is, the updated parameters of the neural network model obtained after a certain round of local training for the m-th vehicle in the z-th cluster. The model before update for the m-th vehicle in the z-th cluster, η>0, is the local learning rate;
[0103] The local loss function is specifically expressed as:
[0104]
[0105] in, represents the local loss function of the mth vehicle in the zth cluster model, l(w,ξ) is the prediction loss of the parameter vector w of the neural network model for the sample ξ, is the number of training samples of the m-th vehicle in the z-th cluster. Represents the parameters of the initial model of the mth vehicle in the zth cluster, the vehicle's local dataset Top pair Perform multiple gradient descents to obtain The dataset refers to the vehicle local dataset, defined as Represented as the i-th training data sample as input data, Represented as the corresponding output data, The number of samples collected by cluster member vehicles.
[0106] Indicates vehicle v nm In cluster c z The number of local iterations within the effective connection time is already stated.
[0107] S2.3, Cluster model aggregation: After the cluster member vehicles in the same cluster complete their local training, they synchronously upload local updates to the cluster head to obtain the cluster model. Due to the heterogeneity of vehicle datasets and computing power, the number of local iterations of each vehicle will be different. Indicates vehicle v nm In cluster c z The number of local iterations within the effective connection time, where E is the iteration period and B is the mini-batch size.
[0108] Cluster model aggregation introduces the normalized average method, that is, in the same cluster, the parameters of the model of each cluster member vehicle are sent to the cluster head for normalized average to obtain the parameters of the cluster model. z The specific rules for updating model parameters are as follows:
[0109]
[0110] Among them, w z (t+1) represents the updated model parameters of the zth cluster, w z (t) represents the model parameters before the update of the z-th cluster, represents the relative sample size, Indicates vehicle v zm Cumulative local progress achieved, Indicates vehicle v zm In cluster c z The number of local iterations within the effective connection time, where E is the iteration period, B is the mini-batch size, |D z | represents the sum of the training data samples of all cluster member vehicles in the zth cluster, represents the mth vehicle v zm Model parameters before training.
[0111] The model loss function of the cluster is specifically:
[0112]
[0113] the training sample size in the zth cluster, where the training sample size refers to the data set carried by all vehicles in the zth cluster for training. z
[0114] S3, global model aggregation: whenever the edge server (base station in this embodiment) receives one of the cluster model parameters, it immediately performs global aggregation to update the global model after asynchronous aggregation, and when the edge server receives multiple cluster models at the same time, it performs global aggregation according to the received cluster models in turn. The edge server performs aggregation immediately after receiving the update from one of the cluster heads, and does not wait.
[0115] The expression for updating the global model parameters is as follows:
[0116] w(t+1) = (1-α δ )w(t) + α δ w z (t+1);
[0117] where α δ is the weight of the cluster model corresponding to the global model aggregation, w(t) is the parameter of the global model before updating at the edge server (at the base station), w(t+1) is the parameter of the global model after updating at the edge server, and w z (t+1) is the parameter of the updated cluster model of the zth cluster.
[0118] After the base station receives the updated w z (t+1) of the cluster z, it updates the global model parameters at the base station according to the rules of the above formula to obtain a new w(t+1).
[0119] The weight α δ of the cluster model is determined according to the staleness of the cluster model, that is, the number of global rounds experienced by the cluster in the cluster model training process, and the specific formula is:
[0120]
[0121] where α∈(0,1), α is the weight of each initial cluster model, δ represents the staleness of the cluster model, the initial model weight α is the weight of evaluating the diversity of the cluster data sample, and b≥0 represents the staleness threshold.
[0122] The adaptive initial weight α primarily reflects the diversity of the training data. If the vehicle dataset participating in the training is not independent and identically distributed, the weight α can be the ratio of the number of cluster labels to the expected number of output labels. If the vehicle dataset participating in the training is independent and identically distributed, the weight α can be the ratio of the number of vehicles in the cluster to the maximum number of vehicles that can be included in the cluster.
[0123] S4, calculating a global loss function of the global model, and establishing an objective function according to the global loss function;
[0124] The global loss function is specifically:
[0125]
[0126] in, is the global sample size involved in training, F z (w) is cluster c z The model loss function at .
[0127] S5. Determine whether the objective function reaches the optimal solution or whether the number of rounds of global aggregation of the global model in S3 reaches the specified number of iterations. If so, the entire hierarchical federated learning process ends; otherwise, jump to S3.
[0128] The goal of FL training is to find a set of optimal global model parameters w to minimize the global loss function G, which can be expressed as:
[0129] w * =arnminG(w).
[0130] S6. After the cluster head in the vehicle cluster completes uploading the cluster model to the edge server, the cluster head determines whether the cluster member vehicles in the vehicle cluster are still within the effective communication range. If so, the edge server sends the updated global model to the original vehicle cluster and then jumps to S2. Otherwise, the vehicle cluster is disbanded, jumps to S1 to build a new vehicle cluster, and the edge server sends the updated global model to the new vehicle cluster and then jumps to S2.
[0131] Whether there is a change here means that if the original cluster head and cluster member vehicles cannot communicate effectively during driving, the cluster needs to be re-divided.
[0132] The application is equivalent to three layers. The first layer is vehicle local training update, the second layer is intra-cluster cluster head synchronization aggregation according to cluster member update, and the third layer is asynchronous aggregation between clusters and base stations to obtain the update of the global model. Synchronous federated learning needs to wait until all nodes are uploaded before updating the global model, which can improve the model accuracy, but the learning completion time is long. In asynchronous federated learning, once the edge server receives the local model from the client, it performs global aggregation, which can reduce communication delay and improve training speed and efficiency. However, due to asynchronous update, the model parameters may not be consistent, which may reduce the accuracy of the model. Therefore, the scheme in this paper adopts the method of synchronous aggregation within the cluster and asynchronous aggregation between the clusters and the base station to speed up the process of federated learning.
[0133] In order to verify the superiority of the application (Proposed in the figure), three reference schemes are set as comparison, which are: 1. Improved synchronous federated learning algorithm FedAvg, which receives models from all edge nodes in each round to aggregate the global model. 2. FedAsync, which is an asynchronous FL algorithm using stale processing. When the server receives a model from any edge node, it updates the global model. 3. TiFL, which is a synchronous federated learning method that can divide training clients into different levels according to the response delay of the client. In each round, a level is selected according to a novel adaptive selection strategy (which is related to the test accuracy of all levels), and then a certain number of clients in the level are selected for training. The aggregation method of TiFL comes from FedAvg.
[0134] The application considers that vehicles complete the federated learning task under the urban road scene, and 120 vehicles are randomly distributed on 6 lanes within the coverage range of the base station. The vehicle speed is generated by truncated Gaussian distribution, and the vehicle speed is distributed in the range of (30km / h, 60km / h).
[0135] The application uses MNIST dataset and FashionMNIST dataset to train CNN model. The detailed information of the dataset and the model is shown in Table 2.
[0136] Table 2 Dataset and model information
[0137] Parameter Task1 Task2 Dataset MNIST FashionMNIST Models CNN CNN Model size 1.6MB 1.7MB Target Accuracy (%) 95 75
[0138] The system simulation parameters are as follows: the SGD optimizer learning rate is set to 0.0005. In both FedAvg and TiFL, the number of local training rounds is set to 15. In FedAsync, a is set to 0.6, b is 100, and ρ is 0.1, with 15 local vehicle iterations. In the solution of the present invention, 15 clusters are first formed, each with at least 4 vehicles. a is set to 0.7 and b is 10, and the number of iterations is set to different values based on the computing power of the vehicle, ranging from 5 to 30. In terms of model training, the present invention constructs a neural model within the PyTorch framework and uses an NVIDIA GeForce RTX 3090 to accelerate the training process.
[0139] In order to evaluate the impact of data imbalance on simulation performance, the present invention redistributes the data to create an unbalanced, non-iid distributed dataset to simulate the heterogeneity of data distribution among vehicles.
[0140] In order to evaluate the convergence speed of the proposed algorithm, the present invention uses the training time required for different algorithms to reach the same model accuracy level to compare the convergence speed.
[0141] To evaluate the communication resource consumption of the proposed algorithm, we quantify the communication cost, using the cost of each model exchanged between a vehicle and the base station as 1 unit. The cost of inter-vehicle communication is set to 0.1 unit for the following reasons: 1) The communication latency between a vehicle and the base station is more than 10 times that of intra-cluster communication. 2) Long communication distances and frequent backhauls lead to network congestion.
[0142] Figure 2 、 Figure 3 The relationship between the global model accuracy and loss value of the four algorithms on the MNIST and FashionMNIST datasets and time is shown in Figure 2. Figure 2 、 Figure 3 It can be seen that the present invention is superior to the other three algorithms and has a faster convergence speed than the other three algorithms when achieving the same model accuracy. Figure 2 The reason why the FashionMNIST dataset takes longer to reach the target accuracy is that FashionMNIST contains more complex images than MNIST. The trained model requires more layers and parameters, and the model is more complex, so it requires more training time to a certain extent.
[0143] Figure 4 It represents the communication resources consumed by the four algorithms to achieve the same global model accuracy. Figure 4As can be seen, the present invention consumes fewer communication resources than the other three algorithms. This is because, in the hierarchical federated learning process based on vehicle clusters, the present invention first performs synchronous aggregation within the cluster, and then asynchronously uploads the data to the base station for global aggregation, reducing the communication cost between the vehicle and the base station. The other three algorithms all rely on direct communication between the vehicle and the base station, which results in higher communication costs. This demonstrates that, while achieving the same model accuracy, the present invention achieves faster convergence and higher communication efficiency.
[0144] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles, implemented between a base station containing a server, several vehicles, and a C-V2X communication network, characterized in that: include: S1. Each vehicle dynamically constructs several vehicles into several vehicle clusters based on the maximum computing resource CCR that can be used within the effective connection time of direct communication with neighboring vehicles; The calculation formula of the maximum computing resource CCR is: ; in, is the shortest effective communication time between the i-th neighbor vehicle and the cluster head, is the calculation frequency of the cluster head, is the calculation frequency of the jth neighbor vehicle, is the sum of the calculated frequencies of the i-th to I-th neighbor vehicles, and I is the total number of neighbor vehicles of the cluster head; ; in, is the coordinate of the i-th neighbor vehicle, is the broadcast communication range of the cluster head, is the moving speed of the i-th neighbor vehicle, is the moving speed of the cluster head, are the coordinates of the cluster head; S2. Performing synchronous federated learning on each of the vehicles in the vehicle cluster, thereby updating the cluster models after independent synchronous aggregation, and then calculating the cluster model loss function in each cluster; The specific steps of S2 are: S2.
1. Each cluster head receives an initial model from an edge server and distributes the initial model to each cluster member vehicle in its respective cluster; S2.
2. For clusters Each cluster member vehicle in , perform multiple stochastic gradient descents on the vehicle local dataset to independently update the parameters of the initial model, , is the total number of clusters, , M is the total number of vehicles in a cluster, represents the mth vehicle in the zth cluster; Specifically: Vehicle According to its data set right Perform training by calculating the local gradient descent , the training process is as follows: ; is the model parameter of the mth vehicle in the zth cluster after training and update, is the updated model of the m-th vehicle in the z-th cluster, , is the local learning rate; S2.
3. Cluster model aggregation: In the same cluster, each cluster member vehicle sends the updated model parameters to the cluster head for normalization and averaging to obtain the cluster model parameters. Specifically: ; in, represents the updated model parameters of the z-th cluster, represents the model parameters before the update of the z-th cluster, , represents the relative sample size, , indicating vehicle Cumulative local progress achieved, Indicates vehicle In the cluster The number of local iterations within the effective connection time, where E is the iteration period, B is the mini-batch size, represents the sum of the training data samples of all cluster member vehicles in the zth cluster, represents the mth cluster member vehicle Model parameters before training; The cluster model loss function is specifically: ; in , for clusters The size of the internal training sample, is the local loss function; The local loss function is specifically expressed as: ; in, represents the local loss function of the m-th cluster member vehicle in the z-th cluster, For the parameter vector w to sample The prediction loss, is the number of training samples of the m-th vehicle in the z-th cluster; S3. Whenever the edge server receives parameters of one of the cluster models, it immediately performs global aggregation to update the global model after asynchronous aggregation. When the edge server receives multiple cluster models at the same time, it performs global aggregation sequentially according to the received cluster models. S4, calculating a global loss function of the global model, and establishing an objective function according to the global loss function; The global loss function is specifically: ; in, , is the global sample size involved in training, For cluster The model loss function at ; The objective function is expressed as: ; S5. Determine whether the objective function has reached the optimal solution or whether the number of rounds of global aggregation of the global model in S3 has reached the specified number of iterations. If so, the entire hierarchical federated learning process ends. Otherwise, jump to S6. S6. After the cluster head in the vehicle cluster completes uploading the cluster model to the edge server, the cluster head determines whether the cluster member vehicles in the vehicle cluster are still within the effective communication range. If so, the edge server sends the updated global model to the original vehicle cluster and then jumps to S2. Otherwise, the vehicle cluster is disbanded, jumps to S1 to build a new vehicle cluster, and the edge server sends the updated global model to the new vehicle cluster and then jumps to S2.
2. A hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles according to claim 1, characterized in that: Two vehicles communicate with each other via a V2V link; a vehicle and a base station communicate with each other via a V2I link.
3. The hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles according to claim 1, characterized in that: The specific process of dynamically constructing several vehicle clusters is as follows: S1.1, let each vehicle be within the communication range of Inner multicast contains vehicle coordinates The vehicle moving speed is , calculate frequency Send message; S1.
2. Each vehicle simultaneously monitors and records messages received from neighboring vehicles, calculates the effective connection time for direct communication with neighboring vehicles based on the received messages, and then sorts the neighboring vehicles based on the effective connection time to generate a neighbor vehicle sequence for the corresponding vehicle. A vehicle and the corresponding neighbor vehicle sequence form a candidate cluster. S1.
3. Each vehicle is used as the cluster head of its own candidate cluster, and the maximum computing resource (CCR) that can be utilized within the effective connection time is calculated. The CCR of each vehicle is then obtained and sent to the corresponding neighboring vehicles. S1.
4. Each vehicle receives the CCR from a neighboring vehicle and compares the CCR of the neighboring vehicle with its own CCR; S1.
5. Sort the CCRs from largest to smallest to obtain a CCR sequence; S1.
6. Find the vehicle with the highest ranked CCR as the cluster head, and use this vehicle and its corresponding neighboring vehicles as the cluster strategy to form a cluster. The CCR of the vehicle that has already been the cluster head is no longer included in the CCR sequence. S1.
7. Determine whether there are any CCRs in the CCR sequence. If so, jump to S1.8; otherwise, jump to S1.
10. S1.
8. Find the vehicle with the first CCR in the CCR sequence and determine whether the vehicle is considered a clustered vehicle. If so, remove the CCR of the vehicle from the CCR sequence, recalculate the CCRs of all remaining vehicles that have not formed a cluster, and then jump to S1.
5. Otherwise, jump to S1.
9. S1.
9. Determine whether the neighboring vehicles of the vehicle are considered as established cluster vehicles. If so, recalculate the CCR and jump to S1.
5. Otherwise, jump to S1.
6. S1.
10. Form several clusters.
4. The hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles according to claim 1, characterized in that: In S3, the expression for updating the global model is as follows: ; in, is the weight corresponding to the cluster model when the global model is aggregated, are the global model parameters before update at the edge server, are the updated global model parameters at the edge server, is the cluster model parameter of the zth cluster.
5. The hierarchical federated learning method based on dynamic clustering in the Internet of Vehicles according to claim 4, characterized in that: The weights of the cluster model It is determined according to the staleness of the cluster model. The specific formula is: ; in, , is the weight of each initial cluster model, represents the staleness of the cluster model, , which represents the staleness threshold.
Citation Information
Patent Citations
Asynchronous federated learning method, system, device and terminal for mobile vehicle
CN114116198A
Internet of vehicles federal learning hierarchical knowledge security migration method based on gradient memory
CN114492833A