Blockchain-fused federated learning method and device, server, and storage medium

By calculating the similarity of client models and verifying them through the blockchain network, the problem of malicious clients disrupting model training is solved, thus achieving secure and efficient blockchain federated learning.

CN120012874BActive Publication Date: 2025-11-04SUN YAT SEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411871939.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-11-04
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

Existing blockchain federated learning architectures are difficult to effectively prevent malicious clients from disrupting model training, and they also pose risks of high computational resource consumption, communication latency, and data leakage.

Method used

By calculating the similarity between the updated global model of participating clients and the specified clients in the central server, malicious clients are eliminated, the updated global model of benevolent clients is aggregated, and transaction data is verified using the blockchain network to ensure the security and accuracy of model training.

Benefits of technology

Effectively identify and eliminate malicious clients to ensure the accuracy and security of model training, reduce the risk of data leakage, and improve the efficiency and accuracy of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012874B_ABST
    Figure CN120012874B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing, in particular to a federated learning method and device fusing a blockchain, a server and a storage medium. Each participating client obtains an initial global model from a central server, and the initial global model is trained based on a local database. After the training is completed, an updated global model is obtained, and the updated global model is sent to the central server. When the central server receives the updated model parameters sent by the first target client, the similarity between the updated global model of each participating client and the updated global model of the specified client is calculated, so as to eliminate malicious clients in the participating clients based on the similarity, and the updated global models of the remaining good-willed clients are aggregated to obtain a target global model. The influence of the malicious clients on the system is fully considered, and the model training is prevented from being damaged by the malicious clients.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a blockchain-fused federated learning method and device, a server and a storage medium. BACKGROUND

[0002] The existing blockchain federated learning (BCFL) architecture can be divided into three categories, namely fully coupled BCFL (FuC-BCFL), flexibly coupled BCFL (FlC-BCFL) and loosely coupled BCFL (LoC-BCFL).

[0003] FuC-BCFL is a fully coupled form of blockchain-supported federated learning framework, in which blockchain nodes and federated learning clients are located in the same network. Since all data updates are processed and stored in decentralized nodes, data privacy can be protected and single-point failure can be effectively avoided. The blockchain technology is used to aggregate the global model, perform local model updates, verify the updated global model and integrate the global model to ensure data privacy and security, significantly reducing the risk of data leakage and improving the reliability of the federated learning process, but it increases the consumption of computing resources, and due to the communication bandwidth limitation of the blockchain network, FuC-BCFL has communication delay. FlC-BCFL is a flexibly coupled blockchain federated learning architecture, in which the blockchain system and the federated learning system run in different networks. Since the original data is saved in the client of the federated learning system, the risk of data leakage can be reduced, and the system has the advantages of high communication efficiency and low latency. However, the blockchain and FL are two different systems, and it is difficult to coordinate the two under limited resources, and since there is still a central controller, single-point failure may occur. LoC-BCFL is a loosely coupled blockchain federated learning framework, in which the blockchain system is mainly used to verify model updates and manage participant reputation, and is applied to the medical care field to improve data quality by using its reputation management mechanism to prevent malicious participants. SUMMARY

[0004] In order to overcome the deficiencies of the prior art, the present application provides a blockchain-fused federated learning method, device, server and storage medium, which fully considers the influence of malicious clients on the system and prevents malicious clients from destroying model training.

[0005] The first aspect of the present application provides a blockchain-fused federated learning method, the method comprising:

[0006] sending initial global model parameters to a first target client, so that the first target client trains an initial global model based on a local data set to optimize the initial global model parameters, the initial global model parameters including the initial global model, the first target client being any one of a plurality of participating clients participating in the initial global model training;

[0007] when receiving the updated model parameters sent by the first target client, calculating a similarity between an updated global model and a specified client, the updated model parameters including the updated global model;

[0008] aggregating the updated global models of the plurality of participating clients based on the similarity to obtain a target global model.

[0009] In an optional implementation, the aggregating the updated global models of the plurality of participating clients based on the similarity to obtain a target global model comprises:

[0010] determining a second target client set from the plurality of participating clients, the similarity of the second target client set being greater than a preset similarity threshold, the second target client set including a plurality of second target clients;

[0011] determining a target score of the second target client;

[0012] performing a weighted average on a plurality of the updated global models based on the target score to obtain the target global model.

[0013] In an optional implementation, the determining a target score of the second target client comprises:

[0014] determining an original score and a data credibility of the second target client;

[0015] determining the target score based on the similarity, the original score and the data credibility.

[0016] In an optional implementation, before the determining the target score based on the similarity, the original score and the data credibility, the method further comprises:

[0017] determining a flexible control function;

