Abnormal edge device determination method and device, storage medium and electronic equipment
By using global training data sets and gradient descent algorithms to identify abnormal edge devices in federated learning, the problem of difficult detection of data attacks in federated learning is solved, the accuracy and security of the model are ensured, and the efficiency and accuracy of attack detection are improved. .
Patent Information
- Application Number
- CN202411216501.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-26
AI Technical Summary
The prior art is difficult to accurately detect and identify local edge devices under data attacks in federated learning, resulting in inaccuracy and security issues in model training.
In the initial stage of distributed training, the cloud server receives part of the training data sent by multiple edge devices, forms a global training data set, calculates global model parameters, and uses gradient descent algorithm to determine the abnormal local training data, thereby identifying and eliminating the attack. edge devices ensure the accuracy and security of model training.
It realizes accurate identification and elimination of local devices that are attacked by data, improves the accuracy and security of model training, and protects the privacy of edge devices, and improves the efficiency and accuracy of attack detection.
Smart Images

Figure CN119026119A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computers, and more specifically, to a method and apparatus for determining an abnormal edge device, a storage medium, and an electronic device. Background Art
[0002] With the in-depth development of big data and artificial intelligence technology, artificial intelligence has made continuous breakthroughs in image recognition, natural language processing, speech recognition and other fields. While using distributed training to implement model training reduces complexity and improves model performance, it also puts forward higher requirements for data privacy protection and security. For example, as an emerging distributed machine learning technology, federated learning allows data to be retained locally and only uploads training model parameters to the cloud, thereby achieving the unity of model training and data privacy protection. However, in federated learning, in addition to normal edge devices, there may also be edge devices that implement Byzantine attacks by modifying model parameters. At present, the Byzantine attack detection method based on machine learning realizes Byzantine attack detection by identifying abnormal behaviors that occur during training or by analyzing the attacker's ability to destroy the model. However, this method relies on a complete training set, and in federated learning, the data is retained locally, which makes this method unsuitable for attack detection in federated learning. Summary of the invention
[0003] The embodiments of the present application provide a method and apparatus for determining an abnormal edge device, a storage medium, and an electronic device, so as to at least solve the problem in the related art that a local device that is attacked by data cannot be accurately determined.
[0004] According to an embodiment of the present application, a method for determining an abnormal edge device is provided, which is applied to a cloud server, wherein the cloud server is connected to multiple edge devices, and the global model of the cloud server and multiple local models of the multiple edge devices are all models trained based on a distributed machine learning algorithm. The method includes: receiving N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1; using the global training data set and the global loss function, calculating the first model parameter of the global model; sending the first model parameter to the N edge devices respectively, wherein the edge device is used to calculate the gradient of the local model in the process of training with the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model; based on the N gradients and the first model parameters received from the N edge devices, determining the abnormal local training data in the N groups of the local training data, and determining the abnormal edge device based on the abnormal local training data.
[0005] In an exemplary embodiment, the global training data set and the global loss function are used to calculate the first model parameters of the global model, including: defining the global loss function, wherein the global loss function includes initial model parameters and features of data in the global training data set; using the global training data set and the initial model parameters, performing a gradient descent operation on the global model to minimize the loss value of the global loss function to obtain the first model parameters of the global model.
[0006] In an exemplary embodiment, defining the global loss function includes:
[0007] Among them, the Used to represent the loss value, the X j =(x j ,y j )∈R d ×R is used to represent the data features of the data in the global training data set and the classification target of the global model, θ is used to represent the initial model parameters, S is used to represent the global training data set, and j is used to represent the data in the global training data set.
[0008] In an exemplary embodiment, based on the N gradients and the first model parameters received from the N edge devices, abnormal local training data in the N groups of local training data is determined, and abnormal edge devices are determined based on the abnormal local training data, including: when the N gradients sent by the N edge devices are received, the following operations are performed for the local model of each edge device to obtain N current model parameters of the N local models: using the gradient and the first model parameters, the current model parameters of the local model are calculated using the gradient descent algorithm; for the local model of each edge device, the following operations are performed to determine the N groups of abnormal edge devices: calculating the Euclidean distance between the current model parameters and the first model parameters; when the Euclidean distance is less than or equal to a preset threshold, , determining the current model parameter as an abnormal model parameter, wherein the preset threshold is a natural number greater than 0; determining the local training data corresponding to the abnormal model parameter as the abnormal layout training data to determine the abnormal edge device, wherein the abnormal local training data includes data that is subject to a preset attack; wherein calculating the Euclidean distance between the current model parameter and the first model parameter includes: respectively converting a plurality of parameters included in the current model parameter and a plurality of parameters included in the first model parameter into vector representations to obtain a plurality of first eigenvectors and a plurality of second eigenvectors; respectively calculating the squares of the differences between a plurality of the first eigenvectors and a plurality of the second eigenvectors at corresponding positions to obtain a plurality of squared differences; calculating the sum of a plurality of the squared differences, and determining the square root of the sum as the Euclidean distance.
[0009] In an exemplary embodiment, after determining abnormal local training data in N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determining abnormal edge devices based on the abnormal local training data, the method further includes: removing the abnormal edge devices from the N edge devices to obtain M edge devices, wherein M is a natural number less than N; and combining the M edge devices to obtain an edge device set.
[0010] In an exemplary embodiment, after combining M edge devices to obtain an edge device set, the method further includes: obtaining a local training data set sent by the edge device set; training the global model using the local training data set until the loss value of the global loss function is less than a preset loss value, ending the training, and obtaining a target global model; and sending a first target model parameter of the target global model to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the first target model parameter.
[0011] In an exemplary embodiment, after combining M edge devices to obtain an edge device set, the method further includes: performing an average operation on the M gradients corresponding to the edge device set to obtain a gradient average; using the gradient average to update the model parameters of the global model using a gradient descent algorithm to obtain a second target model parameter; sending the second target model parameter to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the second target model parameter.
[0012] According to another embodiment of the present application, a device for determining an abnormal edge device is provided, which is applied to a cloud server, wherein the cloud server is connected to multiple edge devices, and the global model of the cloud server and multiple local models of the multiple edge devices are models trained based on a distributed machine learning algorithm. The device includes: a first receiving module, which is used to receive N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1; a first calculation module, which is used to calculate a first model parameter of the global model using the global training data set and a global loss function; a first sending module, which is used to send the first model parameter to the N edge devices respectively, wherein the edge device is used to calculate the gradient of the local model in the process of training with the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model; a first determination module, which is used to determine abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determine the abnormal edge device based on the abnormal local training data.
[0013] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0015] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0016] Through this application, since the cloud server obtains part of the training data sent by multiple edge devices in the initial stage of distributed training of local models and global models, it forms a global training data set, and first calculates the first model parameter using the global training data set. After sending the first model parameter to the local model, the gradient of the local model is obtained, and the abnormal local training data in the N groups of local training data are determined through N gradients and the first model parameters, thereby determining the local edge device that is attacked by the data. The accuracy and security of model training are ensured. It not only protects the privacy of edge devices, but also improves the efficiency and accuracy of attack detection. Therefore, the problem that the local device that is attacked by data cannot be accurately determined in the related art can be solved, and the effect of accurately determining the local device that is attacked by data can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a hardware structure block diagram of a server device of a method for determining an abnormal edge device in an embodiment of the present application;
[0018] Figure 2 is a flow chart of a method for determining an abnormal edge device according to an embodiment of the present application;
[0019] Figure 3 is a schematic diagram of a federated learning method based on attack identification according to an embodiment of the present application;
[0020] Figure 4 is a flow chart of a federated learning method based on attack identification according to an embodiment of the present application;
[0021] Figure 5 It is a structural block diagram of a device for determining an abnormal edge device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0024] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a method for determining an abnormal edge device in an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0025] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for determining abnormal edge devices in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0026] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0027] In this embodiment, a method for determining an abnormal edge device is provided, which is applied to a cloud server, wherein the cloud server is connected to multiple edge devices, and the global model of the cloud server and multiple local models of the multiple edge devices are models trained based on a distributed machine learning algorithm. Figure 2 is a flow chart of a method for determining an abnormal edge device according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:
[0028] Step S202, receiving N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1;
[0029] Step S204, using the global training data set and the global loss function, calculating the first model parameter of the global model;
[0030] Step S206: Send the first model parameters to the N edge devices respectively, wherein the edge devices are used to calculate the gradient of the local model during the training process using the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model;
[0031] Step S208: determining abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determining abnormal edge devices based on the abnormal local training data.
[0032] Optionally, N local models of N edge devices and the global model of the cloud server constitute a distributed machine learning model, where distributed machine learning refers to algorithms and systems that use multiple computing nodes (also known as edge devices) for machine learning or deep learning, aiming to improve performance, protect privacy, and be scalable to larger training data and larger models. Distributed machine learning includes but is not limited to federated machine learning, which allows each edge device to perform local training and send the obtained local model to the cloud server for model aggregation. Generally, distributed machine learning uses deep neural networks as machine learning models, which have achieved unprecedented success in many applications, such as model classification and pattern recognition.
[0033] Optionally, this embodiment receives N groups of local training data sent by N edge devices to obtain a global training data set. For example, each edge device uniformly and randomly collects part of the training data and sends the training data to the cloud server at the initial moment. It is assumed that there is no attack in the entire cloud server edge device network at the initial moment. After the cloud server collects the training data sent by all edge devices, it integrates the data to form a global training data set at the initial moment of the cloud server.
[0034] Optionally, in this embodiment, the first model parameter calculated by the cloud server using the global loss function is the prior parameter. When the edge device sends a gradient each time, the cloud server uses the gradient descent method to calculate the current moment parameters of each local model, and calculates the Euclidean distance between the prior parameter and the current parameter of the local model, and determines whether the local model has been attacked by setting a threshold. If attacked, it is removed from the network, and the average gradient is calculated in the remaining edge devices, and then the model training parameters are updated and sent to all local models.
[0035] Optionally, the abnormal local training data in this embodiment includes, but is not limited to, data that is subject to a Byzantine attack. A Byzantine attack is a network attack technique that aims to consume the resources of a target system by sending a large number of requests to it, thereby preventing it from operating normally. This attack usually exploits vulnerabilities or weaknesses in the target system, causing system crashes or service interruptions. Byzantine attacks can be carried out in a variety of ways, including DDoS (distributed denial of service) attacks, SYN flood attacks, U DP flood attacks, etc. These attack methods are all aimed at exhausting the resources of the target system by sending a large number of invalid requests to it, making it unable to provide services normally. When the edge terminal is attacked by Byzantine, the results of the local model learning using the local training set will be unreliable. When this local result is sent to the cloud server, the cloud server aggregates the insecure local results, which directly affects the global prediction results of the cloud server.
[0036] Through the above steps, since the cloud server obtains part of the training data sent by multiple edge devices in the initial stage of distributed training of local models and global models to form a global training data set, the first model parameter is first calculated using the global training data set. After sending the first model parameter to the local model, the gradient of the local model is obtained, and the abnormal local training data in the N groups of local training data are determined through N gradients and the first model parameters, thereby determining the local edge device that is attacked by the data. The accuracy and security of model training are ensured. It not only protects the privacy of edge devices, but also improves the efficiency and accuracy of attack detection. Therefore, the problem that the local device that is attacked by the data cannot be accurately determined in the related technology can be solved, and the effect of accurately determining the local device that is attacked by the data can be achieved.
[0037] In an exemplary embodiment, the global training data set and the global loss function are used to calculate the first model parameters of the global model, including: defining the global loss function, wherein the global loss function includes the initial model parameters and the features of the data in the global training data set; using the global training data set and the initial model parameters, performing a gradient descent operation on the global model to minimize the loss value of the global loss function, thereby obtaining the first model parameters of the global model.
[0038] Optionally, the global loss function in this embodiment includes but is not limited to:
[0039] Among them, the above Used to represent the loss value, the above X j =(x j ,y j )∈R d ×R is used to represent the data features of the data in the above global training data set and the classification target of the above global model, the above θ is used to represent the above initial model parameters, the above S is used to represent the above global training data set, and the above j is used to represent the data in the above global training data set.
[0040] Optionally, in this embodiment, X∈X is data generated by an unknown distribution μ, let is a set of model parameters. Consider a loss function f:X×Θ→R, where f(X,θ) measures the risk of model parameters θ and data X. Linear regression is a typical example, where X=(x, y)∈R d ×R is a feature and target pair, and is a commonly used loss function. The goal of standard statistical learning is to learn the model parameters θ * The number that minimizes population risk is θ * ∈argmir θ∈Θ F(θ)=E[f(X,θ)].
[0041] When the distribution of the data X∈X is known and can be accurately evaluated, θ * It can be solved by solving the minimization problem. When the data distribution is unknown, there are n independent and identically distributed data samples. Note that because the data is random, there will always be a statistical error if a limited number of data samples are used for estimation. Assume that the n data samples are evenly distributed in N edge devices, and each edge device stores a certain number of data samples, denoted as S i , where S i ∩S j =Φ, and For each edge device, the local empirical risk function is defined as: here, is the edge device i about the data sampling S i function, so, is random. For any x∈X, assume f(x, .) is differentiable. Definition is the gradient of the function f(x, θ) at θ, which can be simplified to
[0042] Optionally, the goal of the standard federated learning module is to design an algorithm that enables multiple local edge devices to use their own data sets to perform gradient solution and parameter update. For each cloud server i∈V, the parameter update iteration process at step t includes the following steps:
[0043] S1, the cloud server sets the model parameters θ t-1 Send to all edge devices N and wait for the gradients sent by these N edge devices
[0044] S2, all edge devices receive the parameter θ t-1 After that, the gradient The calculation of the gradient Send to the cloud server.
[0045] S3, the cloud server receives After that, the gradient average operation is performed For the convenience of description, we define
[0046] S4, the cloud server updates the model parameters θ by using the gradient descent method t ←θ t-1 -η×g(θ t-1 ).
[0047] S5, the updated model parameters θ t Sent back to each edge device for the next round of parameter update iteration.
[0048] This embodiment can effectively find the optimal parameters of the global model through the gradient descent algorithm, thereby improving the prediction performance of the model. The defined loss function can better measure the gap between the model prediction value and the actual value, and guide the model optimization.
[0049] In an exemplary embodiment, based on the N above-mentioned gradients and the above-mentioned first model parameters received from the N above-mentioned edge devices, abnormal local training data in the N above-mentioned local training data is determined, and abnormal edge devices are determined based on the above-mentioned abnormal local training data, including: when the N above-mentioned gradients are received from the N above-mentioned edge devices, the following operations are performed for the local model of each above-mentioned edge device to obtain N current model parameters of the N above-mentioned local models: using the above-mentioned gradients and the above-mentioned first model parameters, the above-mentioned current model parameters of the above-mentioned local models are calculated using the gradient descent algorithm; for the local model of each above-mentioned edge device, the following operations are performed to determine the N groups of above-mentioned abnormal edge devices: the Euclidean distance between the above-mentioned current model parameters and the above-mentioned first model parameters is calculated; when the above-mentioned Euclidean distance is less than or equal to a preset threshold value , determine the above-mentioned current model parameters as abnormal model parameters, wherein the above-mentioned preset threshold is a natural number greater than 0; determine the above-mentioned local training data corresponding to the above-mentioned abnormal model parameters as the above-mentioned abnormal layout training data to determine the above-mentioned abnormal edge device, wherein the above-mentioned abnormal local training data includes data that is subject to a preset attack; wherein calculating the Euclidean distance between the above-mentioned current model parameters and the above-mentioned first model parameters includes: respectively converting the multiple parameters included in the above-mentioned current model parameters and the multiple parameters included in the above-mentioned first model parameters into vector representations to obtain multiple first eigenvectors and multiple second eigenvectors; respectively calculating the squares of the differences between the multiple first eigenvectors and the multiple second eigenvectors at corresponding positions to obtain multiple square differences; calculating the sum of the multiple square differences, and determining the square root of the above sum as the above-mentioned Euclidean distance.
[0050] Optionally, the gradient descent algorithm is an optimization algorithm that can be used to adjust model parameters to minimize the loss function. Using the gradient descent algorithm to calculate local model parameters specifically includes: initializing model parameters with random small values, selecting a learning rate, which is a hyperparameter that determines the step size of the gradient descent. Using the above gradient formula to calculate the gradient of the current model parameters. Update the model parameters based on the gradient and the learning rate. For example, Among them, θ represents the model parameters, α represents the learning rate, The above steps are repeated until the stopping condition is met, for example, the gradient is very small or the number of iterations reaches a preset value.
[0051] Optionally, in this embodiment, the Euclidean distance between two model parameters is calculated, that is, the straight-line distance between two points in the Euclidean space is measured. For a parameter vector, for example, the calculation formula is as follows: Assume that the two model parameter vectors are \(\mathbf{p}_1\) and \(\mathbf{p}_2\), which have the same dimension \(n\), that is, \(\mathbf{p}_1=[p_{11},p_{12),…,p_{1n}]\) and \(\mathbf{p}_2=[p_{21},p_{22},…,p_{2n}]\). Then, the Euclidean distance \(d\) between the two vectors can be calculated by the following formula: \[d=\sqrt{\sum_{i=1}^{n}(p_{1i}-p_{2i})^2}\].
[0052] Optionally, the calculation process includes:
[0053] S1, conversion to vector representation: convert the model parameters into vectors \(\mathbf{p}_1\) and \(\mathbf{p}_2\).
[0054] S2, calculate the square of the difference: for each parameter \(i\) (from 1 to \(n\)), calculate \((p_{1i}-p_{2i})^2\).
[0055] S3, sum: sum all the above square differences to get \(\sum_{i=1}^{n}(p_{1i}-p_{2i})^2\).
[0056] S4, square root: Take the square root of the above summation result to obtain the final Euclidean distance \(\sq rt{\sum_{i=1}^{n}(p_{1i}-p_{2i})^2}\).
[0057] This embodiment can determine whether the edge device is under security threat by calculating the Euclidean distance between the current model parameters and the first model parameters, thereby realizing attack detection and elimination.
[0058] In an exemplary embodiment, after determining abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determining the abnormal edge device based on the abnormal local training data, the method further includes: eliminating the abnormal edge device from the N edge devices to obtain M edge devices, wherein M is a natural number less than N; and combining the M edge devices to obtain an edge device set.
[0059] Optionally, this embodiment calculates the parameters of each edge device and the prior parameters θ * Euclidean distance of (first model parameter) Set the threshold ε>0, if Then remove the current edge device j, and finally remove all those that do not meet the conditions. The cloud server combines the remaining edge devices to form an edge device set C, and |C| < N. With a set of edge devices that are robust to attacks, the cloud server performs gradient averaging For the convenience of description, we can define
[0060] This embodiment can avoid the negative impact of abnormal local training data on the model training results by identifying and removing abnormal local training data, thereby improving the quality and accuracy of the overall model training. In addition, removing abnormal edge devices can reduce potential security risks because these devices may send abnormal data due to failure, attack or other reasons.
[0061] In an exemplary embodiment, after combining M of the above-mentioned edge devices to obtain an edge device set, the above-mentioned method also includes: obtaining a local training data set sent by the above-mentioned edge device set; using the above-mentioned local training data set to train the above-mentioned global model until the loss value of the above-mentioned global loss function is less than a preset loss value, ending the training to obtain a target global model; sending the first target model parameter of the above-mentioned target global model to the above-mentioned edge device set to instruct each corresponding local model in the above-mentioned edge device set to be trained according to the above-mentioned first target model parameter.
[0062] Optionally, this embodiment is a distributed training process. First, it is necessary to obtain local training data sets owned by each edge device. These data sets may contain different features and samples, and they may differ in distribution. Then the collected local training data sets are integrated together as a global training data set. Use this global training data set to train the global model until the loss value of the global loss function is less than the preset loss value. This preset loss value can be a preset threshold value used to determine whether the model training has achieved satisfactory results. When the loss value of the global loss function is less than the preset loss value, the training process is stopped. The model obtained at this time is the target global model, and its performance on the global data set should have achieved the expected effect. Some parameters (such as weights, biases, etc.) in the target global model are sent to each edge device. These parameters can be used as the initial parameters of the local models in each edge device so that they can be further trained on this basis. After receiving the target global model parameters, each edge device can use its own local training data set to train the local model. In this way, the local model on each edge device can be optimized under the guidance of the global model to improve its performance on a specific task.
[0063] This embodiment obtains the local training data set sent by the above-mentioned edge device set for distributed training, which can achieve coordinated optimization of the global model and the local model, make full use of the data and computing resources of the edge devices, and improve the efficiency and performance of the entire system.
[0064] In an exemplary embodiment, after combining the M edge devices to obtain an edge device set, the method further includes: performing an average operation on the M gradients corresponding to the edge device set to obtain a gradient average; using the gradient average to update the model parameters of the global model using a gradient descent algorithm to obtain second target model parameters; sending the second target model parameters to the edge device set to instruct each local model corresponding to the edge device set to be trained according to the second target model parameters.
[0065] Optionally, this embodiment is a distributed machine learning model training process. For example, first, the gradients obtained from the local model training on each device are collected from multiple edge devices. Then, these gradients are averaged to obtain an average value of the gradient. This step is to reduce the noise and instability that may be caused by a single gradient, so as to obtain a more stable gradient estimate. Then: use the obtained gradient average to apply the gradient descent algorithm to update the parameters of the global model. The gradient descent algorithm is a commonly used optimization algorithm for minimizing the loss function of the model. The updated model parameters (second target model parameters) are sent back to each edge device. In this way, each edge device can use these updated parameters to continue training its local model. After receiving the new model parameters, each edge device continues to train its local model to approach the global optimal solution.
[0066] This embodiment includes but is not limited to being completed in federated learning or multi-node training. The training of the federated learning model can be quickly completed by utilizing the data and computing power of multiple devices.
[0067] The present application is described below in conjunction with specific embodiments:
[0068] This specific embodiment aims at the problem that when there is a Byzantine attack in the process of federated learning, the results of learning using the local training set will be unreliable. When the results of this local model are sent to the cloud server, the cloud server will use the insecure local training results for aggregation, which will directly affect the global prediction results of the cloud server. An attack identification algorithm based on prior knowledge is proposed.
[0069] like Figure 3 As shown, it is a schematic diagram of the federated learning method based on attack identification in this embodiment. Each edge device (i.e., the edge device mentioned above) uniformly and randomly collects part of the training data and sends this data to the cloud server at the initial moment. After the cloud server collects the training data sent by all edge devices, it integrates the data to form a training set at the initial moment of the cloud server, and uses the global loss function to calculate the prior parameters. Then, each time the edge device sends a gradient, the cloud server uses the gradient descent method to calculate the current moment parameters of each edge device respectively, and calculates the Euclidean distance between the prior parameters and the current parameters of the edge device, and determines whether the edge device has been attacked by setting the threshold. If it is attacked, it is removed from the network, and the average gradient is calculated among the remaining edge devices. Then the model training parameters are updated and sent to all edge devices. As shown Figure 4 As shown, the specific steps include:
[0070] S401, extracting edge device training subsets at the initial moment, each edge device stores a certain number of data samples Si , and then the edge device randomly and evenly collects data in the training sample to form a training sample subset Right now And send the data in this subset to the cloud server.
[0071] S402, the establishment of a priori training data set of the cloud server at the initial moment. When the cloud server collects the training subsets sent by all edge devices at the initial moment After that, the prior training data set is composed as follows:
[0072]
[0073] S403, calculation of cloud server prior information at the initial moment:
[0074] First, define the global loss function of the cloud server: Among them, X j =(x j ,y j )∈R d ×R is a feature and target pair. Secondly, the cloud server uses the initial parameters θ k-1 Computing Gradients Then, the cloud server selects the parameter η and performs the following gradient descent method: Calculate the suboptimal parameter θ * .
[0075] S404, a method for eliminating potential threat edge devices based on prior information and updating model parameters, includes the following steps:
[0076] S4041, the cloud server sets the model parameter θ t-1发 Send it to all edge devices N and wait for the gradients sent by these N edge devices
[0077] S4042, all edge devices receive parameter θ t-1 After that, the gradient The calculation of the gradient Send to cloud server;
[0078] S4043, the cloud server receives After that, define The cloud server updates the model parameters by using the gradient descent method Use the prior gradient to eliminate potential threat edge devices. That is, calculate the parameters of each edge device and the prior parameters θ * Euclidean distance Set the threshold ε>0, if Then remove the current edge device j, and finally remove all those that do not meet the conditions. After the edge devices are found, the cloud server combines the remaining edge devices to form a set C, and |C| < N. After having a set of edge devices that are robust to attacks, the cloud server performs the average operation of the gradient For the convenience of description, we define
[0079] S4044, the cloud server updates the model parameter θ by using the gradient descent method t ←θ t-1 -η×g′(θ t-1 ).
[0080] S4045, the updated model parameters θ t Sent back to each edge device for the next round of parameter update iteration.
[0081] In this specific embodiment, the cloud server uses the gradients and part of the training data sent by all edge devices to calculate the parameters of each edge device, and determines whether the edge device is under security threat by calculating the Euclidean distance between the prior parameters and the current edge device parameters, thereby realizing attack detection and elimination. Federated learning is completed by the cloud server and the remaining edge devices, which improves the security of learning.
[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0083] In this embodiment, a device for determining abnormal edge devices is also provided, which is applied to a cloud server, and the cloud server is connected to multiple edge devices. The global model of the cloud server and the multiple local models of the multiple edge devices are models trained based on distributed machine learning algorithms. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation in hardware, or a combination of software and hardware, is also possible and conceivable.
[0084] Figure 5is a structural block diagram of a device for determining an abnormal edge device according to an embodiment of the present application, such as Figure 5 As shown, the device comprises:
[0085] A first receiving module 52 is configured to receive N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1;
[0086] A first calculation module 54, used to calculate a first model parameter of the global model using the global training data set and the global loss function;
[0087] A first sending module 56, configured to send the first model parameters to the N edge devices respectively, wherein the edge devices are configured to calculate the gradient of the local model during training using the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model;
[0088] The first determination module 58 is used to determine abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and to determine abnormal edge devices based on the abnormal local training data.
[0089] In an exemplary embodiment, the above-mentioned first calculation module 54 includes: a first definition unit, used to define the global loss function, wherein the global loss function includes initial model parameters and features of data in the global training data set; a first processing unit, used to use the global training data set and the initial model parameters to perform a gradient descent operation on the global model to minimize the loss value of the global loss function and obtain the first model parameters of the global model.
[0090] In an exemplary embodiment, the first definition unit includes a first processing subunit, which is used to determine the following formula: Among them, the Used to represent the loss value, the X j =(x j ,y j )∈R d ×R is used to represent the data features of the data in the global training data set and the classification target of the global model, θ is used to represent the initial model parameters, S is used to represent the global training data set, and j is used to represent the data in the global training data set.
[0091] In an exemplary embodiment, the first determination module 58 includes: a second processing unit, which is used to perform the following operations for the local model of each edge device when receiving N gradients sent by N edge devices to obtain N current model parameters of the N local models: a first calculation unit, which is used to use the gradient and the first model parameter to calculate the current model parameter of the local model using a gradient descent algorithm; a third processing unit, which is used to perform the following operations for the local model of each edge device to determine N groups of abnormal edge devices: a second calculation unit, which is used to calculate the Euclidean distance between the current model parameter and the first model parameter; when the Euclidean distance is less than or equal to a preset threshold, the current model parameter is determined as abnormal Model parameters, wherein the preset threshold is a natural number greater than 0; the local training data corresponding to the abnormal model parameters is determined as the abnormal layout training data to determine the abnormal edge device, wherein the abnormal local training data includes data that is subject to a preset attack; wherein calculating the Euclidean distance between the current model parameters and the first model parameters includes: respectively converting a plurality of parameters included in the current model parameters and a plurality of parameters included in the first model parameters into vector representations to obtain a plurality of first eigenvectors and a plurality of second eigenvectors; respectively calculating the squares of the differences between a plurality of the first eigenvectors and a plurality of the second eigenvectors at corresponding positions to obtain a plurality of squared differences; calculating the sum of a plurality of the squared differences, and determining the square root of the sum as the Euclidean distance.
[0092] In an exemplary embodiment, the above-mentioned device also includes: a first elimination module, which is used to determine abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and after determining the abnormal edge device based on the abnormal local training data, eliminate the abnormal edge device from the N edge devices to obtain M edge devices, wherein M is a natural number less than N; a first combination module, which is used to combine the M edge devices to obtain an edge device set.
[0093] In an exemplary embodiment, the above-mentioned device also includes: a first acquisition module, used to combine M of the edge devices to obtain an edge device set, and then obtain a local training data set sent by the edge device set; a first training module, used to train the global model using the local training data set until the loss value of the global loss function is less than a preset loss value, end the training, and obtain the target global model; a second sending module, used to send the first target model parameter of the target global model to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the first target model parameter.
[0094] In an exemplary embodiment, the above-mentioned device also includes: a first operation module, which is used to combine M edge devices to obtain an edge device set, and then perform an average operation on the M gradients corresponding to the edge device set to obtain a gradient average; a first update module, which is used to update the model parameters of the global model using the gradient descent algorithm using the gradient average to obtain a second target model parameter; and a third sending module, which is used to send the second target model parameter to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the second target model parameter.
[0095] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0096] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0097] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0098] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0099] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0100] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0101] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0102] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above method embodiments.
[0103] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0104] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0105] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for determining abnormal edge devices, characterized in that: Applied to a cloud server, the cloud server is connected to multiple edge devices, the global model of the cloud server and multiple local models of the multiple edge devices are models trained based on a distributed machine learning algorithm, and the method includes: Receive N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1; Using the global training data set and the global loss function, calculating a first model parameter of the global model; Sending the first model parameters to the N edge devices respectively, wherein the edge devices are used to calculate the gradient of the local model during the training process using the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model; Based on the N gradients and the first model parameters received from the N edge devices, abnormal local training data in the N groups of local training data are determined, and abnormal edge devices are determined based on the abnormal local training data.
2. The method according to claim 1, characterized in that Using the global training data set and the global loss function, calculating a first model parameter of the global model includes: Defining the global loss function, wherein the global loss function includes initial model parameters and features of data in the global training data set; Using the global training data set and the initial model parameters, a gradient descent operation is performed on the global model to minimize the loss value of the global loss function to obtain the first model parameters of the global model.
3. The method according to claim 2, characterized in that The global loss function is defined as follows: Among them, the Used to represent the loss value, the X j =(x j ,y j )∈R d ×R is used to represent the data features of the data in the global training data set and the classification target of the global model, θ is used to represent the initial model parameters, S is used to represent the global training data set, and j is used to represent the data in the global training data set.
4. The method according to claim 1, characterized in that Determining abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determining an abnormal edge device based on the abnormal local training data, including: When the N gradients sent by the N edge devices are received, the following operations are performed for the local model of each edge device to obtain N current model parameters of the N local models: Using the gradient and the first model parameters, calculating the current model parameters of the local model using a gradient descent algorithm; For each local model of the edge device, the following operations are performed to determine N groups of abnormal edge devices: Calculating the Euclidean distance between the current model parameter and the first model parameter; determining the current model parameter as an abnormal model parameter when the Euclidean distance is less than or equal to a preset threshold, wherein the preset threshold is a natural number greater than 0; determining the local training data corresponding to the abnormal model parameter as the abnormal layout training data to determine the abnormal edge device, wherein the abnormal local training data includes data subject to a preset attack; Among them, calculating the Euclidean distance between the current model parameters and the first model parameters includes: converting the multiple parameters included in the current model parameters and the multiple parameters included in the first model parameters into vector representations, respectively, to obtain multiple first eigenvectors and multiple second eigenvectors; respectively calculating the squares of the differences between the multiple first eigenvectors and the multiple second eigenvectors at corresponding positions, to obtain multiple square difference values; calculating the sum of the multiple square difference values, and determining the square root of the sum as the Euclidean distance.
5. The method according to claim 1 or 4, characterized in that: After determining abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and determining an abnormal edge device based on the abnormal local training data, the method further includes: Eliminate the abnormal edge device from the N edge devices to obtain M edge devices, where M is a natural number less than N; The M edge devices are combined to obtain an edge device set.
6. The method according to claim 5, characterized in that After combining the M edge devices to obtain an edge device set, the method further includes: Obtaining a local training data set sent by the edge device set; The global model is trained using the local training data set until the loss value of the global loss function is less than a preset loss value, and the training is terminated to obtain a target global model; The first target model parameter of the target global model is sent to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the first target model parameter.
7. The method according to claim 5, characterized in that After combining the M edge devices to obtain an edge device set, the method further includes: Performing an average operation on the M gradients corresponding to the edge device set to obtain a gradient average; Using the gradient average update, the model parameters of the global model are updated using a gradient descent algorithm to obtain second target model parameters; The second target model parameters are sent to the edge device set to instruct each corresponding local model in the edge device set to be trained according to the second target model parameters.
8. A device for determining abnormal edge devices, characterized in that: Applied to a cloud server, the cloud server is connected to multiple edge devices, the global model of the cloud server and multiple local models of the multiple edge devices are models trained based on a distributed machine learning algorithm, and the device includes: A first receiving module is configured to receive N groups of local training data sent by N edge devices to obtain a global training data set, wherein one edge device corresponds to a group of local training data, and the local training data is part of the training data extracted from the local training data set for training the local model, and N is a positive integer greater than 1; A first calculation module, used to calculate a first model parameter of the global model using the global training data set and a global loss function; A first sending module, configured to send the first model parameters to the N edge devices respectively, wherein the edge devices are configured to calculate the gradient of the local model during training using the model parameters, and the gradient of the local model is used to represent the rate of change of the loss function of the local model; The first determination module is used to determine abnormal local training data in the N groups of local training data based on the N gradients and the first model parameters received from the N edge devices, and to determine abnormal edge devices based on the abnormal local training data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
