Federal learning method and device fusing block chain, server and storage medium

By calculating and aggregating the similarity of client models in the blockchain federated learning system, eliminating malicious clients and generating target global models, the problem of malicious clients destroying model training is solved, and higher model training accuracy and security are achieved.

CN120012874AActive Publication Date: 2025-05-16SUN YAT SEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing blockchain federated learning architecture has the risk of malicious clients breaking model training, and it is difficult to coordinate blockchain and federated learning systems under limited resources.

Method used

By sending the initial global model parameters to the target client for training, the similarity between the update model parameters and the specified client is calculated, the update global model of the participating client is aggregated based on the similarity, the malicious client is eliminated, the target global model is generated, and the transaction data is verified using the blockchain network to ensure data security.

Benefits of technology

Effectively prevent malicious clients from corruption of model training, improve the accuracy and security of model training, reduce the risk of data leakage, and improve the reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012874A_ABST
    Figure CN120012874A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a federal learning method and device for fusing a block chain, a server and a storage medium, and the method comprises the steps: obtaining an initial global model from a central server through each participating client, carrying out the training of the initial global model based on a lost database, obtaining an updated global model after the training is completed, and carrying out the recognition of the updated global model. And sending the updated global model to a central server, and when the central server receives an updated model parameter sent by the first target client, calculating the similarity between the updated global model of each participating client and the updated global model of the specified client, so as to eliminate malicious clients in the participating clients based on the similarity. And aggregation is carried out based on the updated global models of the remaining good clients to obtain a target global model, the influence of malicious clients on the system is fully considered, and the malicious clients are prevented from damaging model training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[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 failures can be effectively avoided. Blockchain technology is used to aggregate global models, perform local model updates, verify updates and integrate global models 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 delays. FlC-BCFL is a flexibly coupled blockchain federated learning architecture, in which the blockchain system and the federated learning system run in different networks respectively. Since the original data is stored on the client of the federated learning system, the risk of data leakage can be reduced, and it has the advantages of high communication efficiency and low latency. However, blockchain and FL are two different systems, and it is difficult to coordinate the two under limited resources, and single point failures may occur because there is still a central controller. LoC-BCF is a loosely coupled blockchain federated learning framework, in which the blockchain system is mainly used to verify model updates and manage the reputation of participants. It is applied in the healthcare field, using its reputation management mechanism to improve data quality and prevent malicious participants. Summary of the invention

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

[0005] The first aspect of the present application provides a federated learning method integrating blockchain, the method comprising: Sending initial global model parameters to a first target client, so that the first target client trains the initial global model based on a local data set to optimize the initial global model parameters, wherein 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 the initial global model training; When receiving the updated model parameters sent by the first target client, calculating the similarity between the updated global model and the designated client, the updated model parameters including the updated global model; The updated global models of the multiple participating clients are aggregated based on the similarities to obtain a target global model.

[0006] In an optional implementation, aggregating the updated global models of the multiple participating clients based on the similarity to obtain a target global model includes: Determine a second target client set from the multiple participating clients whose similarity is greater than a preset similarity threshold, wherein the second target client set includes multiple second target clients; Determining a target score for the second target client; A weighted average is performed on the multiple updated global models based on the target scores to obtain the target global model.

[0007] In an optional implementation, determining the target score of the second target client includes: Determining the original score and data credibility of the second target client; The target score is determined based on the similarity, the original score, and the data credibility.

[0008] In an optional implementation, 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; comparing the similarity with the flexible control function; When the similarity is greater than the flexible control function, determining the target score based on the similarity, the original score and the data credibility is performed; When the similarity is less than the flexible control function, the similarity is determined to be zero, and the target score is determined based on the original score and the data credibility.

[0009] In an optional embodiment, the method further comprises: Determining the score of the second target client according to the target score; The points are distributed to the second target client.

[0010] In an optional embodiment, the method further comprises: Encapsulating transaction data using a smart contract pre-deployed in a blockchain network, wherein the transaction data includes the initial global model parameters and the updated global model parameters; Verifying the transaction data using multiple endorsement nodes of the blockchain network; When the transaction data passes verification, generating endorsement information using the endorsement node, and adding the endorsement information to the transaction data; Using the sorting nodes on the blockchain network to package the sorted transaction data into new blocks; Using the sorting node to send the new block to all nodes of the blockchain network for consensus verification; When it is determined that the new block passes the verification, the new block is added to the blockchain network.

[0011] In an optional embodiment, the method further comprises: Acquire malicious clients and a ratio coefficient of the malicious clients, wherein the malicious clients are participating clients whose similarity among the multiple participating clients is less than the preset similarity threshold; The accuracy of the target global model is verified based on the plurality of scale factors.

[0012] A second aspect of the present application provides a federated learning device integrating blockchain, the device comprising: A sending module, configured to send initial global model parameters to a first target client, so that the first target client trains the initial global model based on a local data set to optimize the initial global model parameters, wherein 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 the initial global model training; a calculation module, configured to calculate the similarity between the updated global model and the designated client upon receiving the updated model parameters sent by the first target client, wherein the updated model parameters include the updated global model; An aggregation module is used to aggregate the updated global models of the multiple participating clients based on the similarity to obtain a target global model.

[0013] The third aspect of the present application provides a server, including 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 integrating blockchain when executing the computer program.

[0014] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned blockchain-integrated federated learning method.

[0015] In summary, the federated learning method, device, server and storage medium integrated with blockchain provided by the present application obtain an initial global model from a central server through each participating client, and train the initial global model based on the native 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 to eliminate malicious clients among the participating clients based on the similarity, and the updated global models of the remaining good-intentioned clients are aggregated to obtain the target global model, fully considering the impact of malicious clients on the system and preventing malicious clients from destroying model training. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is a system architecture diagram of a federated learning system integrating blockchain shown in an embodiment of the present application; Figure 2 It is a flowchart of a federated learning method integrating blockchain shown in an embodiment of the present application; Figure 3 is a schematic diagram of a cosine similarity calculation method shown in an embodiment of the present application; Figure 4 It is another flowchart of a federated learning method integrating blockchain shown in an embodiment of the present application; Figure 5 It is a functional module diagram of a federated learning device integrating blockchain shown in an embodiment of the present application; Figure 6 It is a structural diagram of a server shown in an embodiment of the present application. DETAILED DESCRIPTION

[0017] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0018] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present invention. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features in the invention can be combined interchangeably without conflicting with each other.