[0018] comparing the similarity and the flexible control function;

[0019] when the similarity is greater than the flexible control function, performing the determining the target score based on the similarity, the original score and the data credibility;

[0020] determining the target score based on the original score and the data credibility when the similarity is less than the flexible control function.

[0021] In an optional implementation, the method further includes:

[0022] determining a point of the second target client according to the target score;

[0023] allocating the point to the second target client.

[0024] In an optional implementation, the method further includes:

[0025] encapsulating transaction data by using a smart contract pre-deployed in a blockchain network, the transaction data including the initial global model parameters and the updated global model parameters;

[0026] verifying the transaction data by using a plurality of endorsement nodes of the blockchain network;

[0027] generating endorsement information by using the endorsement nodes when the transaction data passes the verification, and adding the endorsement information to the transaction data;

[0028] packing the transaction data after the sorting into a new block by using a sorting node on the blockchain network;

[0029] sending the new block to all nodes of the blockchain network for consensus verification by using the sorting node;

[0030] adding the new block to the blockchain network when it is determined that the new block passes the verification.

[0031] In an optional implementation, the method further includes:

[0032] obtaining a malicious client and a proportion coefficient of the malicious client, the malicious client being a participating client in the plurality of participating clients whose similarity is less than the preset similarity threshold;

[0033] verifying the accuracy of the target global model based on a plurality of the proportion coefficients.

[0034] The second aspect of the application provides a federated learning device fused with a blockchain, the device comprising:

[0035] The sending module is configured to send initial global model parameters to a first target client, so that the first target client trains an initial global model based on a local data set to optimize the initial global model parameters, the initial global model parameters including the initial global model, and the first target client is any one of a plurality of participating clients participating in the initial global model training.

[0036] The computing module is configured to calculate the similarity between the updated global model of each participating client and the updated global model of a specified client when receiving the updated model parameters sent by the first target client, the updated model parameters including the updated global model.

[0037] The aggregating module is configured to aggregate the updated global models of the plurality of participating clients based on the similarity to obtain a target global model.

[0038] The third aspect of the present application provides a server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the federated learning method of the fusion blockchain when executing the computer program.

[0039] The fourth aspect of the present application provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the steps of the federated learning method of the fusion blockchain.

[0040] In summary, the federated learning method, device, server and storage medium of the fusion blockchain provided by the present application are used to obtain an initial global model from a central server by each participating client, train the initial global model based on a local database, obtain an updated global model after training, and send the updated global model to the central server. When the central server receives the updated model parameters sent by the first target client, the similarity between the updated global model of each participating client and the updated global model of a specified client is calculated to eliminate malicious clients in the participating clients based on the similarity, and the updated global models of the remaining good-willed clients are aggregated to obtain a target global model. The influence of malicious clients on the system is fully considered, and the model training is prevented from being damaged by malicious clients. BRIEF DESCRIPTION OF DRAWINGS

[0041] Figure 1 is a system architecture diagram of a federated learning system of the fusion blockchain according to an embodiment of the present application;

[0042] Figure 2 is a flowchart of a federated learning method of the fusion blockchain according to an embodiment of the present application;

[0043] Figure 3is a schematic diagram of a cosine similarity calculation method shown by an embodiment of the present application.

[0044] Figure 4 is another flowchart of a federated learning method fusing a blockchain shown by an embodiment of the present application.

[0045] Figure 5 is a function module diagram of a federated learning device fusing a blockchain shown by an embodiment of the present application.

[0046] Figure 6 is a structural schematic diagram of a server shown by an embodiment of the present application. DETAILED DESCRIPTION

[0047] The present application will be further described below in conjunction with the drawings and embodiments.

[0048] The concept, specific structure and generated technical effects of the present application will be clearly and completely described below in conjunction with embodiments and drawings, so as to fully understand the purposes, features and effects of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments of the present application, other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application. In addition, all the coupling / connection relations involved in the patent do not mean that the components are directly connected, but means that a better coupling structure can be composed by adding or reducing coupling accessories according to the specific implementation situation. The technical features in the present application can be combined interactively without mutual contradiction and conflict.

[0049] Referring to Figure 1 , it is a system architecture diagram of a federated learning system fusing a blockchain shown by an embodiment of the present application.

[0050] The federated learning system fusing a blockchain 1 includes a blockchain system 10 and a federated learning system 20. In the embodiment of the present application, the blockchain system 10 is first established using a smart contract, which is used to record the model update and participant reputation in each communication round; then the federated learning system 20 is established, which is used to perform collaborative model training in a privacy protection manner, and provide a reward mechanism to encourage more sharing of training data. Finally, the blockchain system 10 and the federated learning system 20 are combined in a loose coupling architecture, in which the model federated learning system 20 is trained, and the intermediate information is transmitted to the blockchain system 10, while considering privacy protection, computation, storage cost and model performance, and the performance is verified on real training data, and the accuracy of the model shows that the model has achieved superior results.

