A blockchain-based data model detection method

By employing a device selection algorithm based on reputation and user participation, a malicious model identification algorithm based on a DAG blockchain network, and a weighted aggregation algorithm in a fog computing environment, the problems of decreased model accuracy and slowed convergence speed caused by security and Non-IID data in federated learning are solved, achieving efficient and secure global model updates and sharing.

CN116647388BActive Publication Date: 2025-11-04CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310633143.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-31
Publication Date
2025-11-04
Estimated Expiration
2043-05-31

AI Technical Summary

Technical Problem

In fog computing environments, federated learning suffers from security issues due to reliance on a central server and decreased model accuracy and slower convergence speed due to Non-IID data.

Method used

A device selection algorithm based on reputation value and user participation is adopted, combined with DAG blockchain network for malicious model identification and weighted aggregation. High-reputation devices are selected through reputation value and user participation, global models are stored using DAG blockchain, and the weighted aggregation algorithm is used to improve model accuracy and training efficiency.

Benefits of technology

It improves the security and training efficiency of federated learning, solves the problems of decreased model accuracy and slowed convergence speed in Non-IID data scenarios, and ensures efficient updates and secure sharing of global models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116647388B_ABST
    Figure CN116647388B_ABST
Patent Text Reader

Abstract

The application relates to a blockchain-based data model detection method and belongs to the technical field of mobile communication. Firstly, the security and efficiency of a shared global model between fog nodes are ensured through a blockchain network. Secondly, a device selection algorithm based on a reputation value and user participation is proposed, and IoT device IDs participating in training are selected through the reputation value and the user participation. Thirdly, a malicious model identification algorithm based on an outlier value is proposed, the identification rate of a malicious node in a Non-IID data scene is improved, and thus the security of learning is ensured. Then, a weighted aggregation federated learning algorithm is adopted, different aggregation weights are allocated to different local models, and the training efficiency of the federated learning is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of mobile communication, and relates to a data model detection method based on a block chain. BACKGROUND

[0002] With the wide popularity of IDs such as smart phones, smart watches and various sensors, a large amount of data will be generated in real time. At the same time, with the continuous innovation of machine learning technology, machine learning technology based on large-scale data mining has become an important means to apply these massive data. Machine learning technology can be used for massive data processing to meet people's demand for more intelligent and personalized services. However, with the increasing awareness of users and institutions in data security and privacy protection, they are reluctant to share their own data, thus forming a "data island" problem.

[0003] In view of the challenges faced by the above-mentioned traditional machine learning, a new distributed learning algorithm-federated learning is currently proposed. Federated learning allows multiple IDs to collaboratively train a shareable global model using local data sets, and then a central server updates the global model by aggregating all local model parameters, thereby realizing user privacy protection. Specifically, the federated learning process mainly includes three steps. First, all IDs participating in the federated learning task download the global model from the central server. Then, the IDs train and update the global model using the local data set to generate a local model for each ID. Finally, the IDs upload the local model to the central server, and the central server aggregates all the collected local models to update the global model. Repeat the above steps until the global model accuracy reaches the target accuracy.

[0004] However, the current federated learning in fog computing completely depends on the central server in the process of global model updating and storage, which is prone to single point failure or targeted attack and other security problems. At the same time, in the highly open fog computing environment, the discrete deployment of fog nodes and the high uplink and downlink information exchange will cause great threat to the data security and privacy of IDs. At present, as a distributed data ledger that provides a secure and trusted mechanism, the block chain technology has the characteristics of multi-centralization, smart contract, multi-party maintenance and non-tamperability, which is highly consistent with the distributed architecture of federated learning. Therefore, the combination of federated learning and block chain technology in fog computing has become a hot research topic in the current academic field.

[0005] However, in federated learning, the central server cannot access the local data sets of the IDs, and the statistical distribution and size of the local data sets are different between different IDs, so that the local data of the IDs is Non-IID. In the Non-IID data scene, the traditional federated learning algorithm has problems such as decline of global model accuracy and slow convergence speed. In view of the above problems, the embodiment of the present application proposes a data model detection method based on a blockchain under a fog computing architecture, which improves the security and training efficiency of federated learning. SUMMARY

[0006] Therefore, the purpose of the present application is to provide a data model detection method based on a blockchain. This method can effectively solve the problem of model accuracy decline caused by malicious model detection and Non-IID data in the federated learning model aggregation process.

[0007] To achieve the above purpose, the present application provides the following technical solutions:

[0008] A data model detection method based on a blockchain, the method comprising the following steps:

[0009] S1: selecting equipment based on reputation value and user participation;

[0010] S2: identifying malicious models based on outliers;

[0011] S3: federated learning weighted aggregation;

[0012] S4: federated learning based on DAG blockchain;

[0013] In S1, IDs with a certain reputation value are selected in combination with user participation to solve the problem of global model overfitting;

[0014] In S2, the distance between each layer of neural network parameters of all local models and the corresponding layer of neural network parameters of the global model is evaluated, and the outlier of the distance of each layer of neural network is found by using the box plot method to screen malicious models;

[0015] In S3, the local model weighted weight is obtained based on the angle between the local model gradient and the global model gradient, and the accuracy of the local model;

[0016] In S4, the DAG blockchain is used to store the global model generated by the fog node, wherein the fog node is a DAG blockchain node, and the ledger information of the DAG blockchain network is stored. First, FN k selects IDs participating in federated learning based on reputation value and user participation, then selects Tips in the local DAG blockchain based on transaction selection TS algorithm, and updates the global model by using federated average FedAvg algorithm and broadcast it to selected IDs, which use local data to train the received model locally; IDs upload the local model to FN k after training, FN k filters out normal models through the outlier-based malicious model identification algorithm, and aggregates the normal models to obtain a new global model using the federated learning weighted aggregation algorithm FN k then encapsulates the model and the digital signature Sig k into a block S k and publishes it to the DAG blockchain network. The specific format of the block is shown in equation (1):

