Heterogeneous data-oriented adversarial sample robustness federated learning method and system
By embedding backdoor triggers and bijective mapping relationships into federated learning, and combining supervised contrastive learning, the problems of insufficient model representation of heterogeneous data and adversarial attacks in federated learning are solved, thereby improving the robustness and stability of the model.
Patent Information
- Application Number
- CN202410827543.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-06-25
AI Technical Summary
In federated learning scenarios, the heterogeneous data from IoT devices leads to insufficient model representation capabilities, making it difficult to construct an effective mapping between samples and labels, and also exposes the model to the threat of adversarial sample attacks. Existing methods are not effective in defending against white-box attacks.
We adopt an adversarial example robust federated learning method for heterogeneous data. By embedding backdoor triggers and bijective mapping relationships in the client and combining supervised contrastive learning, we generate backdoor samples and introduce supervised contrastive learning during training to enhance the robustness of the model.
It improves the model's representation ability on heterogeneous data, enhances its defense against adversarial attacks, reduces the attack success rate, and maintains the stability of the main task performance.
Smart Images

Figure CN118863012B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network information security technology, and in particular to a robust federated learning method and system for adversarial examples of heterogeneous data. Background Technology
[0002] With the widespread application of artificial intelligence and big data technologies in the Internet of Things (IoT) environment, the importance of data is becoming increasingly prominent. As a fundamental strategic resource for nations, more and more countries are recognizing the importance of data security and user privacy, and have introduced relevant laws, policies, and guidelines to enhance data security protection and prevent data breaches. In traditional IoT environments, IoT devices collect vast amounts of information through sensors. However, to ensure data security, companies holding private data cannot share confidential information, and machine learning models trained on publicly available datasets cannot achieve satisfactory results in specific tasks and scenarios. Federated Learning (FL) offers a new solution to this problem, attracting widespread attention from industry and academia.
[0003] To improve computational efficiency and model performance without sharing private data, Google's federated learning has gradually become an effective paradigm for large-scale distributed training. Federated learning typically involves a central server and multiple local clients, with the server managing the clients' collaborative training of machine learning models. In this invention's scenario, the local clients consist of IoT devices. In each round of federated learning training, the server first distributes the global model to the clients. The clients use their local data to train and optimize the global model, obtaining local model updates, which are then uploaded to the server. The server aggregates the updates from multiple clients (usually a weighted average) to obtain the global model for that round. Through multiple iterations, federated learning enables clients to jointly train a high-performance global model without sharing private data, and has been widely applied in various privacy-sensitive scenarios.
[0004] Existing research demonstrates that neural networks face the threat of adversarial attacks, where even small adversarial perturbations can significantly alter the model's output. Based on the attacker's understanding of the neural network model, attacks can be categorized as black-box or white-box attacks. In black-box attacks, attackers lack access to the target model's structure and algorithm, posing a significant challenge. In white-box attacks, attackers know the complete training process and model parameters, allowing them to create more targeted adversarial examples and achieve better attack results. Currently, adversarial attacks are widely used in fields such as autonomous driving, anomaly detection, and facial recognition. For example, attackers may insert perturbations into malware, causing detection systems to identify it as "benign," thereby bypassing security systems and achieving system intrusion.
[0005] The distributed and interactive nature of federated learning increases the probability of model leakage, making white-box attacks easier to implement. Attackers can intentionally construct adversarial examples to cause the model to make incorrect judgments. Furthermore, existing adversarial attack detection and defense methods mainly target centralized learning scenarios, while research on federated learning is still in the exploratory stage. Zhu et al. found that backdoors embedded in the model can suppress the function of adversarial examples in most cases. Inspired by this, this invention proposes using backdoor triggers to defend against the influence of adversarial examples on the client side of federated learning on the model's prediction results.
[0006] Compared to traditional centralized learning, federated learning can improve model training efficiency and fully utilize the computing resources of each client. However, client data in IoT scenarios is often not independently and identically distributed (No-IID), exhibiting significant heterogeneity and imbalance, which makes model convergence difficult and affects the stability of existing methods. The root cause of this phenomenon lies in the insufficient representational capacity of the model, making it unable to construct an effective mapping between samples and labels. Contrastive learning (CL) offers a solution to this problem due to its flexibility and good performance. Summary of the Invention
[0007] The purpose of this invention is to address the challenges faced in current federated learning scenarios. It proposes a Federated Learning Method Against Sample Robustness for Heterogeneous Data (FLSR) and system, which maps sample source class labels to specific target class labels to enhance the model's robustness against adversarial attacks. Furthermore, it introduces supervised contrastive learning to improve the model's representation ability on heterogeneous data, thereby enabling the feature representation to have stronger generalization ability.
[0008] To achieve the above objectives, the present invention adopts the following technical solution:
[0009] A robust federated learning method for adversarial examples on heterogeneous data, comprising:
[0010] Server-side design and distribution of backdoor triggers to clients, and bijection mapping relationships;
[0011] The client embeds backdoor triggers in the local dataset and maps their labels to generate backdoor samples;
[0012] The server distributes the global model to the client, and the client trains the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process.
[0013] After the model converges, the client uploads the parameters to the server for global aggregation. After multiple iterations, a global model that can resist federated adversarial sample attacks is obtained.
[0014] According to the adversarial sample robust federated learning method for heterogeneous data of the present invention, the bijective mapping relationship is to correspond one-to-one with the source class label and the target class label; after the model predicts the result of the backdoor sample, the inverse mapping is performed, and the correct source class label corresponding to the target class label is obtained through the bijective mapping relationship.
[0015] According to the adversarial example robust federated learning method for heterogeneous data of the present invention, the backdoor trigger further satisfies the following objective:
[0016]
[0017]
[0018]
[0019]
[0020]
[0021] Formula (1) represents the model's performance on clean samples; P represents the confidence level, and M represents the model's prediction function. This represents a clean sample with an embedded backdoor trigger. The label represents the original label of a clean sample, mapped using a bijective mapping relation; x i Indicates a clean sample, y i D represents the label corresponding to a clean sample. test It's the test set, ACC clean It is the clean sample prediction accuracy threshold for the embedded backdoor trigger;
[0022] Formula (2) represents the model's performance on adversarial examples; This represents an adversarial example containing an embedded backdoor trigger. ACC represents the label obtained by mapping the original label of the adversarial sample through a bijective mapping relation. ae It is the threshold for predicting adversarial examples with embedded backdoor triggers;
[0023] In formula (3), m is the trigger mask matrix and trigger is the trigger; in formulas (4) and (5), Bijection represents the bijective mapping relationship.
[0024] According to the adversarial sample robust federated learning method for heterogeneous data of the present invention, the supervised contrastive learning further includes: for a certain batch D of backdoor samples t Samples within Will have the same label sample set Treated as a positive sample, except Samples outside the set are considered negative samples. Define the contrastive loss function L supcon as follows:
[0025]
[0026] Where sim() represents the correlation measure of the samples, and γ is the temperature coefficient.
[0027] According to the adversarial example robust federated learning method for heterogeneous data of the present invention, a classification loss function L is further defined. Classifier as follows:
[0028] L Classifier =E(M(x) t ), y t (7)
[0029] Where E represents the cross-entropy loss, y t M(x) represents the true label of a clean backdoor sample. t ) represents the predicted label value of a clean backdoor sample.
[0030] According to the adversarial example robust federated learning method for heterogeneous data of the present invention, the overall loss function of the client model is further as follows:
[0031] L=λ1L supcon +λ2L classifier (8)
[0032] Where λ1 and λ2 are dynamic hyperparameters, representing the loss weights for the enhancement and downstream fine-tuning stages, respectively. L is used in the enhancement stage. Supcon The encoding and projection layers of the training model are trained using L280 ... Classifier The encoding layer and classification head of the training model.
[0033] Furthermore, this invention proposes a robust federated learning system for adversarial examples of heterogeneous data, comprising: a distribution module, a backdoor sample module, a training module, and an aggregation module, wherein:
[0034] The distribution module is used for server-side design and distribution of backdoor triggers and bijection mappings to clients;
[0035] The backdoor sample module is used by the client to embed backdoor triggers in the local dataset and map their labels to generate backdoor samples.
[0036] The training module is used for the server to distribute the global model to the client, and the client to train the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process.
[0037] The aggregation module is used after the model converges. The client uploads parameters to the server for global aggregation. After multiple rounds of iteration, a global model that can resist federated adversarial sample attacks is obtained.
[0038] Compared with the prior art, the present invention has the following advantages:
[0039] 1. This invention presents a robust federated learning method for adversarial examples on heterogeneous data. It proposes embedding backdoor triggers in samples to control model predictions and resist adversarial example perturbations. Specifically, this invention utilizes backdoor triggers to mitigate the impact of adversarial examples on the client-side of federated learning on model predictions. Unlike traditional backdoors that map all labels to a single target label, this invention designs a bijective backdoor. During the local training phase, triggers are embedded in samples, and the source class labels of the samples are mapped one by one to specific target class labels. After multiple iterations, the model will output specific results on samples with triggers. The correct sample labels can then be obtained by reversing the mapping of these results.
[0040] 2. To further enhance defense effectiveness and stability, this invention designs a backdoor sample representation enhancement method based on supervised contrastive learning, generating more discriminative feature representations. Given that contrastive learning can capture the similarities and differences between samples and extract features important for classification, thus enhancing data representation, this invention introduces supervised contrastive learning during trigger training to improve the feature space, thereby better addressing the challenge of heterogeneous data. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating the adversarial sample robust federated learning method for heterogeneous data according to an embodiment of the present invention.
[0043] Figure 2This is a framework diagram of the adversarial sample robust federated learning method for heterogeneous data according to an embodiment of the present invention;
[0044] Figure 3 This is an example diagram of sample prediction for an embedded trigger according to an embodiment of the present invention;
[0045] Figure 4 This is the t-sne dimensionality reduction representation of adversarial examples in the MNIST-IID scenario according to an embodiment of the present invention;
[0046] Figure 5 This is the t-sne dimensionality reduction representation of adversarial examples in the MNIST-No-IID scenario according to an embodiment of the present invention;
[0047] Figure 6 This is the t-sne dimensionality reduction representation of adversarial examples in the CIFAR-10-IID scenario according to an embodiment of the present invention;
[0048] Figure 7 This is the t-sne dimensionality reduction representation of adversarial examples in the CIFAR-10-No-IID scenario of this invention. Detailed Implementation
[0049] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0050] like Figure 1 and Figure 2 As shown, the adversarial sample robust federated learning method for heterogeneous data in this embodiment includes the following steps:
[0051] Step S101: Design the server-side backdoor trigger and distribute it to the client, along with the bijection mapping relationship.
[0052] Step S102: The client embeds a backdoor trigger in the local dataset and maps its label to generate a backdoor sample.
[0053] Step S103: The server distributes the global model to the client. The client trains the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process to enhance the embedded representation.
[0054] Step S104: After the model converges, the client uploads the parameters to the server for global aggregation. After multiple iterations, a global model that can resist federated adversarial sample attacks is obtained.
[0055] Algorithm 1 summarizes the above process.
[0056]
[0057] For ease of explanation, Table 1 provides the symbols used in this application and their corresponding meanings.
[0058] Table 1. Symbols and their meanings
[0059]
[0060] This research focuses on client-side adversarial example defense methods in federated learning scenarios. During the model prediction phase, attackers introduce subtle perturbations into the samples, affecting the model's prediction results and causing misjudgments. The distributed nature of federated learning increases the risk of model leakage. To demonstrate the defensive performance of this invention, it uses this as an upper bound for the attacker, thereby maximizing the effectiveness of the attack: it assumes that the attacker can obtain information such as the victim's client model structure, network parameters, and federated learning algorithm, and generates arbitrary adversarial examples in a targetless white-box attack manner.
[0061] The client embeds triggers into samples to improve robustness against adversarial examples. The key idea is that, through training, the backdoor triggers control the model's behavior on specific patterns, thereby resisting adversarial attacks. The backdoor triggers should meet the following objectives: ensure performance of clean samples on the main task; reduce the success rate of adversarial attacks; formally represented as follows:
[0062]
[0063]
[0064]
[0065]
[0066]
[0067] Formula (1) represents the model's performance on clean samples; P represents the confidence level, and M represents the model's prediction function. This represents a clean sample with an embedded backdoor trigger. The label represents the original label of a clean sample, mapped using a bijective mapping relation; x i Indicates a clean sample, y i D represents the label corresponding to a clean sample. test This is the test set. For clean samples in the test set, the accuracy after embedding the trigger should be greater than ACC. clean This means that the trigger has a relatively small impact on the model's performance on the main task.
[0068] Formula (2) represents the model's performance on adversarial examples; This represents an adversarial example that incorporates subtle perturbations into an embedded backdoor trigger. This represents the label obtained by mapping the original label of the adversarial example through a bijective mapping relation. For adversarial examples with embedded backdoor triggers, its accuracy should be greater than ACC. ae This means that the success rate of adversarial attacks is low.
[0069] In formula (3), m is the trigger mask matrix, and trigger is the trigger. In formulas (4) and (5), Bijection represents the bijective mapping relationship. Formula (5) indicates that even with adversarial perturbations, the original label of the adversarial sample can still be obtained after mapping.
[0070] Algorithm 2 summarizes the above process.
[0071]
[0072] Traditional backdoor triggers map all source class tags to the same target class tag, making them unsuitable for the scenario described in this invention. Therefore, as Figure 3 As shown, a bijective relation is designed to map source class labels to target class labels one-to-one. After the model predicts the result of the backdoor sample, an inverse mapping is performed, and the correct source class label corresponding to the target class label is obtained through the bijective mapping relation.
[0073] For example, in Figure 3 In the upper half, traditional adversarial examples add perturbations to the original samples, causing the model to misclassify, mispredicting label 0 as label 6, label 1 as label 7, and label 2 as label 5. Figure 3 In the lower half, to resist adversarial example perturbations, the server first predefines a one-to-one mapping table (i.e., a bijective mapping relationship). For example, source label 0 maps to target label 9, source label 1 maps to target label 0, and source label 2 maps to target label 1. Then, a sample with source label 0, after local training, can be predicted by the model as a sample with label 9; a sample with source label 1, after local training, can be predicted by the model as a sample with label 0; and a sample with source label 2, after local training, can be predicted by the model as a sample with label 1. Even if an attacker adds perturbations to the source labels, due to the constraints of the designed loss function, it will still be mapped to the pre-specified label after local training, thus resisting adversarial example perturbations. Finally, it is only necessary to reverse the mapping relationship to restore the target label to the correct source label.
[0074] To enhance the stability of the model in real-world scenarios and further improve its defense performance, a sample representation enhancement method based on client-side supervised contrastive learning is designed. The model is trained on clean backdoor samples to improve its generalization ability, as shown in Algorithm 3.
[0075]
[0076] The key idea behind contrastive learning is to shorten the distance between similar samples in the feature representation space while increasing the distance between dissimilar samples, thereby enhancing the feature representation. Unlike self-supervised contrastive learning, for a certain batch D of backdoor samples... t Samples within. Will have the same label sample set Treated as a positive sample, except Samples outside the set are considered negative samples. Define the contrastive loss function L supcon as follows:
[0077]
[0078] Where sim() represents the correlation measure of the samples, which is calculated by dot product in this embodiment; γ is the temperature coefficient, used to increase the penalty for difficult negative samples.
[0079] like Figure 2 As shown in (b), the client model includes an encoding layer, a projection layer, and a classification head. The training process is divided into a representation augmentation stage and a downstream fine-tuning stage. In the representation augmentation stage, the model trains the encoding layer and projection layer based on the aforementioned positive and negative sample sets, and in L... supcon Under this influence, the model tends to output consistent representations for similar samples. Based on this, the model can learn hidden knowledge in the labels, regularize the model's encoding layer, generate a more effective embedding space, improve its defense against client-side adversarial examples, and achieve stable performance even in No-IID scenarios.
[0080] In the downstream fine-tuning stage, the projection layer is discarded, and a classification head is added for supervised learning image classification training. The local client model is trained on clean backdoor samples, and the classification loss function L is defined. Classifier as follows:
[0081] L Classifier =E(M(x) t ),y t (7)
[0082] Where E represents the cross-entropy loss, y t M(x) represents the true label of a clean backdoor sample. t) represents the predicted label value of a clean backdoor sample.
[0083] The contrastive loss and classification loss are optimized together, and the overall loss function is as follows:
[0084] L=λ1L Supcon +λ2L Classifier (8)
[0085] Where λ1 and λ2 are dynamic hyperparameters, representing the loss weights during the enhancement and downstream fine-tuning stages, respectively.
[0086] Corresponding to the above method, this embodiment also proposes a robust federated learning system for adversarial examples of heterogeneous data, comprising: a distribution module, a backdoor sample module, a training module, and an aggregation module, wherein:
[0087] The distribution module is used for server-side design and distribution of backdoor triggers and bijection mappings to clients.
[0088] The backdoor sample module is used by the client to embed backdoor triggers in the local dataset and map their labels to generate backdoor samples.
[0089] The training module is used by the server to distribute the global model to the client, and the client trains the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process.
[0090] The aggregation module is used after the model converges. The client uploads parameters to the server for global aggregation. After multiple rounds of iteration, a global model that can resist federated adversarial sample attacks is obtained.
[0091] To verify the effectiveness of this solution, the following explanation is based on experimental data:
[0092] This invention implements FLSR based on PyTorch and conducts extensive experiments on different data distributions of the MNIST and CIFAR10 datasets. Adversarial examples are generated using four mainstream adversarial attack methods and compared with baseline defense methods to evaluate their effectiveness. All experiments are performed on NVIDIA RTX 3090 GPUs.
[0093] ① Experimental setup
[0094] The experiments in this invention use two benchmark datasets for image classification: MNIST and CIFAR-10.
[0095] MNIST is a dataset consisting of 70,000 grayscale handwritten digit images, each 28×28 pixels, with 60,000 images in the training set and 10,000 images in the test set. MNIST contains grayscale images of 10 categories, from 0 to 9.
[0096] CIFAR-10 is a dataset consisting of 60,000 three-channel color images of size 32×32, with 50,000 images in the training set and 10,000 images in the test set. CIFAR-10 contains images of 10 categories, including "airplane", "ship", and "dog", with 6,000 samples in each category.
[0097] The classification models on both datasets employed a CNN network with two convolutional layers, with a total of 10 clients, a batch size of 50, a learning rate of 0.005, and 300 communication rounds. Local training was performed once on MNIST and four times on CIFAR-10. During the representation augmentation phase, λ1 = 1, λ2 = 0; during the task fine-tuning phase, λ1 = 0, λ2 = 1.
[0098] This invention has conducted extensive experiments on data distributions of independent and identically distributed (IID) and non-independent and identically distributed (No-IID). In the case of non-independent and identically distributed data, the Dirichlet method was used, and a scenario with a large degree of data dispersion of alpha = 0.1 was set to verify the effectiveness of the method of this invention in general scenarios.
[0099] ② Attack methods and baseline settings
[0100] To demonstrate the effectiveness of the FLSR defense method, this invention assumes that the attacker has complete knowledge of the client model structure, network parameters, and other relevant information, and is able to execute white-box attacks during the prediction phase. Specifically, this invention employs the following four adversarial example attack methods, configured as untargeted attacks, with attack parameters set as shown in Table 2.
[0101] Table 2 Attack Parameter Settings
[0102]
[0103] (1) The Fast Gradient Sign Method (FGSM) utilizes the idea of backpropagation in the neural network training process to increase the perturbation in the gradient direction through one iteration, so as to maximize the influence on the prediction results.
[0104] (2) The Basic Iterative Method (BIM) is an improved version of FGSM. It shortens the step size through multiple iterations to find the optimal perturbation.
[0105] (3) Project Gradient Descent (PGD) is also an extension of FGSM. Unlike BIM, PGD restricts the generated adversarial examples to a specific neighborhood of the example through projection, thereby limiting the size of the perturbation.
[0106] (4) C&W attack is an optimization-based adversarial sample attack method that introduces three distance metrics and narrows the gap between adversarial samples and clean samples by designing a loss function.
[0107] The following three methods were selected as the baseline experiments for this invention:
[0108] (1) No-Defense: No defense methods are added. This is used to test the model’s performance on the main task and its effectiveness against sample attacks.
[0109] (2) Adversarial Training (ADT): The client actively constructs adversarial examples, adds perturbations to clean samples, and trains the model after supplementing the dataset, which enhances the robustness of the model to a certain extent.
[0110] (3) Image compression JPEC: It uses discrete cosine transform to suppress high-frequency information and selectively blurs the image input, thereby eliminating disturbances.
[0111] The performance metrics for the primary task (ACC) and attack success rate (ASR) are used to evaluate the performance of each defense method when facing adversarial examples. The primary task performance refers to the model's performance on the original image classification task, i.e. Where N represents the total number of test samples, n correct This represents the number of correctly classified samples; if the prediction result of the adversarial sample with added perturbation differs from that of the clean sample, it is considered a successful attack, i.e., the attack success rate. Where M(x) represents the model's prediction result on sample x.
[0112] ③Performance Evaluation
[0113] For four distribution scenarios across two datasets, the aforementioned attack method was used to perturb the test set samples, generating four adversarial examples. FLSR demonstrated good performance in resisting adversarial example attacks, as shown in Tables 3 and 4. In the IID scenario, FLSR reduced the attack success rate by an average of 68.05% on the dataset; in the No-IID scenario, FLSR reduced the attack success rate by an average of 61.14% on the dataset. Furthermore, in terms of main task performance, due to the additional information introduced to the model by contrastive learning, FLSR improved performance by 0.02% and 2.24% in the IID and No-IID scenarios, respectively.
[0114] Table 3 Performance of different defense methods in IID scenarios
[0115]
[0116] Table 4 Performance of different defense methods in No-IID scenarios
[0117]
[0118] (1) Performance comparison in IID scenarios
[0119] In IID scenarios, ADT demonstrates a certain level of defensive capability, reducing attack success rates on MNIST and CIFAR-10 by 73.34% and 23.36% respectively, with an average success rate reduction of 48.35%. JPEC attack success rates only decreased by 20.41% and 14.04% respectively, and on MNIST, it even increased the success rate against FGSM and BIM attacks. In comparison, FLSR attack success rates decreased by 89.55% and 46.55% respectively, with an average attack success rate reduction of 68.05%, achieving a good defensive effect.
[0120] The defensive methods showed similar trends in main task performance. Adversarial training resulted in less accuracy loss on MNIST (only 0.12%), while on CIFAR-10 it resulted in an accuracy loss of 4.21%, indicating that adversarial targets affected the model's learning ability to some extent, and this was more pronounced on relatively difficult tasks. FLSR maintained good main task performance on both datasets, improving accuracy by 0.12% on MNIST and only incurring a 0.09% accuracy loss on CIFAR-10. This is because the labels of the embedded trigger samples have a one-to-one correspondence with the original labels. The model learns this bijective relationship rather than the adversarial target, thus reducing complexity and accuracy loss. Simultaneously, contrastive learning introduced class representation information into the model.
[0121] (2) Performance comparison in No-IID scenarios
[0122] As shown in Table 4, adversarial training is ineffective against adversarial example attacks on CIFAR-10, with the attack success rate decreasing by only 9.18%. However, it achieves better defense on MNIST, reducing the attack success rate by 61.62%. In terms of defensive performance, this method lags significantly behind FLSR, with an average attack success rate 25.74% higher. FLSR also outperforms image compression methods, which, while showing superior performance against CW attacks, are almost ineffective against FGSM and BIM attacks. Furthermore, in terms of primary task performance, adversarial training decreases accuracy by an average of 3.96%, while FLSR improves accuracy by 2.24%.
[0123] This shows that adversarial training performs better on MNIST because the variance of the MNIST data distribution is relatively small, allowing the model to better balance the main task and the adversarial target. In contrast, the variance of the CIFAR-10 data distribution is large, making model learning quite complex. In the No-IID scenario, the performance of adversarial training further decreases as the dataset variance increases, validating the above conclusion. However, adversarial training also suffers from high training costs and computational overhead. Image compression methods eliminate perturbations by reducing image quality and blurring high-frequency information, showing some effectiveness in specific attack scenarios. However, as attack intensity increases, this method becomes ineffective. FLSR, based on a bi-shooting backdoor, correlates the model's prediction results with the original labels using embedded trigger samples, improving the model's robustness to various perturbations even in the No-IID scenario. Furthermore, representation enhancement methods based on supervised contrastive learning induce the model to capture the consistency and differences between images, generating trigger representations with clearer classification boundaries. Traditional deep learning methods, on the other hand, only extract abstract features from images and cannot significantly distinguish between samples of different classes.
[0124] ④ Visual Analysis
[0125] To further analyze the defensive effectiveness of the proposed method against adversarial examples, we explored defenses against no defense (None), defense based on bijective triggers (BAEDFL), and defenses enhanced by trigger representations based on supervised contrastive learning (FLSR). Test samples were input into the model. To better compare the results, t-SNE dimensionality reduction was used to reduce the sample representation to a two-dimensional space while preserving its global and local structures, such as... Figures 4 to 7 As shown.
[0126] Observations revealed that without any defensive strategies added to the model, various adversarial examples would intertwine in the embedding space, making it difficult for the model to distinguish them. Even minor perturbations would cause the model to make incorrect predictions. In contrast, the FLSR method proposed in this invention can clearly distinguish the representations of different classes in the IID scenario, maintaining a certain distance between each class. However, in the No-IID scenario with a high degree of data dispersion, the abstract features extracted by the model are insufficient to completely separate the representations. Under the guidance of the supervised contrastive learning task objective, FLSR iteratively optimizes the encoder and learns features that are more conducive to classification on the same training data, thereby better resisting adversarial example attacks.
[0127] Further analysis reveals that the CIFAR-10 dataset, consisting entirely of three-channel color images, contains more information, has larger image sizes, and is composed of real-world objects, resulting in significant noise and making it inherently more challenging to learn. Therefore, FLSR still has room for improvement on CIFAR-10.
[0128] In summary, this invention addresses the problem of adversarial examples on the client side of federated learning affecting model prediction results through small perturbations. It proposes a defense scheme based on a bi-shot backdoor trigger (FLSR) to control the model's behavior on samples with triggers, enhancing the model's robustness against adversarial attacks. Furthermore, to address the issue of heterogeneous client data in federated learning scenarios, making it difficult to extract effective feature representations, a trigger representation enhancement method based on supervised contrastive learning is proposed. This method maps similar samples to similar embedding spaces while increasing the distance between dissimilar samples, giving the feature representation stronger generalization ability and improving the model's defense performance and stability.
[0129] Unless otherwise specifically stated, the relative steps, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0130] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0131] The units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations are not considered to be beyond the scope of this invention.
[0132] Those skilled in the art will understand that all or part of the steps in the above methods can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. Optionally, all or part of the steps in the above embodiments can also be implemented using one or more integrated circuits. Accordingly, each module / unit in the above embodiments can be implemented in hardware or as a software functional module. This invention is not limited to any particular combination of hardware and software.
[0133] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for federated learning of adversarial sample robustness for heterogeneous data, comprising: Include: The server designs and distributes a backdoor trigger and a bijective mapping relationship to the client, wherein the bijective mapping relationship is one-to-one correspondence between a source class label and a target class label; when the model predicts the result of the backdoor sample, inverse mapping is performed to obtain the correct source class label corresponding to the target class label through the bijective mapping relationship; the backdoor trigger satisfies the following targets: (1); (2); (3); (4); (5); formula (1) represents the performance of the model on clean samples; P represents a confidence degree, represents a prediction function of the model, represents a clean sample embedded with a backdoor trigger, represents a label obtained by mapping a clean sample original label through a bijective mapping relationship; represents a clean sample, represents a label corresponding to a clean sample, is a test set, is a clean sample prediction accuracy threshold value embedded with a backdoor trigger; formula (2) represents the performance of the model on an adversarial sample; represents an adversarial sample embedded with a backdoor trigger, represents a label obtained by mapping an adversarial sample original label through a bijective mapping relationship, is an adversarial sample prediction accuracy threshold value embedded with a backdoor trigger; in formula (3) is a trigger mask matrix, is a trigger; in formulas (4) and (5) represents a bijective mapping relationship; The client embeds backdoor triggers in the local dataset and maps their labels to generate backdoor samples; The server distributes the global model to the client, and the client trains the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process. After the model converges, the client uploads the parameters to the server for global aggregation. After multiple iterations, a global model that can resist federated adversarial sample attacks is obtained.
2. The adversarial example robust federated learning method for heterogeneous data according to claim 1, characterized in that, Supervised contrastive learning includes: for a certain batch of backdoor samples Samples within Will have the same label sample set Treated as a positive sample, except Samples outside the set are considered negative samples. Define the contrastive loss function as follows: (6), among which, A measure of the relevance of a sample. This is the temperature coefficient.
3. The adversarial example robust federated learning method for heterogeneous data according to claim 2, characterized in that, Define the classification loss function as follows: (7), among which, Represents cross-entropy loss, This indicates the true label of a clean backdoor sample. This represents the predicted label value for a clean backdoor sample.
4. The adversarial example robust federated learning method for heterogeneous data according to claim 3, characterized in that, The overall loss function for the client-side model is as follows: (8), of which and These are dynamic hyperparameters, representing the loss weights for the enhancement and downstream fine-tuning stages, respectively. They are used during the enhancement stage. The encoding and projection layers of the trained model are used in the downstream fine-tuning stage. The encoding layer and classification head of the training model.
5. A robust federated learning system for adversarial examples of heterogeneous data, used to implement the method as described in any one of claims 1-4, characterized in that, It includes: a distribution module, a backdoor sample module, a training module, and an aggregation module, among which: The distribution module is used for server-side design and distribution of backdoor triggers and bijection mappings to clients; The backdoor sample module is used by the client to embed backdoor triggers in the local dataset and map their labels to generate backdoor samples. The training module is used for the server to distribute the global model to the client, and the client to train the local model on clean local samples and backdoor samples with embedded triggers. Supervised contrastive learning is introduced during the training process. The aggregation module is used after the model converges. The client uploads parameters to the server for global aggregation. After multiple rounds of iteration, a global model that can resist federated adversarial sample attacks is obtained.