[0051] Referring to Figure 2As shown, a flowchart of a federated learning method combined with a blockchain is shown, which includes the following steps.

[0052] S21, send initial global model parameters to the first target client, so that the first target client trains the initial global model based on the local data set to optimize the initial global model parameters.

[0053] Federated learning means that each participating client initializes the model with the same model weight, then trains the model with local data, and uploads the model parameters (also model gradient) to the central server after the model training is completed. The central server aggregates all model parameters according to certain rules (such as taking the average value, or taking the average value according to the score as the weight multiplied by the gradient, that is, weighted average), updates the global model reserved in the central server, and then all participating clients further obtain the aggregated global model as the new local model, repeating the above steps to complete model update.

[0054] Wherein, the initial global model parameters include the initial global model and its corresponding model gradient, and the first target client is any one of the plurality of participating clients participating in the initial global model training. When any one client initiates global model training, other clients can choose to participate, together forming a plurality of participating clients. Further, each participating client in the plurality of participating clients obtains the global model parameters (referred to as initial global model parameters) from the central server, and trains the initial global model in the corresponding local database based on the local private data. Wherein, the local private data refers to data that other clients cannot directly access and view in addition to the local database. Assuming that the global model is a medical model, the local private data can refer to patient medical data, and different participating clients can correspond to different medical institutions. When training for the first time, each participating client sends the corresponding model parameters to the central server, the central server trains the model parameters based on the deep learning architecture (for example, Tensorflow 2.13.0 and Pytorch 2.0.1), and gives random network weights to obtain the global model. The central server sends the global model as the initial global model to each participating client, so that each participating client continues to train the initial global model based on its local database.

[0055] Specifically, the central server first sets relevant training parameters according to the requirements of the federated learning task, such as the number of participating model training clients in each round, the number of times each participating client trains the local data set in each round of local training, the size of the data set used by each participating client for one local training, and the like. For the first target client (i.e., any one of the multiple participating clients participating in the initial global model training), the first target client receives the initial global model and its corresponding model gradient from the central server, divides the local data set into multiple training test subsets for local training. In each training time, the initial global model is trained based on each training test subset. After each training, the loss value of each data sample in each training test subset is calculated, and back propagation is performed to obtain the gradient of each training test subset, so that the first target client can update the model parameters of the initial global model based on the parameter. After the first target client completes the local training, the updated model parameters (referred to as updated model parameters) are uploaded to the central server.

[0056] where the training and updating of the global model are based on the formula , is the model parameter of the participating client in the first round, is the loss function calculated on the data set . In the training process, each participating client performs multiple rounds of forward propagation and back propagation to calculate the loss and update the model parameters. Each participating client uses an optimization algorithm (such as SGD or Adam) to gradually adjust the model weights to improve the model's adaptability to local private data.

[0057] It should be noted that during the entire global model training process, the user data (such as training input data and training output data, etc.) of each participating client is always retained in the local database corresponding to each participating client and is not uploaded to the central server, ensuring data privacy. After training is complete, each participating client sends the updated model parameters (not the original data) to the central server to prepare for subsequent model aggregation. The entire global model training process is repeated with continuous iteration of the global model until the global model reaches the expected performance (loss function converges) or the training round ends.

[0058] For the purpose of facilitating the understanding of the inventive idea of the present application, the global model in the embodiments of the present application is described by taking a medical model as an example, and the corresponding model input data is the commonly used MNIST data set and the medical data set Blood MNIST, so as to ensure the credibility. The medical model comprises an input layer, a smoothing layer and a connection layer, the connection layer comprises a first connection layer and a second connection layer, and the second connection layer is used as an output layer. The first connection layer contains 128 neurons, and a ReLU activation function is used at the same time, by introducing nonlinearity, allowing the model to learn complex data patterns, and the second connection layer contains 10 neurons. The input layer accepts a 28x28 pixel image as input data, and the input data is flattened into a 784-dimensional vector through the smoothing layer, so as to obtain a flattened input vector. Finally, the classification score of each class is output as the model output data. In the training process, the medical model of each participating client is optimized by the FedSGD optimizer, and the mean square error (MSE) is selected as the model loss function, and the error back propagation algorithm is used to iteratively train and update the model parameters until the loss function converges or the preset iteration termination number is met. Wherein, the mean square error loss function is represented by the following formula:

[0059] ;

[0060] Wherein, N is the total sum of the training test subsets, RR is the real data in the training test subset, is the corresponding model prediction data result.