[0019] Reference Figure 1 As shown, it is a system architecture diagram of a federated learning system integrating blockchain shown in an embodiment of the present application.

[0020] The blockchain-integrated federated learning system 1 includes a blockchain system 10 and a federated learning system 20. In the embodiment of the present application, a blockchain system 10 is first established using a smart contract to record model updates and participant reputations in each communication round; then a federated learning system 20 is established to perform collaborative model training in a privacy-preserving manner and provide a reward mechanism to encourage the sharing of more training data. Finally, the blockchain system 10 and the federated learning system 20 are combined in a loosely coupled architecture, where the model is trained in the federated learning system 20 and the intermediate information is transmitted to the blockchain system 10, while taking into account privacy protection, computational and storage costs, 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.

[0021] Reference Figure 2 As shown, it is a flow chart of a federated learning method integrating blockchain shown in an embodiment of the present application, and the federated learning method integrating blockchain includes the following steps.

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

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

[0024] 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 multiple participating clients participating in the initial global model training. When any client initiates global model training, other clients can choose to participate and form multiple participating clients together. Further, each of the multiple participating clients obtains the global model parameters (referred to as the 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 except the local database. Assuming that the global model is a medical model, the local private data can refer to the patient's medical data, and different participating clients can refer to different medical institutions. When the training is initiated for the first time, each participating client sends the corresponding model parameters to the central server, and 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 changed 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.

[0025] Specifically, the central server first sets relevant training parameters according to the requirements of the federated learning task, such as the number of clients participating in model training in each round, the number of times each participating client trains the local data set in each round of local training, and the size of the data set used by each participating client for a local training. 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, and divides the local data set into multiple training test subsets for local training. At each training number, 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 parameters. After the first target client completes the local training, the updated model parameters (called updated model parameters) are uploaded to the central server.

[0026] Among them, the training and updating of the global model are based on the formula , Is a participating client In the The model parameters of the wheel, yes In the dataset During 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.

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

[0028] In order to facilitate the understanding of the inventive concept of the present application, the global model in the embodiment of the present application is explained by taking the 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 to ensure credibility. The medical model includes an input layer, a smoothing layer and a connection layer, and the connection layer includes 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 uses the ReLU activation function at the same time. By introducing nonlinearity, the model is allowed to learn complex data patterns. The second connection layer contains 10 neurons. The input layer accepts a 28×28 pixel image as input data, and the input data is flattened into a 784-dimensional vector through the smoothing layer to obtain a flattened input vector, and finally outputs the classification score of each class as the model output data. During the training process, the medical model of each participating client passes through 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 number of iterations is met. Among them, the mean square error loss function is expressed by the following formula: ; in, N is the sum of the training and testing subsets, RR is the real data in the training and testing subsets, is the corresponding model prediction data result.

[0029] Through the above optional implementation methods, distributed training and optimization of medical models are achieved through federated learning, which effectively utilizes the local private data of each medical institution (participating client), such as patient medical data, without uploading the data to the central server, ensuring data privacy and security. Through the dynamic update and aggregation of global model parameters, the adaptability and generalization ability of the model to global data are improved. At the same time, the use of specific model structures and optimization algorithms, such as ReLU activation function, FedSGD optimizer and mean square error loss function, improves the training efficiency and accuracy of the model. In addition, model training is performed on the corresponding local client, and the training data is only saved in the local database. Only the global model parameters are uploaded to the central server, which can effectively reduce privacy leakage and data security risks.

[0030] S22: When receiving the updated model parameters sent by the first target client, calculate the similarity between the updated global model and the designated client.

[0031] The updated model parameters include the updated global model. The designated client refers to the client that initiated the model training, which is a good-faith client by default. After each participating client completes the training of the initial global model obtained from the central server based on the local database to obtain the updated global model, and sends the updated model parameters carrying the updated global model to the central server, the central server can aggregate based on the received updated model parameters. 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 ,updated global model of the first target client and the ,updated global model corresponding to the specified client.

[0032] The similarity between the first target client and the specified client is determined by the following formula: ; in, is the model gradient of the first target client, is the model gradient of the specified client, for The Euclidean norm of , for The Euclidean norm of , yes and The dot product of .

[0033] S23, aggregating the updated global models of the multiple participating clients based on the similarity to obtain a target global model.

[0034] Among them, multiple participating clients include malicious clients and benign clients. Malicious clients may upload incorrect model parameters in an attempt to disrupt the model training process, while benign clients submit model parameters normally. Furthermore, based on similarity, the central server can selectively weight the updated model parameters of different participating clients, prioritize the aggregation of participating clients with higher similarity to the updated global model of the specified client, and finally generate an updated global model, called the target global model.

[0035] In an optional implementation, aggregating the updated global models of the multiple participating clients based on the similarity to obtain a target global model includes: Determine a second target client set from the multiple participating clients whose similarity is greater than a preset similarity threshold, wherein the second target client set includes multiple second target clients; Determining a target score for the second target client; A weighted average is performed on the multiple updated global models based on the target scores to obtain the target global model.

[0036] In some embodiments, after calculating the similarity between each participating client and the designated client, the central server can compare the similarity with a preset similarity threshold. When the similarity is less than the preset similarity threshold (e.g., 0.7), the corresponding participating client is determined to be a malicious client, and the malicious client is removed from the aggregation process, and the remaining good-intentioned clients are used for aggregation. Next, 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.

[0037] The client score of the second target client in the t+1th communication round is determined by the following formula: ; in, The client score for the second target client in the t+1th communication round, The client score of the tth communication round of the second target client is 0. is the similarity of the tth round of communication of the second target client, It is the data credibility of the second target client in the tth round of communication. The data credibility is comprehensively judged by the data volume and relevance. For example, the larger the data volume, the higher the score; the better the data quality, the higher the score. , , is the weight parameter that controls the influence of each component, .

[0038] 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 the 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: , the weights of the model parameters assigned to each second client are determined based on the target score, .

[0039] Through the above optional implementation, the central server can eliminate malicious clients from multiple participating clients based on similarity, avoiding malicious clients from causing damage during the aggregation process. By introducing similarity evaluation and client scoring mechanisms, malicious clients can be effectively identified and eliminated during the federated learning process, ensuring the accuracy and security of model training. In addition, by comprehensively considering historical scores, similarities, and data credibility to calculate client scores, and using this as a weight for weighted average aggregation, the aggregation quality of the global model is significantly improved. Secondly, the central server can determine whether it is a malicious client by calculating the similarity based on the model gradients of the participating clients obtained, without having to access their local database, thereby ensuring the security of local private data.

[0040] In an optional implementation, 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; comparing the similarity with the flexible control function; When the similarity is greater than the flexible control function, determining the target score based on the similarity, the original score and the data credibility is performed; When the similarity is less than the flexible control function, the similarity is determined to be zero, and the target score is determined based on the original score and the data credibility.

[0041] In some embodiments, in order to improve the accuracy of the model during the aggregation process, the central server can introduce a flexible control function when calculating the client score f(x) , the similarity calculated in step S22 is compared with the flexible control function. When the similarity is greater than the flexible control function, that is, , when calculating the client score, it is also calculated based on the similarity, ; When the similarity is less than the flexible control function, that is, , when calculating the client score, the similarity is set to 0, Among them, the flexible control function , and It is the value range of the custom flexible control function, between -1 and 1. Control the growth rate and determine the steepness of the curve. To control the center point of growth, is a parameter that changes based on the loss value. When the loss value decreases, , when the loss value increases, , It should be noted that the above parameters can be designed according to the needs of the model.

[0042] Through the above optional implementation, by introducing a flexible control function, the calculation method is dynamically adjusted according to the similarity when aggregating scores, thereby improving the accuracy of the model in the aggregation process and enhancing the flexibility and adaptability of the system.

[0043] In an optional embodiment, the method further comprises: Determining the score of the second target client according to the target score; The points are distributed to the second target client.

[0044] Refer to Figure 4 , the central server can set up a reward mechanism to motivate user participation, for example, clarifying which behaviors users can use to earn points, such as participating in federated learning tasks, submitting high-quality data, sharing platform content, etc., and setting corresponding points reward standards based on the difficulty, value and contribution of user behavior to the platform. In the embodiment of the present application, corresponding points are given based on the client score of the participating client, where the client score is proportional to the points, and the higher the client score, the higher the points given.

[0045] In some embodiments, the central server can also build a points redemption platform or module, where users can view their points balance and browse redeemable offers, privileges or other rewards. Points can be used to redeem offers, privileges or other rewards, which can 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.

[0046] Through the above optional implementation methods, user participation can be effectively motivated, user engagement and satisfaction can be improved, and the activity of the platform can be promoted.

[0047] In an optional embodiment, the method further comprises: Encapsulating transaction data using a smart contract pre-deployed in a blockchain network, wherein the transaction data includes the initial global model parameters and the updated global model parameters; Verifying the transaction data using multiple endorsement nodes of the blockchain network; When the transaction data passes verification, generating endorsement information using the endorsement node, and adding the endorsement information to the transaction data; Using the sorting nodes on the blockchain network to package the sorted transaction data into new blocks; Using the sorting node to send the new block to all nodes of the blockchain network for consensus verification; When it is determined that the new block passes the verification, the new block is added to the blockchain network.

[0048] The blockchain network and the participating clients of the joint learning are located in the same network, and the blockchain network includes sorting nodes, verification nodes, endorsement nodes and shared distributed ledgers. 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. In order to ensure the integrity of the transaction and the credibility of the source, the central server can use the private key to sign the transaction data to ensure the integrity of the transaction data and the credibility of the source. Among them, the transaction data may include the initial global model parameters and the updated global model parameters. Then, the transaction data will be endorsed by the endorsement node of the blockchain network. The endorsement node will verify the validity and compliance of the transaction data, including checking whether the transaction format is correct, whether the signature is valid, and whether the data complies with the business rules. If the transaction passes the verification, the endorsement node will generate endorsement information and attach it to the transaction data, where the endorsement information indicates that the endorsement node has recognized the validity of the transaction data. Then the endorsement node sends the verified transaction data to the sorting node, which sorts the transaction data according to chronological order or other rules, and packages the sorted transaction data into a new block. The 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 and other information. Further, the sorting node sends the new block to all nodes in the blockchain network for consensus verification. Among them, the consensus mechanism is a key step in the blockchain network to ensure that all nodes reach a consensus on the new block, which can include proof of work (PoW), proof of stake (PoS), etc. The node 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 node will add it to its own blockchain ledger. Once the new block is added to the blockchain ledger, the status of the entire blockchain will be updated, and the new transaction data will be permanently stored on the blockchain.

[0049] Through the above optional implementation methods, the blockchain network is used to encapsulate, verify, sort, consensus and store the transaction data in the federated learning, which ensures the integrity of the transaction data, the credibility of the source and the non-tamperability, enhances the security and reliability of the federated learning, and provides a decentralized and transparent solution for the storage and verification of transaction data.

[0050] In an optional embodiment, the method further comprises: Acquire malicious clients and a ratio coefficient of the malicious clients, wherein the malicious clients are participating clients whose similarity among the multiple participating clients is less than the preset similarity threshold; The accuracy of the target global model is verified based on the plurality of scale factors.

[0051] In an embodiment of the present application, the similarity between each participating client and the specified client is first calculated based on the model gradient uploaded by each participating client. After the malicious client is eliminated based on the similarity, the updated global model of the remaining participating clients is further aggregated to obtain the target global model. In order to verify the accuracy of the target global model, different scale factors of malicious clients are set, and the accuracy of the target global model is verified under different scale factors. Specifically, the central server can use the 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 is configured for the central server, such as 64GB of memory, NVIDIA RTX 3090 GPU, Intel (R) Xeon (R) Gold 622R CPU and 9TB of hard disk space, and GPU driver and CUDA toolkit are configured to support deep learning calculations. During the global model training process, the global model is trained based on deep learning frameworks such as Tensorflow 2.13.0 and Pytorch2.0.1. During the training process, the MNIST dataset and the Blood MNIST dataset were downloaded from public data sources to ensure the integrity and correctness of the datasets. The MNIST dataset was standardized so that the image pixel values ​​were between 0 and 1, and the Blood MNIST dataset was similarly preprocessed to ensure the consistency of the data format. Then the MNIST and Blood MNIST data were evenly distributed among the participating clients, and the proportion coefficient of malicious clients was set accordingly, ranging from 10% to 40%. In addition, the batch size was set to 128 and the training rounds were set to 100 to observe whether the loss function converged after 100 rounds. Among them, the global model is a neural network model containing an input layer, a smoothing layer, and two fully connected layers. The input layer accepts a 28×28 pixel image, and the smoothing layer flattens it into a 784-dimensional vector. 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.

[0052] By adjusting the different proportional coefficients of malicious clients, the accuracy of the global model is evaluated. Figure 3, when the proportion of malicious clients is 20%, compared with Krum and Trimmed Mean, this application can achieve the highest accuracy, that is, it reduces the adverse effects of malicious client attacks, and is robust and effective. This application can maintain a stable and reliable global model, and is better than the baseline method even in challenging adversarial scenarios. Figure 4 ,When the proportion of malicious clients is 40%, compared to Krum and Trimmed Mean, this application can still achieve the highest accuracy, and as the proportion of malicious clients increases, the accuracy of this application is higher.

[0053] Through the above optional implementations, the deep learning framework of the present application consistently achieves the highest performance on the blood medical dataset, surpassing 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 are often highly variable and noisy. 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 critical.

[0054] Compared with the existing technology, this application initiates a model training application on the local client by a user, and other users choose to participate, and conduct n rounds of federated learning. The training is stopped after the loss function stabilizes. The gradients, user scores and global models of each round are stored on the blockchain. Finally, a converged global model and the scores of each participant will be obtained. In this way, the initiator obtains the model he needs and prevents malicious users from destroying it. In the future, rewards will be given according to the scores of each user.

[0055] Reference Figure 4 , which is a functional module diagram of a federated learning device integrating blockchain shown in an embodiment of the present application.

[0056] In some embodiments, the blockchain-integrated federated learning device 50 may include multiple functional modules composed of computer program segments. The computer programs of each program segment of the blockchain-integrated federated learning device 50 may be stored in the memory of the server and executed by at least one processor to execute (see Figure 1 The function of federated learning of blockchain is integrated into the description. According to the functions performed by it, it can be divided into multiple functional modules. The functional modules may include: a sending module 501, a calculation module 502, an aggregation module 503, a reward module 504, a storage module 505 and a verification module 506. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0057] It should be understood that the various variations and specific embodiments of the federated learning method for integrating blockchains provided in the above embodiments are also applicable to the federated learning device for integrating blockchains in this embodiment. Through the above detailed description of the federated learning method for integrating blockchains, those skilled in the art can clearly understand the implementation method of the federated learning device for integrating blockchains in this embodiment. For the sake of brevity of the specification, it will not be described in detail here.

[0058] The sending module 501 is used to send the 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, the initial global model parameters include the initial global model, and the first target client is any one of the multiple participating clients participating in the initial global model training.

[0059] The calculation module 502 is used to calculate the similarity between the updated global model and the designated client when receiving the updated model parameters sent by the first target client, and the updated model parameters include the updated global model.

[0060] The aggregation module 503 is used to aggregate the updated global models of the multiple participating clients based on the similarity to obtain a target global model.

[0061] The aggregation module 503 is further specifically used to: determine a second target client set whose similarity is greater than a preset similarity threshold from the multiple participating clients, the second target client set including multiple second target clients; determine a target score for the second target client; and perform weighted averaging of the multiple updated global models based on the target score to obtain the target global model.

[0062] The aggregation module 503 is further specifically configured to: determine the original score and data credibility of the second target client; and determine the target score based on the similarity, the original score and the data credibility.

[0063] The calculation module 502 is also used to: determine a flexible control function; compare the similarity with the flexible control function; when the similarity is greater than the flexible control function, determine the target score based on the similarity, the original score and the data credibility; when the similarity is less than the flexible control function, determine the similarity to zero, and determine the target score based on the original score and the data credibility.

[0064] The reward module 504 is used to: determine the points of the second target client according to the target score; and distribute the points to the second target client.

[0065] The storage module 505 is used to: encapsulate 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; verify the transaction data using multiple endorsement nodes of the blockchain network; when the transaction data passes the verification, generate endorsement information using the endorsement node, and add the endorsement information to the transaction data; use the sorting node on the blockchain network to package the sorted transaction data into a new block; use the sorting node to send the new block to all nodes of the blockchain network for consensus verification; When it is determined that the new block passes the verification, the new block is added to the blockchain network.

[0066] The verification module 506 is used to: obtain malicious clients and proportion coefficients of the malicious clients, wherein the malicious clients are participating clients whose similarity is less than the preset similarity threshold among the multiple participating clients; and verify the accuracy of the target global model based on the multiple proportion coefficients.

[0067] See also Figure 6 FIG. 1 is a schematic diagram of the structure of a server according to an embodiment of the present application. In a 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 .

[0068] Those skilled in the art should understand that Figure 6 The structure of the server shown does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure. The server 6 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0069] In some embodiments, the server 6 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The server 6 may also include user equipment, which includes but is not limited to any electronic product that can interact with a user through a keyboard, mouse, remote control, touchpad, or voice control device, such as a personal computer, tablet computer, smart phone, digital camera, etc.