[0017]

[0018] where H is the hash value of the entire block; V k is the hash value vector of the verified Tips; c k is a proof-of-work parameter with less computational power requirement; and Q is the weight vector of the block, including its own weight and cumulative weight.

[0019] Optionally, in the DAG blockchain, a fog computing architecture is established, which is composed of a task publisher, an external agent, fog nodes, and IDs. Assume that there are K fog nodes in the network, denoted as K = {1,..., k,..., K}. Assume that there are M IDs under each fog node, denoted as M = {1,..., m,..., M}, and the corresponding training data set is denoted as D = {D1,..., D m ,..., D M}. ID m trains a local model based on the data set D m , and uploads the model to the fog node after training for global aggregation. When the accuracy of the global model meets the requirements, the global model is returned to the task publisher.

[0020] The task publisher publishes a task through an external agent, and the fog node selects IDs that meet the training conditions to participate in the training task using a device selection algorithm based on reputation value and user engagement after receiving the task. The entire training process includes the following four steps:

[0021] S41: Training task publishing; the task publisher broadcasts the training task including task requirements and an initial model to the fog node through the external agent, the fog node publishes the task requirements to the IDs belonging to it, and the IDs that meet the requirements send data information containing their identities to the fog node. The fog node selects some IDs to participate in the training task using a device selection algorithm based on reputation value and user engagement, and sends the initial model to the selected IDs. The IDs receive the model and perform local training using the local data set.

[0022] S42: The fog node performs malicious model identification and global aggregation; after the IDs complete local training, upload the local model to the fog node to which it belongs; the fog node collects the model and uses an outlier-based malicious model identification algorithm to identify malicious models in the uploaded local model and update the number of times the IDs upload malicious models; then the fog node uses a federated learning weighted aggregation algorithm to calculate the weight of each model after screening the normal model, and then performs global aggregation to update the global model;

[0023] S43: Update task participants; after the fog node performs multiple rounds of global training, update the reputation value of the IDs based on the model attributes uploaded by the IDs, and then use a device selection algorithm based on the reputation value and user engagement to update the IDs participating in the training task;

[0024] S44: Update the DAG blockchain network; after the fog node generates a new global model, package the model into a block and publish it to other fog nodes in the DAG blockchain network through broadcasting; after receiving the broadcasted new block, the fog node updates the local DAG blockchain copy and uses the transaction selection TS algorithm to select some Tips from it to extract the global model parameters stored therein for aggregation to obtain a new global model; the fog node distributes the new global model to the IDs belonging to it for a new round of global training; repeat S41-S44 until the global model accuracy meets the target requirement.

[0025] Optionally, the calculation method of the reputation value is specifically:

[0026] First, the fog node selects IDs participating in the training task according to the reputation value and user engagement of the IDs; the reputation value and user engagement of the IDs are updated every T rounds of global training, and the IDs are reselected according to the updated reputation value and user engagement; wherein the reputation value updating process is as follows:

[0027] First, in T rounds of global training, the FN k trains a local model based on the ID m The reputation evaluation is as shown in formula (2);

[0028]

[0029] In the formula, b k→m ,d k→m ,u k→m respectively represent trust, distrust and uncertainty, and b k→m +d k→m +u k→m = 1, wherein b k→m ,d k→m ,u k→m ∈ [0, 1], which is represented as formula (3) based on the subjective logic model;

[0030]

[0031] where q k→m represents the probability of successful data transmission; κ,η represent the weights of normal model and malicious model respectively and η+κ=1 and η≤κ; α k ,β k are the number of normal model and malicious model uploaded by ID m during T rounds of global training, where α k +β k =T; the reputation evaluation of ID m is shown in formula (4):

[0032] T k→m = b k→m +au k→m (4) where a∈[0,1] represents the degree of uncertainty affecting reputation; the reputation value of ID m in the t+1 round is shown in formula (5):

[0033] T k→m (t+1) = λ × T k→m (t) + r × T k→m (5)

[0034] where λ and r are the decay weight of historical reputation value and the weight of current reputation value respectively;

[0035] Secondly, the device selection algorithm based on reputation value and user engagement selects IDs participating in training by jointly considering the reputation value and user engagement of IDs, and models the problem as shown in formula (6):

[0036]

[0037] s.t.C1

[0038] C2: T k→m (t+1) ≥ T min

[0039] C3:

[0040] where is a binary indicator, represents that ID m is selected by FN k to participate in federated learning task, otherwise β is the control parameter of the importance trade-off between reputation value and user engagement; constant P is used to map the reputation value T k→m (t+1) to the same range as C m ; C muser engagement of ID m; N represents the maximum number of selected IDs; constraint condition C1 represents that the maximum number of selected IDs cannot exceed N; constraint condition C2 represents a pre-defined ID reputation value threshold T min different threshold values are set according to different security requirements; constraint condition C3 represents , and the value of is 0 or 1, and the solution is obtained by a greedy algorithm: first, a set satisfying the constraint condition C2 is established, then the utility of all IDs in the set is calculated by using the greedy algorithm, the utility value is obtained according to the objective function, and finally, N IDs with large utility in the set are selected, and the set is L = {1,..., l,..., L}, L ≤ M and L ≤ N.

[0041] Optionally, the malicious model is:

[0042] First, in the t+1th round, FN k receives the local model where L is the number of IDs selected by FN k to participate in training, and then the distance between the i th layer of the local model of ID l and the i th layer of the global model is calculated based on formula (7);

[0043]

[0044] Then, the first quartile, the median, the third quartile, the minimum observation value and the maximum observation value of the distances of all local models in the same layer are calculated; the distance exceeding the minimum observation value and the maximum observation value is determined as an outlier; if the distance of the i th layer of ID l is not an outlier, then OS(d il ) = True, and when OS(d 1l ),...,∧OS(d il )∧,...,∧OS(d Il ) = True, the model of ID l is marked as a normal model, where I is the number of layers of the neural network; finally, the set of normal models participating in global aggregation is

[0045] Optionally, the federated learning weighted aggregation algorithm is:

[0046] First, based on the angle θ l (t+1) quantifies the efficiency of the local model uploaded by ID l in the t+1th round to the global aggregation, which is defined as formula (8);

[0047]

[0048] In the formula, is the global model gradient in the t+1th round, which is the global model average gradient calculated by FedAvg algorithm, and its calculation is shown in equation (9);

[0049]

[0050] In the federated learning weighted aggregation algorithm, the angle θ l (t+1) is smaller, which means that the local gradient is more similar to the global gradient , thereby having greater efficiency for global aggregation; when θ l (t+1) is larger, for example, greater than π / 2, the local gradient has an opposite direction to the global gradient, reducing the efficiency of global aggregation;

[0051] Secondly, in the federated learning weighted aggregation algorithm, in order to suppress the angle θ l (t+1) of each round due to randomness, the average angle (in radians) is used to replace θ l (t+1), which is defined as shown in equation (10);

[0052]

[0053] The size of depends on the Non-IID degree of the local data set of ID, and the greater the Non-IID degree , the greater the value of;

[0054] Finally, the local model aggregation weight of ID l is calculated by the average angle and the model accuracy, which is specifically calculated as shown in equation (11):

[0055]

[0056] In the formula, is the Gompertz function, where α is a constant; p l is defined as shown in equation (12);

[0057]

[0058] In the formula, a l represents the local model accuracy uploaded by ID l;

[0059] Finally, the global aggregation is performed using equation (13) to obtain the updated global model;

[0060]

[0061] Optionally, S44 specifically includes:

[0062] S441: First, FN k selects IDs to participate in federated learning training. Then, FN k uses the TS algorithm to select Tips in the local DAG blockchain replica, that is: FN k randomly selects Tips from the local DAG blockchain replica within the aging range τ using the TS algorithm. max Internal Tips, τ max This refers to the difference between the time the transaction was generated and the current time; some tips do not exceed α.

[0063] S442: FN k first verifies the completeness and validity of the data in the Tips selected in S441; FN k extracts the global model parameters from the selected Tips and uses the test dataset to test the accuracy of the model;

[0064] S443: FN k aggregates the global models stored in the c most accurate Tips from S442 using the FedAvg algorithm, where c ≤ α and c ≥ 2, to obtain a new global model. FN k will obtain the global model The system broadcasts to selected IDs for local training. After local training is complete, FNk collects the local models trained on the IDs, then uses an outlier-based malicious model identification algorithm to filter out malicious models, and finally uses a federated learning weighted aggregation algorithm on the normal models to obtain a new global model.

[0065] S444: FN k utilizes the global model aggregated by S443 A new block is constructed, and the information contained in the block is shown in Equation (1), where the parent block verified by the new block is the c Tips selected by S442; then, the new block FN k is broadcast to other fog nodes. After receiving the new block, the other fog nodes verify the data integrity of the block and add it to their local DAG blockchain replica.

[0066] FN k completes one iteration of the federated learning algorithm based on the DAG blockchain; repeats S441 to S444 until the global model accuracy stored in the DAG blockchain network reaches the target accuracy, and returns the target model to the task issuer;

[0067] The specific implementation steps of federated learning are as follows:

[0068] S201: Algorithm initialization;

[0069] S202: Fog nodes select IDs to participate in federated learning based on reputation value and user engagement;

[0070] S203: After the IDs receive the training task issued by the fog node, the training is started, and the local model trained is uploaded to the fog node after the training is completed;

[0071] S204: After the fog node collects the local model trained by the IDs, the normal local model is screened out by using the outlier-based malicious model identification algorithm;

[0072] S205: The fog node uses the weighted aggregation algorithm to perform global aggregation on the screened normal local model, and updates the global model;

[0073] S206: After a certain number of global training, the fog node reselects the IDs participating in federated learning based on the reputation value and user participation degree;

[0074] S207: Determine whether the accuracy of the global model generated by the fog node in the network meets the target requirement;

[0075] S208: When the accuracy of the global model generated by the fog node in the network does not meet the requirement, the fog node publishes the current generated global model to the DAG block chain network, selects part of the global model from the network for aggregation, updates the global model, and publishes the new global model to the IDs for training;

[0076] S209: End.

[0077] The beneficial effects of the present application are:

[0078] Firstly, a fog computing architecture based on DAG block chain is proposed. In the architecture, the task publisher publishes the learning task to the fog node through the external agent, and the fog nodes share the global model by maintaining the DAG block chain network. The fog node aggregates the local model uploaded by the IDs, and then packs the obtained global model into a block and uploads it to the DAG block chain network. Then, the fog node obtains the latest global model from the DAG block chain network to aggregate the new global model, and issues the new global model to the IDs for local training.

