Blockchain federated learning method based on round-based updating and client weight optimization
By using a blockchain federated learning framework, evaluating high-quality clients with loss values, and employing round-based training, the problems of low efficiency and poor security in traditional federated learning are solved, achieving efficient and secure global model training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-06
- Publication Date
- 2026-03-24
AI Technical Summary
Traditional federated learning frameworks are inefficient, vulnerable to single-point attacks, and their data is easily tampered with. The synchronous learning method causes fast-training clients to wait for slow-training clients, which affects efficiency.
We adopt a blockchain federated learning method based on round-based updates and client weight optimization. The blockchain provides data anti-tampering resistance, the loss value decreases to evaluate the quality of client contributions, selects high-quality clients for training, and collects local models for aggregation at regular intervals.
It improves the efficiency of global learning and training, reduces client waiting time, enhances the robustness of the framework and data security, and prevents data tampering.
Smart Images

Figure CN116484978B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning, and in particular to a blockchain federated learning method based on round-based updates and client weight optimization. Background Technology
[0002] Deep learning is a machine learning technology that has emerged in recent years. By using different models to learn from a given dataset, deep learning frameworks can identify patterns and features in the data, extract useful information, and are widely used in natural language generation, speech recognition, object detection, data mining, and data prediction. With the continuous development of the Internet and IoT technologies, the data from sensors, terminal devices, and servers is growing exponentially. Deep learning on a single device faces problems such as insufficient hardware resources, long training times, low efficiency, and poor results. These problems have spurred the development of distributed learning. Distributed learning distributes the specified learning task across many devices. Each device uses a portion of the dataset to train locally. After training, a server integrates the training results from each device to collectively train a single model.
[0003] Federated learning, as a learning paradigm similar to distributed learning, has its own application scenarios. Like distributed learning, it distributes learning tasks to many clients, allowing them to train locally and then integrates the trained models. However, unlike distributed learning, clients use their own datasets, and the clients participating in federated learning can be various types of devices. The goal of federated learning is to coordinate these different devices to complete training using their own datasets and integrate their models to learn a large global model. Therefore, federated learning needs to consider the heterogeneity of the devices' systems and data during training, while also protecting the privacy of user data during transmission.
[0004] Current federated learning frameworks still suffer from efficiency and security issues. In terms of efficiency, traditional federated learning frameworks use random sampling of participating clients, selecting clients randomly without considering their configuration information and learning capabilities. This results in clients with low learning capabilities participating in the learning process, slowing down the overall learning speed. Simultaneously, because traditional federated learning frameworks use a synchronous learning mode, faster-training clients must wait for slower-training clients, which also reduces efficiency to some extent. In terms of security, the central server of federated learning is vulnerable to attacks, potentially causing the overall training process to stall, and the server's data is also at risk of being tampered with.
[0005] Therefore, those skilled in the art are dedicated to developing a blockchain federated learning framework based on round-based updates and client weight optimization. Summary of the Invention
[0006] In view of the above-mentioned defects of the prior art, the technical problem to be solved by the present invention is that the traditional federated learning randomly selects clients for training, resulting in low efficiency. In addition, the traditional federated learning framework adopts a synchronous learning method, and the faster training clients need to wait for the slower training clients to finish training, which reduces efficiency due to waiting time. Finally, the central server of the traditional federated learning framework is vulnerable to attack, causing a single point of failure, and the data stored in it is also easy to be tampered with.
[0007] To achieve the above objectives, this invention provides a blockchain federated learning method based on round-based updates and client weight optimization, characterized by the following steps:
[0008] S1: Obtain the first global model set from the blockchain. The client performs local training on the first global model set to generate a trained local model.
[0009] S2: The client performs aggregation locally based on the trained local model and calculates the test loss value; based on the test loss value, it obtains the difference in loss value when it did not participate in this round of training;
[0010] S3: Obtain the first parameter based on the difference in the loss values to filter the clients, collect the local models trained by the filtered clients at certain time slots, generate an aggregated model, and upload it to the blockchain;
[0011] S4: Repeat the above training steps until the global model converges or the preset number of training rounds is reached.
[0012] Furthermore, the method for obtaining the first parameter in step S3 is as follows:
[0013] The weights are calculated based on the difference in loss values during the training history of each client, and the probability of each client being selected to participate in the current training is calculated based on the weights.
[0014] Furthermore, in step S3,
[0015] Before generating the aggregated model, a determination is made as to whether to generate the aggregated model based on whether the number of local models reaches a certain proportion of the total number of all clients.
[0016] Furthermore,
[0017] The first global model set is updated based on the aggregated model uploaded to the blockchain.
[0018] Furthermore, the loss difference calculation yields the client's contribution evaluation index. The weights are calculated from the contribution evaluation indicators and then updated.
[0019] Furthermore,
[0020] The client's contribution evaluation metrics The calculation method is as follows:
[0021]
[0022] in To indicate whether client i is selected to participate in learning during the Rth round of training, set to 1 if yes and 0 otherwise;
[0023] This represents the probability that client i is selected in the Rth round of training; The difference in loss values calculated for client i during the training phase.
[0024] Furthermore,
[0025] Weight per client The update formula is:
[0026]
[0027] Where η is the learning rate and θ is the correction factor. Size correction factor, w i All values were set to 1 during the first round of training.
[0028] The probability of the client being selected The calculation method is as follows:
[0029]
[0030] Where K is the total number of clients and C is the selection ratio of clients.
[0031] Furthermore,
[0032] The difference in the loss value is:
[0033]
[0034] L′ is the loss value on the temporary model after aggregation. R This is the loss value obtained during the training of the first global model set in the previous round of training.
[0035] Furthermore,
[0036] In step S1, the clients are selected to participate in the training of the first global model set based on the probability of being selected in the previous round of training.
[0037] Furthermore,
[0038] The process of obtaining the first global model set from the blockchain is as follows:
[0039] Download the latest first global model set from the blockchain and distribute it to the selected clients.
[0040] Technical effect
[0041] This invention uses the loss value reduction value as an indicator to select high-quality clients for training, thereby improving the learning quality of the selected clients, which can improve the overall learning and training efficiency, improve the overall efficiency of each round of learning, and thus improve the learning efficiency of the framework.
[0042] This invention employs a round-based update training method, which reduces client waiting time. It uses a compromise between synchronous and asynchronous updates, collecting the trained local model from the client at regular intervals, thereby reducing global waiting time, lowering training waiting time, and improving framework efficiency.
[0043] This invention combines federated learning with blockchain. Due to its characteristics, blockchain can provide data with tamper resistance and a certain degree of privacy protection, preventing data from being tampered with.
[0044] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating one implementation of the blockchain federated learning method based on round-based updates and client weight optimization according to the present invention.
[0046] Figure 2 This is a flowchart illustrating another implementation of the blockchain federated learning method based on round-based updates and client weight optimization according to the present invention. Detailed Implementation
[0047] The following description, with reference to the accompanying drawings, illustrates several preferred embodiments of the present invention to make its technical content clearer and easier to understand. The present invention can be embodied in many different forms, and the scope of protection of the present invention is not limited to the embodiments mentioned herein.
[0048] In the accompanying drawings, components with the same structure are indicated by the same numerical designation, and components with similar structures or functions are indicated by similar numerical designations. The dimensions and thicknesses of each component shown in the drawings are arbitrary, and the present invention does not limit the dimensions and thicknesses of each component. To make the illustrations clearer, the thickness of some components has been appropriately exaggerated in the drawings.
[0049] This invention discloses a blockchain-based federated learning method based on round-based updates and client weight optimization. Traditional federated learning suffers from vulnerabilities to single-point attacks, long synchronization wait times, and low efficiency. This invention integrates blockchain into the traditional federated learning framework, making the framework resistant to single-point attacks and ensuring that uploaded model data is not easily tampered with, thus improving the framework's robustness. The client selection algorithm uses the decrease in loss value contributed by the client's uploaded model as an indicator to evaluate the client with the best learning quality, increasing their probability of being selected during model training, thereby improving overall learning efficiency. The round-based training method uses a periodic collection of local models from clients, reducing the waiting time caused by synchronous training, which also improves the framework's efficiency. Overall, this framework uses a blockchain-based federated learning method based on round-based updates and client weight optimization, improving the robustness and efficiency of traditional federated learning frameworks.
[0050] like Figure 1-2 As shown, the present invention includes the following steps:
[0051] Step 1: Calculate the weight based on the historical loss decrease value of each client, and use this as the basis to calculate the probability of each client being selected to participate in this round of learning.
[0052] Step 2: Select clients to participate in learning based on their selection probability.
[0053] Step 3: Download the latest global model from the blockchain and send it to all participating clients for local training.
[0054] Step 4: The client performs local training. After training, it aggregates the model locally and tests the loss value. After testing, the client returns the difference between the trained local model and the test loss value and the loss value of the global model when it did not participate in this round of training, so as to calculate the weights and selection probabilities later.
[0055] Step 5: Collect local models from clients in time slots. After a period of training, begin collecting and aggregating the local models sent by the trained clients. If the number of these models is insufficient to reach a proportion of the total number of clients, continue waiting until the number of models is sufficient. After aggregation, upload the models to the blockchain, and this round of training ends.
[0056] Step 6: Repeat the above training steps until the global model converges or reaches the preset number of training rounds.
[0057] The specific steps described above are explained below:
[0058] Step 1: Calculate the weights based on the loss reduction value contributed by the client. Let the current round be R, and the loss difference calculated by the client during the training phase be... Then calculate the client's contribution evaluation metrics. The formula is:
[0059]
[0060] in This indicates whether client i was selected to participate in learning in the Rth round; 1 indicates yes, 0 indicates no. This represents the probability that client i is selected in the R-th round. The weights used to calculate the probability for each client are... The update formula is:
[0061]
[0062] Where η is the learning rate and θ is the correction factor. Size correction factor, w i All values were set to 1 during the first round of training. The probability of a client being selected. Then it is given by the following formula:
[0063]
[0064] Where K is the total number of clients and C is the selection ratio of clients.
[0065] Step 2: Use the probabilities calculated in the previous step to select clients and have them participate in learning.
[0066] Step 3: Download the latest global model from the blockchain and distribute it to the client for local training.
[0067] Step 4: After local training is complete, the client temporarily aggregates a global model. This model does not affect the actual global model; it is only used to test the loss value. Let the loss value on this temporary model be... The loss value of the previous global model is L′ R The loss decreases. The calculation formula is:
[0068]
[0069] Step 5: Collect local model and loss reduction data from clients in time slots. After a period of training, begin collecting and aggregating the local models sent by the trained clients. If the number of these models is insufficient to reach a proportion of the total number of clients, continue waiting until the number of models is sufficient. After aggregation, upload the models and data to the blockchain, and this round of training ends.
[0070] Step 6: Repeat the above training steps until the global model converges or reaches the preset number of training rounds.
[0071] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A blockchain federated learning method based on round-based updates and client weight optimization, characterized in that, The method includes the following steps: S1: Obtain the latest first global model set from the blockchain and distribute it to the selected client; the client performs local training on the first global model set to generate a trained local model; S2: The client performs aggregation locally based on the trained local model and calculates the test loss value; The difference in loss values between the test loss values and the values not used in this training round is obtained based on the test loss values. ; Through the difference of the loss value Calculate and obtain the contribution evaluation index of the client. The contribution evaluation indicators Calculate and update the weights; wherein, the contribution evaluation metric of the client. The calculation method is as follows: in To indicate whether client i is selected to participate in learning during the Rth round of training, set to 1 if yes and 0 otherwise; This represents the probability that client i is selected in the Rth round of training; The difference in loss values calculated for client i during the training phase; S3: Based on the updated weights from the training of each client's historical experience, calculate the probability that each client will be selected to participate in the current training, and use the probability as the first parameter to filter the clients; collect the local models trained by the filtered clients at certain time slots; if the number of collected local models reaches a preset proportion of the total number of all clients, generate an aggregate model and upload it to the blockchain. S4: The first global model set is updated based on the aggregated model uploaded to the blockchain; the above training steps are repeated until the global model converges or the preset number of training rounds is reached.
2. The blockchain federated learning method based on round-based updates and client weight optimization as described in claim 1, characterized in that, Weight per client The update formula is: in For learning rate, To correct Size correction factor, All values were set to 1 during the first round of training. The probability of the client being selected The calculation method is as follows: in The total number of clients This refers to the selection ratio for the client.
3. The blockchain federated learning method based on round-based updates and client weight optimization as described in claim 2, characterized in that, The difference in the loss value is: The loss value is the value applied to the temporary model after aggregation. This is the loss value obtained during the training of the first global model set in the previous round of training.
4. The blockchain federated learning method based on round-based updates and client weight optimization as described in claim 2, characterized in that, In step S1, the clients are sorted according to the probability of being selected in the previous round of training and then selected to participate in the training of the first global model set.
Citation Information
Patent Citations
Federated learning toilet vehicle attack defense method based on block chain
CN112714106A
Federal learning method and device
CN114091356A