[0070] In the above 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 ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple components or modules can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.

[0071] The components described as separate components may or may not be physically separated, and the components shown as components may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the components may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0072] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each component may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0073] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0074] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0075] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0076] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A federated learning method integrating blockchain, characterized in that: The method comprises: Sending initial global model parameters to a first target client, so that the first target client trains the initial global model based on a local data set to optimize the initial global model parameters, wherein 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 the initial global model training; When receiving the updated model parameters sent by the first target client, calculating the similarity between the updated global model and the designated client, the updated model parameters including the updated global model; The updated global models of the multiple participating clients are aggregated based on the similarities to obtain a target global model.

2. The method for federated learning integrating blockchain according to claim 1, characterized in that: Aggregating the updated global models of the multiple participating clients based on the similarity to obtain a target global model comprises: Determine a second target client set from the multiple participating clients whose similarity is greater than a preset similarity threshold, wherein the second target client set includes multiple second target clients; Determining a target score for the second target client; A weighted average is performed on the multiple updated global models based on the target scores to obtain the target global model.

3. The method for federated learning integrating blockchain according to claim 2, characterized in that: Determining the target score of the second target client includes: Determining the original score 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 method for federated learning integrating blockchain according to claim 3 is 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; comparing the similarity with the flexible control function; When the similarity is greater than the flexible control function, determining the target score based on the similarity, the original score and the data credibility is performed; When the similarity is less than the flexible control function, the similarity is determined to be zero, and the target score is determined based on the original score and the data credibility.