[0079] Secondly, in view of the low local model accuracy in the Non-IID scene, the accuracy of the global model is reduced, and the convergence speed is slowed down. The device selection algorithm based on reputation value and user participation degree is proposed. The fog node calculates and updates the reputation value of the IDs according to the quality of the local model uploaded by the IDs. After a certain number of global training, the fog node reselects the IDs participating in the training according to the reputation value and the user participation degree (i.e. the number of global training rounds participating in federated learning in this task), thereby reducing the influence of device selection on federated learning and improving the training efficiency of federated learning.

[0080] Thirdly, in order to further improve the training efficiency of federated learning in the Non-IID data scene, the federated learning weighted aggregation algorithm is adopted, the similarity of local model gradient update and global model gradient update is calculated, and the accuracy of the local model is obtained The weight of each local model is then updated by weighted aggregation to update the global model.

[0081] Finally, in order to ensure the security and efficiency of the global model shared among the fog nodes, the DAG blockchain network is used to share and store the global model generated by the fog nodes.

[0082] Other advantages, objects, and features of the application will be set forth in part by the description that follows, and in part will become apparent to those skilled in the art upon examination of the following specification or can be learned by practice of the application. The objects and other advantages of the application can be realized and attained by the methods and instrumentalities described below. BRIEF DESCRIPTION OF DRAWINGS

[0083] In order to make the objects, technical solutions and advantages of the present application clearer, the preferred detailed description of the present application will be combined with the drawings as follows, wherein:

[0084] Figure 1 is a system model diagram;

[0085] Figure 2 is a federated learning flowchart based on DAG blockchain. DETAILED DESCRIPTION

[0086] The embodiments of the present application are described below through specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the disclosure of the present specification. The present application can also be implemented or applied by different specific embodiments, and the details in the specification can be modified or changed based on different views and applications without departing from the spirit of the present application. It should be noted that the diagrams provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and the following examples and features in the examples can be combined with each other without conflict.

[0087] Wherein, the drawings are only used for illustrative description, and the representation is only a schematic diagram, not a physical diagram, and cannot be understood as a limitation of the present application; in order to better illustrate the embodiments of the present application, some components of the drawings are omitted, enlarged or reduced, and do not represent the size of the actual product; for those skilled in the art, it is understandable that some known structures and their descriptions in the drawings can be omitted.

[0088] The same or similar reference numerals in the drawings of the embodiments of the present application correspond to the same or similar components; in the description of the present application, it is understood that if the orientations or positional relationships indicated by the terms "upper", "lower", "left", "right", "front", "back" and the like are based on the orientations or positional relationships shown in the drawings, they are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, therefore the terms describing the positional relationship in the drawings are only used for exemplary illustration, and cannot be understood as a limitation on the present application, for those skilled in the art, the specific meanings of the above terms can be understood according to the specific circumstances.

[0089] The implementation process of the present application includes the following steps:

[0090] S1: device selection algorithm based on reputation value and user participation degree;

[0091] S2: malicious model identification algorithm based on outliers;

[0092] S3: federated learning weighted aggregation algorithm;

[0093] S4: federated learning algorithm based on DAG block chain;

[0094] In step S1, in order to reduce the influence of Non-IID data on the training efficiency of federated learning, while ensuring the security of the federated learning process, the security of federated learning is ensured by selecting IDs with high reputation value, and the over-participation of high-reputation IDs is solved by combining user participation degree, which solves the problem of global model overfitting caused by over-participation of high-reputation IDs.

[0095] In step S2, due to the discrete distribution of IDs participating in federated learning training, federated learning is prone to malicious attacks during the training process, such as data poisoning attacks and model poisoning attacks. In the Non-IID scenario, when there is no malicious attack and the global model converges, the difference between the local model parameter distribution and the global model parameter distribution is small. However, when there is a malicious attack, the difference between the local model parameter distribution and the global model parameter distribution is large. The present application finds the outliers of the distance of each layer of neural network by evaluating the distance between each layer of neural network parameters of all local models and the corresponding layer of neural network parameters of the global model, and screening malicious models by using the box plot method.

[0096] In step S3, the local model quality difference caused by not considering the Non-IID data in the federated learning training process leads to a low-quality model having a larger aggregation weight, thereby causing the global model accuracy to be reduced and the convergence speed to be slowed down. Based on the angle between the local model gradient and the global model gradient and the accuracy of the local model, the local model weighting weight is obtained. Based on the weighted aggregation strategy, the global model accuracy and the convergence speed can be improved.

[0097] In step S4, in order to ensure the security and efficiency of the global model shared between the fog nodes. The algorithm stores the global model generated by the fog nodes in the DAG blockchain, wherein the fog nodes are nodes of the DAG blockchain, and store the ledger information of the DAG blockchain network. First, FN k selects IDs participating in federated learning based on reputation value and user participation, then selects Tips in the local DAG blockchain based on the transaction selection (TS) algorithm, updates the global model by using the federated averaging (FedAvg) algorithm and broadcasts it to the selected IDs, and the IDs perform local training on the received global model. The IDs upload the local model to FN k after completing the training, FN k filters out normal models by using the malicious model identification algorithm based on outlier value, and aggregates the normal models by using the federated learning weighted aggregation algorithm to obtain a new global model FN k then encapsulates the model and the digital signature Sig k into a block S k and publishes it to the DAG blockchain network. The specific format of the block is shown in formula (1).

[0098]

[0099] In the formula, H is the hash value of the entire block; V k is the hash value vector of the verified Tips; c k is a proof-of-work parameter with less computing power requirement; and Q is the weight vector of the block, including the self weight and the cumulative weight.

[0100] 1. System model