[0061] Through the above optional implementation, the distributed training and optimization of the medical model are realized through federated learning, and the local private data of each medical institution (participating client) such as patient medical data is effectively utilized, without the need to upload the data to the central server, ensuring the data privacy and security. Through the dynamic updating and aggregation of the global model parameters, the adaptability and generalization ability of the model to global data are improved. At the same time, specific model structures and optimization algorithms such as ReLU activation function, FedSGD optimizer and mean square error loss function are adopted, which improves the training efficiency and accuracy of the model. Moreover, the model training is performed on the corresponding local client, and the training data is also saved in the local database, and only the global model parameters are uploaded to the central server, which can effectively reduce the risk of privacy leakage and data security.

[0062] S22, when receiving the updated model parameters sent by the first target client, calculating the similarity between the updated global model and the specified client.

[0063] The updating model parameter includes the updating global model, and the specified client refers to a client initiating the current model training, which is a benign client by default. After each participating client trains the initial global model obtained from the central server based on the local database to obtain an updating global model, and sends the updating model parameter carrying the updating global model to the central server, the central server can aggregate based on the received updating model parameter. For a further understanding Figure 3 During the aggregation process, the central server can first evaluate the contribution of each participating client by calculating the cosine similarity between the updating global model of the first target client and the updating global model corresponding to the specified client.

[0064] The similarity between the first target client and the specified client is determined by the following formula:

[0065] ;

[0066] wherein, is the model gradient of the first target client, is the model gradient of the specified client, is the Euclidean norm of is the Euclidean norm of is the dot product of and .

[0067] S23, based on the similarity, aggregate the updating global models of the plurality of participating clients to obtain a target global model.

[0068] Wherein, the plurality of participating clients includes malicious clients and benign clients, wherein the malicious clients may upload incorrect model parameters to try to destroy the model training process, and the benign clients normally submit model parameters. Further, based on the similarity, the central server can selectively weight the updating model parameters of different participating clients, preferentially aggregate the participating clients with high similarity to the updating global model of the specified client, and finally generate an updated global model, referred to as a target global model.

[0069] In an optional implementation, the aggregation of the updating global models of the plurality of participating clients based on the similarity to obtain a target global model includes:

[0070] determining a second target client set with a similarity greater than a preset similarity threshold from the plurality of participating clients, the second target client set including a plurality of second target clients;

[0071] determining a target score of the second target client;​​

[0072] weighting average of the plurality of updated global models based on the target scores, to obtain the target global model.

[0073] In some embodiments, when the similarity between each participating client and the specified client is calculated, the central server can compare the similarity with a pre-set similarity threshold value. When the similarity is less than the pre-set similarity threshold value (e.g., 0.7), it is determined that the corresponding participating client is a malicious client, and the malicious client is excluded from the aggregation process, and the remaining benign clients are aggregated. Then, the central server can calculate the client score (referred to as the target score) of each second target client, where the client score represents the reputation score of each participating client.

[0074] The client score of the second target client in the t+1th communication round is determined by the following formula:

[0075] ;

[0076] wherein, is the client score of the second target client in the t+1th communication round, is the client score of the second target client in the tth communication round, and the initial score value is 0, is the similarity of the second target client in the tth communication round, is the data credibility of the second target client in the tth communication round, which is determined by the amount of data and relevance, etc. For example, the amount of data is large, the score is high, and the data quality is good, the score is high. 、 、 is a weight parameter for controlling the influence of each component, .

[0077] After determining the target score of each second target client, the central server can use the target score as the weight of the second target client, and use the weighted average method to aggregate the updated global models in the second target client set, to obtain an updated target global model. Specifically, the central server determines a global model update rule, and updates the initial global model to the target global model based on the global model update rule. The global model update rule is , and the weight of the model parameter allocated to each second client is determined based on the target score, .

[0078] Through the above optional implementation, the central server can eliminate malicious clients in the plurality of participating clients based on the similarity, avoiding the malicious clients from destroying the aggregation process. By introducing the similarity evaluation and the client score mechanism, the malicious clients can be effectively identified and eliminated in the federated learning process, ensuring the accuracy and security of the model training. In addition, the client score is calculated by comprehensively considering the historical score, the similarity and the data reliability, and the client score is used as a weight for weighted average aggregation, which significantly improves the aggregation quality of the global model. Secondly, the central server only needs to calculate the similarity based on the obtained model gradient of the participating client to determine whether it is a malicious client, without accessing the local database, thereby ensuring the security of the local private data.

[0079] In an optional implementation, before the target score is determined based on the similarity, the original score and the data reliability, the method further comprises:

[0080] determining a flexible control function;

[0081] comparing the similarity and the flexible control function;

[0082] when the similarity is greater than the flexible control function, performing the determination of the target score based on the similarity, the original score and the data reliability;

[0083] when the similarity is less than the flexible control function, determining the similarity as zero, and determining the target score based on the original score and the data reliability.

[0084] In some embodiments, in order to improve the accuracy of the model in the aggregation process, when calculating the client score, the central server can introduce a flexible control function f(x) , the similarity calculated in step S22 and the flexible control function are compared, and when the similarity is greater than the flexible control function, that is , the similarity is calculated when calculating the client score, ; when the similarity is less than the flexible control function, that is , the similarity is set to 0 when calculating the client score, . Wherein, the flexible control function , and is the value range of the self-defined flexible control function, which is between -1 and 1, controls the growth rate and determines the steepness of the curve, is the center point of the control growth, is a parameter that changes based on the change of the loss value, when the loss value decreases, , when the loss value increases, , Take positive value. It should be noted that the above parameters can be designed by the model itself.

[0085] Through the above optional implementation, by introducing a flexible control function, the calculation method is dynamically adjusted according to the similarity during the aggregation score, which improves the accuracy of the model in the aggregation process and enhances the flexibility and adaptability of the system.

[0086] In an optional implementation, the method further comprises:

[0087] determining the score of the second target client according to the target score;

[0088] allocating the score to the second target client.

[0089] Referring to Figure 4 , the central server can set up a reward mechanism to encourage users to participate, for example, it is clear that users can obtain scores through which behaviors, such as participating in federated learning tasks, submitting high-quality data, sharing platform content, etc., and according to the difficulty, value and contribution of user behavior to the platform, set corresponding score reward standards. In the embodiments of the present application, the corresponding score is given based on the score of the participating client, wherein the score of the client is in a positive correlation with the score, the higher the score of the client, the higher the score given.

[0090] In some embodiments, the central server can also build an exchange platform or module for scores, where users can check their balance and browse available discounts, privileges or other rewards. Among them, the score can be used to exchange discounts, privileges or other rewards, improve user participation and satisfaction, and also promote the activity of the platform. The platform can also make personalized recommendations and improve services to meet user needs.

[0091] Through the above optional implementation, the user can be effectively encouraged to participate, and the user participation and satisfaction can be improved, and the activity of the platform can be promoted.

[0092] In an optional implementation, the method further comprises:

[0093] encapsulating transaction data by using a smart contract pre-deployed in a blockchain network, the transaction data comprising the initial global model parameters and the updated global model parameters;

[0094] verifying the transaction data by using a plurality of endorsement nodes of the blockchain network;

[0095] when the transaction data passes the verification, generating endorsement information by using the endorsement nodes, and adding the endorsement information to the transaction data;

[0096] packaging the ordered transaction data into a new block using the ordering node on the blockchain network;

[0097] sending the new block to all nodes of the blockchain network for consensus verification using the ordering node;

[0098] adding the new block into the blockchain network when it is determined that the new block passes the verification.

[0099] wherein the blockchain network and the participating clients of federated learning are located in the same network, and the blockchain network includes ordering nodes, verification nodes, endorsement nodes, and a shared distributed ledger. For reference Figure 4 When the central server receives the transaction data, it calls the smart contract pre-deployed on the blockchain network to encapsulate the transaction data. To ensure the integrity and credibility of the transaction, the central server can sign the transaction data with a private key to ensure the integrity and credibility of the transaction data. The transaction data can include initial global model parameters and updated global model parameters. Then the transaction data is endorsed by the endorsement node of the blockchain network, which verifies the validity and compliance of the transaction data, including checking whether the transaction format is correct, whether the signature is valid, whether the data complies with business rules, etc. If the transaction passes the verification, the endorsement node will generate endorsement information and attach it to the transaction data, which indicates that the endorsement node has approved the validity of the transaction data. Then the endorsement node sends the verified transaction data to the ordering node, which sorts the transaction data in chronological order or other rules, and packs the sorted transaction data into a new block. A block usually contains the hash value of the previous block (used to link to the blockchain), the transaction list of the current block, the timestamp, etc. Further, the ordering node sends the new block to all nodes in the blockchain network for consensus verification. The consensus mechanism is a key step in the blockchain network to ensure that all nodes agree on the new block, which can include Proof of Work (PoW), Proof of Stake (PoS), etc. The nodes will verify whether the transactions in the new block have been correctly endorsed, whether the block format is correct, etc. If the new block passes the verification, the nodes will add it to their own blockchain ledger. Once the new block is added to the blockchain ledger, the state of the entire blockchain is updated, and the new transaction data has been permanently stored on the blockchain.