5. The method for federated learning integrating blockchain according to claim 2, characterized in that: The method further comprises: Determining the score of the second target client according to the target score; The points are distributed to the second target client.

6. The method for federated learning integrating blockchain according to any one of claims 1 to 5, characterized in that: The method further comprises: Encapsulating transaction data using a smart contract pre-deployed in a blockchain network, wherein the transaction data includes the initial global model parameters and the updated global model parameters; Verifying the transaction data using multiple endorsement nodes of the blockchain network; When the transaction data passes verification, generating endorsement information using the endorsement node, and adding the endorsement information to the transaction data; Using the sorting nodes on the blockchain network to package the sorted transaction data into new blocks; Using the sorting node to send the new block to all nodes of the blockchain network for consensus verification; When it is determined that the new block passes the verification, the new block is added to the blockchain network.

7. The method for federated learning integrating blockchain according to any one of claims 1 to 5, characterized in that: The method further comprises: Acquire malicious clients and a ratio coefficient of the malicious clients, wherein the malicious clients are participating clients whose similarity among the multiple participating clients is less than the preset similarity threshold; The accuracy of the target global model is verified based on the plurality of scale factors.

8. A federated learning device integrating blockchain, characterized in that: The device comprises: A sending module, configured to send initial global model parameters to a first target client, so that the first target client trains the initial global model based on a local data set to optimize the initial global model parameters, wherein 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 the initial global model training; a calculation module, configured to calculate the similarity between the updated global model and the designated client upon receiving the updated model parameters sent by the first target client, wherein the updated model parameters include the updated global model; An aggregation module is used to aggregate the updated global models of the multiple participating clients based on the similarity to obtain a target global model.

9. A server, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the federated learning method for integrating blockchains described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the federated learning method of the integrated blockchain described in any one of claims 1 to 7 are implemented.

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