Attack defense image classification method based on angle similarity detection

By using angle similarity detection methods in federated learning to identify and eliminate malicious convolution kernels, the problem of difficulty in identifying Byzantine attackers in the prior art is solved, and higher defense performance and image classification accuracy in federated learning are achieved.

CN119068248AActive Publication Date: 2024-12-03BEIJING INSTITUTE OF TECHNOLOGY ZHENGZHOU RESEARCH INSTITUTE +1

Patent Information

Application Number
CN202411148748.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2024-12-03
Estimated Expiration
2044-08-21

AI Technical Summary

Technical Problem

In federated learning, existing distance and angle-based defense schemes are difficult to effectively identify and eliminate Byzantine attackers, resulting in increased model training time and reduced accuracy, especially in high-dimensional spaces, which is difficult to distinguish between malicious and normal clients.

Method used

Using an angle similarity detection method, by calculating the angle cosine value between the convolution kernel gradients, identifying and eliminating the malicious convolution kernel, converging the normal convolution kernel gradients to form a global model gradient, mitigating the impact of Byzantine attacks, and Data diversity is preserved without affecting model accuracy.

Benefits of technology

It improves the defense performance and image classification accuracy of federated learning under Byzantine attacks, improves the robustness and generalization of the model, and significantly improves the image classification accuracy under Byzantine attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068248A_ABST
    Figure CN119068248A_ABST
Patent Text Reader

Abstract

The invention discloses an attack defense image classification method based on angle similarity detection, and the method comprises the steps: carrying out the robustness convergence training for federal learning under Byzantine attack, determining the angle between convolution kernel gradients as the measurement standard of attack detection through analyzing the difference between an attacker and a normal client, and carrying out the detection of the attack defense image. According to the image classification method based on the federated learning, malicious convolution kernels are eliminated on the basis of a measurement standard so as to reduce the influence of attackers on the model, and the defensive performance of the federated learning under various Byzantine attacks is improved through robustness convergence training, so that the accuracy of image classification based on the federated learning is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of machine learning security technology, and in particular relates to an attack defense image classification method based on angle similarity detection. Background Art

[0002] In recent years, machine learning has been widely used in data analysis to provide data-driven analysis, decision-making, and prediction. The application areas of machine learning are diverse, including speech recognition, image recognition, and computer vision. Federated learning is a new form of machine learning, which is to collaboratively train a global model on multiple devices while still keeping the data on the user's local device to protect privacy, which greatly reduces the risk of sensitive information exposure. In addition, federated learning can also achieve multi-device parallel computing through a distributed architecture, speeding up the training of machine learning models.

[0003] The parameter server (PS) architecture is a typical structure adopted in federated learning. In the PS architecture, the central parameter server is responsible for maintaining global model parameters, while multiple clients perform local computations on their respective local datasets. These local models are synchronized with the central server regularly, allowing the models to be updated collaboratively without centrally sharing the original data. The PS architecture is critical for scalable and efficient federated learning. However, in federated learning based on the PS structure, the system may be attacked. These attacks are intentional actions against the system with the aim of maliciously disrupting or manipulating the training process of federated learning. Attackers attempt to obtain unauthorized information or affect the training results of the model.

[0004] Byzantine attacks are a typical form of attack in federated learning. Byzantine attacks refer to the behavior of a part of the clients in the system deliberately providing false information, thereby disrupting the normal operation of the system. In federated learning, Byzantine attacks may manifest as clients sending incorrect local model updates or model parameters, thereby affecting the training process of the global model. The main impact of Byzantine attacks on federated learning is to increase the training time of the model or reduce the inference accuracy of the model. Since clients may transmit malicious updates, the learning process of the global model will be disturbed, resulting in a decrease in the quality of the final model. Therefore, it is crucial to protect the federated learning system from Byzantine attacks.

