A federated learning aggregation method based on MD sampling and model credibility
By employing a federated learning aggregation method based on MD sampling and model credibility, the problems of inconsistent computing time on edge devices and malicious device contamination are addressed, thereby improving the convergence rate and security of the model and ensuring the accuracy of the global model.
Patent Information
- Application Number
- CN202211618927.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-12-14
AI Technical Summary
Existing federated learning suffers from iteration lag due to inconsistent computation times of edge devices, as well as the contamination effect of malicious devices on model training, which affects the model's convergence rate and security.
The MD sampling method is used to select edge devices for training. Sampling is performed based on the ratio of the data volume of the devices, and poisoning attack detection and weighted aggregation are combined with model credibility to ensure that high-quality models are selected for training.
It improves the model's convergence rate and security, reduces waiting time, enhances resistance to malicious nodes, and ensures the accuracy and security of the global model.
Smart Images

Figure CN115859113B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a federated learning aggregation method based on MD sampling and model credibility. BACKGROUND
[0002] At present, federated learning is a machine learning paradigm proposed by Google to solve the privacy and security problem in machine learning. Instead of using centrally stored data to train the model, federated learning requires edge devices to train using local data and send model-related parameters and gradients to the central aggregation server. The central server will use these local models to generate an accurate global model. In this whole process, the data of each edge device does not need to be directly shared, so the safety of personal data is well protected while the ideal model is obtained.
[0003] Unlike typical distributed machine learning, a key feature of federated learning is the heterogeneity of data. Due to the different frequencies of users using services or applications, the amount of data on edge devices is different. During training, the operation time of different devices will be different. If all edge devices are allowed to participate in the training process of federated learning, there will be participants who fall behind in iterations, and some edge devices that do not respond for a long time may cause the entire system to fail to complete joint training. The most classic FedAvg algorithm uses a random sampling method to select edge devices to participate in training each time, which may affect the convergence rate of training.
[0004] At the same time, since federated learning receives the parameters trained by each edge device during training, the model generated by a malicious device is likely to affect the optimization of the model. Malicious edge devices can pollute the samples in the training set, such as adding incorrect labels or biased data, reducing the quality of the data, or changing the direction of model parameter changes, such as sending incorrect parameters, slowing down the convergence speed of the model.
[0005] The significance of solving the above problems and defects is that improving the sampling method of edge devices according to the characteristics of federated learning can reduce the influence of the edge device selection strategy in traditional federated learning on the convergence rate of model training, improve the training rate and the quality of the final model; detecting poisoning attacks on local models can enhance the resistance of federated learning to malicious nodes and enhance the security of federated learning. SUMMARY
[0006] Invention purposes: In view of the problems existing in the prior art, the application provides a federated learning aggregation method based on MD sampling and model credibility, uses the MD sampling method to extract the edge device, and based on the ratio of the local data volume of the edge device to the total data volume, the edge device with approximate data volume is added to the training, since the calculation time of the edge device with the same data volume is similar, the server reduces the waiting time, thereby improving the convergence rate of the model.
[0007] Technical scheme: The application provides a federated learning aggregation method based on MD sampling and model credibility, comprising the following steps:
[0008] Step 1: The edge device obtains the sample data of the node it is located in, constructs a pre-training data set, and performs global training initialization;
[0009] Step 2: In the tth training, the server sends a task instruction to all edge devices, the edge devices receiving the task instruction upload the return value of the response, and the server calculates the ratio η of the data volume of each edge device according to the received return value i ;
[0010] Step 3: MD sampling is performed according to the ratio η i to select the edge devices participating in this training;
[0011] Step 4: The server sends a task instruction to request training to the selected edge devices, and the edge devices use the stochastic gradient descent algorithm to update the local model until the training times reach the local training times E;
[0012] Step 5: The sum G of the accuracy rate and the gradient update value Δg of the local model of the edge device i is uploaded to the server;
[0013] Step 6: The server detects the poisoning attack according to the received local model related parameters of the m edge devices, which mainly includes two kinds, one is used in the IID data scene, and the other is used in the non-IID data scene, and the model credibility of the local model of the ith edge device in the tth round is calculated
[0014] Step 7: The server calculates the model accuracy of the ith edge device in the tth round according to the accuracy rate , and stores it in the server;
[0015] Step 8: The server updates the historical model accuracy of the ith edge device
[0016] Step 9: The server combines the model credibility and the historical model accuracy to perform weighted aggregation on the local model;
[0017] Step 10: update the global model and save, then continue to perform step 2 operation, repeat steps 2-9 until the training times reach F.
[0018] Further, the task instruction in step 2 is to request the edge device to upload its local data volume, and calculate the ratio η i Specifically:
[0019]
[0020] Wherein, η i is the proportion of the data volume of the edge device i, p i is the data volume of the edge device i, and a is the number of successfully uploaded edge devices.
[0021] Further, in step 3, according to the ratio η i , MD sampling is performed to select the edge device participating in this training, and the specific steps are as follows:
[0022] Step 3.1: generate two values in the interval [0, 1] according to uniform distribution, and get the interval [o1, o2];
[0023] Step 3.2: judge whether the η i of the edge device i falls into the interval [o1, o2], if it is in the interval, select the edge device i to participate in this training, and the number of edge devices participating in this training is m.
[0024] Further, the specific method in step 4 is as follows:
[0025] Step 4.1: the edge device uses stochastic gradient descent to update the model, and the model parameter w is updated as follows at the dth iteration:
[0026]
[0027] Wherein, α d represents the local learning rate, λ is the regularization parameter to prevent overfitting, B d is the sample batch participating in training, and b is the data volume of B d , represents the gradient of the loss function;
[0028] Δg d is the gradient update value each time, which is specifically represented as:
[0029]
[0030] Step 4.2: the edge device locally iterates the model for E times.
[0031] Further, the step 5 is specifically as follows:
[0032] Step 5.1: The accuracy of the local model is the accuracy of the test set, which is specifically expressed as:
[0033]
[0034] Wherein, right represents the number of correct judgments, and all represents the total number;
[0035] Step 5.2: The sum G of the gradient update value Δg of the local model of the edge device i after local training is specifically expressed as:
[0036]
[0037] Wherein, α d represents the local learning rate, λ is a regularization parameter to prevent overfitting, B d is the sample batch participating in training, and b is the data amount of this batch, d represents the gradient of the loss function.
[0038] Further, the specific method in the step 6 is as follows:
[0039] Step 6.1: For the edge device in the IID data scenario, by comparing the accuracy of the aggregated model of the local model containing the i-th edge device and the accuracy of the aggregated model of the local model without the edge device, the following formula is satisfied:
[0040]
[0041] Wherein, represents the evaluation result of the edge device i in the IID data scenario, w′ t represents the global model aggregated by all the local models participating in training, represents the aggregated model after the edge device i does not participate in aggregation, and acc() represents the accuracy after testing using the pre-training data set;
[0042] w′ t satisfies the following formula:
[0043]
[0044] Wherein, m is the number of edge devices participating in this round of training, represents the local model of the edge device i in the t-th round of training;
[0045] Step 6.2: For the edge device in the non-IID data scenario, according to the gradient update value G i cosine similarity of another local model gradient update value G j The specific formula is:
[0046]
[0047] Step 6.3: Since there are multiple edge devices compared with each other, then take the maximum value of v for edge device i i ;
[0048] Step 6.4: In order to reduce the probability of misjudging the normal local model as a toxic model, the cosine similarity is reweighted by the ratio of v i and v j , then will be updated according to the ratio of v i and v j , and satisfy the following formula:
[0049]
[0050] Step 6.5: Take the maximum value of v as v This value represents the evaluation result of edge device i under non-IID data scene;
[0051] Step 6.6: Combine v and v to calculate the model credibility of the local model of edge device i, and satisfy the following formula:
[0052]
[0053] Wherein, σ max and σ min are threshold values for judging whether the model is reliable, when v is greater than σ max , it means that the model is a reliable model, and the model credibility of the local model is 1, when v is less than σ min , the local model is an unreliable model, and the model credibility of the local model is 0.
[0054] Further, the specific method for calculating the model accuracy in step 7 is:
[0055]
[0056] Wherein, is the accuracy rate of client i in the tth iteration of the global model, and acc_min t , acc_max t The minimum and maximum values of the accuracy of the participating training clients.
[0057] Further, the step 8 updates the historical model accuracy of the i-th edge device and satisfies the following formula:
[0058]
[0059] wherein e -α(t-n) is a time decay function, and alpha is a cooling coefficient, is the model accuracy.
[0060] Further, the step 9 combines the model credibility and the historical model accuracy, and the server performs weighted aggregation on the local model, and satisfies the following formula:
[0061]
[0062] wherein, is the model credibility, is the historical model accuracy, and m is the number of edge devices participating in the current round of training, represents the local model of the edge device i in the t-th round of training.
[0063] Compared with the prior art, the present application has the following beneficial effects:
[0064] 1. Since the model optimization rate in federated learning is affected by the computing speed of the edge device, the present application uses the MD sampling method to extract the edge device, which is based on the ratio of the local data volume of the edge device to the total data volume, and the edge device with an approximate data volume is added to the training. Since the edge devices with the same data volume have similar computing times, the server reduces the waiting time, thereby improving the convergence rate of the model.
[0065] 2. The present application sets the model credibility based on the evaluation of the model poisoning situation, which is used to detect whether the edge device is attacked, especially the data poisoning represented by adding incorrect labels or biased data to the training set, which helps to improve the security of federated learning. Because the data of the edge device is uncertain, two types of attack detection are performed, The derivation of RONI is based on the RONI detection scheme, that is, the difference of different models on the same data set is judged. is based on the FoolsGold detection scheme.
[0066] 3. The present application performs weighted aggregation according to the model credibility and accuracy of the local model, so as to select high-quality models for training in each round, thereby ensuring the security and accuracy of the global model. BRIEF DESCRIPTION OF DRAWINGS
[0067] Figure 1 Flow chart of federated learning aggregation method of the present application;
[0068] Figure 2 Flow chart of edge device sampling in federated learning aggregation method of the present application;
[0069] Figure 3 Flow chart of federated learning aggregation in federated learning aggregation method of the present application. DETAILED DESCRIPTION
[0070] The method of the present application will be described in detail below in conjunction with the accompanying drawings and examples, which provide detailed implementation and specific operation processes, but the scope of protection of the present application is not limited to the following examples.
[0071] The implementation environment of the present application includes one server, N edge devices, and N or more sampling devices. N is an integer equal to at least 2, one edge device can correspond to one or more sampling devices, but one sampling device can only correspond to one edge device. The edge device includes a processor and a memory for storing calculations and programs on the processor.
[0072] As shown in Figure 1 , the federated learning aggregation method based on MD sampling and model credibility disclosed by the present application includes the following steps:
[0073] Step 1: Construct a pre-training data set and initialize global training.
[0074] Among them, the edge device collects data from the sampling points it controls and labels them, and uploads the data values with a proportion s after labeling, and the data set is the pre-training data set.
[0075] Among them, the server side performs the first round of training based on the pre-training data set, initializes the global model parameters, and the server side downloads the trained global model to all edge devices.
[0076] It should be noted that the data proportion uploaded by the edge device needs to be adjusted according to the actual situation, and in this example, the proportion is 10%.
[0077] Step 2: As shown in Figure 2 , the server sends task instructions to all edge devices, and the edge devices that successfully receive the task instructions upload the return value of the response, and the server calculates the ratio of the data volume of each edge device according to the received return value.
[0078] The task instruction in this embodiment is to request all edge devices to upload the data size of their local training data. Successfully receiving the task instruction means that the edge device receives the task instruction issued by the server within a certain time. If the time is exceeded or a damaged instruction is received, it is considered that the task instruction is not successfully received.
[0079] In addition, the return value of the edge device i received by the server side includes the data size of the local training data of the edge device i and the id of the edge device i.
[0080] The server side needs to set the ratio of the local data size of the edge device to the local data size of the edge device that has successfully uploaded to η i , that is:
[0081]
[0082] η i is the ratio of the data size of the edge device i, and p i is the data size of the edge device i.
[0083] Step 3: Because the data size of the edge device is different, the edge device in the same ratio range is selected to participate in the training, so that the training rate can be guaranteed. According to the ratio η i , the edge device participating in the training is selected by sampling MD sampling.
[0084] wherein two values between [0, 1] are randomly generated according to uniform distribution, and the interval is [o1, o2]. The random values o1 and o2 are 2-bit decimals and are not equal.
[0085] In addition, it is judged whether the η i of the edge device i falls within the interval [o1, o2]. If it is within the interval, the edge device i is selected to participate in the training, and the number of edge devices participating in the training is m.
[0086] Step 4: As shown in Figure 3 , the server side issues a task instruction to request training to the selected edge device, and the edge device uses the stochastic gradient descent algorithm to update the local model until the training times reach the local training times E:
[0087] It should be noted that the selected edge device is the edge device sampled in the previous step. The task instruction issued by the server side includes the global model, the optimizer, and the device.
[0088] The global model is a model specified by the server side and the aggregated model parameters, the optimizer is used for the way of local model update, and the device is used to select whether the GPU in the edge device participates in the training. In addition, the edge device in the present application uses stochastic gradient descent for model update, and the model parameter w is updated at the dth iteration. The calculation formula is:
[0089]
[0090] Where, α t represents the local learning rate, λ is the regularization parameter to prevent overfitting, B d is the sample batch participating in training, b is the data amount of B d in this batch, represents the gradient of the loss function.
[0091] In this example, the fixed local learning rate is 0.01, and the regularization parameter is 0.01. Δg d is the gradient update value each time, which is specifically represented as:
[0092]
[0093] After the edge device performs E iterations, the local model update of this round is ended.
[0094] Step 5: as Figure 3 shown, upload the accuracy of the local model trained by the edge device i and the sum G of the gradient update value Δg to the server side.
[0095] The accuracy of the local model is the accuracy of the test set, which is specifically represented as:
[0096]
[0097] Where, right represents the number of correct judgments, and all represents the total number.
[0098] The sum G of the gradient update value Δg of the local model of the edge device i after local training is specifically represented as:
[0099]
[0100] Step 6: the server side detects the poisoning attack according to the received local model related parameters of the edge device, which is mainly divided into two kinds, one is used in the IID data scene, and the other is used in the non-IID data scene. After calculation, the model credibility of the local model of the i-th edge device in this round is obtained
[0101] For edge devices in the IID data scene, the accuracy of the global model containing the local model of the i-th edge device is compared with the accuracy of the global model without the local model of the edge device. The following formula is satisfied:
[0102]
[0103] wherein, represents the evaluation result of edge device i in the IID data scene, w' t represents the global model aggregated by all local models participating in training, represents the global model after edge device i does not participate in global aggregation, and acc() represents the accuracy after testing using the pre-training data set.
[0104] wherein, w' t satisfies the following formula:
[0105]
[0106] For edge devices in the non-IID data scene, according to the local model gradient update value G i of edge device i, the cosine similarity of another local model gradient update value Gj is calculated.
[0107]
[0108] Since there are multiple edge devices compared with each other, for edge device i, the maximum value of is v i . In order to reduce the probability of misjudging a normal local model as a toxic model, the cosine similarity is reweighted by the ratio of v i and v j . will be updated according to the ratio of v i and v j , and satisfy the following formula:
[0109]
[0110] The maximum value of is , which is used to represent the evaluation result of edge device i in the non-IID data scene.
[0111] Combine and to calculate the model credibility of the local model of edge device i, and satisfy the following formula:
[0112]
[0113] Wherein, σ max and σ min are the threshold values for determining whether the model is reliable, when σ max is greater than σ , it indicates that the model is a reliable model, and the model credibility of the local model is 1, when σ min is less than σ , the local model is an unreliable model, and the model credibility of the local model is 0.
[0114] Step 7: The server calculates the model accuracy of the i-th edge device in the t-th round according to the accuracy rate , and stores it in the server, and the model accuracy satisfies the following formula:
[0115]
[0116] Wherein, is the accuracy rate of the i-th client in the t-th iteration of the global model, and acc_min t , acc_max t is the minimum and maximum of the accuracy rate of the participating training clients.
[0117] Step 8: The server updates the historical model accuracy of the i-th edge device and satisfies the following formula:
[0118]
[0119] Wherein, e -α(t-n) is a time decay function, α is a cooling coefficient, is the model accuracy.
[0120] Step 9: The server combines the model credibility and the historical model accuracy to perform weighted aggregation on the local model, and satisfies the following formula:
[0121]
[0122] Step 10: Update the global model, and then continue to perform step 2. Repeat steps 2-9 until the training times reach F.
[0123] In summary, the application is used to complete the selection and model aggregation tasks of edge devices in federated learning. It can help to solve the problem of improving the model convergence speed of edge devices under data heterogeneity conditions in federated learning, and further ensure the accuracy and security of the model.
[0124] The above embodiments are only for illustrating the technical concept and characteristics of the present application, and the purpose is to enable those skilled in the art to understand the content of the present application and implement it, and cannot limit the protection scope of the present application. Any equivalent transformation or modification according to the spirit and essence of the present application should be covered within the protection scope of the present application.
Claims
1. A federated learning aggregation method based on MD sampling and model credibility, characterized in that, Comprise the following steps: Step 1: the edge device acquires the sample data of the node, constructs a pre-training data set, and initializes global training; Step 2: In the t-th round of training, the server sends task instructions to all edge devices, the edge devices receiving the task instructions upload the return values of the responses, and the server calculates the ratio η of the data volume of each edge device according to the received return values i ; Step 3: According to the ratio η i MD sampling is performed to select edge devices participating in the training; Step 4: the server end issues a task instruction to request training to the selected edge device, and the edge device uses the random gradient descent algorithm to update the local model until the training times reach the local training times E; Step 5: Local model trained by edge device i The accuracy and the sum of gradient update values Ag are uploaded to the server side. Step 6: The server side performs a poisoning attack detection according to the received local model related parameters of the m edge devices, which is divided into two types, one for IID data scene and one for non-IID data scene, and the model credibility r of the local model of the i-th edge device in this round is obtained after calculation i t ; Step 6.1: for the edge device in the IID data scene, by comparing the accuracy of the aggregation model of the local model containing the i-th edge device and the aggregation model of the local model without the edge device, the following formula is satisfied: wherein, represents the evaluation result of edge device i on the IID data scenario, w' t represents the global model aggregated by all local models participating in the training, represents the aggregated model after edge device i does not participate in the aggregation, acc() represents the accuracy after testing using the pre-training data set; w' t satisfies the following equation: Wherein, m is the number of edge devices participating in the current round of training, denotes the local model of edge device i in the tth round of training. Step 6.2: For the edge device in the non-IID data scenario, according to the local model gradient update value G of the edge device i i cosine similarity with another local model gradient update value G j cosine similarity with another local model gradient update value G The specific formula is: Step 6.3: Since there are multiple edge devices comparing with each other, then take the maximum value of v for edge device i as v i ; Step 6.4: To reduce the probability of misjudging a normal local model as a toxic model, the cosine similarity is re-weighted by the ratio of v i to v j , then will be updated according to the ratio of v i and v j , and satisfies the following formula: Step 6.5: Get CS ij The maximum value is This value represents the evaluation result of edge device i in the non-IID data scenario; Step 6.6: Combine and to calculate the model confidence of the local model of edge device i and satisfy the following equation: wherein σ max and σ min are thresholds for determining whether the model is reliable, and when σ is greater than σ max , it indicates that the model is a reliable model, and the model confidence of the local model is 1, and when σ is less than σ min , the local model is an unreliable model, and the model confidence of the local model is 0. Step 7: The server side calculates the accuracy rate of the i-th edge device in the t-th round Calculate the model accuracy and store it in the server; Step 8: Server side updates the history model accuracy of the ith edge device Step 9: combine the model credibility with the historical model accuracy, and the server end aggregates the local model by weighting; Step 10: update the global model and save, then continue to execute step 2 operation, repeat step 2-step 9 until the training times reach F.
2. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, The task instruction in step 2 is to request the edge device to upload the local data amount, and calculate the ratio η of the data amount of the i-th edge device i Specifically: wherein η i is the proportion of the data volume of the edge device i, p i is the data volume of the edge device i, and a is the number of successfully uploaded edge devices.
3. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, The step 3 according to the ratio η i MD sampling is performed to select the edge device participating in the training, and the specific steps are as follows: Step 3.1: two values in the interval [0,1] are randomly generated according to uniform distribution, and the interval [o1, o2] is obtained; Step 3.2: Determine the η of edge device i i Whether it falls within the interval [o1, o2], if it is within this interval, select edge device i to participate in this training, and the number of edge devices participating in this training is m.
4. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, The specific method in step 4 is: Step 4.1: the edge device uses random gradient descent to update the model, and the model parameter w is updated as follows at the d-th iteration: where α d denotes the local learning rate, λ is a regularization parameter to prevent overfitting, B d is the batch of samples participating in the training, b is the B d size of this batch, denotes the gradient of the loss function; Δg d is the value of the gradient update for each iteration, specifically: Step 4.2: the edge device local model is iterated for E times.
5. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, The specific steps of step 5 are: Step 5.1: the accuracy of the local model is the accuracy of the test set, which is specifically expressed as: Wherein, right indicates the number of correct judgments, and all indicates the total number; Step 5.2: the sum G of the gradient update value Δg of the edge device i local model after local training is specifically expressed as: where α d denotes the local learning rate, λ is a regularization parameter to prevent overfitting, B d is the batch of samples participating in the training, b is the B d size of this batch, denotes the gradient of the loss function.
6. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, The specific method of calculating the model accuracy in step 7 is: wherein, is the accuracy of the client i at the global model at the t-th iteration, while acc_min t , acc_max t is the minimum and maximum of the accuracy among the clients participating in the training.
7. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, updating the history model accuracy of the i-th edge device in step 8 and satisfies the following equation: where e -α(t-n) is a time decay function, a is a cooling coefficient, is the model accuracy.
8. The federated learning aggregation method based on MD sampling and model credibility according to claim 1, wherein, In step 9, the model credibility is combined with the historical model accuracy, the server aggregates the local model by weighting, and satisfies the following formula: wherein, is the model credibility, is the historical model accuracy, m is the number of edge devices participating in the current round of training, denotes the local model of edge device i in the tth round of training.
Citation Information
Patent Citations
Global and local gradient processing method and device for federal learning, equipment and medium
CN113139662A
Dam defect identification model rapid convergence method based on federated learning
CN115410103A