[0100] Through the above optional implementation, the blockchain network is used to encapsulate, verify, sort, consensus, and store the transaction data in federated learning, ensuring the integrity, credibility, and non-tamperability of the transaction data, enhancing the security and reliability of federated learning, and providing a decentralized and transparent solution for the storage and verification of transaction data.

[0101] In an optional implementation, the method further comprises:

[0102] obtaining malicious clients and proportion coefficients of the malicious clients, the malicious clients being the participating clients in the plurality of participating clients whose similarity is less than the preset similarity threshold;

[0103] verifying the accuracy of the target global model based on the plurality of proportion coefficients.

[0104] In the embodiments of the present application, first, the similarity between each participating client uploaded model gradient and the specified client is calculated, and after eliminating the malicious clients based on the similarity, the remaining participating clients are further aggregated to update the global model to obtain the target global model. In order to verify the accuracy of the target global model, different proportion coefficients of malicious clients are set, and the accuracy of the target global model is verified under different proportion coefficients. Specifically, the central server can use Ubuntu 20.04 operating system as the system environment, and configure the system environment variables to ensure that all necessary dependencies are ready. At the same time, the hardware environment of the central server is configured, such as having 64GB memory, NVIDIA RTX 3090 GPU, Intel(R) Xeon(R) Gold 622R CPU and 9TB hard disk space, etc., and the GPU driver and CUDA toolkit are configured to support deep learning calculation. During the training of the global model, the global model is trained based on the deep learning framework, such as Tensorflow 2.13.0 and Pytorch2.0.1. During the training process, the MNIST dataset and the Blood MNIST dataset are downloaded from the public data source to ensure the integrity and correctness of the dataset, and the MNIST dataset is standardized to make the image pixel value between 0 and 1, and the Blood MNIST dataset is preprocessed similarly to ensure the consistency of the data format. Then, the MNIST and Blood MNIST data are evenly distributed among the participating clients, and the proportion coefficients of the malicious clients are set from 10% to 40%. In addition, the batch size is set to 128, and the training round is set to 100 to observe whether the loss function converges after 100 rounds. The global model is a neural network model including an input layer, a smoothing layer, two fully connected layers. The input layer accepts 28x28 pixel images, and the smoothing layer flattens them into 784-dimensional vectors. The first fully connected layer contains 128 neurons and uses the ReLU activation function. The second fully connected layer (output layer) contains 10 neurons corresponding to the number of classes in the dataset.

[0105] By adjusting the different proportion coefficients of the malicious clients, the accuracy of the global model is evaluated. For the convenience of understanding the embodiments of the present application, by comparing with the anti-poisoning algorithms Krum and Trimmed Mean, it is shown that Figure 3 When the proportion of malicious clients is 20%, compared with Krum and Trimmed Mean, the present application can achieve the highest accuracy, that is, alleviate the adverse effects of malicious client attacks, and has robustness and effectiveness. The present application can maintain a stable and reliable global model, which is superior to the baseline method even in challenging adversarial scenarios. Referring to Figure 4 When the proportion of malicious clients is 40%, compared with Krum and Trimmed Mean, the present application can still achieve the highest accuracy, and as the proportion of malicious clients increases, the accuracy of the present application is higher.

[0106] Through the above optional implementation, the deep learning framework of the present application always achieves the highest performance on the blood medical dataset, which is superior to other baseline methods in terms of accuracy and robustness, that is, the effectiveness and adaptability of the present application in processing complex medical data, which usually has high variability and noise. The results not only highlight the superiority of our framework, but also verify its applicability and reliability in real-world healthcare scenarios where data integrity and model accuracy are crucial.

[0107] Compared with the prior art, the present application initiates a model training application by a certain user at a local client, other users choose to participate, and n rounds of federated learning are performed, and the training is stopped after the loss function is stable. The gradient of each round, the user score and the global model are stored on the blockchain, and finally a converged global model and the score of each participant are obtained, so that the initiator obtains the required model, prevents malicious users from destroying, and subsequent rewards will be given according to the score of each user.

[0108] Referring to Figure 4 As shown, the functional module diagram of the federated learning device fused with the blockchain is shown.