[0005] At present, many solutions have been proposed to alleviate the Byzantine attack problem suffered by federated learning systems during training, which can be divided into two categories: distance-based defense solutions and angle-based defense solutions. Distance-based defense solutions use distance as a metric to identify and eliminate malicious clients. This type of method determines malicious attackers by evaluating the distance between different clients, and regards the client with the largest distance as an attacker, and aggregates the remaining clients. However, this type of method requires prior knowledge of the number of malicious attackers, which is a relatively strict requirement and difficult to implement. Angle-based defense solutions regard the angle between the client gradient and the global model gradient as the difference between clients, and use these angle values ​​to evaluate the similarity between different client gradients, and regard clients with larger angle values ​​as malicious attackers. However, since the angles between all vectors in high-dimensional space are approximately 90 degrees, this type of method is difficult to distinguish between malicious attackers and normal clients when the model parameters are large when facing Byzantine attacks, resulting in low model accuracy. Summary of the invention

[0006] In view of this, the present invention proposes an attack defense image classification method based on angle similarity detection, which can achieve high-precision federated learning image classification when facing Byzantine attacks.

[0007] The present invention proposes an attack defense image classification method based on angle similarity detection, which comprises the following steps:

[0008] Step 1: construct a training sample data set. The server uses a small data set with normal data annotation as a local training sample data set, which is recorded as the first local training set. The client uses the training sample data set as a local training sample data set, which is recorded as the second local training set.

[0009] Step 2: Establish an image classification model based on federated learning, deploy the image classification model as a global model and a local model to the server, and deploy the image classification model as a local model to the client; initialize the global model;

[0010] Step 3: The server uses the first local training set to train its deployed local model to obtain the server model, and the client uses the second local training set to train its deployed local model to obtain the client model; calculate the angle between each convolution kernel gradient in the client model and the convolution kernel gradient at the corresponding position in the server, and use the convolution kernel with a cosine value greater than zero as the normal convolution kernel; converge the normal convolution kernel gradient of all clients at the same position in the server model with the server convolution kernel gradient to form a new global model gradient, and use the global model gradient to update the global model, server model and client model; if the number of training rounds does not reach the preset value, execute step 3, otherwise the current global model is the trained image classification model based on federated learning;

[0011] Step 4: In actual use, the image to be classified is input into the trained federated learning-based image classification model to complete the classification.

[0012] Furthermore, the method of initializing the global model is: initializing the shape and number of convolution kernels in the global model to be the same as those of the local model on the server side, and setting all elements in the global convolution kernel gradient to 0.

[0013] Furthermore, the cosine value of the angle is calculated as follows: firstly, two convolution kernels are arranged into two one-dimensional vectors, and then the inner product of the two one-dimensional vectors is divided by the respective modulus values ​​of the two one-dimensional vectors to obtain the cosine values ​​of the two one-dimensional vectors.

[0014] Furthermore, the method of converging the normal convolution kernel gradients of all clients at the same position in the server model with the server convolution kernel gradient to form a new global model gradient is as follows: the normal convolution kernel gradients of all clients at the same position in the server model are divided by their own convolution kernel gradient modulus, and then accumulated with the server convolution kernel gradient; the accumulated result is divided by the number of convolution kernels involved in the accumulation and then multiplied by the modulus of the server convolution kernel gradient to obtain the global model convolution kernel gradient at this position; the global model convolution kernel gradients at each position are combined into the global model gradient to complete the convergence of the global model gradient.

[0015] Furthermore, the method of using the global model gradient to update the global model is: multiplying the global gradient by the learning rate, and subtracting this value from the global model to obtain an updated global model, wherein the learning rate is a hyperparameter of federated learning.

[0016] Beneficial effects:

[0017] 1. The present invention performs robust convergence training on federated learning under Byzantine attacks. By analyzing the differences between attackers and normal clients, it is determined to use the angle between convolution kernel gradients as a metric for attack detection, and malicious convolution kernels are eliminated based on the metric to reduce the impact of attackers on the model. Through robust convergence training, the defense performance of federated learning under various Byzantine attacks is improved, thereby improving the accuracy of image classification based on federated learning.

[0018] 2. By eliminating malicious convolution kernels instead of malicious clients, the present invention can retain the diversity of data without affecting the accuracy of the model, thereby improving the generalization of the global model and further improving the accuracy of image classification based on federated learning. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A training structure diagram of an attack defense image classification method based on angle similarity detection provided by the present invention.