[0101] The embodiment of the application proposes a fog computing architecture based on a DAG blockchain, as shown in Figure 1The network architecture is composed of task publishers, external agents, fog nodes and IDs. Among them, the fog node has a large amount of computing and communication resources, and can act as a blockchain node and a central server of federated learning. It is assumed that there are K fog nodes in the network, denoted as K = {1,..., k,..., K}. Each fog node is assumed to have M IDs, denoted as M = {1,..., m,..., M}, and the corresponding training data set is denoted as D = {D1,..., D m ,...,D M}. ID m trains the local model based on data set D m , and uploads the model to the fog node after completing the training. Global aggregation is performed. When the global model accuracy meets the requirements, the global model is returned to the task publisher.

[0102] Figure 1 Among them, the task publisher publishes the task through the external agent, and the fog node selects the IDs that meet the training conditions to participate in the training task using the device selection algorithm based on the reputation value and user engagement after receiving the task. The whole training process includes the following four steps:

[0103] Step 1: Training task publishing. The task publisher broadcasts the training task including task requirements (such as: data type, size, and task accuracy requirements, and training time range, etc.) and initial model to the fog node through the external agent (such as some authoritative organization), and the fog node publishes the task requirements to the IDs belonging to it. The IDs that meet the requirements send the data information containing their identities to the fog node. The fog node selects some IDs to participate in the training task using the device selection algorithm based on the reputation value and user engagement, and sends the initial model to the selected IDs. The IDs receive the model and perform local training using the local data set.

[0104] Step 2: Fog node performs malicious model identification and global aggregation. After the IDs complete the local training, they upload the local model to the fog node. The fog node collects the models and uses the malicious model identification algorithm based on the outlier value to identify the malicious models in the uploaded local models and update the number of times the related IDs upload malicious models. Then the fog node uses the federated learning weighted aggregation algorithm to calculate the weight of each model after screening the normal models, and then performs global aggregation to update the global model.

[0105] Step 3: Update task participants. After the fog node performs multiple rounds of global training, update the reputation value of the IDs based on the properties of the uploaded models, and then update the IDs participating in the training task using the device selection algorithm based on the reputation value and user engagement.

[0106] Step 4: updating the DAG blockchain network. After the fog node generates a new global model, the model is packaged into a block and published to other fog nodes in the DAG blockchain network through broadcasting. After receiving the broadcasted new block, the fog node updates the local DAG blockchain copy and selects some Tips from the new block using a Tip Selection (TS) algorithm to extract the global model parameters stored therein for aggregation to obtain a new global model. The fog node distributes the new global model to the IDs under its jurisdiction for a new round of global training. Repeat the above steps until the global model accuracy meets the target requirement.

[0107] 2. Reputation value calculation model

[0108] The specific implementation steps of the reputation value calculation method proposed in the embodiments of the application are as follows:

[0109] First, the fog node selects IDs participating in the training task according to the reputation values and user engagement of the IDs. The reputation values and user engagement of the IDs are updated every T rounds of global training, and the IDs are reselected according to the updated reputation values and user engagement. The reputation value updating process is as follows:

[0110] First, in T rounds of global training, the fog node FN k trains a local model based on the ID m The reputation is evaluated, as shown in formula (2).

[0111] γ k→m :={b k→m ,d k→m ,u k→m} (2)

[0112] In the formula, b k→m ,d k→m ,u k→m represent trust, distrust and uncertainty respectively and b k→m +d k→m +u k→m =1, where b k→m ,d k→m ,u k→m ∈[0,1], which can be represented as formula (3) based on the subjective logic model.

[0113]

[0114] In the formula, q k→m represents the probability of successful data transmission; κ, η represent the weights of normal models and malicious models respectively and η+κ=1 and η≤κ; α k ,β k are the number of normal models and malicious models uploaded by the ID m during T rounds of global training, where α k+ β k = T. Based on this, the reputation evaluation of ID m is shown in equation (4).

[0115] T k→m = b k→m + au k→m (4)

[0116] In the formula, a ∈ [0, 1] represents the degree of influence of uncertainty on reputation. Therefore, the reputation value of ID m in the t+1 round is shown in equation (5).

[0117] T k→m (t+1) = λ × T k→m (t) + r × T k→m (5)

[0118] In the formula, λ and r are the decay weight of historical reputation value and the weight of current reputation value, respectively.

[0119] Secondly, the device selection algorithm based on reputation value and user engagement selects IDs participating in training by jointly considering the reputation value and user engagement of IDs, which can model the problem as shown in equation (6).

[0120]

[0121] s.t.C1

[0122] C2: T k→m (t+1) ≥ T min

[0123] C3:

[0124] In the formula, is a binary symbol, represents that ID m is selected by FN k to participate in federated learning tasks, otherwise β is a control parameter for the importance trade-off between reputation value and user engagement; constant P is used to map the reputation value T k→m (t+1) to the same range as C m ; C m represents the user engagement of ID m; N represents the maximum number of selected IDs; constraint condition C1 represents that the maximum number of selected IDs cannot exceed N; constraint condition C2 represents a pre-defined ID reputation value threshold T min , which can set different thresholds according to different security requirements; constraint condition C3 represents The value of is 0 or 1. The optimization problem can be solved by a greedy algorithm. First, a set satisfying the constraint C2 is established, then the utility of all IDs in the set is calculated using the greedy algorithm, the utility value is obtained from the objective function, and finally, the N IDs with large utility in the set are selected, and the set is L={1,...,l,...,L}, L≤M and L≤N.

[0125] 3. Outlier-based malicious model identification algorithm

[0126] The embodiment of the application proposes an outlier-based malicious model identification algorithm for malicious model identification in the federated learning process, and the specific implementation process of the algorithm is as follows:

[0127] First, in the t+1th round, FN k receives the local model Where L is the number of IDs selected by FN k to participate in training, then the distance between the i th layer of the local model of ID l and the i th layer of the global model is calculated based on formula (7).

