An adaptive federated learning method and device based on inter-layer difference
By decomposing the model into a hierarchical structure and calculating the differences between layers, and dynamically adjusting the aggregation weights, the problem of insufficient model generality in the Internet of Vehicles is solved, and the cross-domain generalization ability and training efficiency of the global model are improved.
Patent Information
- Application Number
- CN202510400785.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2045-04-01
AI Technical Summary
Traditional federated learning methods struggle to build global models with strong generalization capabilities in connected vehicle scenarios. They suffer from low computational efficiency, are unable to adapt to heterogeneous environments, and fail to fully consider the differences in computing power among terminal devices, resulting in training latency and low resource utilization efficiency.
By decomposing the model into a hierarchical structure, calculating the differences between layers and dynamically adjusting the aggregation weights, and introducing a regularization term based on the differences between layers, the aggregation weights of each client are dynamically adjusted, thereby improving the cross-domain generalization ability of the global model.
It improves the cross-domain generalization ability of the global model, reduces the risk of model overfitting, improves training efficiency, and adapts to the highly heterogeneous data environment in the Internet of Vehicles.
Smart Images

Figure CN119918620B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of Internet of Vehicles machine learning, and in particular to a self-adaptive aggregation federated learning method and device based on inter-layer difference. BACKGROUND
[0002] In the Internet of Vehicles application scenario, the processing of multi-source heterogeneous data faces severe challenges. The data collected by vehicle terminals comes from complex dynamic environments such as urban roads, highways, and rural roads, making it difficult for the model to maintain stable performance across different domains. Especially when the model is migrated to unknown domains, traditional federated learning methods are difficult to build a global model with strong generalization ability, which seriously affects the actual deployment effect.
[0003] Although the federated domain generalization method can improve the adaptability of the model, it still has significant defects: (1) computational efficiency bottleneck: existing solutions mostly use implicit distribution alignment, reinforcement learning strategy or pseudo-label generation mechanism. Although these methods can improve the generalization of the model, they consume a large amount of computing resources and cannot meet the real-time requirements of the Internet of Vehicles scenario; (2) insufficient adaptability to heterogeneous environments: some methods reduce communication overhead through gradient transmission or fairness regularization, but do not fully consider the differences in client data distribution and sample size heterogeneity, while the Non-IID characteristics of terminal devices in the Internet of Vehicles are particularly prominent; (3) lack of dynamic resource adaptation: although existing dynamic weight aggregation schemes can adjust the client weights by evaluating the model difference, they generally ignore the computing power differences of terminal devices, and there is significant heterogeneity in computing power and hardware resources among participating devices in the Internet of Vehicles.
[0004] For example, the high-efficiency federated learning method in the Internet of Vehicles scenario disclosed in the invention patent with publication number CN113313264B includes: step 1: the roadside unit obtains a set of candidate learning tasks; step 2: selects a training task; step 3: establishes initial model parameters and sends the training task and its network address to vehicles within the coverage range; step 4: each vehicle parses the task information of the training task and then decides whether to participate in the training process; if it participates, it establishes a communication connection with the roadside unit through the network address; step 5: sends the initial model parameters to each vehicle; step 6: each vehicle uses local data to perform local training on the current model parameters and uploads them to the roadside unit; step 7: once the local training model uploaded by a vehicle is received, its weight is calculated in real time, and it is aggregated into the global model in real time, and the current model parameters are generated and returned to each vehicle in real time; step 8: iteratively execute steps 6 to 7 until the set number of iterations is met.
[0005] For example, the invention patent announcement with announcement number: CN113657606B announces a local area federal learning method for voltage division and aggregation in a vehicle networking scene, which includes the following steps: step 1: a plurality of road side units are connected to form a local area network, and one of the plurality of road side units is selected as a proxy group leader; step 2: the proxy group leader selects a training task, establishes an initial model state of the training task, and publishes the training task to vehicles in the dense area through broadcast; step 3: the vehicles participating in the training task use local data to perform local training on the received current model state of the training task, and upload the local training model to the nearest road side unit; step 4: each road side unit receives the local training model of the vehicle and performs average aggregation on it, and feeds back the aggregated current model state to the corresponding vehicle; step 5: iteratively execute steps 3 to 4 until the aggregated current model state meets the requirements.
[0006] However, in the process of implementing the technical scheme of the embodiments of the present application, the applicant found that the above-mentioned technology at least has the following technical problems:
[0007] The method is applied in vehicle networking. The difference in vehicle trajectory and sensor type causes the data distribution to present multimodal characteristics, such as dense urban road vehicle emergency braking data and mainly uniform speed data of high-speed vehicles. Traditional regularization forces the model to align global parameters and ignores the importance weight of local data characteristics, resulting in model bias towards high-frequency data patterns such as urban vehicles, sacrificing the generalization of edge scenarios such as mountain vehicles. The static aggregation weight is disconnected from the dynamic computing power, and a dynamic adaptation mechanism to the device computing power has not been established. There are problems such as increased training delay, low resource utilization efficiency in the vehicle networking scene, unstable connection caused by vehicle mobility, and the need for vehicles to repeat and wait for timeout due to dropped nodes such as 5G signal loss in traditional synchronous federal learning when vehicles enter and exit the coverage range of the base station. There is a problem of insufficient generality of the adaptive aggregation federal learning method model. SUMMARY
[0008] The embodiments of the present application provide a self-adaptive aggregation federal learning method and device based on interlayer difference, which solves the problem of insufficient generality of the adaptive aggregation federal learning method model in the prior art, and improves the cross-domain generalization ability of the global model.
[0009] The embodiment of the application provides a kind of adaptive aggregation federal learning method based on interlayer difference, comprising the following steps: collecting and processing vehicle terminal data;Each client receives global model issued from server, utilizes the vehicle terminal data and carries out local model training, minimizes loss function by iterative optimization, obtains local model new parameter;Collect local model new parameter, and global model and local model are disassembled into multi-layer structure, and are stored according to layer classification;The L2 norm difference value between each client model layer and the corresponding layer of global model is calculated, and the interlayer difference is quantified;Based on the training sample amount of each client and the interlayer difference value obtained, the weight of each client model parameter in the aggregation process is obtained by weight iterative calculation method containing linear decay hyperparameter;The model parameters of each client are independently aggregated according to layer, and the aggregated layer parameters are spliced to form a new global model, and the federal learning training cycle is carried out.
[0010] Further, the specific steps of collecting and processing vehicle terminal data are: collecting vehicle terminal raw data through Internet of Vehicles terminal equipment;Vehicle terminal raw data is cleaned and denoised to obtain vehicle terminal data.
[0011] Further, the specific steps of obtaining local model new parameter are: the client uses vehicle terminal data to train global model to obtain local model parameter;The client adjusts local model parameter by iterative optimization algorithm, calculates loss function according to vehicle terminal data, updates local model parameter using the gradient of loss function, and obtains local model new parameter;The client uploads local model new parameter to server for updating global model.
[0012] Further, the specific steps of disassembling local model and global model into multi-layer structure and storing according to layer classification are: the server collects local model new parameter from each client, disassembles the collected local model new parameter and global model parameter, and disassembles them into multiple levels respectively;Collect the same level parameters of different clients into the same set, and disassemble the global model into the same level structure as the local model, and add each level to the corresponding set.
[0013] Further, the specific steps of calculating the L2 norm difference value between each client model layer and the corresponding layer of global model and quantifying the interlayer difference are: the server obtains the parameter set corresponding to each level from the model parameters stored according to layer classification;Each set contains the corresponding level parameters of all clients and the corresponding level parameters of global model;For each level, calculate the L2 norm difference value between the global model layer parameters and the model layer parameters of each client, the L2 norm difference value is an index for measuring the distance between vectors, and quantifies the difference between two vectors.
[0014] Further, the specific step of obtaining the weight of each client model parameter in the aggregation process is: obtaining an initial weight according to the proportion of the number of training samples of each client in the total number of samples; and performing mean value processing on the initial weight and the L2 norm difference value to obtain the weight of each client model parameter in the aggregation process.
[0015] Further, the specific step of independently aggregating the model parameters of each client by layer and splicing the aggregated layer parameters to form a new global model is: selecting the model parameters of the corresponding layer of all clients; for the model parameters of the corresponding layer of each client, performing mean value processing according to the weight of each client model parameter in the aggregation process to obtain the model parameters of each client independently aggregated by layer; and splicing all the model parameters of each client independently aggregated by layer to form a global model.
[0016] Further, the specific step of the method of performing a federal learning training cycle is: the server distributes the global model to the client for local training; the client uploads the trained model to the server; the server splices the model to form a new global model; and the server distributes the new global model to the client for the next round of training.
[0017] Further, the method of performing a federal learning training cycle further includes: if the global model reaches a preset convergence condition in the federal learning training, the server sends a convergence signal to the client, indicating the client to stop the current training round; and if the global model does not reach the preset convergence condition in the federal learning training, the server sends a non-convergence signal to the client, indicating the client to continue the next round of training.
[0018] The embodiment of the application provides a terminal device, which is characterized by comprising: one or more processors, the plurality of processors comprising: a local client, configured to perform model training when local resources are sufficient, and upload a trained local model to a server; a central cloud server, configured to receive a client model, and distribute a trained model to each client; and a memory having one or more programs stored thereon, which, when executed by the one or more processors, cause the one or more processors to implement the inter-layer difference-based adaptive aggregation federal learning method and device.
[0019] The one or more technical solutions provided in the embodiment of the application have at least the following technical effects or advantages:
[0020] 1. By decomposing the model into layers and incorporating the difference between global and local model layers into the calculation process of aggregation weight, the contribution of different clients in high data heterogeneity scenarios is measured. At the same time, a regularization term based on the difference between layers is introduced, and the aggregation weight of each client in each round is dynamically adjusted according to the difference between layers, so as to improve the cross-domain generalization ability of the global model;
[0021] 2. By incorporating the difference between global and local model layers into the calculation process of aggregation weight, the federal learning training cycle can avoid the model parameters of some clients from having too great an impact on the global model, thereby reducing the risk of model overfitting, allocating more computing resources to clients with greater differences from the global model, and improving training efficiency;
[0022] 3. By introducing a regularization term based on the difference between layers in the aggregation process, the aggregation weight of each domain is dynamically adjusted, thereby prompting the global model to learn more universal features; and the global model is decomposed into multiple layers, aggregation is performed on each layer, and the difference between layers is introduced in the weight calculation process to solve the data heterogeneity problem in the Internet of Vehicles. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 A flowchart of an adaptive aggregation federal learning method based on the difference between layers is provided for the embodiments of the present application;
[0024] Figure 2 A federal learning framework based on the difference between layers is provided for the embodiments of the present application;
[0025] Figure 3 An illustration showing that there is a visual difference between the data sets of the clients is provided for the embodiments of the present application;
[0026] Figure 4 An illustration showing that there is data distribution heterogeneity between the data sets of the clients is provided for the embodiments of the present application;
[0027] Figure 5 An illustration showing the results of comparing the feature distributions learned by different methods on the PACS data set is provided for the embodiments of the present application;
[0028] Figure 6 An illustration showing the comparison results of combining FLLG with domain generalization method is provided for the embodiments of the present application;
[0029] Figure 7 An illustration showing the comparison results of combining FLLG with federal learning algorithm is provided for the embodiments of the present application;
[0030] Figure 8 An illustration showing the influence of the number of clients on the FLLG module is provided for the embodiments of the present application;
[0031] Figure 9 Schematic diagram of the impact of different dataset heterogeneity on the FLLG module provided in the embodiments of this application;
[0032] Figure 10 This is a schematic diagram of the impact of different local round numbers on the FLLG module provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The embodiments of the present application address the problem of insufficient versatility of the existing adaptive aggregated federated learning method model by providing an adaptive aggregated federated learning method and device based on inter-layer differences. This method breaks down the model into layers and incorporates the differences between global and local model layers into the calculation of aggregation weights to measure the contributions of different clients in high data heterogeneity scenarios. A regularization term based on inter-layer differences is also introduced to dynamically adjust the aggregation weights of each client in each round based on the inter-layer differences, thereby improving the cross-domain generalization capability of the global model.
[0034] The technical solution in the embodiments of the present application is to solve the above-mentioned problem of insufficient versatility of the adaptive aggregate federated learning method model. The overall idea is as follows:
[0035] By breaking the model down into layers and incorporating the differences between global and local model layers into the calculation of aggregation weights, we can measure the contributions of different clients in scenarios with high data heterogeneity. We also introduce a regularization term based on inter-layer differences to dynamically adjust the aggregation weights of each client in each round based on these inter-layer differences, thereby improving the cross-domain generalization capabilities of the global model.
[0036] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0037] like Figure 1 As shown, a flow chart of an adaptive aggregation federated learning method based on inter-layer differences provided in an embodiment of the present application, the method includes the following steps: collecting and processing vehicle terminal data; each client receives the global model sent from the server, uses the vehicle terminal data to perform local model training, and obtains new local model parameters by iterative optimization and minimizing the loss function; collects new local model parameters, decomposes the local model and the global model into a multi-layer structure, and stores them by layer classification; calculates the L2 norm difference value between each client model layer and the corresponding layer of the global model, and quantifies the inter-layer difference; based on the training sample size of each client and the calculated inter-layer difference value, obtains the weight of each client model parameter in the aggregation process through a weight iterative calculation method including a linear attenuation hyperparameter; independently aggregates the model parameters of each client by layer, and splices the aggregated parameters of each layer to form a new global model, and performs a federated learning training cycle.
[0038] In this embodiment, by refining the aggregation process of the global model, it is extended from single model aggregation to aggregation of single model layer or neural network layer. Through the independent aggregation mode based on the model layer, the performance and importance of each layer can be adjusted more flexibly, and the difference between the global model layer and the client model layer is taken into account in the weight calculation in the aggregation process to effectively cope with the high heterogeneity of the client dataset. At the same time, a dynamic weight adjustment mechanism based on the difference between layers is proposed. By measuring the difference between each client and the global model, the weight is dynamically adjusted according to the size of the difference based on the amount of training data of the client, so as to solve the problem of model cross-domain generalization in the federated learning of Internet of Vehicles. Figure 2 As shown, a federated learning framework is shown, which is composed of a central server and multiple local models. The global model is optimized through collaborative training. The server side (central coordination node) is responsible for global model aggregation, and the parameter updates from local models are integrated through weighted summation. The local model side (edge device) uses local data to train an independent model on each device (such as a mobile phone, a sensor), uploads the trained model parameters (not the original data) to the server, and obtains the updated global model parameters from the server. The device performs local training (such as gradient descent) based on the current global model, uploads the local model parameters to the server, and the server calculates the weighted average of the new global model. The updated model is distributed to each device to start the next round of training. The global model is a unified model maintained by the server side, which is used to coordinate the training direction of each local model. The local model is an independent model on the edge device, which adapts to the local data distribution (such as device heterogeneity), 、 、 is the weight coefficient of the different local models.
[0039] Further, the specific steps of collecting and processing vehicle terminal data are: collecting vehicle terminal raw data through Internet of Vehicles terminal equipment; cleaning and denoising the vehicle terminal raw data to obtain vehicle terminal data.
[0040] In this embodiment, the Internet of Vehicles terminal equipment includes real-time collection of road images, position information and environmental data through vehicle-mounted cameras, LiDAR, GPS and other sensors. The collected vehicle terminal raw data includes structured data such as vehicle speed, GPS coordinates and unstructured data such as images and point clouds.
[0041] Further, the specific steps of obtaining the new parameters of the local model are as follows: the client trains the global model using the vehicle terminal data to obtain the parameters of the local model; the client adjusts the parameters of the local model through an iterative optimization algorithm, calculates a loss function according to the vehicle terminal data, updates the parameters of the local model using the gradient of the loss function, and obtains new parameters of the local model; and the client uploads the new parameters of the local model to the server for updating the global model.
[0042] In this embodiment, the client receives the latest global model parameters issued from the server, which are the model parameters trained by all clients and represent the best fitting of the current model to the overall data. The client trains a local model using vehicle terminal data, which reflects the characteristics of the environment where the client is located, such as road conditions, traffic signs, etc. The client adjusts the model parameters through an iterative optimization algorithm, such as the gradient descent algorithm. Each iteration calculates a loss function according to the local data and updates the model parameters using the gradient of the loss function. The goal of the client is to find a set of model parameters that minimize the loss function of the model on the local data, meaning that the model can better predict the local data and more accurately reflect the characteristics of the environment where the client is located. After multiple iterations of optimization, a set of new parameters of the local model is obtained, which reflects the contribution of the client to the global model and contains information about the environment where the client is located. The new parameters of the local model are uploaded to the server for updating the global model.
[0043] Specifically, in federated learning, is used to represent each client, where represents the training samples of each client, where represents the number of selected clients for training, represents the training samples of all clients. In each , there are many sample pairs, represented by , where represents the features of the sample, represents the label value of the sample. Each client trains a local model using the dataset, where .
[0044] First, different clients train models according to vehicle terminal data. In the local training phase, when a client receives a new round of global model issued, it trains a local model using vehicle terminal data, and the optimization goal is:
[0045] ;
[0046] in, represents the client's optimization goal, is the loss function of the sample, used to measure the model predict and The error between represents the parameters of the model, Indicates in the dataset In local training, each client performs optimization independently, so that the local model is optimal for its specific data distribution.
[0047] Furthermore, the local model and the global model are decomposed into a multi-layer structure. The specific steps for storing them by layer classification are as follows: the server collects new local model parameters from each client, decomposes the collected new local model parameters and global model parameters into multiple levels respectively; collects the same-level parameters of different clients into the same set, decomposes the global model into the same hierarchical structure as the local model, and adds each level to the corresponding set.
[0048] In this embodiment, the server decomposes the collected local and global model parameters into multiple layers. Each layer represents a module or layer in the model, such as a convolutional layer or a fully connected layer. The same layer parameters from different clients are collected into the same set. To facilitate subsequent inter-layer difference calculation and inter-layer aggregation, the server creates multiple sets, each corresponding to a layer in the model, and adds the corresponding layer parameters from each client to the corresponding set.
[0049] Specifically, the collected local models Disassembled into I layer, expressed as , and collect the same model layer of different clients into the same collection, represented as . Then the global model Disassembled into , and add each layer of the global model to the corresponding set.
[0050] Furthermore, the L2 norm difference value between each client model layer and the corresponding layer of the global model is calculated. The specific steps for quantifying the difference between layers are as follows: the server obtains the parameter set corresponding to each layer from the model parameters stored by layer classification; each set contains the corresponding layer parameters of all clients and the corresponding layer parameters of the global model; for each layer, the L2 norm difference value between the global model layer parameters and the model layer parameters of each client is calculated. The L2 norm difference value is an indicator to measure the distance between vectors, which quantifies the degree of difference between two vectors.
[0051] In this embodiment, the steps of calculating the L2 norm difference between the global model layer parameters and each client model layer parameters are as follows:
[0052] ;
[0053] in, Indicates the The first client model The difference between the layer and the corresponding layer of the global model, Represents the global model layer, Indicates the The first client model layer, Representing the difference measurement function, such as the L2 norm, L2 norm is selected as the difference measurement function. The inter-layer difference reflects the feature difference between the client model layer and the corresponding layer of the global model. The greater the difference, the smaller the contribution of the client model layer to the global model.
[0054] Furthermore, the specific steps for obtaining the weight of each client model parameter in the aggregation process are as follows: obtaining the initial weight based on the ratio of the number of training samples of each client to the total number of samples; averaging the difference between the initial weight and the L2 norm to obtain the weight of each client model parameter in the aggregation process.
[0055] In this embodiment, the initial weight is calculated using the ratio of the number of client training samples to the total number of samples, that is: ;in, Indicates the Wheel Client Model The initial weights of the layers, Represents the client The number of training samples, Indicates the total number of training samples of all clients;
[0056] like Figure 3 As shown in Figure 2, the training data comes from different domains, such as highlight, blur, dim, etc., while the test data comes from the blank domain. Due to the large visual differences between domains, it is difficult for a single model to perform well on all domains. Specifically, according to Figure 4is the feature distribution map taken from the four client groups divided in the German Traffic Sign Recognition Benchmark (GTSRB) dataset, where different colors of points represent different data categories contained in the clients. By observing, it can be found that the data categories of each client have obvious differences, not only the data categories are different, but also the number of samples of each category is unbalanced. This phenomenon clearly shows that there is a significant distribution difference between the client data, that is, high heterogeneity, which leads to the model bias between the local model and the global model. This bias makes the local model of each client and the global model significantly different. When aggregating these models, the global model is difficult to achieve good accuracy on each client. The traditional federated learning only considers the proportion of the training dataset in the calculation of the aggregation weight, which is difficult to maintain good accuracy in the case of highly heterogeneous datasets. How to change the aggregation strategy to improve the performance of the overall system is the second problem we want to solve. To this end, a regularization term based on the inter-layer difference is introduced, which dynamically adjusts the aggregation weight of each client according to the difference, guiding the global model to better capture the same features in each domain. Through this method, the model can effectively reduce the domain bias when dealing with different data distributions and improve the generalization ability of the global model.
[0057] For general federated learning, the global optimization goal is:
[0058] ;
[0059] where represents the global model, represents the optimization goal of the client , , and represents the aggregation weight calculated by the number of training samples of each client. Weight distribution based on the data size of the training samples of each client ignores the data distribution difference between clients, which has a negative impact on the accuracy and generalization ability of the model. Therefore, based on the inter-layer difference and the number of training samples calculated above, a new global optimization goal is proposed for FedAvg:
[0060] where is the aggregation weight obtained by combining the inter-layer difference and the number of training samples. In the first round, since the global model has not been trained, the inter-layer difference is not considered, and the aggregation weight ;
[0061] From the second round, the global aggregation considers the difference between the client model layer and the global model layer, and implements dynamic weight aggregation, and each model layer has its own aggregation weight, represented as:
[0062] ;
[0063] ;
[0064] in, Indicates the current training round, represents the expected difference between the parameters of each layer, Indicates the Round The first client model The layer calculates the intermediate value of the aggregate weight, express Aggregate weight of the round, is a hyperparameter. It becomes stable as the number of training rounds increases, due to the fixed The size of will cause the model loss to continue to oscillate in the later stages of training and make it difficult to converge, so a linear attenuation strategy is used to stabilize the training. The value range is limited to Inside, and add a The index of It should decrease as the number of training rounds increases.
[0065] Furthermore, the specific steps of independently aggregating the model parameters of each client by layer and splicing the aggregated parameters of each layer to form a new global model are as follows: selecting the model parameters of the corresponding layers of all clients; for the model parameters of the corresponding layers of each client, averaging them according to the weights of the model parameters of each client in the aggregation process to obtain the model parameters of each client independently aggregated by layer; splicing all the model parameters of each client independently aggregated by layer to form a global model.
[0066] In this embodiment, the formula for obtaining the model parameters for independently aggregating each client by layer is:
[0067] ;
[0068] in, Represents the first Layer model parameters, Indicates the number of clients, Indicates the The first client model Aggregate weights of layer model parameters, Indicates the The first client model Layer model parameters; then perform global model aggregation , Indicates the operation of model splicing. After the model aggregation is completed, the server sends the global model to each client to start a new round of training.
[0069] Further, the specific steps of the method for performing a federated learning training cycle are: the server distributes a global model to the client for local training; the client uploads the trained model to the server; the server performs model splicing to form a new global model; and the server distributes the new global model to the client for the next round of training.
[0070] Further, the method for performing a federated learning training cycle further comprises: if the global model reaches a preset convergence condition during federated learning training, the server sends a convergence signal to the client, indicating the client to stop the current training round; and if the global model does not reach the preset convergence condition during federated learning training, the server sends a non-convergence signal to the client, indicating the client to continue the next round of training.
[0071] The embodiment of the application provides a terminal device, characterized in that comprising: one or more processors, the plurality of processors comprising: a local client, configured to perform model training when local resources are sufficient, and upload the trained local model to a server; a central cloud server, configured to receive a client model, and distribute the trained model to each client; a memory having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, the one or more processors implement a self-adaptive aggregation federated learning method based on inter-layer difference.
[0072] In this embodiment, in the federated learning data heterogeneous scene, in the cross-domain generalization scene, leave-one-domain evaluation is performed on all benchmark data sets, that is, one domain is selected as a never-seen client in turn, and the remaining domains are used as source clients for training. The learning rate of each client is 0.001, the batch size is 16, the number of local training epochs is 5, and a total of 40 rounds of training are performed. A variant of ResNet
[52] , ResNet-18, is used as the training model for cross-domain generalization, which includes a convolutional layer, a fully connected layer, and 4 residual blocks composed of 2 basic residual units.
[0073] FLLG is compared with the most advanced algorithm in two scenarios respectively, the performance and modularization of FLLG are demonstrated, and the broader application range of FLLG is explored.
[0074] Table 1 Accuracy and loss of different federated learning methods on 3 data sets:
[0075]
[0076] In Table 1, the accuracy and loss of different federated learning methods in the federated learning data heterogeneous scenario on three datasets are shown. The performance of each method on different datasets is quantified as two indicators: accuracy represents the classification performance of the model, and loss reflects the convergence of the model. Table 1 shows that the performance of FLLG on three datasets is better than other federated learning methods, showing excellent generalization ability and robustness. On the MNIST dataset, the accuracy of FLLG is 94.09%, which is 1.43% higher than FedAvg, and the loss value is significantly reduced. On the F-MNIST and GTSRB datasets, FLLG also maintains the lead, especially on GTSRB, with an accuracy of 95.38%, verifying its robustness and efficiency in highly data-heterogeneous scenarios. The experimental results clearly show that FLLG has obvious advantages in handling heterogeneous distributed data, both improving classification accuracy and significantly reducing loss value, outperforming current mainstream federated learning methods, verifying the effectiveness of the modular design and inter-layer difference perception strategy of FLLG.
[0077] In Table 2, the performance comparison of FLLG, FedDG, AM, and RSC in the domain generalization field is shown in the cross-domain generalization scenario. The evaluation criterion is the accuracy of the trained model on the unknown domain. The four columns in the table (such as P, A, C, R, or S) represent different fields, and the last column (Avg) is the average performance of the method in each field.
[0078] Table 2 Performance comparison of FLLG and other domain generalization methods:
[0079]
[0080] The P domain is chosen as the test domain. From the table, it can be seen that the test accuracy of FLLG in the test domain of the two datasets is 1.75% higher than the average accuracy of the other three methods, indicating that FLLG has stronger performance in cross-domain generalization tasks. The average accuracy of FLLG on the two datasets is 1.4% higher than the other three methods, indicating that FLLG has stronger robustness and cross-domain adaptability. Figure 5 is a comparison of the feature distributions learned by different methods on the PACS dataset. FLLG has better discrimination than other methods and generates semantic feature representations that are clear and compact in the field.
[0081] As FLLG only improves the aggregation strategy of the model and does not intervene in the training process, this design gives FLLG strong modularity and adaptability, enabling it to be flexibly embedded in existing federated learning frameworks to further improve algorithm performance. To verify its effectiveness, FLLG is combined with various federated learning algorithms (such as FedProx, FedBN, Ditto, and FedDBE) and common domain generalization methods (AM and RSC), and the performance difference before and after adding the FLLG module is compared. Among them Figure 6 FLLG combined with domain generalization methods, Figure 7 FLLG combined with federated learning algorithms. In a highly heterogeneous environment, FLLG significantly improves the performance of existing algorithms, with the precision of the model after adding FLLG generally increasing by 3%-8% compared to before.
[0082] Figure 8 shows the precision improvement percentage of the FLLG module for four federated learning methods when the number of clients is 10, 30, and 50 on three datasets. The average precision improvement brought by FLLG on the three datasets is 1.22%, 2%, and 0.7%. When the number of clients is small, the precision improvement brought by the FLLG module is best on the FMNIST dataset. As the number of clients increases to 30, the performance gain of the FLLG module on the MNIST and GTSRB datasets reaches a peak. When the number of clients further increases to 50, although there is still a gain, the precision improvement is reduced, which may be because the increase in the number of clients causes more noise interference when aggregating the global model. The FLLG module can adapt well to changes in the number of clients, especially when the number of clients is moderate.
[0083] Figure 9 The influence of the heterogeneity level of different datasets on the performance improvement brought by the FLLG module is discussed. As can be seen from the figure, the smaller the heterogeneity level and the higher the heterogeneity, the higher the precision improvement brought by FLLG, and the average precision improvement on the three datasets is 0.5%, 4.05%, and 1.08%. This is because FLLG adopts a hierarchical aggregation approach, with higher-level models being more sensitive to data features. Assigning separate aggregation weights can help the global model perceive common characteristics in each non-identically distributed dataset. At the same time, FLLG adjusts the weights adaptively according to the differences between layers, improving the model's generalization ability while reducing the impact of non-identically distributed data.
[0084] Figure 10The influence of different local training rounds on the performance gain brought by FLLG is shown, and the average precision improvement brought by the four methods plus FLLG on the three data sets is calculated as 1.21%, 3.82%, and 0.45%. As can be seen from the figure, with the increase of local rounds, the performance gain brought by FLLG first increases and then decreases, but it can still stably bring performance gain. This is because as the number of local training rounds increases, the local model trained is more likely to overfit, which will reduce the performance of each method.
[0085] Table 3 Influence of different domain numbers on the performance gain brought by FLLG:
[0086]
[0087] Table 3 shows the influence of different domain numbers on the performance gain brought by FLLG under two data sets. Since FLLG is a federated domain generalization method, when the number of domains in the data set is small, FLLG cannot significantly improve the performance compared to traditional methods. This is because when the number of domains is small, the training and aggregation process of the model can be relatively balanced, and the difference between the models of each client is small, so the traditional method can already obtain good performance. However, as the number of domains gradually increases, the advantage of FLLG gradually emerges, effectively dealing with the differences between different domains and significantly improving the performance of the global model. This shows that the FLLG method can better play its advantages when facing higher heterogeneity scenarios, enhancing the generalization ability of the model.
[0088] Table 4 Ablation experiment:
[0089]
[0090] In Table 4, the ablation experiment is shown, where FLLG-2 represents the removal of the regularization term based on the inter-layer difference and the consideration of the inter-layer difference in the calculation of the aggregation weight, and FLLG-1 represents the removal of the regularization term based on the inter-layer difference. Since the inter-layer difference is the calculation condition of the regularization term, it does not consider the case where the regularization term is retained and the inter-layer difference is not considered in the weight calculation. From the table, it can be seen that in both federated learning and domain generalization scenarios, the complete FLLG method performs best, indicating that the inter-layer difference plays a key role in the aggregation weight calculation and regularization process, effectively improving the model's performance in heterogeneous data and cross-domain environments.
[0091] Those skilled in the art will appreciate that embodiments of the present application can be devised for a variety of applications. It is intended that the present application be limited only by the scope of the appended claims, and it is intended that various modifications and alterations made by those skilled in the art be considered as within the scope of the present application. The embodiments of the present application will be described with reference to the attached drawings, wherein:
[0092] The present application is described in reference to the drawings using a flowchart and / or a block diagram of the method, apparatus (system) and computer program product according to embodiments of the application. It will be understood that each block of the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing device or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0093] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0094] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.
[0095] While the preferred embodiments of the application have been described, additional variations and modifications can be made to the embodiments by those skilled in the art once they learn of the basic inventive concepts. Therefore, the appended claims are intended to cover all such modifications and alterations as fall within the true spirit and scope of the present application.
[0096] Obviously, a person skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application belong to the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these modifications and variations.
Claims
1. An adaptive federated learning method based on inter-layer difference, characterized in that, Comprise the following steps: Collect and process vehicle terminal data; Each client receives the global model issued from the server, trains the local model using the vehicle terminal data, minimizes the loss function through iterative optimization, and obtains new parameters of the local model; Collect new parameters of the local model, and disassemble the local model and the global model into a multi-layer structure and store them by layer; Calculate the L2 norm difference value between each client model layer and the corresponding layer of the global model, and quantify the inter-layer difference; Based on the training sample size of each client and the calculated inter-layer difference value, a regularization term based on the inter-layer difference is introduced, the aggregation weight of each client is dynamically adjusted according to the difference, and the weight of each client model parameter in the aggregation process is obtained through a weight iterative calculation method containing a linear decay hyperparameter, and the specific steps of obtaining the weight of each client model parameter in the aggregation process are: obtaining the initial weight according to the proportion of the training sample size of each client to the total sample size; The initial weight and the L2 norm difference value are processed by mean value to obtain the weight of each client model parameter in the aggregation process, and the introduction of a regularization term based on the inter-layer difference can effectively reduce the domain bias and improve the generalization ability of the global model when dealing with different data distributions by dynamically adjusting the aggregation weight of each client. Aggregate the model parameters of each client by layer independently, and splice the aggregated parameters of each layer to form a new global model for federated learning training cycle. It should be further pointed out that in the federated learning data heterogeneous scene, in the cross-domain generalization scene, leave-one-domain evaluation is performed on all benchmark data sets, that is, one domain is selected as a client that has not been seen, and the remaining domains are selected as source clients for training.
2. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of collecting and processing vehicle terminal data are: Collect vehicle terminal raw data through Internet of Vehicles terminal equipment; Clean and denoise the vehicle terminal raw data to obtain vehicle terminal data.
3. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of obtaining new parameters of the local model are: The client trains the global model using the vehicle terminal data to obtain local model parameters; The client adjusts the local model parameters through an iterative optimization algorithm, calculates the loss function based on the vehicle terminal data, updates the local model parameters using the gradient of the loss function, and obtains new parameters of the local model; The client uploads the new parameters of the local model to the server for updating the global model.
4. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of disassembling the local model and the global model into a multi-layer structure and storing them by layer are: The server collects new parameters of the local model from each client, disassembles the collected new parameters of the local model and the global model parameters, and disassembles them into multiple levels respectively; Collect the same level parameters of different clients into the same set, and disassemble the global model into the same level structure as the local model, and add each level to the corresponding set.
5. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of calculating the L2 norm difference value between each client model layer and the corresponding layer of the global model and quantifying the inter-layer difference are: The server obtains the parameter set corresponding to each level from the model parameters stored by layer; Each set contains corresponding hierarchical parameters of all clients and corresponding hierarchical parameters of the global model; For each hierarchy, the L2 norm difference value between the global model layer parameters and each client model layer parameter is calculated, which is an index for measuring the distance between vectors and quantifying the difference between two vectors.
6. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of independently aggregating the model parameters of each client by layer and splicing the aggregated layer parameters to form a new global model are: Selecting the model parameters of the corresponding layer of all clients; For each client's corresponding layer model parameters, the mean value is processed according to the weight of each client model parameter in the aggregation process to obtain the model parameters of each client aggregated independently by layer; Splicing all the model parameters of each client aggregated independently by layer to form a global model.
7. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The specific steps of the method for performing a federal learning training cycle are: The server distributes the global model to the client for local training; The client uploads the trained model to the server; The server splices the model to form a new global model; The server distributes the new global model to the client for the next round of training.
8. The adaptive federated learning method based on inter-layer difference according to claim 1, wherein, The method for performing a federal learning training cycle further comprises: If the global model reaches the preset convergence condition during federal learning training, the server sends a convergence signal to the client, indicating the client to stop the current training round; If the global model does not reach the preset convergence condition during federal learning training, the server sends a non-convergence signal to the client, indicating the client to continue the next round of training.
9. A terminal device, comprising: Comprise: One or more processors, the plurality of processors comprising: a local client for training a model when local resources are sufficient, and uploading the trained local model to a server; a central cloud server for receiving client models and distributing trained models to each client; a memory having one or more programs stored thereon, which, when executed by the one or more processors, cause the one or more processors to implement a layer difference based adaptive aggregation federal learning method according to any one of claims 1-8.
Citation Information
Patent Citations
Efficient Federated Learning Methods in the Internet of Vehicles Scenarios
CN113313264B
A local federated learning method with pressure distribution and aggregation in the Internet of Vehicles scenario
CN113657606B
Narrow-sense asynchronous personalized federated learning adaptive aggregation method
CN115796274A
Fair privacy calculation method based on federated node contribution
CN116306910A