[0020] Figure 2 A schematic diagram of the gradient convergence process of an attack defense image classification method based on angle similarity detection provided by the present invention. DETAILED DESCRIPTION

[0021] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0022] The invention provides an attack defense image classification method based on angle similarity detection, the core idea of ​​which is: deploy a small data set with normal data standards in the server, the server and the client use their own local data sets for training respectively, and converge the global model in the server; firstly, calculate the angle between the gradient of each convolution kernel of each client and the gradient of the corresponding server convolution kernel in parallel, then remove the malicious client convolution kernels with angles greater than 90 degrees, and finally converge the remaining convolution kernels as the convolution kernels in the global model. By removing malicious convolution kernels, the impact of Byzantine attacks on the global model is weakened, and the reasoning accuracy of the global model is improved.

[0023] The present invention provides an attack defense image classification method based on angle similarity detection, which mainly includes the following steps:

[0024] Step 1: Construct a training sample data set. The samples in the training sample data set are pictures. The size of the pictures is the same as the size of the pictures that need to be classified during model inference, and the number of categories is the same. The server side uses a small data set with normal data annotation as the local training sample data set, recorded as the first local training set. The client side uses the training sample data set as the local training sample data set, recorded as the second local training set.

[0025] Among them, the training sample data set used during training should ensure that each image is different to enrich the diversity of the data set and ensure the generalization ability of the model.

[0026] Step 2: Establish an image classification model based on federated learning, deploy the image classification model as a global model and a local model to the server, and deploy the image classification model as a local model to the client; initialize the shape and number of convolution kernels in the global model to be the same as those in the local model on the server, and set all elements in the global convolution kernel gradient to 0.

[0027] Step 3: Use the first local training set and the second local training set to complete the training of the federated learning-based image classification model. The training structure is as follows: Figure 1 As shown, the following steps are included:

[0028] Step 3.1: The server uses the first local training set to train its deployed local model to obtain a server model, and the client uses the second local training set to train its deployed local model to obtain a client model.

[0029] Step 3.2: For each client, calculate the angle between each convolution kernel gradient in its client model and the convolution kernel gradient at the corresponding position in the server in a parallel manner, and record this angle as the target angle.

[0030] The essence of federated learning training is the gradient descent process in convex optimization. The angle-based attacker elimination method is more robust than the distance-based scheme. This is because the correctness of the gradient descent direction is more important than the correctness of the gradient magnitude. For example, if the descent direction is incorrect during the gradient descent process, the convex optimization may enter the local minimum, or the optimization process may diverge. However, if the gradient magnitude is relatively large, the convex optimization can achieve the ideal global optimum by increasing the number of iterations.

[0031] Therefore, in order to enhance the robustness of the defense method in federated learning, the present invention uses angles, more precisely cosine similarity, as a metric to distinguish and eliminate attackers. However, when using angles, there is an obvious problem, that is, each vector is almost vertical in high-dimensional space, and the difference between different vectors is almost zero. In commonly used models, the parameters are all on the order of thousands, which means that the dimension of the vector transformed by the model gradient is also on the order of thousands. Therefore, it is necessary to move these high-dimensional vectors to low-dimensional space as much as possible without obviously destroying the model structure, and use angles as indicators in this low-dimensional space to identify and eliminate attackers.

[0032] However, directly mapping the entire model gradient to a lower dimension, no matter what mapping method is used, is likely to lose the high-dimensional information of the model gradient. Therefore, the present invention divides it into multiple low-dimensional gradients for parallel calculation, taking into account that the dimension of the model gradient increases with the increase of the model size, while the size of the convolution kernel remains fixed, usually in 5×5 and 3×3 dimensions, and the convolution kernel, as the basic unit of the model, retains the structural information of the model to the maximum extent. The present invention identifies and eliminates malicious attack convolution kernels by calculating the angles of multiple convolution kernels in parallel, and uses the convolution kernel angle as a metric, which can improve the robustness of the defense method in federated learning, thereby improving the reasoning accuracy of the model. In addition, by eliminating malicious convolution kernels instead of malicious models, the diversity of training data is retained, the generalization performance of the model is improved, and the reasoning accuracy of the model is further improved.