[0128]

[0129] Then, the first quartile, median, third quartile, minimum observation value and maximum observation value of the distance of all local models of the same layer are calculated. For the distance exceeding the minimum observation value and the maximum observation value, it is determined as an outlier. If the distance of the i th layer of ID l is not an outlier, then OS(d il )=True, therefore, when OS(d 1l ),...,∧OS(d il )∧,...,∧OS(d Il )=True, the model of ID l is marked as a normal model, where I is the number of layers of the neural network. Finally, the set of normal models participating in global aggregation is obtained as

[0130] 4. Federated learning weighted aggregation algorithm

[0131] The embodiment of the application proposes a federated learning weighted aggregation algorithm for model aggregation in the Non-IID scenario, and the specific implementation steps of the algorithm are as follows:

[0132] First, based on the angle θ l (t+1), the efficiency of the local model uploaded by ID l in the t+1th round to the global aggregation is quantified, which is defined as formula (8).

[0133]

[0134] In the formula, is the global model gradient in the t+1th round, which is the global model average gradient calculated by the FedAvg algorithm, and its calculation is shown in equation (9).

[0135]

[0136] In the federated learning weighted aggregation algorithm, the angle θ l (t+1) is smaller, which means that the local gradient is more similar to the global gradient , thus having greater efficiency for global aggregation. Conversely, when θ l (t+1) is larger, for example, greater than π / 2, the local gradient has the opposite direction of the global gradient, thus reducing the efficiency of global aggregation.

[0137] Secondly, in the federated learning weighted aggregation algorithm, in order to suppress the angle θ l (t+1) of each round due to randomness, the average angle (in radians) is used instead of θ l (t+1) in this algorithm, which is defined as shown in equation (10).

[0138]

[0139] The size of depends on the Non-IID degree of the local data set of ID, the greater the Non-IID degree , the greater the value of.

[0140] Finally, the local model aggregation weight of ID l is calculated by the average angle and the model accuracy, which is calculated as shown in equation (11).

[0141]

[0142] In the formula, is the Gompertz function, where α is a constant; p l is defined as shown in equation (12).

[0143]

[0144] In the formula, a l represents the local model accuracy uploaded by ID l.

[0145] Finally, the global aggregation is performed using equation (13) to obtain the updated global model.

[0146]

[0147] 5. A federated learning algorithm based on DAG blockchain

[0148] The embodiment of the present application proposes a federated learning algorithm based on DAG blockchain for sharing global model among fog nodes, and the specific implementation steps are as follows:

[0149] Step 1: First, FN k selects IDs participating in federated learning training, and then FN k selects Tips in the local DAG blockchain copy using the TS algorithm, that is, FN k randomly selects part of Tips (not more than a) within the aging range τ max (the difference between the time of generating the transaction and the current time) from the local DAG blockchain copy through the TS algorithm.

[0150] Step 2: FN k first verifies the integrity and validity of the data of the selected Tips in step 1. Then, FN k extracts the global model parameters from the selected Tips and tests the accuracy of the model using the test data set.

[0151] Step 3: FN k aggregates the global model stored in the c (c≤a and c≥2) Tips with the highest accuracy in step 2 through the FedAvg algorithm to obtain a new global model FN k broadcasts the obtained global model to its selected IDs for local training. After completing the local training, FN k collects the local models trained by the IDs, then filters out the malicious models using the outlier-based malicious model identification algorithm, and then uses the federated learning weighted aggregation algorithm on the normal models to obtain a new global model

[0152] Step 4: FN k uses the global model aggregated in step 3 to construct a new block, and the information contained in the block is shown in formula (1), where the parent block verified by the new block is the c Tips selected in step 2. Then, FN k broadcasts the new block to other fog nodes, and after receiving the new block, other fog nodes verify the data integrity of the block and add it to the local DAG blockchain copy.

[0153] After completing the above four steps, FN k completes one iteration of the federated learning algorithm based on DAG blockchain. Repeat the above steps until the accuracy of the global model stored in the DAG blockchain network reaches the target accuracy, and return the target model to the task publisher.

[0154] Figure 2 The flowchart of the federated learning algorithm based on DAG blockchain is as follows:

[0155] Step 201: algorithm initialization;

[0156] Step 202: the fog node selects IDs participating in federated learning based on the reputation value and user participation;

[0157] Step 203: after the IDs receive the training task issued by the fog node to which the IDs belong, the IDs start training, and after the training is completed, the IDs upload the trained local model to the fog node to which the IDs belong;

[0158] Step 204: after the fog node collects the local models trained by the IDs, the fog node uses an outlier-based malicious model identification algorithm to screen out normal local models from the local models;

[0159] Step 205: the fog node uses a weighted aggregation algorithm to perform global aggregation on the screened normal local models, and updates the global model;

[0160] Step 206: after a certain number of global training, the fog node reselects IDs participating in federated learning based on the reputation value and user participation;

[0161] Step 207: determine whether the accuracy of the global model generated by the fog node in the network meets the target requirement;

[0162] Step 208: when the accuracy of the global model generated by the fog node in the network does not meet the requirement, the fog node publishes the currently generated global model to the DAG block chain network, selects part of the global models from the network for aggregation, updates the global model, and publishes the new global model to the IDs for training;

[0163] Step 209: end.

[0164] Finally, it should be pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the purpose and scope of the technical solutions, and all should be covered in the scope of the claims of the present application.

Claims

