A blockchain-based federated learning method, device, equipment and storage medium
By employing a blockchain-based federated learning approach, the credibility of client models is evaluated using the Shapley value method and the SHAP method. High-trust models are then selected for aggregation, which solves the problem of global model defects caused by malicious client behavior and achieves higher quality and more reliable model aggregation.
Patent Information
- Application Number
- CN202310805823.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2043-06-30
AI Technical Summary
In federated learning, the data gradients or model parameters provided by the client may be malicious, leading to global model defects and making it difficult to guarantee the quality and reliability of the model.
A blockchain-based federated learning approach is adopted, which calculates the model's explanatory value using the Shapley value method and the SHAP method to determine the client's credibility. The trust score is determined based on the detection score, contribution ratio, and reputation, and client models with high trust scores are selected for aggregation.
This improves the model quality and reliability of federated learning, ensures the accuracy and reliability of aggregated models, and avoids the impact of malicious clients.
Smart Images

Figure CN117010526B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of federated learning, and in particular to a federated learning method based on a blockchain, a device, an apparatus, and a storage medium. BACKGROUND
[0002] In the existing federated learning environment, each data holder, that is, a client, generally only provides data gradients or model parameters without transmitting original data to ensure data privacy, and the data gradients or model parameters provided by the client are used to obtain a global model through centralized server aggregation. However, since the client does not provide original data, there is a problem of malicious clients providing malicious data gradients or model parameters, which leads to a great defect in the final global model. Therefore, a method is needed to ensure that the data gradients or model parameters provided by the client are not malicious when participating in global optimization. SUMMARY
[0003] According to the federated learning method based on a blockchain, an apparatus, a device, and a storage medium provided by the present application, federated learning based on a blockchain can be implemented, the training model uploaded by a client can be discriminated, and the quality and reliability of the federated learning aggregated model can be ensured according to the credibility of the client.
[0004] In a first aspect, the present application provides a federated learning method based on a blockchain, applied to a full node of a blockchain, comprising:
[0005] receiving a training model sent by at least one client, and calculating a plurality of model explanation values of each training model;
[0006] aggregating the plurality of model explanation values of each training model into an aggregated value x, determining a detection score representing whether the corresponding client is a malicious client according to whether each aggregated value x meets a first preset condition;
[0007] determining a contribution score of the corresponding client and a total score of the contribution scores of the clients sending the training models according to whether each model explanation value meets a second preset condition, and determining a contribution proportion of the contribution score of each client in the total score;
[0008] determining an explanation score of each client according to the product of the detection score and the contribution proportion, and determining a trust score according to the sum of the explanation score and a reputation score representing the reputation of the client;
[0009] determining an aggregated model by aggregating the training models of the top K clients in the trust score.
[0010] In one or more possible embodiments, determining a trust score according to the detection score and the contribution proportion comprises:
[0011] determining the reputation score of the client according to a difference between the trust score corresponding to the last iteration of the client and the maximum trust score of the last iteration;
[0012] determining the trust score according to a sum of the explanation score and the reputation score.
[0013] In one or more possible embodiments, determining whether each aggregation value x satisfies the first preset condition includes:
[0014] determining a standard score corresponding to each of the x according to a standard score evaluation detection method;
[0015] determining that the first preset condition is satisfied when the standard score is less than a first preset threshold value ξ1;
[0016] determining that the first preset condition is not satisfied when the standard score is not less than the first preset threshold value ξ1.
[0017] In one or more possible embodiments, after determining the training model of the top K clients of the trust score is aggregated to obtain an aggregation model, further comprising:
[0018] determining whether the aggregation model converges;
[0019] if yes, determining a global model, otherwise sending the aggregation model to each of the clients for training.
[0020] In one or more possible embodiments, calculating a plurality of model explanation values of each of the training models includes:
[0021] calculating a plurality of Shapley values corresponding to a plurality of features in each of the training models;
[0022] determining a plurality of model explanation values of each of the training models according to the plurality of Shapley values.
[0023] In one or more possible embodiments, according to whether each of the model explanation values satisfies a second preset condition, determining a total score of a contribution score of the corresponding client and a contribution score of the client sending the training model, and determining a contribution proportion of the contribution score of each client in the total score, includes:
[0024] determining that the second preset condition is satisfied when the model explanation value is less than a second preset threshold value ξ2;
[0025] determining to increase the contribution score of the client corresponding to each of the model explanation values satisfying the second preset condition by a first fixed value and update the total score of the contribution score of the client sending the training model;
[0026] The contribution proportion of each client is determined by dividing the contribution score of each client by the total score.
[0027] In one or more possible embodiments, when the model explanation value is determined to be less than the second preset threshold ξ2, the second preset condition is satisfied, including:
[0028] The model explanation values are normalized.
[0029] When the normalized model explanation value is less than the second preset threshold ξ2, it is determined that the second preset condition is satisfied.
[0030] In a second aspect, the present application provides a blockchain-based federated learning device, including:
[0031] The receiving calculation module is configured to receive training models sent by at least one client, and calculate a plurality of model explanation values of each training model.
[0032] The detection score determination module is configured to aggregate the plurality of model explanation values of each training model into an aggregated value x, and determine a detection score representing whether the corresponding client is a malicious client according to whether each aggregated value x satisfies a first preset condition.
[0033] The contribution proportion determination module is configured to determine a contribution score of each client and a total score of the contribution scores of the clients sending the training models according to whether each model explanation value satisfies a second preset condition, and determine a contribution proportion of the contribution score of each client in the total score.
[0034] The trust score determination module is configured to determine an explanation score of each client according to a product of the detection score and the contribution proportion, and determine a trust score according to a sum of the explanation score and a reputation score representing the reputation of the client.
[0035] The aggregated model determination module is configured to aggregate the training models of the top K clients in the trust score to obtain an aggregated model.
[0036] In a third aspect, the present application provides a blockchain-based federated learning device, including:
[0037] at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the blockchain-based federated learning method according to any one of the first aspect.
[0038] In a fourth aspect, the present application provides a storage medium, which stores a computer program, and the computer program is used to make a computer execute the method according to any one of the first aspect.
[0039] According to the method, device, equipment and storage medium for federated learning based on a block chain provided in the present application, federated learning based on a block chain can be realized, the training model uploaded by a client is discriminated, and the quality and reliability of the federated learning aggregation model are ensured according to the credibility of the client. BRIEF DESCRIPTION OF DRAWINGS
[0040] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, function to explain the principles of the application, and do not limit the present application in any inconsiderate manner.
[0041] Figure 1 A flowchart according to an embodiment is provided;
[0042] Figure 2 A flowchart according to an embodiment is provided;
[0043] Figure 3 A flowchart according to an embodiment is provided;
[0044] Figure 4 A flowchart according to an embodiment is provided;
[0045] Figure 5 A flowchart according to an embodiment is provided;
[0046] Figure 6 A flowchart according to an embodiment is provided;
[0047] Figure 7 A flowchart according to an embodiment is provided;
[0048] Figure 8 A flowchart according to an embodiment is provided;
[0049] Figure 9 A table according to an embodiment is provided;
[0050] Figure 10 A module diagram according to an embodiment is provided;
[0051] Figure 11 A module diagram according to an embodiment is provided;
[0052] Figure 12 A flowchart according to an embodiment is provided;
[0053] Figure 13 A module diagram according to an embodiment is provided;
[0054] Figure 14 A module diagram provided according to an embodiment;
[0055] Figure 15 A module diagram provided according to an embodiment. DETAILED DESCRIPTION
[0056] In order to make the objects, technical solutions and advantages of the present application clearer, the following will further describe the present application with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0057] In the prior art, the global model needs to be trained by relying on a center server in federated learning, but in actual application, it is difficult to find a completely trusted center server, and if a malicious server is used, the performance of the trained global model will be reduced, but the federated learning structure based on the blockchain can get rid of the centralized server; although the federated learning structure based on the blockchain can get rid of the centralized server, the model uploaded by the client is still a malicious model, the robustness of the model cannot be guaranteed, and based on the above problems, the present application provides a federated learning method, device and equipment based on the blockchain and a storage medium, which can realize federated learning based on the blockchain, discriminate the training model uploaded by the client, and ensure the quality and reliability of the federated learning aggregation model according to the trustworthiness of the client.
[0058] The following will introduce the professional terms involved in the present application:
[0059] Federated learning: Federated machine learning / Federated Learning, also known as joint learning, alliance learning, federated machine learning is a machine learning framework that can effectively help multiple institutions to meet the requirements of user privacy protection, data security and government regulations, and carry out data use and machine learning modeling.
[0060] Shapley value method: also known as Shapley method (Shapley Value Method) is a concept in cooperative game theory, which is used to measure the contribution of each participant to the value created by cooperation in cooperative game. In the field of machine learning, Shapley value is used to explain the influence degree of each feature in the model on the prediction result.
[0061] SHAP method: full name SHapley Additive exPlanations, is a novel method for explaining machine learning models, which can be used to reveal the reasons behind the model's decision. SHAP method is based on Shapley value, which is a concept in game theory, used to evaluate the contribution of each participant in the game. Shapley value can be used to estimate the influence of each input on the output of the model, thus providing an explanation of the model's decision. The advantage of SHAP is that it can provide meaningful explanations, not just simple feature importance ranking. It can also be used to identify interactions between features, and can be used for a variety of machine learning models, including linear models, tree models and neural networks. In this application, the SHAP method can obtain the model explanation value of each model feature.
[0062] Maximum and minimum value normalization processing: that is, using the maximum and minimum values in the data column for standardization processing, the standardized value is between [0, 1], and the specific calculation method is to subtract the minimum value in the data column from the data and then divide by the range.
[0063] According to the blockchain-based federated learning method provided in the application, the federated learning based on the blockchain can be realized, the training model uploaded by the client can be distinguished, the quality and reliability of the federated learning aggregation model can be ensured according to the credibility of the client, and the method can be applied to the full node of the blockchain, such as Figure 1 As shown, it comprises:
[0064] Step 101, receiving at least one training model sent by a client, calculating a plurality of model explanation values of each training model;
[0065] In one or more possible embodiments, the blockchain-based federated learning method provided in the application is applied to the full node of the blockchain. The full node is a node that occupies memory and synchronizes all data in the blockchain. It can independently check and process all data in the blockchain, and can also broadcast the processing or checking results. Each client can send a training model to the full node through a fog node device associated with the blockchain system. The client in the application can be an Internet of Things device or other device. The full node receives the training model and calculates the Shapley value of each feature corresponding to the training model in each client using the Shapley method, and then calculates the model explanation value corresponding to each feature using the SHAP method according to the obtained Shapley value.
[0066] Step 102, aggregating the plurality of model explanation values of each training model into an aggregation value x, and determining a detection score representing whether the corresponding client is a malicious client according to whether each aggregation value x satisfies a first preset condition.
[0067] In one or more possible embodiments, the model explanation values obtained according to the SHAP method correspond to the aggregation of the model explanation values of the same client into an aggregated value x, one client corresponds to one aggregated value x, the standard score corresponding to each aggregated value x is calculated according to the standard score evaluation detection method, and whether the feature data uploaded from each client is maliciously uploaded can be detected according to the standard score. When it is determined that the aggregated value x satisfies the first preset condition, it is determined that the feature data of the client is not maliciously uploaded, and the detection score corresponding to the client is set to 1, indicating that the client is not a malicious client. When it is determined that the aggregated value x does not satisfy the first preset condition, it is determined that the client has maliciously uploaded feature data, and the detection score corresponding to the client is set to 0, indicating that the client is a malicious client.
[0068] In step 103, the contribution score of the corresponding client and the total score of the contribution score of the client sending the training model are determined according to whether each of the model explanation values satisfies a second preset condition, and the contribution proportion of the contribution score of each client in the total score is determined.
[0069] In one or more possible embodiments, when each of the model explanation values satisfies the second preset condition, it is determined that the client is an important contributor to the corresponding feature data, and the contribution score of the client is increased by a fixed value. In order to facilitate calculation, the fixed value in the embodiments of the present application is 1, that is, the total score of the contribution score of the client and the contribution score of the client sending the training model is increased by 1. For example, it is determined that there are three clients, each client has two model explanation values, the contribution score of the first client is 1, the contribution score of the second client is 2, and the contribution score of the third client is 2. The total score is 5. Among them, the contribution proportion corresponding to the first client is 0.2, the contribution proportion corresponding to the second client is 0.4, and the contribution proportion corresponding to the third client is 0.4.
[0070] In step 104, the explanation score of each client is determined according to the product of the detection score and the contribution proportion, and the trust score is determined according to the sum of the explanation score and the reputation score representing the reputation of the client.
[0071] In one or more possible embodiments, the explanation score of each client can be determined according to the product of the detection score and the contribution proportion obtained above. When a client is detected as a malicious client, the explanation score of the client is determined as 0 regardless of the contribution proportion of the client. Then, the final trust score is determined according to the sum of the explanation score and the reputation score. When it is not the first iteration, the reputation score of the client is determined by the trust score.
[0072] Step 105, determine to aggregate the training model of the top K clients of the trust score to obtain an aggregated model.
[0073] In one or more possible embodiments, after determining that the trust score of each client is obtained, the each client is sorted according to the high and low of the trust score, the client with the highest trust score is determined as the first, and the top K clients are selected; the training model sent to the full node of the selected top K clients is aggregated to determine the aggregated model; after determining the aggregated model, as shown in Figure 12 , it further comprises:
[0074] Step 1201, determine whether the aggregated model converges; if yes, execute step 1202, if no, execute step 1203;
[0075] Step 1202, determine that the aggregated model is the final aggregated model;
[0076] Step 1203, send the aggregated model to each client for retraining.
[0077] According to the federated learning method based on the blockchain provided in the application, the federated learning based on the blockchain can be realized, the training model uploaded by the client is discriminated, and the quality and credibility of the federated learning aggregated model are ensured according to the credibility of the client.
[0078] In one or more possible embodiments, as shown in Figure 2 , the trust score is determined according to the detection score and the contribution ratio:
[0079] Step 201, determine the credit score of the client according to the difference between the trust score corresponding to the last iteration of each client and the maximum trust score of the last iteration;
[0080] Step 202, determine the trust score according to the sum of the explanation score and the credit score.
[0081] In one or more possible embodiments, when a client sends feature data to a node for the first time, it is determined to be the first iteration, and thus the initial reputation scores of each client are determined to be 0, ensuring that the initial reputation scores of each client are the same; when the iteration number of a client is determined to be greater than 1, in order to track the performance of each client, the reputation score of each client needs to be updated, and the update is according to the following formula: reputation score = trust score - maximum trust score; for example, there are five clients, and the trust scores corresponding to each client are [0, 0.5, 0.4, 0.1, 0]; according to the above five trust scores, the updated reputation scores of each client are [0-0.5, 0.5-0.5, 0.4-0.5, 0.1-0.5, 0-0.5], and the final updated reputation scores of each client are [-0.5, 0, -0.1, -0.4, -0.5]; the reputation score for the next iteration is calculated using the updated reputation score above, and the trust score is determined according to the sum of the explanation score and the reputation score.
[0082] In one or more possible embodiments, the following method is used to determine whether each aggregate value x satisfies the first preset condition, as shown in the following formula: Figure 3 As shown in the following formula:
[0083] Step 301: Determine the standard score corresponding to each x according to the standard score evaluation detection method;
[0084] In one or more possible embodiments, the following method is used to determine whether each aggregate value x satisfies the first preset condition, as shown in the following formula: Figure 4 As shown in the following formula:
[0085] Step 401: Calculate the mean value μ and the standard deviation σ according to each x;
[0086] In one or more possible embodiments, the above x is an aggregate value of the model explanation value corresponding to each client, for example, there are five clients, and the corresponding aggregate values are x1, x2, x3, x4, and x5, then μ = (x1+x2+x3+x4+x5) / 5; and the corresponding standard deviation The mean value and the standard deviation have existing calculation formulas, which will not be specifically illustrated here.
[0087] Step 402: Determine the standard score of each x according to the difference between each x and the mean value μ divided by the standard deviation σ.
[0088] In one or more possible embodiments, the specific formula of the standard score evaluation detection method is as follows:
[0089]
[0090] In the above formula, z-score is the standard score, which is used to determine whether each client is a malicious client.
[0091] Step 302, determining that the standard score is less than the first preset threshold ξ1, the first preset condition is met;
[0092] Step 303, determining that the standard score is not less than the first preset threshold ξ1, the first preset condition is not met;
[0093] In one or more possible embodiments, the above-mentioned first preset threshold ξ1 can be determined according to the calculated standard deviation. Generally, the range of the first preset threshold ξ1 can be (0, σ) or [σ, 2σ] or greater than 2σ, and will be determined according to the sensitivity of the application, for example, for a more sensitive system or model, the range of the first preset threshold ξ1 can be (0, σ). When the standard score corresponding to the client is calculated in the present application and it is determined that the standard score is less than the first preset threshold ξ1, it is determined that the first preset condition in the present application is met, which means that the client is a non-malicious client. When the standard score corresponding to the client is calculated in the present application and it is determined that the standard score is not less than the first preset threshold ξ1, it is determined that the first preset condition in the present application is not met, which means that the client is a malicious client.
[0094] In one or more possible embodiments, the plurality of model explanation values of each of the training models are calculated, such as Figure 5 As shown, including:
[0095] Step 501, calculating a plurality of Shapley values corresponding to a plurality of features in each of the training models;
[0096] In one or more possible embodiments, the Shapley value of at least one feature data in each of the training models is determined using the shapley method. The specific formula is as follows:
[0097]
[0098] Wherein, M is the number of features, F is the set of all features, f is the explained model, x ′ is an explained feature vector, x i ′ is the i-th feature in the feature vector, F\{x i ′ is the feature set without the i-th feature, S is all subsets of F\{i}, is the shapiey value of the i-th feature.
[0099] Step 502, determining a plurality of model explanation values of each of the training models according to the plurality of Shapley values.
[0100] In one or more possible embodiments, the Shapley value explanation is expressed as an additive feature attribution method according to SHAP, and a prediction value of the model is explained as a linear function of a binary variable; for example, a model g is constructed, and the specific formula is as follows:
[0101]
[0102] In the above formula, M is the number of features, z ′ is a simplified feature, and z ′ ∈{0, 1} M When the value in z ′ is 1, it means that the feature is exactly the same as the corresponding feature of the instance being explained, and when the value in z ′ is 0, it means that the feature is not explained, g is an explanation model, is a base value, that is, the average value of f(x), is the average value of f(S) after adding the ith feature; for an instance being explained, all instances participate in the explanation process, at this time all z ′ are 1, so the above formula of g(z ′ ) can be simplified as:
[0103]
[0104] The application calculates the model explanation value according to the formula g(x ′ ).
[0105] In one or more possible embodiments, according to whether each model explanation value satisfies a second preset condition, the contribution score of the corresponding client and the total score of the contribution scores of the clients sending the training model are determined, and the contribution proportion of the contribution score of each client in the total score is determined, as shown in Figure 6 , including:
[0106] Step 601, determining that the model explanation value is less than a second preset threshold ξ2, the second preset condition is satisfied;
[0107] In one or more possible embodiments, it is determined that each model explanation value is less than a second preset threshold ξ2, and the second preset condition is satisfied, as shown in Figure 7 , including:
[0108] Step 701, normalizing each model explanation value;
[0109] In one or more possible embodiments, generally, before modeling, the data needs to be standardized to eliminate the influence of the dimension, and if the non-standardized data is directly modeled, it is likely to cause the model to learn too much about the variable with large numerical value and not enough about the variable with small numerical value, and the training effect of the obtained model is not good. The maximum and minimum normalization is selected to normalize the model explanation value, and the specific formula is as follows:
[0110]
[0111] In the above formula, x represents the model explanation value, x min represents the minimum one of all model explanation values, x max represents the maximum one of all model explanation values, and the final result a ′ represents the normalized model explanation value.
[0112] Step 702, when each of the normalized model explanation values is less than a second preset threshold ξ2, it is determined that the second preset condition is met.
[0113] Step 602, determining that the contribution score of the client corresponding to each of the model explanation values meeting the second preset condition is increased by a first fixed value, and updating the total score of the contribution scores of the clients sending the training model;
[0114] In one or more possible embodiments, when it is determined that the second preset condition is met, that is, the model explanation value after normalization is less than the second preset threshold ξ2, the contribution score of the client corresponding to the model explanation value is increased by a fixed value. In order to facilitate description, the fixed value in the present application is replaced by 1, that is, the contribution score of the client is increased by 1, and the total score of the clients sending the training model is also increased by 1.
[0115] Step 603, dividing the contribution score corresponding to each client by the total score to determine the contribution proportion corresponding to each client.
[0116] In one or more possible embodiments, for example, there are three clients C1, C2 and C3, and each client corresponds to three model explanation values, as shown in the specific table in Figure 9 , the final contribution score and total score of each client can be determined; according to Figure 9 , the contribution proportions of each client can be calculated as 0.33, 0.5 and 0.17 respectively.
[0117] According to the federated learning method based on the blockchain provided by the present application, as shown in Figure 8 , the method comprises the following steps:
[0118] Step 801: Receive at least one training model sent by a client, and calculate multiple model interpretation values for each training model according to the Shapley method and the SHAP method.
[0119] Step 802: Aggregate the model interpretation values of each trained model into an aggregate value x, and determine the detection score of the client based on each aggregate value x;
[0120] Step 803: Determine the total score of the contribution score of the corresponding client and the contribution score of the client that sent the training model for each model interpretation value, and determine the contribution ratio of each client's contribution score in the total score;
[0121] Step 804: Determine the explanation score for each client based on the product of the detection score and the contribution ratio; determine the trust score based on the sum of the explanation score and the reputation score that characterizes the client's credibility.
[0122] Step 805: Determine to aggregate the training models of the top K clients with the highest trust scores to obtain an aggregated model;
[0123] Step 806: Determine whether the aggregation model has converged. If yes, proceed to step 807; otherwise, proceed to step 801.
[0124] Step 807: Determine that the aggregation model is the final aggregation model.
[0125] like Figure 10 As shown, the architecture of this solution consists of an IoT device 1001, a fog node device 1002, and a blockchain 1003. Figure 11 The diagram shows a system diagram of the blockchain-based federated learning method provided in this application. In the first iteration, fog nodes (F1, F2…Fm) initialize a training model w0 and push this model to each client (E1, E2…En). Each client trains the training model w0 and uploads the trained model w1 to each fog node. After a fixed time interval, the nodes in the blockchain receive the trained model from each fog node and broadcast it to other nodes on the blockchain. After receiving the training model w1, the full nodes in the blockchain determine whether the model is malicious based on the calculated model interpretation value, calculate the contribution and trust score of different features of the model, and select the top k features of each feature for aggregation to obtain an aggregated model. If the preset conditions are met, the aggregated model is determined to be the final global model. Otherwise, the full nodes send the aggregated model as the next training model to each fog node, and each fog node resubmits the trained model to each client for retraining.
[0126] Based on the same inventive concept, the present application also provides a blockchain-based federated learning device, as shown in Figure 13 The device comprises:
[0127] The receiving computing module 1301 is configured to receive training models sent by at least one client, and calculate a plurality of model explanation values of each training model.
[0128] The detection score determining module 1302 is configured to aggregate the plurality of model explanation values of each training model into an aggregated value x, and determine a detection score representing whether the corresponding client is a malicious client according to whether each aggregated value x meets a first preset condition.
[0129] The contribution ratio determining module 1303 is configured to determine a contribution score of the corresponding client and a total score of the contribution scores of the clients sending the training models according to whether each model explanation value meets a second preset condition, and determine a contribution ratio of the contribution score of each client in the total score.
[0130] The trust score determining module 1304 is configured to determine an explanation score of each client according to the product of the detection score and the contribution ratio, and determine a trust score according to the sum of the explanation score and a reputation score representing the reputation of the client.
[0131] The aggregated model determining module 1305 is configured to determine to aggregate the training models of the top K clients in the trust score to obtain an aggregated model.
[0132] Based on the same inventive concept, the present application also provides a blockchain-based federated learning device, comprising at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the blockchain-based federated learning method described above.
[0133] As shown in Figure 14 The device comprises a processor 1401, a memory 1402, a communication interface 1403 and a bus 1404. The processor 1401, the memory 1402 and the communication interface 1403 are connected to each other through the bus 1404.
[0134] The processor 1401 is configured to read instructions in the memory 1402 and execute them to enable the at least one processor to perform the blockchain-based federated learning method provided by the above-described embodiments.
[0135] The memory 1402 is configured to store various instructions and programs of the blockchain-based federated learning method provided by the above-described embodiments.
[0136] The bus 1404 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, Figure 14 Only one thick line is used to represent the bus in the figure, but it does not mean that there is only one bus or only one type of bus.
[0137] The processor 1401 can be a central processing unit (CPU), a network processor (NP), a graphic processing unit (GPU), or any combination of CPU, NP, and GPU. It can also be a hardware chip. The hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0138] Based on the same inventive concept, the present application also provides a readable storage medium, such as Figure 15 As shown, the computer storage medium stores a computer program, and the computer program is used to make the computer execute any one of the above-mentioned methods.
[0139] The memory can include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1521 and / or a cache memory 1522, and can further include a read-only memory (ROM) 1523.
[0140] The memory can also include a program / utility 1525 having a set of program modules 1524, such as an operating system, one or more application programs, other program modules, and program data, each of which or a combination of which can include implementation of a network environment.
[0141] Those skilled in the art will appreciate that embodiments of the present application can be readily used as software, hardware, or a combination of software and hardware. In one embodiment, the present application can be implemented in software and can be stored on a computer readable medium, which can include random access memory (RAM), read only memory (ROM), magnetic disk or optical disk, or the like. The software implementation can comprise one or more computer program components embodied on one or more computer readable medium(s).
[0142] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0143] These computer program instructions can also be stored in a computer readable medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0145] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A blockchain-based federated learning method, characterized in that, Applied to full nodes and multiple clients in the blockchain, including: The system receives a training model sent by at least one client, calculates multiple Shapley values corresponding to multiple features in each training model using the Shapley method, and determines multiple model interpretation values for each training model based on the multiple Shapley values using the SHAP method. The training model is generated by the client based on local data and sent to the full blockchain node through a fog node device associated with the blockchain. The multiple model interpretation values of each training model are aggregated into an aggregate value x. Based on whether each aggregate value x satisfies the first preset condition, a detection score representing whether the corresponding client is a malicious client is determined. Based on whether each model interpretation value meets the second preset condition, determine the total score of the contribution score of the corresponding client and the contribution score of the client that sent the training model, and determine the contribution ratio of each client's contribution score in the total score; The explanation score for each client is determined by multiplying the detection score and the contribution ratio. The trust score is determined by summing the explanation score and the trust score that characterizes the client's credibility. The trust score that characterizes the client's credibility is determined as follows: the client's credibility score is determined by the difference between the trust score corresponding to the previous iteration and the maximum trust score of the previous iteration. The training models of the top K clients with the highest trust scores are aggregated to obtain an aggregated model; it is then determined whether the aggregated model has converged; if so, a global model is determined; otherwise, the aggregated model is sent to each of the clients for training until the model converges.
2. The method according to claim 1, characterized in that, The following methods are used to determine whether each aggregate value x satisfies the first preset condition, including: The standard score corresponding to each x is determined according to the standard score evaluation test method; When the standard score is less than the first preset threshold ξ1, the first preset condition is met; If the standard score is determined to be not less than the first preset threshold ξ1, the first preset condition is not met.
3. The method according to claim 1, characterized in that, Based on whether each model interpretation value meets the second preset condition, determine the total score of the contribution score of the corresponding client and the contribution score of the client that sent the training model, and determine the contribution ratio of each client's contribution score in the total score, including: When the model's interpreted value is less than the second preset threshold ξ2, the second preset condition is satisfied; The contribution score of the client corresponding to each model interpretation value that meets the second preset condition is increased by a first fixed value, and the total contribution score of the client that sent the training model is updated. Divide the contribution score of each client by the total score to determine the contribution ratio of each client.
4. The method according to claim 3, characterized in that, When the model's explained value is less than the second preset threshold ξ2, the second preset condition is satisfied, including: The interpreted values of each model are normalized. When the normalized model interpretation value is less than the second preset threshold ξ2, it is determined that the second preset condition is met.
5. A blockchain-based federated learning device, characterized in that, Applied to full nodes and multiple clients in the blockchain, including: The receiving and computing module is used to receive training models sent by at least one client, calculate multiple Shapley values corresponding to multiple features in each training model using the Shapley method, and determine multiple model interpretation values for each training model based on the multiple Shapley values using the SHAP method. The training models are generated by the client based on local data and sent to the full blockchain node through a fog node device associated with the blockchain. The detection score determination module is used to aggregate multiple model interpretation values of each training model into an aggregate value x, and determine the detection score representing whether the corresponding client is a malicious client based on whether each aggregate value x meets a first preset condition. The contribution ratio determination module determines the total score of the contribution score of the corresponding client and the contribution score of the client that sent the training model, based on whether the interpretation value of each model meets the second preset condition, and determines the contribution ratio of each client's contribution score in the total score. The trust score determination module is used to determine the explanation score of each client based on the product of the detection score and the contribution ratio, and to determine the trust score based on the sum of the explanation score and the trust score that characterizes the client's credibility; wherein, the trust score that characterizes the client's credibility is determined in the following way: the client's credibility score is determined based on the difference between the trust score corresponding to the previous iteration of each client and the maximum trust score of the previous iteration; The aggregation model determination module is used to determine whether to aggregate the training models of the top K clients with the highest trust scores to obtain an aggregated model; determine whether the aggregated model has converged; if so, determine the global model; otherwise, send the aggregated model to each of the clients for training until the model converges.
6. A blockchain-based federated learning device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the blockchain-based federated learning method as described in any one of claims 1-4.
7. A storage medium, characterized in that, The storage medium stores a computer program that enables a computer to perform the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Federated modeling method, device and equipment based on block chain, and storage medium
CN111552986A
Federated learning defense method and device, computer equipment and computer storage medium
CN113962402A