[0033] Step 3.3, traverse all clients, and determine the convolution kernel whose cosine value of the target angle in each client is greater than zero as a normal convolution kernel, otherwise it is determined as a malicious convolution kernel.

[0034] When calculating the angle between the client convolution kernel and the server convolution kernel, the present invention first arranges the two convolution kernels into two one-dimensional vectors, and then divides the inner product of the two one-dimensional vectors by the respective modulus values ​​of the two one-dimensional vectors to obtain the cosine value of the two one-dimensional vectors. This cosine value is used as the metric for each client convolution kernel. Each client contains M convolution kernels, and M target angles are obtained by calculation, that is, there are M cosine values.

[0035] The training process of federated learning is essentially a convex optimization gradient descent process. Since the training data sets of each client and server are the same type of image data, the descent direction of the local convolution kernel gradient trained by each client using the local data set should be consistent with the descent direction of the local convolution kernel gradient trained by the central server in the general direction. If the descent direction of the client convolution kernel gradient is greater than 90 degrees from the descent direction of the server convolution kernel gradient, it means that the descent direction of the client convolution kernel gradient has a component opposite to the descent direction of the server convolution kernel gradient. This means that the client convolution kernel gradient is a malicious convolution kernel and needs to be removed. Therefore, the client convolution kernel with an angle greater than 90 degrees is a malicious convolution kernel, that is, the cosine value is less than 0 for a malicious convolution kernel, and the cosine value is greater than 0 for a normal convolution kernel.

[0036] Step 3.4: Divide the normal convolution kernel gradient of all clients at the same position in the server model by their own convolution kernel gradient modulus, and then add them to the server convolution kernel gradient; divide the accumulated result by the number of convolution kernels involved in the accumulation and multiply it by the modulus of the server convolution kernel gradient to obtain the global model convolution kernel gradient at this position; the global model convolution kernel gradient of each position is placed and combined according to its position to form the global model gradient (for example, each convolution kernel in the AlexNet model is placed from the first convolution kernel of the first layer to the last convolution kernel of the last layer according to its position mark, and all the convolution kernels of all layers after placement are the entire AlexNet model), completing the convergence of the global model gradient. The gradient convergence process is as follows: Figure 2 shown.

[0037] The essence of federated learning training is the gradient descent process in convex optimization. The angle-based attacker elimination method is more robust than the distance-based scheme. This is because the correctness of the gradient descent direction is more important than the correctness of the gradient magnitude. For example, if the descent direction is incorrect during the gradient descent process, the convex optimization may enter a local minimum, or the optimization process may diverge. However, if the gradient magnitude is relatively large, the convex optimization can reach the ideal global optimum by increasing the number of iterations.

[0038] In order to reduce the impact of the size of the convolution kernel gradient on the number of training rounds, we unify all the convolution kernel gradient sizes to the server convolution kernel gradient size. In order to integrate the characteristics of each data set while ensuring that the client's data privacy is not leaked, we need to combine the client convolution kernel gradients with different data set characteristics. Considering that the size of each convolution kernel gradient has been unified, it is only necessary to integrate its perspective below. Considering that the training data set in each client is as important as the training data set in the server, the present invention will integrate each normal convolution kernel gradient by taking the average value to obtain the global convolution kernel gradient.

[0039] The convergence process in the prior art is usually integrated only by taking the average value, without considering the impact of the gradient size on the model training, resulting in an increase in the number of model training rounds. In comparison, when facing the Byzantine attack that modifies the gradient size, the present invention requires fewer training rounds when the same inference accuracy is required.

[0040] Step 3.5: Use the global model gradient to update the global model, then send the global model to the client, and update all the local models of the client and server to the new global model.

[0041] The way to update the global model using the global model gradient is: multiply the global gradient by the learning rate, and subtract this value from the global model to obtain the updated global model. The learning rate is one of the hyperparameters of federated learning and can be set based on experience.

[0042] Step 3.6: If the number of training rounds does not reach the preset number of training rounds, execute step 3.1; otherwise, the global model is used as the federated learning-based image classification model to complete the training.

[0043] Step 4: In actual use, the image to be classified is input into the trained federated learning-based image classification model to complete the classification.