1. A data model detection method based on blockchain, characterized in that: The method includes the following steps: S1: Select devices based on reputation score and user engagement; S2: Perform malicious model identification based on outliers; S3: Perform federated learning weighted aggregation; S4: Conduct federated learning based on DAG blockchain; In S1, IDs with certain reputation values ​​are selected and combined with user engagement to solve the problem of global model overfitting; In S2, outlier values ​​of the distance between each layer of the local model and the corresponding layer of the global model are found by evaluating the distance between the parameters of each layer of the local model and the parameters of the corresponding layer of the global model, and malicious models are filtered out. In S3, the weighted weights of the local model are obtained based on the angle between the local model gradient and the global model gradient, as well as the accuracy of the local model. In S4, a DAG blockchain is used to store the global model generated by fog nodes, where fog nodes act as DAG blockchain nodes, storing the ledger information of the DAG blockchain network. First, FN k selects IDs to participate in federated learning based on reputation value and user engagement. Then, in the local DAG blockchain, Tips are selected based on the TS algorithm for transaction selection. Finally, the global model is updated using the FedAvg algorithm for federated averaging. And broadcast it to the selected IDs, which use local data to analyze the received data. Local training is performed; IDs complete the training and upload the local model to FNk. FNk uses an outlier-based malicious model identification algorithm to filter out normal models, and then uses a federated learning weighted aggregation algorithm to aggregate the normal models to obtain a new global model. FN k then used the model and digital signature Sig k Together they are encapsulated into block S k The block is published to the DAG blockchain network, and the specific format of the block is shown in formula (1): In the formula, H is the hash value of the entire block; V k c is the hash vector of the verified tips; k The parameters for proof-of-work have relatively low computational requirements; Q is the weight vector of the block, including its own weight and cumulative weight; In the DAG blockchain, a fog computing architecture is established, consisting of task publishers, external agents, fog nodes, and IDs. It is assumed that there are K fog nodes in the network, denoted as K = {1,...,k,...,K}; each fog node is assumed to have M IDs, denoted as M = {1,...,m,...,M}, and the corresponding training dataset is denoted as D = {D1,...,D...}. m ,...,D M ID m is based on dataset D m Train a local model, and after training is complete, upload the model to the fog node for global aggregation; when the global model accuracy meets the requirements, return the global model to the task publisher. The task publisher publishes the task through an external agent. After receiving the task, the fog node uses a device selection algorithm based on reputation and user engagement to select IDs that meet the training conditions to participate in the training task. The entire training process includes the following four steps: S41: Training task publication; The task publisher broadcasts the training task, including task requirements and the initial model, to the fog nodes through an external agent. The fog nodes publish the task requirements to their respective IDs. The IDs that meet the requirements send their identity and data information to the fog nodes. The fog nodes use a device selection algorithm based on reputation and user participation to select some IDs to participate in the training task and send the initial model to the selected IDs. After receiving the model, the IDs use their local dataset for local training. S42: Fog nodes perform malicious model identification and global aggregation; after IDs complete local training, they upload the local model to their respective fog nodes; after collecting the models, the fog nodes use an outlier-based malicious model identification algorithm to identify malicious models in the uploaded local models and update the number of times the relevant IDs have uploaded malicious models; then the fog nodes use a federated learning weighted aggregation algorithm to calculate the weight of each model for the filtered normal models, and then perform global aggregation to update the global model; S43: Update task participants; After the fog node performs multiple rounds of global training, it uploads model attributes based on IDs to update its reputation value, and then uses a device selection algorithm based on reputation value and user engagement to update the IDs of participants in the training task. S44: Update the DAG blockchain network; After generating a new global model, the fog node packages the model into a block and broadcasts it to other fog nodes in the DAG blockchain network; Upon receiving the broadcasted new block, the fog node updates its local DAG blockchain copy and selects some Tips from it using the Transaction Selection (TS) algorithm, extracts the stored global model parameters, and aggregates them to obtain a new global model; The fog node distributes the new global model to its associated IDs for a new round of global training; Repeat S41 to S44 until the global model accuracy reaches the target requirement; The specific method for calculating the reputation value is as follows: First, the fog nodes select IDs to participate in the training task based on the reputation value and user engagement of the IDs. Every T rounds of global training, the reputation value and user engagement of the IDs are updated, and IDs are reselected based on the updated reputation value and user engagement. The reputation value update process is as follows: First, in the T rounds of global training, FNk is based on the local model trained on ID m. A credit rating is conducted, as shown in formula (2); c k→m :={b k→m ,d k→m ,u k→m } (2) In the formula, b k→m ,d k→m ,u k→m Representing trust, distrust, and uncertainty respectively, and b k→m +d k→m +u k→m =1, where b k→m ,d k→m ,u k→m ∈[0,1], based on the subjective logic model, it is represented as shown in formula (3); In the formula, q k→m α represents the probability of successful data transmission; κ and η represent the weights of the normal model and the malicious model, respectively, with η+κ=1 and η≤κ; k ,β k α is the number of normal and malicious models uploaded by ID m during round T of global training. k +β k =T; The credit rating of ID m is shown in formula (4): T k→m =b k→m +au k→m (4) In the formula, a∈[0,1] represents the degree of influence of uncertainty on reputation; the reputation value of ID m in the (t+1)th round is shown in formula (5); T k→m (t+1)=λ×T k→m (t)+r×T k→m (5) In the formula, λ and r are the weights of historical reputation value decline and current reputation value, respectively; Secondly, the device selection algorithm based on reputation value and user engagement selects IDs to participate in training by jointly considering the reputation value and user engagement of IDs, and models the problem as shown in formula (6); In the formula, It is a binary representation. This indicates that ID m was selected by FN k to participate in the federated learning task; otherwise... β is a control parameter for the importance trade-off between reputation score and user engagement; the constant P is used to adjust the reputation score T. k→m (t+1) maps to C m Within the same range; C m This represents the user engagement level of ID m; N represents the maximum number of IDs selected; constraint C1 indicates that the maximum number of IDs selected cannot exceed N; constraint C2 represents the predefined ID reputation threshold T. min Different thresholds are set according to different security requirements; constraint C3 represents... The value can be 0 or 1. The solution is obtained by a greedy algorithm: First, establish a set that satisfies the constraint C2. Then, use the greedy algorithm to calculate the utility of all IDs in the set. The utility value is obtained according to the objective function. Finally, select the N IDs with the largest utility in the set, and the set is L={1,...,l,...,L},L≤M and L≤N; The federated learning weighted aggregation algorithm is as follows: First, based on angle θ l (t+1) quantifies the efficiency of the local model uploaded by ID l in the (t+1)th round for global aggregation, and its definition is shown in formula (8); In the formula, Let be the global model gradient in round t+1, which is the average global model gradient calculated by the FedAvg algorithm, as shown in formula (9); In the weighted aggregation algorithm of federated learning, the angle θ l The smaller (t+1) is, the more representative the local gradient. With global gradient More similar, thus more efficient for global aggregation; when θ l When (t+1) is large, for example, greater than π / 2, the local gradient... It has a direction opposite to the global gradient, reducing global aggregation efficiency; Secondly, in the federated learning weighted aggregation algorithm, in order to suppress the angle θ in each round l (t+1) Due to the randomness, the quantification of local model efficiency is unstable, so the average angle is used. The unit is radians, replacing θ. l (t+1), whose definition is shown in formula (10); The size depends on the degree of Non-IID in the local dataset of IDs; the greater the degree of Non-IID, the better. The larger the value; Finally, the average angle of the ID l local model aggregate weights is calculated using the Softmax function. The model accuracy is obtained, and its specific calculation is shown in formula (11): In the formula, Let p be the Goppert function, where α is a constant; l The definition is shown in formula (12); In the formula, a l This indicates the local model accuracy uploaded by ID l; Finally, global aggregation is performed using formula (13) to obtain the updated global model; 2. The data model detection method based on blockchain according to claim 1, characterized in that: The malicious model is: First, in round t+1, FNk receives the local model. Where L is the number of IDs selected by FN k to participate in training, and then the local model of ID l is calculated based on formula (7) for the i-th ID. th Layer to global model i-th th The distance between layers; Then, the first quartile, median, third quartile, minimum observation, and maximum observation of the distances within the same layer of all local models are calculated; distances exceeding the minimum and maximum observations are identified as outliers; if the i-th distance of ID l... th If the distance between layers is not an outlier, then let OS(d) il ) = True, when OS(d 1l ),...,∧OS(d il )∧,...,∧OS(d Il When ) = True, the model labeled with ID l is a normal model, where l is the number of layers in the neural network; finally, the set of normal models participating in global aggregation is obtained as follows:

3. The data model detection method based on blockchain according to claim 1, characterized in that: Specifically, S44 is: S441: First, FN k selects IDs to participate in federated learning training. Then, FN k uses the TS algorithm to select Tips in the local DAG blockchain replica, that is: FN k randomly selects Tips from the local DAG blockchain replica within the aging range τ using the TS algorithm. max Internal Tips, τ max This refers to the difference between the time the transaction was generated and the current time; some tips do not exceed α. S442: FN k first verifies the completeness and validity of the data in the Tips selected in S441; FN k extracts the global model parameters from the selected Tips and uses the test dataset to test the accuracy of the model; S443: FN k aggregates the global models stored in the c most accurate Tips from S442 using the FedAvg algorithm, where c ≤ α and c ≥ 2, to obtain a new global model. FN k will obtain the global model The system broadcasts to selected IDs for local training. After local training is complete, FNk collects the local models trained on the IDs, then uses an outlier-based malicious model identification algorithm to filter out malicious models, and finally uses a federated learning weighted aggregation algorithm on the normal models to obtain a new global model. S444: FN k utilizes the global model aggregated by S443 Construct a new block, the information contained in the block is shown in Equation (1), where the parent block verified by the new block is the c Tips selected by S442; Then, FN k broadcasts the new block to other fog nodes. After receiving the new block, the other fog nodes verify the data integrity of the block and add it to their local DAG blockchain replica. FN k completes one iteration of the federated learning algorithm based on the DAG blockchain; repeats S441 to S444 until the global model accuracy stored in the DAG blockchain network reaches the target accuracy, and returns the target model to the task issuer; The specific implementation steps of federated learning are as follows: S201: Algorithm initialization; S202: Fog nodes select IDs to participate in federated learning based on reputation value and user engagement; S203: After receiving the training task issued by its fog node, IDs start training and upload the trained local model to its fog node after training is completed. S204: After collecting the local models trained by the IDs belonging to the fog node, the malicious model identification algorithm based on outliers is used to filter out the normal local models. S205: The normal local model selected by fog node pairs is globally aggregated using a weighted aggregation algorithm to update the global model; S206: After a certain number of rounds of global training, fog nodes reselect IDs to participate in federated learning based on reputation value and user engagement. S207: Determine whether the accuracy of the global model generated by the fog nodes in the network meets the target requirements; S208: When the accuracy of the global model generated by the fog node in the network does not meet the requirements, the fog node publishes the currently generated global model to the DAG blockchain network, selects some global models from the network for aggregation, updates the global model, and publishes the new global model to its respective IDs for training; S209: End.

Citation Information

Patent Citations

  • Federal learning method based on fog calculation

    CN113379066A

  • Federal learning method based on DAG block chain

    CN113919507A