Efficient robust federated learning method for realizing double-end collaborative optimization in Internet of Things
By decomposing the model training process into "head training" and "characterization layer training" in the IoT environment and combining contrast learning and drift correction technology, the federated learning model performance degradation caused by data heterogeneity in the IoT environment is solved, and efficient, robust and adaptive model training is achieved.
Patent Information
- Application Number
- CN202510137752.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-05-30
AI Technical Summary
The problem of data heterogeneity in the IoT environment leads to a significant decline in performance of federated learning models when global model aggregation, and traditional methods often sacrifice model flexibility and adaptability when solving this problem.
By decomposing the model training process into two stages: "head training" and "characterization layer training", and dynamically adjusting the training parameters according to the device's data distribution and computing resources, combining contrast learning and drift correction techniques, the robustness and adaptability of the model are enhanced. At the same time, an intelligent client selection strategy based on data distribution differences is proposed to optimize device selection to improve the convergence efficiency of the global model.
It significantly improves the efficiency and performance of model training, enhances the robustness and adaptability of the global model, reduces the parameter drift problem caused by data heterogeneity, and improves the stability and generalization ability of the model under heterogeneous data distribution.
Smart Images

Figure CN120069124A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of the Internet of Things, and particularly relates to an efficient and robust federated learning method for realizing dual - end collaborative optimization in the Internet of Things. Background Art
[0002] In today's data - driven world, the development and deployment of machine - learning models highly rely on high - quality large - scale data. However, in the Internet - of - Things (IoT) environment, the problems of data distribution and heterogeneity are particularly prominent. At the same time, the increasingly strict privacy - protection regulations also pose great challenges to traditional centralized learning methods. Traditional centralized methods require transmitting all device data to a central server for training, which not only faces the risk of data - privacy leakage but also incurs high communication costs due to the large number of IoT devices and bandwidth limitations. Federated learning, as an emerging distributed machine - learning paradigm, provides an ideal solution for the distributed learning requirements in the IoT environment. It protects data privacy by allowing multiple devices (i.e., clients) to independently train models on local data and only share model parameters, while achieving global model training for cross - device collaboration. Compared with traditional methods, this approach can significantly reduce bandwidth overhead and meet the diverse privacy requirements of IoT devices.
[0003] Federated learning was initially proposed in the mobile - device scenario to solve the problem of joint modeling between devices, such as next - word prediction on smartphones. With the development of technology, the application of federated learning has rapidly expanded to more fields, such as healthcare, smart cities, and IoT devices. In the IoT scenario, federated learning enables distributed devices to collaboratively train efficient models without sharing raw data. For example, in smart homes, various devices (such as voice assistants, thermostats, and security cameras) can locally train models based on user - behavior data to improve the quality of personalized services. In industrial IoT, various sensors and edge devices can enhance the performance of fault detection and predictive maintenance through federated learning. In addition, in the field of intelligent transportation, distributed traffic nodes can use federated learning technology to achieve more accurate traffic flow prediction and optimize urban traffic resource scheduling. These practical applications fully demonstrate the great potential and broad prospects of federated learning in the IoT environment.
[0004] However, despite the broad application prospects of federated learning in the Internet of Things (IoT), it still faces many challenges in actual deployment, making the originally supposed "intelligent collaboration" process complex and difficult to manage. Among them, the problem of data heterogeneity unique to the IoT environment is particularly prominent. Data heterogeneity refers to the significant differences in the data distributions of different devices. For example, in the smart home scenario, the data collected by different household devices may have completely different usage habits and environmental characteristics; in the industrial IoT, the sensor data of different factories may focus on different production processes; in intelligent transportation, the traffic data at each traffic node is significantly affected by regional characteristics and time periods. This high degree of heterogeneity makes it difficult for the global model to simultaneously meet the needs of all devices, becoming one of the core bottlenecks faced by federated learning in the IoT scenario.
[0005] To more intuitively understand the impact of data heterogeneity on federated learning in the IoT environment, it can be analogized to "multi-voice chorus". In an ideal situation, all participants (clients, i.e., IoT devices) can coordinate in accordance with the rhythm of the conductor (global model), and finally present a harmonious and wonderful movement. However, in reality, due to the different data distributions and computing capabilities of IoT devices, each participant plays discordant notes and deviates from the global goal respectively, resulting in a chaotic final ensemble. Due to the differences in data distributions among IoT devices, the local models of each device develop in different optimization directions, which makes the divergence between model parameters increase when aggregating the global model, ultimately leading to a significant decline in the performance of the global model. This phenomenon not only undermines the original intention of federated learning but also limits its wide application in the IoT scenario in practice. Taking smart home as an example, the usage scenarios of devices in different households may be completely different, some mainly rely on voice control, while others are more used for security monitoring, resulting in great differences in the data distributions of each device. These non-independent and identically distributed data characteristics make it difficult for the global model to simultaneously meet the needs of all devices.
[0006] To address these issues, researchers have proposed various countermeasures. Some methods attempt to reduce the divergence from the global model by adjusting the local training process on the client side. For example, FedProx introduces a regularization term to limit the update magnitude of the local model, thereby alleviating the impact of data heterogeneity. However, these methods often sacrifice the flexibility of the global model when solving local problems, especially in the case where IoT devices have a high degree of heterogeneity. Another class of methods focuses on optimizing the global model on the server side, such as improving its adaptability by fine-tuning the global model. Although these methods have achieved certain results to some extent, most of them rely on unified training and aggregation strategies, ignoring the importance of data distribution differences in the IoT environment. With the deepening of research, it is recognized that to truly overcome the data heterogeneity problem faced by federated learning in the IoT scenario, relying solely on single optimization on the client or server side is not enough. The particularity of the IoT requires designing a more flexible and adaptable optimization strategy from a global perspective. Based on an in-depth analysis of existing methods, it is found that the core bottlenecks of federated learning in the IoT can be summarized into the following three aspects: The first is how to efficiently utilize the computing resources of devices. IoT devices often have limited hardware performance, and model training not only needs to adapt to the characteristics of local data but also maximize its contribution when aggregating the global model. The second is how to improve the robustness of the global model in a heterogeneous data environment. The global model needs to remain stable under complex distributions while taking into account the data characteristics of different devices. The third is how to optimize the device selection strategy. In the case of limited network resources in the IoT network, how to select the optimal devices to participate in federated learning to achieve the rapid convergence of the global model. Summary of the Invention
[0007] The purpose of the present invention is to provide an efficient and robust federated learning method for realizing dual - end collaborative optimization in the Internet of Things. The model training of Internet of Things devices is decomposed into "head training" and "representation layer training", and the training parameters are dynamically adjusted according to the data distribution and computing resources of the devices. In this way, different devices can select the optimal training combination according to their specific requirements and resource limitations, thereby significantly improving the training efficiency and model performance. Secondly, contrastive learning and drift correction techniques are introduced. By comparing the outputs of the local model and the global model, the robustness of the global model is enhanced; at the same time, the drift correction mechanism is used to effectively alleviate the parameter drift problem caused by data heterogeneity during the model aggregation process, ensuring the stability of the global model under the complex data distribution of the Internet of Things. Finally, in terms of the optimization of the server - side mechanism, an intelligent client selection strategy based on data distribution differences is proposed. In the initial stage of federated learning, devices with a large difference in data distribution from the global target are preferentially selected to participate in training to quickly cover the diversity of Internet of Things data; in the later training, a combination of random selection and data distribution optimization strategies is used to effectively reduce the number of communication rounds while significantly improving the generalization ability and convergence efficiency of the global model. Through experiments on datasets such as CIFAR - 10, CIFAR - 100, and FashionMNIST, the effectiveness and robustness of the method of the present invention are verified.
[0008] To achieve the above - mentioned technical objectives and reach the above - mentioned technical effects, the present invention is realized through the following technical solutions:
[0009] An efficient and robust federated learning method for realizing dual - end collaborative optimization in the Internet of Things, comprising the following steps:
[0010] S1: Decompose the model training process of Internet of Things devices into two stages: "head training" and "representation layer training". Head training focuses on adapting to specific tasks of local data, while representation layer training focuses on extracting global features.
[0011] S2: Align the feature representations of the local and global models through a contrastive learning mechanism to enhance the feature generalization ability;
[0012] S3: Introduce a drift correction mechanism to dynamically adjust the representation layer gradient to ensure the model stability under heterogeneous data distributions;
[0013] S4: Implement an intelligent client selection strategy to preferentially select clients with representative data distributions to improve the global learning effect;
[0014] S5: The client trains according to an adaptive strategy and uploads the representation layer parameters for weighted averaging to update the global model;
[0015] S6: Through multiple rounds of communication and aggregation, FedRAE converges quickly in a non - independent and identically - distributed data environment, demonstrating excellent performance.
[0016] Advantages of the present invention:
[0017] By decomposing the training process of the model into "head training" and "representation layer training", the present invention significantly improves the efficiency and effectiveness of local training. In the head training stage, only the parameters of the head layer are updated to quickly adapt to the local data characteristics and optimize for specific task requirements. The application of this strategy enables the model to quickly establish connections with local data and reduces the latency caused by complex calculations. In addition, in the representation layer training stage, the parameters of the head layer are frozen, and only the extraction of global features is focused on. This phased training method ensures the adaptability of the model between local and global. By dynamically adjusting the training parameters, the system can optimize the training configuration according to the specific resources and data distribution of each device. The computational load and communication overhead of the model will be significantly reduced, which is particularly important for Internet of Things devices with limited hardware performance, thereby improving the test accuracy while ensuring efficiency.
[0018] The contrastive learning mechanism introduced in the present invention establishes a strong feature representation alignment ability between the local model and the global model, thereby enhancing the feature generalization ability of the global model. Through the design of the contrastive loss function, the model can effectively minimize the difference between the output of the local representation layer and the output of the global representation layer. This mechanism ensures that the local model not only focuses on the feature learning of its own data but also can gradually align with the global features during the training process. This feature alignment process is achieved by optimizing the parameters of the local representation layer and can effectively enhance the adaptability of the model to different data distributions. Through gradual alignment, the local model can learn global features, thereby enhancing its generalization ability in practical applications. This enhanced feature generalization enables the global model to maintain higher performance when facing new data or changing data distributions.
[0019] The drift correction mechanism of the present invention effectively solves the common data distribution heterogeneity problem in the Internet of Things environment and significantly improves the stability of model training. By updating the local drift variable, which is dynamically generated according to the representation layer gradient and aims to record and feedback the drift amount caused by data distribution differences. The introduction of this drift variable can help the model adjust the parameter update direction in real time to ensure its stability in a complex environment. This method not only reduces the performance degradation of the model caused by parameter drift but also improves the robustness of the global model in a heterogeneous data distribution environment. As the training progresses, the drift correction mechanism can effectively suppress parameter inconsistency and enhance the adaptability of the model when facing different client data, ensuring the stable performance of the global model.
[0020] Through the application of the intelligent client selection strategy, the present invention significantly improves the convergence efficiency of federated learning. In the initial communication rounds, by preferentially selecting clients with a large difference from the global data distribution for rapid training, this strategy ensures that the most representative data samples can be quickly learned by the global model. In subsequent communication rounds, the clients are divided into a large-difference group and a small-difference group, and combined with a random selection method, the client selection process is optimized. Such a selection strategy not only ensures the diversity in the training process but also enhances the stability in model training, reducing the degradation of the global model performance caused by local optima. This mechanism optimizes the aggregation process of the global model by effectively integrating diverse data brought by different devices, enabling it to achieve rapid convergence within a limited number of communication rounds, thereby improving the generalization ability and applicability of the global model.
[0021] Of course, it is not necessary for any product implementing the present invention to achieve all the above advantages simultaneously. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0023] Figure 1 It is a schematic diagram of the FedRAE framework;
[0024] Figure 2 It is a schematic diagram of the ablation experiment;
[0025] Figure 3 It is a schematic diagram of the performance verification of the dynamic adaptive strategy on the local training rounds;
[0026] Figure 4 It is a schematic diagram of the performance verification of the dynamic adaptive strategy on the client participation ratio;
[0027] Figure 5 It is a schematic diagram of the influence of the drift correction smoothing coefficient β on the model performance;
[0028] Figure 6 It is a schematic diagram of the influence of the temperature coefficient τ on the model performance;
[0029] Figure 7 It is a schematic diagram of the influence of the grouping ratio in the client selection strategy based on KL divergence on the model performance;
[0030] Figure 8 It is a schematic diagram of the influence of the grouping sampling probability in the client selection strategy based on KL divergence on the model performance
[0031] Figure 9 It is a schematic diagram of the influence of the grouping ratio on the model performance in the client selection strategy based on cosine similarity;
[0032] Figure 10 It is a schematic diagram of the influence of the grouping ratio on the model performance in the client selection strategy based on L1 norm;
[0033] Figure 11 It is a schematic diagram of the influence of the grouping ratio on the model performance in the client selection strategy based on L2 norm;
[0034] Figure 12 It is a schematic diagram of the influence of the grouping sampling probability on the model performance in the client selection strategy based on cosine similarity
[0035] Figure 13 It is a schematic diagram of the influence of the grouping sampling probability on the model performance in the client selection strategy based on L1 norm
[0036] Figure 14 It is a schematic diagram of the influence of the grouping sampling probability on the model performance in the client selection strategy based on L2 norm Detailed implementation manners
[0037] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0038] Embodiment 1
[0039] An efficient and robust federated learning method for realizing dual - end collaborative optimization in the Internet of Things according to this embodiment includes the following steps:
[0040] S1: Decompose the training process of the model into two stages: head training and representation layer training. In the head training stage, freeze the parameters of the representation layer and only update the parameters of the head layer to quickly adapt to the specific task requirements of local data; while in the representation layer training stage, freeze the parameters of the head layer and only update the parameters of the representation layer to focus on the extraction of global features. To optimize the efficiency and effect of local training, when first contacting a certain client, the system will try multiple combinations of the number of training times, evaluate the training losses of each combination, and select the combination with the smallest loss as the optimal training parameters for this client. This not only allows the model to quickly adapt to local data but also ensures reducing unnecessary computational overhead in subsequent communications.
[0041] S2: Improve the feature representation alignment ability between the local model and the global model through a contrastive learning mechanism. The contrastive learning introduces a loss function between the representation layer of the local model and that of the global model, aiming to enhance the local model's understanding of global features by minimizing the differences between feature representations. Calculate the contrastive loss between the outputs of the local representation layer and the global representation layer, and integrate this loss into the total loss function to optimize the parameters of the local representation layer. The model can gradually align the local features with the global features, thereby improving the feature generalization ability of the global model.
[0042] S3: Introduce a drift correction mechanism to avoid the problem of model parameter drift caused by data distribution heterogeneity. First, update the local drift variable, which is dynamically updated based on the gradients of the representation layer and aims to record and feedback the drift amount caused by data distribution differences. Then, integrate the updated drift variable into the gradients of the current representation layer to correct the gradient update direction and ensure the stability and robustness of the model. Effectively suppress the drift phenomenon of the representation layer parameters and ensure the stable training of the model in a heterogeneous data distribution environment.
[0043] S4: Introduce an intelligent client selection strategy. In the initial communication rounds, first prioritize the selection of clients according to the difference metric between the client and the global data distribution, ensuring that the most representative data distribution can be quickly learned by the global model. In subsequent communication rounds, the strategy divides the clients into a large-difference group and a small-difference group, and combines random selection and data distribution differences for client selection. While ensuring training diversity, pay attention to the stability of training.
[0044] S5: Each selected client trains according to an adaptive strategy and uploads the parameters of the trained representation layer to the server. The server performs weighted averaging on the uploaded parameters of the representation layer to update the parameters of the global representation layer, ensuring that the global model adapts to diverse data distributions.
[0045] S6: Through multiple rounds of communication and aggregation processes, FedRAE gradually optimizes the global model, achieves fast convergence within a small number of communication rounds, and reaches the best performance in a non-independent and identically distributed data environment.
[0046] In each round of communication, the server selects some clients to perform local training and adjusts the training parameters according to an adaptive strategy to optimize the local model. After training, the clients upload the parameters of their representation layers, and the server performs weighted averaging on these parameters to update the parameters of the global representation layer. Through continuous communication and aggregation, the method gradually optimizes the global model within a small number of communication rounds, enabling it to achieve the best performance in a non-independent and identically distributed data environment. Finally, the experimental results of the method of the present invention on multiple complex datasets show that, compared with traditional methods, it demonstrates better test accuracy and convergence speed and is very suitable for the Internet of Things application scenario.
[0047] Example 2
[0048] The present invention proposes an innovative federated learning algorithm, FedRAE, aiming to solve problems such as data heterogeneity, low training efficiency, and poor model stability. FedRAE effectively improves the performance of federated learning in non-i.i.d. data environments by introducing key strategies, such as decomposing local training and adaptively adjusting the number of training times for the head and representation layers individually, contrastive learning, drift correction, and an intelligent client selection mechanism.
[0049] The core of FedRAE lies in improving the local training process and optimizing the client selection mechanism in the server side to better adapt to data heterogeneity and improve model performance. During the training process, FedRAE decomposes the local training task into two stages: head layer training and representation layer training, and realizes optimization for client needs by individually adjusting the number of training times: the head layer focuses on learning client-specific tasks, while the representation layer focuses on extracting global feature representations. Through this decomposition and individual adjustment strategy, FedRAE not only improves computational efficiency but also significantly enhances the stability and adaptability of the model in heterogeneous data environments.
[0050] To further improve the robustness and stability of the model under heterogeneous data distributions, FedRAE introduces contrastive learning and drift correction mechanisms. By comparing the feature representations of the local model and the global model, FedRAE achieves efficient alignment between the two, significantly reducing the differences between models and improving the robustness of the global model. In addition, the drift correction mechanism balances the global and local optimization objectives by adjusting the gradient update direction of the local model, alleviates the catastrophic forgetting problem caused by data heterogeneity, and effectively improves the stability of the training process.
[0051] To accelerate the convergence of the model and reduce communication overhead, FedRAE adopts an intelligent client selection mechanism. The server optimizes the client selection strategy by evaluating the differences in client data distributions, thereby significantly improving the convergence speed of the global model within fewer communication rounds.
[0052] The overall process of FedRAE is as shown in Algorithm 1 and Figure 1 can be divided into the following stages:
[0053] Initialization stage: The server sets parameters such as the number of communication rounds, client participation rate, and number of iterations for local training, and initializes the global representation layer parameters. The clients synchronously initialize their local models, including the shared representation layer and task-specific head layer.
[0054] Communication and Training Phase: The server selects a portion of clients to participate in the current round of training through the ClientSelect algorithm and sends the current global representation layer parameters. The selected clients use the AdaptTrain algorithm to dynamically determine the number of training times for the head layer and the representation layer. First, the head layer training is executed to optimize the client task-specific parameters; then the representation layer training is executed. By invoking the ConDrift algorithm and combining contrastive learning with the drift correction mechanism, the globally shared representation layer parameters are further optimized. The clients upload the completed representation layer parameters to the server, while the unselected clients keep the head layer parameters unchanged to maintain model stability.
[0055] Aggregation Phase: The server performs weighted averaging on the representation layer parameters uploaded by all selected clients, updates the global representation parameters, and sends them to the clients in the next round for further training.
[0056] After multiple rounds of communication and aggregation, FedRAE gradually optimizes the global model to achieve the optimal performance in the Non-IID data environment, and finally realizes a federated learning process with balanced robustness, adaptability, and efficiency.
[0057]
[0058]
[0059] First Adaptive Decomposition Training Strategy
[0060] To address the data heterogeneity problem, an adaptive local training decomposition strategy is proposed. The local training process is decomposed into head training and representation layer training, and the optimal combination of training times is dynamically selected when first encountering a client. In each round of communication, the client divides the local training into two stages. In the head layer training stage, the representation layer parameters are frozen, and only the head layer parameters are updated to quickly adapt the head layer to the local data distribution. In the representation layer training stage, the head layer parameters are frozen, and only the representation layer parameters are updated to retain the globally shared feature representation.
[0061] When the system first encounters a certain client i, to dynamically determine the optimal number of training rounds for the head layer and the representation layer, the system will try all possible combinations of training times (ρ h , ρ γ ), where ρ h is the number of head training times, ρ γ is the number of representation layer training times, and the total number of training times satisfies:
[0062] ρ = ρ h + ρ γ (1)
[0063] For each group (ρ h , ργ ), the client conducts head training and representation layer training respectively, and calculates the corresponding training loss L(γ i , h i ). Record the training losses of all combinations, and select the combination with the smallest loss as the optimal training parameter for this client:
[0064]
[0065] Cache the optimal number of training times into the client access record cl. When the system encounters this client again later, it will directly use the cached optimal training parameters for training without re-verification, thus significantly reducing the computational overhead. Through the above strategy, FedRAE can adaptively adjust the training rounds of the head and the representation layer according to the personalized needs of different clients. This dynamic decomposition training mechanism ensures that the head layer converges quickly to the local task, while the representation layer can stably learn the global features, thus achieving higher accuracy and efficiency in heterogeneous data environments. The specific process of the algorithm is shown in Algorithm 2.
[0066]
[0067]
[0068] Contrastive learning and drift correction
[0069] Contrastive learning: Contrastive learning aims to strengthen the adaptability of the local representation layer to the global features by comparing the feature representations output by the local model and the global model in the representation layer, and reduce the difference between the local representation layer and the global representation layer. During the local training process of federated learning, a contrastive loss is introduced to optimize the parameters of the representation layer to improve the feature generalization ability of the global model.
[0070] Let the feature representation output by the local model's representation layer be F local , and the feature representation output by the global model's representation layer be F global . First, perform L2 normalization on the representation vectors to ensure that the vector norm is 1. Then, construct a contrastive loss by calculating the similarity between them, and its loss function is defined as:
[0071]
[0072] where N is the batch size, τ is the temperature parameter used to adjust the smoothness of the similarity distribution, F local,i and are the normalized local and global representation vectors respectively, y i is the constructed label, and let sample i form a positive sample pair only with the global representation vector j corresponding to itself, while other sample pairs are regarded as negative samples.
[0073] In each training batch, the client extracts the output F of the local model's representation layer respectively local and the output F of the global model's representation layer global , calculates the contrastive loss and adds it to the total loss function to optimize the parameters of the local representation layer. The total loss function is defined as:
[0074]
[0075] where L ce is the cross-entropy loss, and λ is the weight hyperparameter used to balance the contributions of the cross-entropy loss and the contrastive loss. Through contrastive learning, the representation layer of the local model can gradually align with the global feature representation, thereby enhancing the feature generalization ability of the global model.
[0076] Drift correction: To address the drift problem caused by data distribution heterogeneity during the training of the representation layer, FedRAE introduces a local drift variable Δ and adjusts the gradient update of the representation layer parameters, thereby achieving drift correction.
[0077] Specifically, the drift correction mechanism mainly includes two steps. The first step is to update the local drift variable, which is dynamically updated based on the representation layer gradient, and the expression is as follows:
[0078]
[0079] where β ∈ [0, 1] is the smoothing coefficient.
[0080] The second step is to correct the representation layer gradient. The updated drift variable Δ is added to the current representation layer gradient to correct the gradient update direction:
[0081]
[0082] Through drift correction, FedRAE can effectively suppress the drift phenomenon of the representation layer parameters and ensure the stable training of the model under heterogeneous data distributions.
[0083] FedRAE combines two mechanisms, contrastive learning and drift correction, in the training of the representation layer. Contrastive learning improves the robustness of feature representation by enhancing the feature alignment between the local representation layer and the global representation layer; drift correction alleviates the model drift problem caused by heterogeneous data by adjusting the gradient. This design ensures that the representation layer can stably learn global features and achieve an efficient optimization process in a non-independent and identically distributed data environment. The specific implementation process is shown in Algorithm 3.
[0084]
[0085] Client selection strategy
[0086] In federated learning, the client selection strategy plays a crucial role in training efficiency and model performance. The present invention proposes an intelligent client selection strategy based on data distribution differences, adopting different selection schemes in the initial and later stages of communication rounds to address data heterogeneity and improve communication efficiency.
[0087] Let the data distribution of client i be p i , and the global data distribution be p g . Use the distribution difference metric function D(·||·) to calculate the difference degree δ between client i and the global distribution i :
[0088] δ i = D(p i ||p g ) (7)
[0089] Among them, D(·∥·) can be a metric function such as KL divergence, L1 norm, L2 norm, or cosine similarity.
[0090] In the initial communication rounds (t < 1 / r), in order to quickly cover the data distributions of clients, first sort in descending order according to the difference degree δ i between the client and the global data distribution, and sequentially select the first t*|C|*r clients to participate in training. This strategy ensures that all clients have the opportunity to participate in one training session in the initial stage, and at the same time gives priority to selecting clients with the largest data distribution differences, which helps the model quickly learn and adapt to the diversity of data distributions. The client selection formula is:
[0091] χ t ← client diff [t*|C|*r] (8)
[0092] In the later communication rounds (t ≥ 1 / r), in order to balance the data distribution differences and improve the stability of training, the client selection strategy adopts a grouped random sampling mechanism. Specifically, first, according to the descending order of the data distribution difference degree δ i , divide the clients into a large-difference group and a small-difference group. The small-difference group contains the last α clients with smaller difference degrees, and the remaining clients are divided into the large-difference group. Subsequently, randomly sample according to the proportion from the two groups: randomly select (|C|*r*(1 - μ)) clients from the large-difference group, and at the same time randomly select (|C|*r*μ) clients from the small-difference group, where μ represents the proportion of clients drawn from the small-difference group. The finally selected client set is composed of the union of the two groups of clients.
[0093] The advantage of this strategy is that FedRAE can quickly adapt to the diversity of data distribution in the early stage, and in the later stage, by combining the client selection of large difference groups and small difference groups, it gradually balances the update of the global model to ensure the adaptability and stability of the model to different client data. In addition, group random sampling introduces a certain degree of randomness, which not only avoids the model from being overly dependent on the data of a specific client, but also effectively prevents overfitting, further improving the overall performance and training efficiency. The algorithm flow is shown in Algorithm 4.
[0094]
[0095]
[0096] Example 3
[0097] Experimental setup
[0098] Dataset
[0099] This experiment selected three commonly used datasets: CIFAR-10, CIFAR-100, and FashionMNIST to evaluate the performance of the proposed federated learning optimization algorithm under different data distributions.
[0100] CIFAR-10: This dataset contains 60,000 32x32 color images divided into 10 categories, with 6,000 images in each category. The training set and test set contain 50,000 and 10,000 images respectively. This dataset is widely used for image classification tasks and has high complexity and challenges.
[0101] CIFAR-100: This dataset is similar to CIFAR-10, but the image categories are expanded to 100 categories, each category contains 600 images, of which 500 are used for training and 100 are used for testing. Overall, the training set contains 50,000 images and the test set contains 10,000 images. CIFAR-100 is more challenging because it involves more fine-grained category divisions, which helps evaluate the performance of models in complex multi-class tasks.
[0102] FashionMNIST: This dataset contains 70,000 28x28 grayscale images divided into 10 categories, with 7,000 images in each category. The training set and test set contain 60,000 and 10,000 images respectively. FashionMNIST is widely used to replace the MNIST dataset to evaluate the performance of models on processing more complex clothing images.
[0103] Heterogeneous scenarios
[0104] In practical applications, data distributions often exhibit significant differences. To simulate the heterogeneity of these data distributions, two typical non-independent and identically distributed scenarios, namely NIID-1 and NIID-2, are designed.
[0105] NIID-1: The data is generated through the Dirichlet distribution, denoted as Dir ε , where ε is related to the data heterogeneity level. Under this setting, each client may only contain data of a few categories, forming a highly imbalanced data distribution. In the experiments of the present invention, ε is uniformly set to 0.5.
[0106] NIID-2: This scenario simulates a more complex data heterogeneity, including two types of clients: unbiased clients and biased clients. The data of unbiased clients covers all C categories, maintaining data balance; while the data of biased clients only comes from C / 5 categories out of the total number of categories C, forming a highly imbalanced data distribution. This setting is closer to reality, reflecting the situation where some clients have balanced data while other clients have highly biased data. In the experiments of the present invention, for CIFAR-10 and FashionMNIST, the number of unbiased clients is set to 20, and the number of biased clients is 180; for CIFAR-100, the number of unbiased clients is set to 10, and the number of biased clients is 90.
[0107] Parameter Settings
[0108] During the experiments, some general parameters are set to ensure the fairness and consistency of training. The learning rate is set to 0.01, the optimizer uses the Stochastic Gradient Descent (SGD) method, and the batch size is fixed at 32. In terms of the number of communication rounds, the number of communication rounds for all three datasets is set to 50, and the client participation ratio is uniformly 5%. In terms of the total number of clients, the total number of clients for the CIFAR-100 dataset is set to 100, while the total number of clients for the other two datasets (CIFAR-10 and FashionMNIST) is set to 200. Other experimental parameters will be appropriately adjusted according to the characteristics of different datasets and model architectures to optimize the training effect and ensure the stability and reliability of the experimental results.
[0109] Model
[0110] In this study, a 5-layer Convolutional Neural Network (CNN) model was uniformly adopted for the CIFAR-10, CIFAR-100, and FashionMNIST datasets. The common feature of these datasets is image data, so CNN is an ideal choice for processing and classifying such data. The structure of the CNN model is designed as follows: The first two layers are convolutional layers, which are used to extract the spatial features of the images. After each convolutional layer, a pooling layer follows, which reduces the dimension of the feature map through downsampling, retaining important feature information while reducing computational complexity. The last three layers are fully connected layers, which map the high-level features extracted by the convolutional layers to the output classes, and achieve the final classification task of the images through the linear combination of features.
[0111] To better adapt to the data heterogeneity problem in federated learning, the model was decomposed, and a two-part structure of a global representation layer and a local head layer was designed. The global representation layer includes the first two convolutional layers and the first two fully connected layers. These layers are responsible for extracting general features, which are highly shareable and can be shared among different clients to enhance the stability and generalization ability of the global model. The local head layer includes the weights and bias parameters of the last fully connected layer, which are mainly learned and optimized for the data distribution of specific clients. Due to the differences in the data distributions of different clients, the local head layer can be adjusted personalized according to the characteristics of each client, thereby improving the classification performance of the model on local data.
[0112] Baseline
[0113] In the experiment, to comprehensively evaluate the effectiveness of the method proposed in the present invention, a variety of classical federated learning algorithms were selected as comparison baselines. FedAvg is the earliest proposed federated learning algorithm, which aggregates local model parameters through weighted averaging and is the basic method of federated learning; FedAvgM
[31] introduces momentum optimization on the basis of FedAvg to accelerate model convergence; SCAFFOLD alleviates the client drift problem by introducing control variables, improving the robustness and convergence of the model in heterogeneous data environments; FedProx enhances the stability of the algorithm in heterogeneous scenarios by adding a regularization term to constrain the local optimization process; FedDyn further improves the training stability by aligning the global model and the local model with a dynamic regularization term; FedPer divides the model into a globally shared part and a locally specific part to better adapt to the personalized needs of clients; LG-FedAvg combines local representation learning and a global head model, not only alleviating the impact of data heterogeneity on the model but also reducing the number of parameter transmissions during communication. FedRep emphasizes the global sharing of the representation layer and the local adaptability of the head layer by separating the representation layer and the head layer, and is an important representative of personalized federated learning. FedPAC improves local feature representations by leveraging global semantic information and optimizes classifier weights to achieve client collaboration, taking into account both global generalization ability and personalized performance. FedCP proposes a sample-level conditional policy to separate the global information and personalized information in features, which are processed by a global head and a personalized head respectively, significantly improving the performance and robustness in heterogeneous environments.
[0114] Experimental results
[0115] Evaluation metrics
[0116] To comprehensively evaluate the model performance, the following evaluation metrics were adopted:
[0117] Average accuracy: To evaluate the performance of the model in the steady state, the average of the model accuracies in the last 10 communication rounds was calculated. This metric can reflect the stability and overall performance of the model in the later stage of training.
[0118] Communication rounds to reach the preset accuracy: To evaluate the convergence speed of the model, a preset accuracy threshold was defined for each dataset and heterogeneity setting. Among them, the preset accuracy for CIFAR-10 (NIID-1) is 25%, for CIFAR-100 (NIID-1) is 6%, for FashionMNIST (NIID-1) is 55%, for CIFAR-10 (NIID-2) is 20%, for CIFAR-100 (NIID-2) is 4%, and for FashionMNIST (NIID-2) is 50%.
[0119] Comparative experiments
[0120] Table 1: Accuracy performance of each federated learning algorithm on CIFAR-10, CIFAR-100 and FashionMNIST datasets
[0121]
[0122]
[0123] Table 2: Training efficiency performance of each federated learning algorithm on CIFAR-10, CIFAR-100 and FashionMNIST datasets
[0124]
[0125] In the experiment, a comprehensive comparison was made of the performance of various federated learning algorithms on the CIFAR-10, CIFAR-100 and FashionMNIST datasets. Table 1 shows the average test accuracy of each algorithm under the same communication rounds to evaluate the stable performance of the model. Table 2 records the communication rounds required for each algorithm to reach the preset accuracy to measure the convergence speed of the model. The experimental results show that the algorithm proposed in the present invention exhibits significant advantages on all three datasets, not only far exceeding other algorithms in terms of test accuracy, but also showing obvious improvement in training efficiency.
[0126] In particular, FedRAE(KL) in the table is a client selection algorithm proposed in the present invention based on measuring the difference between the client and the global distribution using KL divergence. In addition, there are also FedRAE(COSINE), FedRAE(L1) and FedRAE(L2) versions, which are based on cosine similarity, L1 norm and L2 norm as the difference metric functions respectively. In the "Discussion" section of the present invention, the performance and applicability of these difference metric functions in different scenarios are discussed in detail to further verify and analyze the generalization ability and robustness of the algorithm.
[0127] Ablation experiment
[0128] To comprehensively evaluate the impact of different innovation points on the model performance, an ablation experiment was designed with FedRep as the basic algorithm (Basic). At the same time, for the convenience of explaining the experimental results and analysis, a concise naming rule was introduced for each innovation point during the experiment. Specifically, a suffix was added after the name of FedRAE to clearly refer to different optimization strategies. For example, the strategy of adaptively selecting the number of training times for the head and the representation layer proposed for the first time in the present invention is denoted as FedRAE-A, the contrastive learning and drift correction strategy is denoted as FedRAE-D, and the intelligent client selection strategy is denoted as FedRAE-C.
[0129] In the ablation experiments, the independent contributions of FedRAE-A, FedRAE-D, and FedRAE-C(KL) (an intelligent client selection strategy based on KL divergence distribution difference metric) were verified respectively. Through experimental analysis, the roles of these strategies in improving model performance and optimizing federated learning tasks were systematically verified.
[0130] Table 3: Ablation Experiments
[0131]
[0132] Table 3 lists the average test accuracies of each algorithm at fixed rounds under different data distribution scenarios, which are used to compare the final performance of each algorithm. Figure 2 It shows the dynamic changes of the test accuracies of each algorithm during the communication rounds, reflecting the contributions of each innovation point to the training efficiency and convergence speed.
[0133] The experimental results show that, based on the Basic algorithm, by introducing the adaptive selection mechanism (FedRAE-A), contrastive learning and drift correction (FedRAE-D), and the difference-based intelligent client selection strategy (FedRAE-C(KL)), each innovation point has significantly improved the model performance. Among them, each innovation point has played a unique role in the data heterogeneity scenario, comprehensively optimizing the stability and convergence speed of the model. When the three major innovation points are combined, the performance improvement is the most significant, fully verifying the effectiveness and comprehensive advantages of the method of the present invention.
[0134] Effect Verification and Performance Analysis of the Core Strategies of the Algorithm
[0135] Based on the FedRep algorithm with fixed head and number of representation trainings, the three major innovation points proposed by the present invention are introduced, and parameter analysis is carried out for each innovation point. To comprehensively evaluate the specific impacts of these innovation points on the algorithm performance, a series of experiments are designed.
[0136] The First Adaptive Training Decomposition Strategy
[0137] To comprehensively verify the impact of the first adaptive selection of the head and the number of representation trainings on the model performance, taking the FedRep algorithm with fixed head and number of representation trainings as the baseline, a dynamic adaptive mechanism is introduced to form the optimized version FedRAE-A for exploring the effectiveness of this innovation point. In the experiment, FedRAE-A is regarded as the representative of the dynamic optimization strategy, while FedRep is used as the control of the static strategy. By comparing their performances under different experimental conditions, the adaptability and generalization performance of the dynamic adaptive strategy in the local training number setting and the client participation ratio are systematically evaluated.
[0138] Performance Verification of the Dynamic Adaptive Strategy in the Local Training Rounds
[0139] For different settings of the number of local training times (such as 4, 6, 8, 10), the number of local training times is further refined into the number of head training times and the number of representation layer training times. In FedRep, the number of representation layer training times is fixed at 1, and the remaining training rounds are all allocated to the head layer; while in FedRAE-A, each client adaptively selects the most suitable training ratio for the head and the representation layer according to its own characteristics to achieve personalized optimization. The experimental results are as Figure 3 shown, demonstrating the impact of the number of local training times on the test accuracy. It can be seen from the results that FedRAE-A is significantly better than FedRep regardless of the number of local training times, indicating that the first adaptive training decomposition strategy can effectively improve the model performance.
[0140] Performance verification of the dynamic adaptive strategy in terms of the client participation ratio
[0141] The impact of different client participation ratios (such as 5%, 10%, 15%, 20%) on the model performance was further investigated. The number of local training times was uniformly set to 8 to exclude the interference of other variables. This experiment focused on evaluating the performance of the first adaptive training decomposition strategy under various client participation conditions to verify its applicability in scenarios of data heterogeneity and limited client resources. The experimental results are as Figure 4 shown, demonstrating the impact of the client participation ratio on the test accuracy. The results show that FedRAE-A is significantly better than FedRep under different participation ratio conditions, reflecting higher training efficiency and stronger generalization ability.
[0142] The results of the two experiments show that the first adaptive training decomposition strategy of FedRAE-A has significant advantages in optimizing the allocation of the number of local training times and dealing with different client participation ratios.
[0143] Contrastive learning and drift correction
[0144] To explore the impact of contrastive learning loss and dynamic drift correction on the model performance, based on the FedRep algorithm with fixed head and representation training times (regarded as the Basic algorithm), a contrastive learning loss and a drift correction mechanism were introduced to form the FedRAE-D algorithm to evaluate its effect in heterogeneous data scenarios. FedRAE-D regards contrastive learning as a key strategy to reduce distribution differences, and improves the generalization ability of the model by optimizing the contrastive loss between the local model and the global model; at the same time, drift correction stabilizes the model training process by adjusting the model parameters and reducing the parameter fluctuations caused by data heterogeneity during the training process.
[0145] In the experiment, the following two studies were designed to evaluate the effectiveness of this innovation point:
[0146] Effect of Drift Correction Smoothing Coefficient β on Model Performance
[0147] To verify the effect of dynamic drift correction on model performance, the temperature coefficient τ was fixed at 1, and various drift correction smoothing coefficients were set. By comparing the test accuracy performance of the Basic algorithm and the FedRAE-D algorithm under different coefficient settings, the effectiveness of this mechanism was evaluated. The experimental data was sourced from the NIID-1 and NIID-2 scenarios of the CIFAR-10, CIFAR-100, and FashionMNIST datasets. The experimental results are as Figure 5 shown. The results indicate that in all datasets and scenarios, as the drift correction coefficient changes, the test accuracy of FedRAE-D is consistently better than that of FedRep, demonstrating that the stability and robustness of the model are significantly improved after introducing drift correction.
[0148] Effect of Temperature Coefficient τ on Model Performance
[0149] To further analyze the impact of the temperature coefficient τ on the contrastive learning loss, the drift correction smoothing parameter β was fixed at 0.5, and different temperature coefficients were set to evaluate the change in the test accuracy of the model. The experimental data was sourced from the NIID-1 and NIID-2 scenarios of the CIFAR-10, CIFAR-100, and FashionMNIST datasets. The experimental results are as Figure 6 shown. The adjustment of the temperature coefficient τ had a significant impact on the accuracy performance of the model. An appropriate temperature coefficient could optimize the effect of the contrastive learning loss and further improve the stability and convergence speed of the model on heterogeneous data.
[0150] The experimental results show that the FedRAE-D algorithm combining contrastive learning and dynamic drift correction performs better than traditional algorithms in heterogeneous data scenarios. Specifically, contrastive learning effectively improves the generalization ability of the model by reducing the distribution difference between the client and the global model; while drift correction significantly enhances the training stability and accelerates the convergence speed by smoothing the model parameter update process. Combining these two mechanisms, FedRAE-D can further improve the performance of the model in complex distribution scenarios while maintaining a high training efficiency.
[0151] Client Selection Strategy
[0152] 1) Effect of Client Grouping Ratio on Model Performance
[0153] To comprehensively evaluate the impact of the client selection strategy based on the dissimilarity mechanism on the model performance, a set of comparative experiments were designed. The random selection strategy (FedRep) was used as the Basic algorithm, and the performance of the intelligent client selection strategy (FedRAE-C(KL)) was mainly analyzed when the KL divergence was used as the distribution dissimilarity metric. This experiment was carried out under two different data distribution scenarios (NIID-1 and NIID-2). By adjusting the client grouping ratio of the large-dissimilarity group and the small-dissimilarity group (the abscissa is the proportion α of the small-dissimilarity group), and fixing the selection probability of the two groups of clients at 50%, the performance of the intelligent selection strategy was evaluated. The experimental results are shown in Figure 7 below.
[0154] The experimental results show that on the CIFAR-10 dataset, whether in the NIID-1 or NIID-2 data distribution scenario, the intelligent client selection strategy (FedRAE-C(KL)) is significantly better than the random selection strategy, fully demonstrating its robustness in optimizing the model performance.
[0155] On the CIFAR-100 dataset, the experimental results are slightly more complex. In the NIID-1 scenario, regardless of the client grouping ratio, FedRAE-C(KL) can stably outperform the random selection strategy. However, in the NIID-2 scenario, although FedRAE-C(KL) can still significantly improve the model performance in most cases, under extreme conditions (such as when the proportion of the small-dissimilarity group is small), the performance of FedRAE-C(KL) is slightly inferior to the random selection strategy. This indicates that although the intelligent selection strategy is still effective under highly heterogeneous data distributions, it may be affected by the grouping structure under certain highly complex distribution conditions.
[0156] On the FashionMNIST dataset, FedRAE-C(KL) can mostly stably outperform the random selection strategy in both the NIID-1 and NIID-2 scenarios. However, in the NIID-1 scenario, when the grouping ratio of the small-dissimilarity group is as high as 90%, the performance of FedRAE-C(KL) is slightly lower than that of the random selection strategy. This phenomenon may be due to the fact that under certain specific data distribution conditions, there is a certain bias in the evaluation of the client contribution by the KL divergence. However, this effect is limited to extreme ratio settings and does not occur in other ratio settings and dissimilarity metrics.
[0157] The experimental results fully verify the effectiveness and robustness of the intelligent client selection strategy (FedRAE-C(KL)), especially on the CIFAR-10 and FashionMNIST datasets. Although in extreme conditions, the performance of individual scenarios may be slightly lower than random selection in some cases, FedRAE-C(KL) significantly improves the model performance under the vast majority of experimental conditions, demonstrating great potential for optimizing the global model.
[0158] 2) Impact of client grouping sampling probability on model performance
[0159] To further verify the performance of the client selection strategy (FedRAE-C) based on the dissimilarity mechanism under different selection probability settings, an experiment was designed. In the experiment, the grouping ratio of the two groups of clients was fixed at 50%, and the performance of the model in different scenarios was observed by adjusting the probability μ of selecting the small-dissimilarity group. This experiment was conducted under the NIID-1 and NIID-2 distribution scenarios of the CIFAR-10, CIFAR-100, and FashionMNIST datasets, and the client selection strategy based on KL divergence was used as the evaluation object. The experimental results are as Figure 8 shown.
[0160] In the CIFAR-10 dataset, regardless of the client grouping sampling probability, the strategy of the present invention is superior to the random selection strategy.
[0161] In the CIFAR-100 dataset, in the NIID-1 scenario, regardless of the client grouping sampling probability, the strategy of the present invention performs stably, with small fluctuations in model performance, and is overall superior to the random selection strategy. However, in the NIID-2 scenario, although most strategies are still superior to the random selection strategy, in some individual cases (such as when the sampling probability of the small-dissimilarity group clients is low), the model performance is slightly lower than the random selection strategy. This may be related to the complexity of the CIFAR-100 dataset and its distribution characteristics in high heterogeneity scenarios.
[0162] In the FashionMNIST dataset, in the NIID-1 scenario, when the sampling probability of the small-dissimilarity group clients is high (such as μ = 0.9), the performance is slightly lower than the random selection strategy, which may be due to excessive focus on the information of the small-dissimilarity group, thus weakening the balance of the global model. In the NIID-2 scenario, the strategy of the present invention is significantly superior to the random selection strategy, showing stronger robustness and adaptability.
[0163] The experiments of this invention mainly verified the effectiveness of KL divergence as a measure of distribution difference. At the same time, exploratory research was also conducted on other common measures of distribution difference (such as cosine similarity, L1 norm, and L2 norm). These studies included: performance comparison of the FedRAE algorithm based on different measures of distribution difference, the impact of client grouping ratio on model performance, and the analysis of the effect of client grouping sampling probability on model performance.
[0164] 1) Performance comparison of the FedRAE algorithm based on different measures of distribution difference
[0165] Table 4: Accuracy performance of the FedRAE algorithm based on different measures of distribution difference
[0166]
[0167] Table 5: Training efficiency performance of the FedRAE algorithm based on different measures of distribution difference
[0168]
[0169] Table 4 and Table 5 respectively show the accuracy performance and training efficiency performance of the FedRAE algorithm under different measures of distribution difference. Combining with the performance comparison results of the FedRAE(KL) algorithm in the comparative experiment, it is found that the performance of FedRAE(KL) under different datasets and distribution scenarios is not much different from that of the other three measures of distribution difference (FedRAE(COSINE), FedRAE(L1), FedRAE(L2)). However, FedRAE(KL) is slightly better in most cases, which indicates that KL divergence, as a measure of distribution difference, can not only accurately capture the distribution difference between clients, but also more effectively guide the client selection strategy, thus improving the overall performance of federated learning.
[0170] 2) The impact of client grouping ratio on model performance
[0171] Figure 9 、 Figure 10 and Figure 11 respectively show the impact of client selection strategies based on cosine similarity, L1 norm, and L2 norm on model performance under different client grouping ratios. The test accuracies of FedRAE-C and the random selection strategy (Basic) were compared.
[0172] It can be observed from the figure that for the client selection strategy on the CIFAR-10 dataset, FedRAE-C outperforms the random selection strategy (Basic) at all grouping ratios, showing the significant advantages of the intelligent selection strategy. In the NIID-2 scenario of the FashionMNIST dataset, the performance improvement of FedRAE-C is more prominent, and the test accuracy is significantly higher than the random selection strategy. However, in the NIID-2 scenario of the CIFAR-100 dataset, it is found that in very rare cases (such as the grouping ratio of small difference groups α = 0.1), the performance of FedRAE-C is slightly lower than the random selection strategy. This phenomenon may be related to the complexity of the CIFAR-100 dataset itself and its distribution characteristics in high heterogeneity scenarios.
[0173] FedRAE-C's client selection strategy based on different distribution difference metrics (cosine similarity, L1 norm, L2 norm) can effectively improve model performance in most cases. At the same time, the change in client grouping ratio significantly affects the performance of the strategy, which provides a valuable reference for the reasonable selection of distribution difference metrics and client grouping ratio.
[0174] Figure 12 , Figure 13 and Figure 14 The effects of client selection strategies based on cosine similarity, L1 norm, and L2 norm on model performance under different client group sampling probabilities are shown respectively. By comparing the test accuracy of FedRAE-C and the random selection strategy (Basic), we can clearly see the performance differences in different data sets and distribution scenarios.
[0175] In the CIFAR-10 dataset, regardless of the sampling probability μ of the small difference group, FedRAE-C performs better than the random selection strategy, demonstrating the robustness of the intelligent selection strategy. In the CIFAR-100 dataset, FedRAE-C generally performs better than the random selection strategy in the NIID-2 scenario, and only in some cases is it slightly lower than the random selection; in the NIID-1 scenario, FedRAE-C's performance always remains ahead. In the FashionMNIST dataset, FedRAE-C outperforms the random selection strategy in the NIID-2 scenario. However, in the NIID-1 scenario, the strategies based on the L1 and L2 norms occasionally have a test accuracy slightly lower than the random selection strategy when the sampling probability of the small difference group is high (such as μ>0.7). This may be related to the sensitivity of the L1 and L2 norms to client selection under high sampling bias.
[0176] The client selection strategy of FedRAE-C based on different distribution divergence metrics can significantly improve the model performance in most cases, and the change of the client grouping sampling probability has an important impact on the performance of the strategy, which provides a strong reference for the reasonable selection of distribution divergence metrics and sampling probabilities.
[0177] The algorithm of the present invention has achieved significantly better test accuracy than traditional federated learning algorithms in all datasets and distribution scenarios, and has achieved fast convergence within fewer communication rounds. The combination of the adaptive selection mechanism and the intelligent client selection strategy significantly optimizes the training efficiency, reduces the waste of communication rounds and computing resources, and further reduces the training time per round of communication especially on resource-constrained clients. In addition, through the introduction of contrastive learning and drift correction techniques, the training process of the model on heterogeneous data is more stable, the parameter fluctuations are significantly reduced, and the generalization ability is improved at the same time. The research of the present invention provides an innovative solution for the practical application of federated learning in the Internet of Things scenarios with data diversity and resource constraints.
[0178] The preferred embodiments of the present invention disclosed above are only used to help illustrate the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of this specification. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the present invention, so that those skilled in the art in the relevant technical field can well understand and utilize the present invention. The present invention is only limited by the claims and their full scope and equivalents.
Claims
1. An efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things, characterized in that: The following steps are involved: S1: Decompose the model training process of IoT devices into two stages: head training and representation layer training; S2: Align the feature representations of local and global models through contrastive learning mechanism to enhance feature generalization ability; S3: Introduce a drift correction mechanism to dynamically adjust the representation layer gradient to ensure model stability under heterogeneous data distribution; S4: Implement intelligent client selection strategy to prioritize clients with representative data distribution to improve global learning effect; S5: The client trains according to the adaptive strategy and uploads the representation layer parameters for weighted averaging to update the global model; S6: Through multiple rounds of communication and aggregation, FedRAE converges quickly in a non-IID data environment and achieves optimal performance.
2. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 1, characterized in that: The step S1 specifically includes: decomposing the training process of the model into two stages: head training and representation layer training; in the head training stage, freezing the representation layer parameters and only updating the head layer parameters so as to quickly adapt to the specific task requirements of the local data; and in the representation layer training stage, freezing the head layer parameters and only updating the representation layer parameters so as to focus on the extraction of global features; in order to optimize the efficiency and effect of local training, when contacting a client for the first time, the system tries multiple combinations of training times, evaluates the training loss of each combination, and selects the combination with the smallest loss as the optimal training parameter for the client; allowing the model to quickly adapt to local data and also ensuring that unnecessary computing overhead is reduced in subsequent communications.
3. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 1, characterized in that: The step S2 specifically includes: improving the feature representation alignment capability between the local model and the global model through a contrastive learning mechanism, wherein contrastive learning introduces a loss function between the representation layer of the local model and the representation layer of the global model, and enhances the local model's understanding of the global features by minimizing the difference between the feature representations; calculating the contrast loss between the output of the local representation layer and the output of the global representation layer, and integrating this loss into the overall loss function to optimize the local representation layer parameters; and gradually aligning the local features with the global features, thereby improving the feature generalization capability of the global model.
4. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 1, characterized in that: The step S3 specifically includes: introducing a drift correction mechanism to avoid the model parameter drift problem caused by data distribution heterogeneity, updating the local drift variable, which is dynamically updated based on the representation layer gradient, aiming to record and feedback the drift caused by data distribution differences; then integrating the updated drift variable into the gradient of the current representation layer, correcting the gradient update direction, and ensuring the stability and robustness of the model; effectively suppressing the drift phenomenon of the representation layer parameters, ensuring the stable training of the model in a heterogeneous data distribution environment.
5. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 1, characterized in that: The step S4 specifically includes: introducing an intelligent client selection strategy, first prioritizing the selection of clients according to the difference metric between the client and the global data distribution in the initial communication round, to ensure that the most representative data distribution can be quickly learned by the global model; in subsequent communication rounds, the strategy divides the clients into large difference groups and small difference groups, and selects the clients in combination with random selection and data distribution differences; while ensuring training diversity, focusing on training stability.
6. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 1, characterized in that: The step S5 specifically includes: each selected client performs training according to the adaptive strategy and uploads the trained representation layer parameters to the server; the server performs weighted averaging on the uploaded representation layer parameters to update the global representation layer parameters to ensure that the global model adapts to the diverse data distribution.
7. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 3, characterized in that: The contrastive learning specifically includes: Assume that the feature representation of the output of the local model representation layer is F local , the feature representation of the output of the global model representation layer is F global ; First, L2 normalize the representation vector to ensure that the vector modulus is 1; then, the contrast loss is constructed by calculating the similarity between them, and its loss function is defined as: Where N is the batch size, τ is the temperature parameter used to adjust the smoothness of the similarity distribution, and F local,i and are respectively the normalized local and global representation vectors, y i For the constructed label, let sample i form a positive sample pair only with its corresponding global representation vector j, and other sample pairs are regarded as negative samples; In each training batch, the client extracts the output F of the local model representation layer local and the output F of the global model representation layer global , calculate the contrast loss And add it to the total loss function to optimize the local representation layer parameters; the total loss function is defined as: Among them, L ce is the cross entropy loss, and λ is a weight hyperparameter used to balance the contribution of cross entropy loss and contrast loss. Through contrastive learning, the representation layer of the local model can gradually align with the global feature representation, thereby improving the feature generalization ability of the global model.
8. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 4, characterized in that: The drift correction mechanism specifically includes: To address the drift problem caused by data distribution heterogeneity during representation layer training, FedRAE introduces a local drift variable Δ and adjusts the gradient update of the representation layer parameters to achieve drift correction. The drift correction mechanism consists of two steps. The first step is to update the local drift variable. The drift variable is dynamically updated based on the representation layer gradient. The expression is as follows: Among them, β∈[0,1] is the smoothing coefficient; The second step is to correct the representation layer gradient, add the updated drift variable Δ to the gradient of the current representation layer, and correct the gradient update direction: Through drift correction, FedRAE can effectively suppress the drift of representation layer parameters and ensure stable training of the model under heterogeneous data distribution.
9. The efficient and robust federated learning method for realizing dual-end collaborative optimization in the Internet of Things as claimed in claim 5, characterized in that: The client selection strategy specifically includes: Assume that the data distribution of client i is pi and the global data distribution is p g , use the distribution difference metric function D(·||·) to calculate the difference δ between client i and the global distribution i : d i =D(p i ||p g ) (7) Among them, D(·||·) can be a metric function such as KL divergence, L1 norm, L2 norm or cosine similarity; In the initial communication round (t<1 / r), in order to quickly cover the client’s data distribution, we first calculate the difference between the client and the global data distribution according to the difference δ i Sort in descending order and select the first t*|C|*r clients to participate in the training. This ensures that all clients have a chance to participate in the training in the initial stage. At the same time, clients with the largest data distribution differences are given priority, which helps the model learn quickly and adapt to the diversity of data distribution. The client selection formula is: x t ←client diff [t*|C|*r] (8) In the later communication rounds (t≥1 / r), in order to balance the data distribution differences and improve the stability of training, the client selection strategy adopts a group random sampling mechanism; first, according to the data distribution difference δ i The clients are divided into a large difference group and a small difference group based on the descending sorting result of , where the small difference group contains the last α clients with smaller differences, and the rest of the clients are divided into the large difference group; then, random sampling is performed from the two groups in proportion: (|C|*r*(1-μ)) clients are randomly selected from the large difference group, and (|C|*r*μ) clients are randomly selected from the small difference group, where μ represents the proportion of clients extracted from the small difference group; the final selected client set is composed of the union of the two groups of clients.
Citation Information
Cited By
Personalized federal learning method applied to privacy calculation
CN115660107A
Federal learning-based human body activity identification method and system for Internet of Things equipment
CN121167329A
A federated learning based internet of things device human activity recognition method and system
CN121167329B