Self-supervised confrontation defense framework for federated learning based on unsupervised disturbance
By using an unsupervised perturbation self-supervised adversarial defense framework in federated learning, the client generates adversarial samples and updates the model, and the server aggregates model parameters, solving the problem of insufficient adversarial defense capabilities in federated learning and significantly improving the model's robustness and Accuracy.
Patent Information
- Application Number
- CN202410689504.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-10
AI Technical Summary
Federated learning is vulnerable to adversarial attacks during the model inference phase. Existing defense methods are poorly adapted in the field of federated learning and lack effective adversarial defense measures.
Adopting a self-supervised adversarial defense framework based on unsupervised perturbation, the client locally generates adversarial samples for self-supervised adversarial training, and updates the model through the robustness-aware exponential moving average algorithm. The server aggregates client models to improve the adversarial defense of the global model. ability.
It effectively improves the adversarial defense capabilities of the federated learning network, significantly improves the model's robustness and accuracy on adversarial samples, and is suitable for the security requirements of federated learning.
Smart Images

Figure CN118627588A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of federated learning, and in particular to a self-supervised adversarial defense framework for federated learning based on unsupervised perturbations. Background Art
[0002] Federated learning is a distributed machine learning paradigm. Each client can use the data of other clients for joint training to obtain a more optimized model without leaving the local data, thus breaking the data silos. However, similar to traditional machine learning, federated learning is also vulnerable to adversarial attacks. Specifically, in the model inference stage, attackers can use algorithms to add adversarial perturbations to test samples to deceive the global model with a high success rate. Such adversarial perturbations are normally imperceptible to the naked eye, and samples with such perturbations are called adversarial samples. This brings security challenges to federated learning, which already attaches great importance to security.
[0003] In traditional neural networks, researchers have proposed many methods to improve the robustness of neural networks. The most widely used defense strategies can be divided into three categories: (1) data preprocessing, (2) improving model robustness, and (3) malicious detection. Data preprocessing methods reduce or eliminate the impact of adversarial samples by processing the input data of the model. This strategy takes advantage of the instability of the position of adversarial samples in the input space and processes the input images through various image transformation operations such as denoising, JPEG compression, rotation, and scaling to eliminate potential adversarial perturbations. Improving model robustness is one of the common methods for defending against adversarial attacks. Its main purpose is to enhance the ability of machine learning models to resist small perturbations of input samples. Among the methods for improving model robustness, adversarial training is a very effective technique. The core idea of malicious detection is to use some detection mechanisms to determine whether the sample has been maliciously modified to deceive the model, thereby preventing the impact of adversarial samples. Adversarial defense methods for federated learning are relatively rare, and mainstream adversarial training methods cannot be perfectly adapted to the field of federated learning. Therefore, research on adversarial defense for federated learning is very necessary.
[0004] Self-supervised learning is a method of automatically generating labels for model learning using data itself. Zhuang WM et al. introduced self-supervised learning into federated learning and realized representation learning of unlabeled data. However, they did not pay attention to the adversarial defense capabilities of federated networks. Summary of the invention
[0005] In view of the defects of the prior art, the present invention provides a self-supervised adversarial defense training framework for federated learning based on unsupervised perturbations. In the local training stage, the local client uses an unsupervised adversarial sample generation algorithm to generate adversarial samples for adversarial training. After the local training of the client is completed, the local model is uploaded to the server. The server aggregates the local models of each client model to obtain a global model, and then transmits the global model to the local client, effectively improving the adversarial defense capability of the federated learning network.
[0006] In order to achieve the above object, the present invention provides a self-supervised adversarial defense framework for federated learning based on unsupervised perturbations, wherein the self-supervised federated adversarial framework includes a server and multiple clients, wherein the client local model includes an online network and a target network, and includes the following steps:
[0007] (1) The server initializes the model of the global model and sends its model parameters to all the clients; the clients use the model parameters of the global model to update the online network of their local models;
[0008] (2) All of the clients generate unsupervised adversarial samples based on unsupervised perturbations;
[0009] (3) performing self-supervised adversarial training on the client using unsupervised adversarial samples. After the training is completed, all the clients upload the model parameters of their online networks;
[0010] (4) The server aggregates the online networks of all the clients to obtain model parameters of a new global model, and sends the model parameters to all the clients;
[0011] (5) All the clients update the online network of their local models using a robustness-aware exponential moving average algorithm according to the model parameters of the new global model;
[0012] (6) Repeat steps (2) to (5) until the stopping condition is met and the training is completed.
[0013] Furthermore, the step (2) is specifically as follows:
[0014] (2.1) Select the input sample x to generate the adversarial sample k , the input samples t(x) of the client online network and the target network at the initial moment are obtained by random data enhancement. k ) and t′(x k );
[0015] (2.2) t(x k ) and t′(x k ) are respectively input into the client online network and the target network, and their outputs are obtained and the loss function L(t(xk ), t′(x k ));
[0016] (2.3) calculating the gradient of the loss function relative to the client online network input sample by projected gradient descent method, and updating the sample according to the gradient;
[0017]
[0018] Where: t(x k ) n The input sample of the client online network in the nth round; α represents the step length of the attack; L is the mean square error loss function, sign is the sign function, represents the gradient function; B(t(x k ) n , ε) defines the perturbation boundary of the adversarial sample, which means that the perturbation boundary of the adversarial sample space is t(x k ) n is the origin and ε is the perturbation sphere with radius;
[0019] (2.4) Repeat steps (2.2) to (2.3) until the maximum number of iterations is reached. The final sample is the input sample x k The corresponding unsupervised adversarial sample x k adv .
[0020] Furthermore, the self-supervised adversarial training loss function in the training process of step (3) is:
[0021] L UPFAT (t(x k ),t′(x k ),x k adv )=L cl (t(x k ),t′(x k ))+μ(L cl (x k adv ,t′(x k ))+L cl (x k adv ,t(x k )))
[0022] Where: t(x k ) and t′(x k ) are input samples of the client online network and the target network; x k adv is the unsupervised adversarial sample; L cl(·) represents the traditional contrast loss function; μ is a hyperparameter;
[0023] Self-supervised adversarial training is completed by minimizing the self-supervised adversarial training loss function.
[0024] Furthermore, the traditional contrast loss function is:
[0025]
[0026] Where: sim() represents the cosine similarity function; τ represents the temperature parameter; 1 [k≠i] is an indicator function, and when k≠i, the function value of the indicator is 1, otherwise the function value is 0.
[0027] Furthermore, the server aggregates the online networks of all the clients to obtain the model parameters of the new global model, which are specifically:
[0028] The server aggregates the online networks of the clients according to a federated averaging algorithm to obtain a new global network;
[0029]
[0030]
[0031] Where: K is the number of clients, n is the total number of samples, n k is the number of samples of the kth client; is the online network of the kth client.
[0032] Furthermore, the step (5) is specifically as follows:
[0033] (5.1) using the robust loss of the client local model in the previous round to calibrate the robust performance;
[0034]
[0035]
[0036] (5.2) using the difference between the current and previous client local models to measure the degree of divergence;
[0037]
[0038]
[0039] (5.3) The client updates the online network of its local model using the robustness-aware exponential moving average algorithm;
[0040]
[0041]
[0042]
[0043] in: is the online network encoder parameter of the kth client in the rth round, are the parameters of the online network encoder of the kth client in the r-1th round; is the online network predictor parameter of the kth client in the rth round, is the online network predictor parameter of the kth client in the r-1th round; are the global model encoder parameters of the rth round, is the global model predictor parameter for round r; β is a control quantity that relates robustness to the degree of divergence, γ is a hyperparameter that controls the effect of robustness, represents the degree of divergence of the model, λ is a scalar that adjusts the degree of divergence of the model, τ∈[0,1] is a scalar that controls the expectation, L is the mean square error loss function, and sign is the sign function.
[0044] The present invention also provides a self-supervised adversarial defense system for federated learning based on unsupervised perturbations, wherein the self-supervised adversarial defense system comprises a server and a plurality of clients, wherein the client local model comprises an online network and a target network:
[0045] The client comprises:
[0046] The adversarial sample generation module is used to obtain training samples and generate unsupervised adversarial samples based on unsupervised perturbations;
[0047] A model training module, used for performing self-supervised adversarial training on the client using unsupervised adversarial samples;
[0048] A first sending module, used for the client to upload the model parameters of the trained online network;
[0049] A first receiving module, configured to receive the updated model parameters of the global network from the server;
[0050] A first updating module, for the client to update its online network of local models using a robustness-aware exponential moving average algorithm according to the new global model;
[0051] The server comprises:
[0052] A second receiving module, used for receiving model parameters of the online network from a plurality of said clients;
[0053] An aggregation module, used for the server to aggregate the online networks of all the clients to obtain model parameters of a new global model;
[0054] The second sending module is used to send the model parameters of the new global model to all the clients.
[0055] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described above.
[0056] The present invention also provides a computer-readable storage medium having computer-readable instructions stored thereon, and when the computer-readable instructions are executed by a processor, the self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described above is implemented.
[0057] Beneficial effects of the present invention:
[0058] The present invention creates adversarial samples for federated adversarial training based on an adversarial sample generation algorithm with unsupervised perturbations on the local client of federated learning. A robustness-aware exponential moving average algorithm is proposed to update the client network, which takes into account the robustness of individual clients while ensuring the effective aggregation of updates from different clients. It can effectively improve the adversarial defense capability of the federated learning network. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 The figure is an overall framework diagram of a self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The present invention will be further explained below in conjunction with the accompanying drawings and embodiments.
[0061] like Figure 1 As shown, the embodiment of the present invention provides a self-supervised adversarial defense framework for federated learning based on unsupervised perturbations, including the following steps:
[0062] S101, the server initializes a global model and sends it to all the clients; the clients use the global model to update the online network of their local models;
[0063] Initialize the server global model and send it to all clients to update their local models' online network.
[0064] S102, all the clients generate unsupervised adversarial samples based on unsupervised perturbations;
[0065] In the local client, given a client input sample instance x k , this paper adopts multi-step PGD to maximize the transformation image t(x k ) and t′(x k ) feature embedding loss, generating an online network This paper adds unsupervised adversarial perturbation ∈ to the transformed image t(x k ), generate adversarial samples These adversarial examples are generated independently of labels and effectively confuse the model, causing it to incorrectly classify them as different examples. The specific process is as follows:
[0066] (1) Select the input sample x to generate the adversarial sample k , the input samples t(x k ) and t′(x k ).
[0067] (2) t(x k ) and t′(x k ) are input to the client online network and the target network respectively, and their outputs are obtained and the loss function L(t(x k ), t′(x k )).
[0068] (3) calculating the gradient of the loss function relative to the client online network input sample by projected gradient descent method, and updating the sample according to the gradient;
[0069]
[0070] Where: t(x k ) n The input sample of the client online network in the nth round; α represents the step size of the attack; L is the mean square error loss function, sign is the sign function, represents the gradient function; B(t(x k ) n , ε) defines the perturbation boundary of the adversarial sample, which means that the perturbation boundary of the adversarial sample space is t(x k ) n is the origin and ε is the radius of the perturbation sphere.
[0071] (4) Repeat steps (2) to (3) until the maximum number of iterations is reached. The final sample is the input sample x k Corresponding unsupervised adversarial examples
[0072] S103, performing self-supervised adversarial training on the client using unsupervised adversarial samples, and after the training is completed, all the clients upload model parameters of their online networks;
[0073] The client uses unsupervised adversarial samples to perform local self-supervised adversarial training.
[0074] The loss for self-supervised adversarial training is:
[0075] L UPFAT (t(x k ),t′(x k ),x k adv )=L cl (t(x k ),t′(x k ))+μ(L cl (x k adv ,t′(x k ))+L cl (x k adv ,t(x k )))
[0076] Where: t(x k ) and t′(x k ) are the input samples of the client online network and the target network respectively; x k adv is an unsupervised adversarial sample; L cl (·) represents the traditional contrastive loss function; μ is a hyperparameter.
[0077] The traditional contrast loss function formula is as follows:
[0078]
[0079] Among them: sim() represents the cosine similarity function, z i 、z i represents input, τ represents temperature parameter, 1 [k≠i] is an indicator function, and when k≠i, the function value of the indicator is 1, otherwise the function value is 0.
[0080] The self-supervised adversarial training is completed by minimizing the self-supervised adversarial training loss function. The local model is trained and the model parameters of the online network of the local model are uploaded.
[0081] S104, the server aggregates the online networks of all the clients to obtain model parameters of a new global model, and sends the model parameters to all the clients;
[0082] The server aggregates the online networks of the clients according to a federated averaging algorithm (FedAvg) to obtain a new global network.
[0083]
[0084]
[0085] Where: K is the number of clients, n is the total number of samples, n k is the number of samples of the kth client; are the model parameters of the online network of the kth client.
[0086] The server aggregates the model parameters of the global network W g Sent to the client.
[0087] S105, all the clients update the online network of their local models using a robustness-aware exponential moving average algorithm according to the model parameters of the new global model;
[0088] The client performs local model updates. The client uses the Robustness-aware Exponential Moving Average Update (REMA) algorithm to dynamically determine the online network The initial update of this round. Keeping the local knowledge of non-independent and identically distributed data is beneficial to improving performance. This paper uses REMA to fuse local and global robust knowledge. The decay rate of REMA considers both the divergence and robustness of the model. In order to quantify the robustness of the model, the robust loss of the previous round model is used to calibrate the robust performance of the model, which is expressed as follows:
[0089]
[0090]
[0091] in: is the robustness of client k in round r-1, is the robust loss of the client k model in round r-1.
[0092] In order to quantify the degree of divergence of the model, the difference between the model and the previous round of model is used to measure the degree of divergence, which is expressed as follows:
[0093]
[0094]
[0095] in: represents the divergence of the model, λ is a scalar that adjusts the divergence of the model, is the local model of client k in round r, is the global model of the rth round, τ∈[0,1] is a scalar controlling the expectation, set to 0.7.
[0096]
[0097]
[0098]
[0099] in, is the online network encoder of client k in round r, is the online network predictor for client k in round r, is the global model of the rth round, β is the control quantity that relates robustness to the degree of divergence, and γ is the hyperparameter that controls the impact of robustness.
[0100] The REMA module adaptively updates each client's local model based on its robustness and variance information. When the local model is less robust, it benefits from the knowledge of a more robust global model. This adaptive update allows the local model to retain its individual strengths while making full use of the global robustness knowledge, thereby improving the overall robustness.
[0101] S106. Repeat steps (S102) to (S105) until the stop condition is met.
[0102] The present invention uses linear evaluation to verify the performance of the proposed method. Linear evaluation is an evaluation method widely used in self-supervised learning. Its essence is to train a linear classifier on the features encoded by the current encoder, while keeping the parameters of the encoder itself unchanged. This evaluation method is convenient for exploring whether the encoder itself has learned useful information represented by the features, rather than constantly changing or optimizing these features through the training process. The specific approach is to freeze the trained encoder and train a new linear classifier for 100 rounds separately for downstream image classification tasks. White box attacks (FGSM, PGD20, BIM) and black box attack methods (Square Attack, GeoDA, AutoAttack) are used to conduct adversarial attacks on the model, and the adversarial defense performance of the model is measured according to the accuracy under the attack.
[0103] The present invention conducts sufficient experiments on three public image datasets, CIFAR-10, CIFAR-100 and SVHN, to verify the algorithm proposed in the present invention. CIFAR-10 is a dataset containing 60,000 32x32 color images, which are divided into 10 categories, with 6,000 images in each category. CIFAR-100 is an extension of CIFAR-10, containing 100 categories, with 600 images in each category. The SVHN (Street View House Numbers) dataset contains digital images from Google Street View images, with a total of 73,257 training images and 26,032 test images. The following tables 1 to 3 respectively give the accuracy results on CIFAR-10, CIFAR-100 and SVHN.
[0104] Table 1
[0105]
[0106] Table 2
[0107]
[0108] Table 3
[0109]
[0110] From the above experimental results, the method proposed in this paper outperforms other methods in most attack scenarios, not only improving the accuracy of the model on clean data, but also further improving the accuracy of adversarial samples. On CIFAR-10, the accuracy of this method on clean data reached 67.49%, and the robustness was significantly improved under different attacks. On CIFAR-100, the defense under PGD20, FGSM and BIM attacks was improved. On SVHN, the highest accuracy of 88.6% was achieved on clean data, and better robustness was shown under PGD20, FGSM and BIM attacks, respectively.
[0111] Another embodiment of the present invention further provides a self-supervised adversarial defense system for federated learning based on unsupervised perturbations, the self-supervised adversarial defense system comprising a server and multiple clients, wherein the client local model comprises an online network and a target network:
[0112] The client includes:
[0113] The adversarial sample generation module is used to obtain training samples and generate unsupervised adversarial samples based on unsupervised perturbations;
[0114] Model training module, used to perform self-supervised adversarial training on the client using unsupervised adversarial samples;
[0115] The first sending module is used for the client to upload the model parameters of its trained online network;
[0116] A first receiving module, used for receiving the updated model parameters of the global network from the server;
[0117] The first update module is used for the online network where the client updates its local model using a robustness-aware exponential moving average algorithm according to the new global model;
[0118] The server includes:
[0119] A second receiving module is used to receive model parameters of an online network from multiple clients;
[0120] Aggregation module, used for server aggregation of all clients’ online networks to obtain model parameters of a new global model;
[0121] The second sending module is used to send the model parameters of the new global model to all clients.
[0122] Another embodiment of the present invention also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described above.
[0123] Another embodiment of the present invention further provides a computer-readable storage medium having computer-readable instructions stored thereon. When the computer-readable instructions are executed by a processor, the self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described above is implemented.
[0124] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A self-supervised adversarial defense framework for federated learning based on unsupervised perturbations, characterized by: The self-supervised federated adversarial framework includes a server and multiple clients, and the client local model includes an online network and a target network, including the following steps: (1) The server initializes the model of the global model and sends its model parameters to all the clients; the clients use the model parameters of the global model to update the online network of their local models; (2) All of the clients generate unsupervised adversarial samples based on unsupervised perturbations; (3) performing self-supervised adversarial training on the client using unsupervised adversarial samples. After the training is completed, all the clients upload the model parameters of their online networks; (4) The server aggregates the online networks of all the clients to obtain model parameters of a new global model, and sends the model parameters to all the clients; (5) All the clients update the online network of their local models using a robustness-aware exponential moving average algorithm according to the model parameters of the new global model; (6) Repeat steps (2) to (5) until the stopping condition is met and the training is completed.
2. The self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to claim 1, characterized in that: The step (2) is specifically: (2.1) Select the input sample x to generate the adversarial sample k , the input samples t(x) of the client online network and the target network at the initial moment are obtained by random data enhancement. k ) and t′(x k ); (2.2) t(xk) and t′(x k ) are respectively input into the client online network and the target network, and their outputs are obtained and the loss function L(t(x k ), t′(x k )); (2.3) calculating the gradient of the loss function relative to the client online network input sample by projected gradient descent method, and updating the sample according to the gradient; Where: t(x k ) n The input sample of the client online network in the nth round; α represents the step length of the attack; L is the mean square error loss function, sign is the sign function, represents the gradient function; B(t(x k ) n , ε) defines the perturbation boundary of the adversarial sample, which means that the perturbation boundary of the adversarial sample space is t(x k ) n is the origin and ε is the perturbation sphere with radius; (2.4) Repeat steps (2.2) to (2.3) until the maximum number of iterations is reached. The final sample is the input sample x k The corresponding unsupervised adversarial sample x k adv .
3. The self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to claim 2, characterized in that: The self-supervised adversarial training loss function in the training process of step (3) is: L UPFAT (t(x k ),t′(x k ),x k adv )=L cl (t(x k ),t′(x k ))+μ(L cl (x k adv ,t′(x k ))+L cl (x k adv ,t(x k ))) Where: t(x k ) and t′(x k ) are input samples of the client online network and the target network; x k adv is the unsupervised adversarial sample; L cl (·) represents the traditional contrast loss function; μ is a hyperparameter; Self-supervised adversarial training is completed by minimizing the self-supervised adversarial training loss function.
4. The self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to claim 3, characterized in that: The traditional contrast loss function is: Where: sim() represents the cosine similarity function; τ represents the temperature parameter; 1 [k≠i] is an indicator function, and when [k≠i], the function value of the indicator is 1, otherwise the function value is 0.
5. The self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to claim 1, characterized in that: The server aggregates the online networks of all the clients to obtain the model parameters of the new global model: The server aggregates the online networks of the clients according to a federated averaging algorithm to obtain a new global network; Where: K is the number of clients, n is the total number of samples, n k is the number of samples of the kth client; is the online network of the kth client.
6. The self-supervised adversarial defense framework for federated learning based on unsupervised perturbations according to claim 1, characterized in that: The step (5) is specifically as follows: (5.1) using the robust loss of the client local model in the previous round to calibrate the robust performance; (5.2) using the difference between the current and previous client local models to measure the degree of divergence; (5.3) The client updates the online network of its local model using the robustness-aware exponential moving average algorithm; in: is the online network encoder parameter of the kth client in the rth round, are the parameters of the online network encoder of the kth client in the r-1th round; is the online network predictor parameter of the kth client in the rth round, is the online network predictor parameter of the kth client in the r-1th round; are the global model encoder parameters of the rth round, is the global model predictor parameter for round r; β is a control quantity that relates robustness to the degree of divergence, γ is a hyperparameter that controls the effect of robustness, represents the degree of divergence of the model, λ is a scalar that adjusts the degree of divergence of the model, τ∈[0,1] is a scalar that controls the expectation, L is the mean square error loss function, and sign is the sign function.
7. A self-supervised adversarial defense system for federated learning based on unsupervised perturbations, characterized in that: The self-supervised adversarial defense system includes a server and multiple clients, and the client local model includes an online network and a target network; The client comprises: The adversarial sample generation module is used to obtain training samples and generate unsupervised adversarial samples based on unsupervised perturbations; A model training module, used for performing self-supervised adversarial training on the client using unsupervised adversarial samples; A first sending module, used for the client to upload the model parameters of the trained online network; A first receiving module, configured to receive the updated model parameters of the global network from the server; A first updating module, for the client to update its online network of local models using a robustness-aware exponential moving average algorithm according to the new global model; The server comprises: The second receiving module is used to receive model parameters of the online network from a plurality of clients: An aggregation module, used for the server to aggregate the online networks of all the clients to obtain model parameters of a new global model; The second sending module is used to send the model parameters of the new global model to all the clients.
8. A computer device comprising a memory and a processor, characterized in that: The memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement a self-supervised adversarial defense framework for federated learning based on unsupervised perturbations as described in any one of claims 1 to 6.
Citation Information
Cited By
False data injection attack detection method and device based on federal learning and comparative learning, and storage medium
CN119030798A