[0044] Finally, we evaluated the performance of the present invention through experiments. We used CIFAR-10 and Fashion-MNIST datasets, and tested the image classification accuracy using three models, AlexNet, ResNet-50 and GoogLeNet, under IID and non-IID data distributions. In order to evaluate the defense performance of the present invention against different types of Byzantine attacks, we tested gradient tampering attacks and data tampering attacks. We used a PS architecture, including 1 central server and 10 clients, of which 20% of the clients were designated as malicious attackers. The number of training times exceeded 500 epochs. The batch size was set to 32 and the learning rate was set to 0.01. The aggregation of model updates occurred after each round of training on the client and server. The experimental results show that compared with the existing angle-based and distance-based solutions, the present invention shows advantages in algorithm versatility and fine-grained exclusion of attackers, and improves the inference accuracy by 67% and 88% respectively, greatly improving the accuracy of the federated learning image classification method under Byzantine attacks.

[0045] In summary, the above are only preferred embodiments of the present invention, and the drawings used are only used to demonstrate the effectiveness of the embodiments of the present invention, and are not used to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. An attack defense image classification method based on angle similarity detection, It is characterized in that The following steps are involved: Step 1: Construct a training sample data set. The server uses a small data set with normal data annotation as the local training sample data set, which is recorded as the first local training set. The client uses the training sample data set as the local training sample data set, which is recorded as the second local training set; Step 2: Establish a federated learning-based image classification model, deploy the image classification model as a global model and a local model to the server, and deploy the image classification model as a local model to the client; Initialize the global model; Step 3: The server uses the first local training set to train its deployed local model to obtain a server model, and the client uses the second local training set to train its deployed local model to obtain a client model; Calculate the angle between each convolution kernel gradient in the client model and the convolution kernel gradient at the corresponding position in the server, and take the convolution kernel whose cosine value of the angle is greater than zero as a normal convolution kernel; The normal convolution kernel gradients of all clients at the same position as the server model are converged with the server convolution kernel gradient to form a new global model gradient, and the global model gradient is used to update the global model, server model and client model; if the number of training rounds does not reach the preset value, execute step 3, otherwise the current global model is the trained image classification model based on federated learning; Step 4: In actual use, the image to be classified is input into the trained federated learning-based image classification model to complete the classification.

2. The attack and defense image classification method according to claim 1, It is characterized in that The method of initializing the global model is: initializing the shape and number of convolution kernels in the global model to be the same as those of the local model on the server side, and setting all elements in the global convolution kernel gradient to 0.

3. The attack and defense image classification method according to claim 1, It is characterized in that The cosine value of the angle is calculated as follows: firstly, two convolution kernels are arranged into two one-dimensional vectors, and then the inner product of the two one-dimensional vectors is divided by the respective modulus values ​​of the two one-dimensional vectors to obtain the cosine values ​​of the two one-dimensional vectors.

4. The attack and defense image classification method according to claim 1, It is characterized in that The method of converging the normal convolution kernel gradients of all clients at the same position in the server model with the server convolution kernel gradient to form a new global model gradient is as follows: the normal convolution kernel gradients of all clients at the same position in the server model are divided by their own convolution kernel gradient modulus, and then accumulated with the server convolution kernel gradient; the accumulated result is divided by the number of convolution kernels involved in the accumulation and then multiplied by the modulus of the server convolution kernel gradient to obtain the global model convolution kernel gradient at this position, and the global model convolution kernel gradients at each position are combined into a global model gradient to complete the convergence of the global model gradient.

5. The attack defense image classification method according to claim 1, It is characterized in that The method of using the global model gradient to update the global model is: multiplying the global gradient by the learning rate, and subtracting this value from the global model to obtain an updated global model, wherein the learning rate is a hyperparameter of federated learning.

Citation Information

Patent Citations

  • Federal learning image classification method capable of defending Byzantine attack

    CN112966741A

  • Federal learning image classification method capable of defending Byzantine attack

    CN117218444A

  • Image classification model structure for resisting confrontation sample attack and training method and system

    CN117765319A

  • Revealing byzantine attackers through smart re-clustering in federated learning

    US20240121248A1

Cited By

  • Federal learning-based image classification method in backdoor attack scene

    CN119851035A