[0109] In some embodiments, the federated learning device fused with the blockchain 50 can include a plurality of functional modules composed of computer program segments. The computer programs of each program segment of the federated learning device fused with the blockchain 50 can be stored in the memory of the server and executed by at least one processor to perform (see Figure 1The function of the federated learning integrated with the blockchain is described. According to the function performed, it can be divided into a plurality of function modules. The function modules can include a sending module 501, a computing module 502, an aggregating module 503, a rewarding module 504, a storage module 505, and a verifying module 506. The module referred to in the present application refers to a series of computer program segments capable of being executed by at least one processor and capable of completing a fixed function, which are stored in the memory. In the present embodiment, the functions of the modules will be described in detail in subsequent embodiments.

[0110] It should be understood that the various changes and specific embodiments of the federated learning integrated with the blockchain method provided in the above embodiments are also applicable to the federated learning integrated with the blockchain device of the present embodiment. Through the foregoing detailed description of the federated learning integrated with the blockchain method, those skilled in the art can clearly understand the implementation method of the federated learning integrated with the blockchain device in the present embodiment. For the sake of brevity of the description, it will not be described in detail here.

[0111] The sending module 501 is configured to send initial global model parameters to a first target client, so that the first target client trains an initial global model based on a local data set to optimize the initial global model parameters, the initial global model parameters include the initial global model, and the first target client is any one of a plurality of participating clients participating in training of the initial global model.

[0112] The computing module 502 is configured to calculate the similarity between an updated global model and a specified client when receiving updated model parameters sent by the first target client, the updated model parameters including the updated global model.

[0113] The aggregating module 503 is configured to aggregate the updated global models of the plurality of participating clients based on the similarity to obtain a target global model.

[0114] The aggregating module 503 is further configured to determine a second target client set having a similarity greater than a preset similarity threshold from the plurality of participating clients, the second target client set including a plurality of second target clients; determine a target score of the second target client; and perform weighted average on a plurality of the updated global models based on the target score to obtain the target global model.

[0115] The aggregating module 503 is further configured to determine an original score and a data credibility of the second target client; and determine the target score based on the similarity, the original score, and the data credibility.

[0116] The computing module 502 is further configured to: determine a flexible control function; compare the similarity and the flexible control function; when the similarity is greater than the flexible control function, perform the determining the target score based on the similarity, the original score, and the data credibility; and when the similarity is less than the flexible control function, determine the similarity as zero, and determine the target score based on the original score and the data credibility.

[0117] The reward module 504 is configured to: determine a point of the second target client according to the target score; and distribute the point to the second target client.

[0118] The storage module 505 is configured to: encapsulate transaction data by using a smart contract pre-deployed in a blockchain network, the transaction data including the initial global model parameters and the updated global model parameters; verify the transaction data by using a plurality of endorsement nodes of the blockchain network; when the transaction data passes the verification, generate endorsement information by using the endorsement nodes, and add the endorsement information to the transaction data; package the transaction data after the sorting into a new block by using a sorting node on the blockchain network; and send the new block to all nodes of the blockchain network for consensus verification by using the sorting node.

[0119] When it is determined that the new block passes the verification, the new block is added to the blockchain network.

[0120] The verification module 506 is configured to: obtain a malicious client and a proportion coefficient of the malicious client, the malicious client being a participating client whose similarity is less than the preset similarity threshold in the plurality of participating clients; and verify the accuracy of the target global model based on a plurality of proportion coefficients.

[0121] Referring to Figure 6 FIG. 6 shows a structural diagram of a server according to an embodiment of the present application. In the preferred embodiment of the present application, the server 6 includes a memory 61, at least one processor 62, and at least one communication bus 63.

[0122] Those skilled in the art should understand that Figure 6 The structure of the server shown in the figure is not a limitation of the embodiments of the present application, and can be a bus structure or a star structure. The server 6 can also include more or fewer other hardware or software, or different component arrangements.

[0123] In some embodiments, the server 6 is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions, and the hardware thereof includes but is not limited to microprocessors, application specific integrated circuits, programmable gate arrays, digital processors and embedded devices, etc. The server 6 can also include user devices, which include but are not limited to any electronic product capable of human-computer interaction with users through keyboards, mice, remote controls, touchpads or voice control devices, such as personal computers, tablet computers, smart phones, digital cameras, etc.

[0124] In the above-described embodiments provided in the present application, it should be understood that the disclosed methods, devices, computer readable storage media and servers can be implemented in other manners. For example, the above-described device embodiments are merely illustrative, and the division of the modules is merely a logical function division, and there can be another division manner in actual implementation. For example, a plurality of components or modules can be combined or integrated into another device, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or components, and can be electrical, mechanical or in other forms.

[0125] The components illustrated as separate components may or may not be physically separate, and the components illustrated as components may or may not be physical modules, i.e., they can be located in one place, or distributed on a plurality of network modules. Some or all of the components can be selected according to actual needs to achieve the purpose of the embodiments.

[0126] In addition, the functional modules in each of the embodiments of the present application can be integrated into a processing module, or each component can exist physically independently, or two or more modules can be integrated into one module. The above integrated module can be realized in the form of hardware or in the form of a software functional module.

[0127] The integrated module, if implemented in the form of a software function module and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, etc.

[0128] It should be noted that, for the foregoing method embodiments, in order to facilitate description, they are all described as a combination of a series of actions, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0129] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0130] The above is a specific description of the preferred embodiments of the present application, but the present application is not limited to the described embodiments. Those skilled in the art can make various equivalent modifications or replacements without departing from the spirit of the present application, and these equivalent modifications or replacements are all included in the scope defined by the claims of the present application.

Claims

1. A federated learning method integrating blockchain, characterized in that, The method includes: Initial global model parameters are sent to a first target client so that the first target client can train the initial global model based on a local dataset to optimize the initial global model parameters. The initial global model parameters include the initial global model. The first target client is any one of a plurality of participating clients that participate in the training of the initial global model. When the updated model parameters sent by the first target client are received, the similarity between the updated global model and the specified client is calculated, wherein the updated model parameters include the updated global model; Based on the similarity, the updated global models of the multiple participating clients are aggregated to obtain the target global model; The method further includes: encapsulating transaction data using a smart contract pre-deployed in the blockchain network, the transaction data including the initial global model parameters and the updated global model parameters; verifying the transaction data using multiple endorsing nodes in the blockchain network; when the transaction data passes verification, generating endorsement information using the endorsing nodes and adding the endorsement information to the transaction data; packaging the sorted transaction data into a new block using sorting nodes in the blockchain network; sending the new block to all nodes in the blockchain network for consensus verification using the sorting nodes; and adding the new block to the blockchain network when it is determined that the new block passes verification. Obtain malicious clients and their proportion coefficients, wherein the malicious clients are participating clients whose similarity is less than a preset similarity threshold among the multiple participating clients; verify the accuracy of the target global model based on the multiple proportion coefficients.

2. The federated learning method integrating blockchain according to claim 1, characterized in that, The step of aggregating the updated global model based on the similarity of the multiple participating clients to obtain the target global model includes: A second target client set is determined from the plurality of participating clients, wherein the similarity is greater than a preset similarity threshold, and the second target client set includes a plurality of second target clients; Determine the target score for the second target client; The target global model is obtained by weighted averaging of multiple updated global models based on the target score.

3. The federated learning method integrating blockchain according to claim 2, characterized in that, The determination of the target score for the second target client includes: Determine the original rating and data credibility of the second target client; The target score is determined based on the similarity, the original score, and the data credibility.

4. The federated learning method integrating blockchain according to claim 3, characterized in that, Before determining the target score based on the similarity, the original score, and the data credibility, the method further includes: Determine the flexible control function; Compare the similarity score with the flexible control function; When the similarity is greater than the flexible control function, the process of determining the target score based on the similarity, the original score, and the data credibility is executed. When the similarity is less than the flexible control function, the similarity is set to zero, and the target score is determined based on the original score and the data credibility.

5. The federated learning method integrating blockchain according to claim 2, characterized in that, The method further includes: The score of the second target client is determined based on the target score; The points are allocated to the second target client.

6. A federated learning device integrating blockchain, characterized in that, The device includes: A sending module is used to send initial global model parameters to a first target client, so that the first target client can train the initial global model based on a local dataset to optimize the initial global model parameters. The initial global model parameters include the initial global model. The first target client is any one of a plurality of participating clients participating in the training of the initial global model. The calculation module is used to calculate the similarity between the updated global model and the specified client when it receives the updated model parameters sent by the first target client, wherein the updated model parameters include the updated global model; The aggregation module is used to aggregate the updated global models of the multiple participating clients based on the similarity to obtain the target global model; The aggregation module is further configured to: encapsulate transaction data using smart contracts pre-deployed in the blockchain network, the transaction data including the initial global model parameters and the updated global model parameters; verify the transaction data using multiple endorsing nodes in the blockchain network; when the transaction data passes verification, generate endorsement information using the endorsing nodes and add the endorsement information to the transaction data; package the sorted transaction data into a new block using sorting nodes in the blockchain network; send the new block to all nodes in the blockchain network for consensus verification using the sorting nodes; when it is determined that the new block passes verification, add the new block to the blockchain network; obtain malicious clients and the proportion coefficient of the malicious clients, the malicious clients being participating clients among the multiple participating clients whose similarity is less than a preset similarity threshold; and verify the accuracy of the target global model based on the multiple proportion coefficients.

7. A server, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the federated learning method of any one of claims 1 to 5 for a converged blockchain.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the federated learning method for fused blockchain as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Federal learning method based on block chain and related device

    CN116523034A

  • Decentralized federated learning method and system based on personalized local differential privacy

    CN118940857A