A federated learning method of a DAG blockchain based on main chain consensus
By using a DAG blockchain method based on main chain consensus, the problem of model training divergence caused by Non-IID data and node dynamics in the Internet of Vehicles environment is solved, achieving efficient, robust training and high accuracy of the global model, and adapting to the needs of complex Internet of Vehicles scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUIZHOU UNIV
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-24
AI Technical Summary
Existing DAG-FL solutions face challenges in the Internet of Vehicles environment due to the characteristics of Non-IID data and the high dynamism of client nodes, leading to divergence and reduced convergence performance in model training. Traditional transaction selection mechanisms have failed to effectively address the challenges posed by data heterogeneity and node dynamism.
We adopt a DAG blockchain approach based on main chain consensus. The main chain generation algorithm guides the client to initialize the local model. The aggregation model is selected by combining model accuracy and gradient difference. A transaction selection algorithm is designed to screen high-quality local models. An edge aggregator is introduced to perform weighted averaging and latency tolerance strategies to optimize the model training process.
It effectively alleviates the model training divergence problem in the vehicle-to-everything (V2X) environment, improves the convergence stability and accuracy of the global model, adapts to the high dynamism of client nodes, and ensures the effectiveness and reliability of model aggregation.
Smart Images

Figure CN121328774B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical classifications of DAG blockchain and federated learning in the field of blockchain technology, and in particular to a federated learning method for DAG blockchain based on main chain consensus, which can be widely applied to intelligent transportation systems and other fields. Background Technology
[0002] With the rapid development of 5G communication and Mobile Edge Computing (MEC) technologies, the Internet of Vehicles (IoV) has entered a critical stage of large-scale development. Core applications such as autonomous driving and intelligent traffic management place extremely high demands on the real-time performance and accuracy of onboard models. Model training, as a core component supporting these applications, is hampered by the massive volume of IoV data, privacy sensitivity, and bandwidth limitations of traditional centralized training methods. Federated Learning (FL), with its ability to train models collaboratively without data leaving the local machine, has become an ideal technology for resolving the conflict between privacy protection and model training in IoV. It trains models locally through multiple clients, uploading only parameter updates to the aggregation node, effectively avoiding the risk of raw data leakage.
[0003] To further enhance the decentralization and credibility of federated learning, blockchain technology has been widely incorporated into federated learning frameworks. Compared to traditional chain-based blockchains, the Directed Acyclic Graph (DAG) structure, with its parallel transaction processing capabilities, congestion resistance, and adaptability to dynamic nodes, is better suited to the needs of concurrent multi-client interaction in mobile edge computing scenarios. As a result, the DAG-FL (DAG-based federated learning) solution has emerged and has demonstrated significant advantages in areas such as collaborative training of smart terminals and modeling of industrial edge devices, providing a new technical path for vehicle-to-everything (V2X) model training.
[0004] However, the unique nature of the connected vehicle environment presents unavoidable technical bottlenecks for existing DAG-FL solutions. Among these, the non-independent and identically distributed (Non-IID) nature of the data and the high dynamism of client nodes are the core factors leading to performance degradation. In connected vehicles, the operating scenarios (such as urban roads, highways, and suburban roads), driving habits, and types of onboard sensors vary significantly, resulting in strong heterogeneity in the data distribution of each client. For example, some client data is concentrated in specific traffic scenarios (such as driving data in congested areas), while some clients lack such samples. This Non-IID characteristic leads to large initialization deviations of the local models of each client in traditional DAG-FL, which easily causes parameter conflicts during aggregation, thus slowing down the convergence speed of the global model and even causing training divergence.
[0005] The high dynamism of client nodes further exacerbates the aforementioned problems. In the Internet of Vehicles (IoV), the high-speed movement of vehicles leads to frequent communication link interruptions and random node additions or removals from the training process, resulting in intermittent and uncertain transactions (i.e., local model parameter submissions) in the DAG blockchain. Existing DAG-FL schemes often rely on transaction generation time or local node credibility for their transaction selection mechanisms, failing to adequately consider the model's quality and training stability. This often results in the inclusion of insufficiently trained or low-accuracy local models in the aggregation process, disrupting the consistency of global model parameter updates. Furthermore, the decentralized consensus mechanism of the DAG structure lacks effective guidance for the global model, making it easy for each client's local training to get trapped in local optima, further deteriorating the model's convergence performance and failing to meet the reliability requirements of core IoV applications for model training.
[0006] While existing research has proposed solutions such as weighted aggregation and improved federated averaging algorithms for the Non-IID problem in federated learning, and designed node reputation mechanisms to address the dynamic nature of DAG blockchains, none of these solutions have achieved a synergistic solution to the two core challenges in the connected vehicle scenario: solutions that optimize data heterogeneity alone cannot adapt to the transaction quality fluctuations caused by the high dynamism of nodes, while improving node management strategies alone is insufficient to mitigate model biases caused by Non-IID data. Therefore, there is an urgent need to construct a DAG-FL optimization scheme that can simultaneously address data heterogeneity and node dynamism, providing technical support for efficient model training in the connected vehicle environment. Summary of the Invention
[0007] The main objective of this invention is to provide a federated learning method for DAG blockchains based on main chain consensus. Addressing the training divergence problem caused by Non-IID data, this invention offers an innovative main chain generation algorithm that guides clients to rationally initialize their local models based on the main chain model, effectively mitigating biases caused by heterogeneity. Secondly, considering the dynamic changes in client nodes, a transaction selection algorithm that integrates model accuracy and training trends is provided to select suitable local models for aggregation, thereby improving the convergence of the global training process.
[0008] Based on the first main aspect of the present invention, a federated learning method for DAG blockchains based on main chain consensus is provided, comprising the following steps executed by a computer system:
[0009] In the system, edge servers are set up as static full nodes to maintain the complete DAG blockchain, while vehicles are light nodes that only synchronize block headers and obtain aggregate models for local training. Each vehicle only connects to the nearest edge server.
[0010] The vehicle initiates a data sharing request as a federated learning task, inputting the shared dataset and training requirements;
[0011] The vehicle constructs a main chain through the main chain generation algorithm, selects an aggregate model from the latest leaf block set of the main chain to initialize the local model, performs a preset number of local updates, and then uploads the local model to the corresponding edge aggregator.
[0012] The edge aggregator collects enough local models, performs weighted aggregation on its client set to generate an aggregated model, evaluates the model accuracy using local data after aggregation, and determines the set of reference blocks.
[0013] The edge aggregator connects the transaction set corresponding to the local model set with the aggregated model. Package them together to generate a new block.
[0014] As a further preferred option, in the aforementioned method, the edge server includes a base station or roadside unit. Each edge server covers a physical area within a preset range and maintains a client set consisting of vehicles within the coverage area. The edge server manages the training state synchronization of the local model and the block on-chain interaction through the client set. The vehicle matches the nearest edge server through the positioning module and establishes a stable communication link.
[0015] As a further preferred option, in the aforementioned method, when the vehicle constructs the main chain using the main chain generation algorithm, it represents the blockchain as a set of blocks. , It is the genesis block; each block consists of a block header and a block body;
[0016] Apart from the genesis block, each block contains The fields form a set of edges pointing to predecessor blocks, used to represent the iterative relationship between aggregated models; these edges are divided into two categories: parent edges and reference edges; among them, the parent edge is the edge with the largest weight, representing the predecessor model source that the global model in the current block mainly depends on; the remaining edges are reference edges, used to help record other referenced model blocks;
[0017] In a DAG, all parent edges together form a parent tree rooted at the genesis block; in this parent tree, a path is selected from the genesis block to a certain leaf block as the main chain.
[0018] As a further preferred option, in the aforementioned method, the path of the main chain is as follows: starting from the genesis block, traversing downwards step by step: in each layer, counting the child blocks whose parent edges point to the current node, selecting the child block with the largest weight as the next jump point, until a certain leaf block is reached.
[0019] As a further preferred option, in the aforementioned method, in the block In the block, the block body contains a set of local transactions. The transactions are organized using a Merkel tree structure and a root hash is generated. ;
[0020] Furthermore, the block header contains the following field: block number. timestamp Aggregation model and its accuracy and the set of pointers to reference blocks. ,in This indicates the total number of predecessor blocks corresponding to the local model contained in the block body;
[0021] Each pointer is defined as , indicating the current block The cited number Block And there are The local model is based on The aggregation model was trained in the middle;
[0022] Define block Aggregation model in With the largest in the referenced block Aggregation model The gradient difference between them is denoted as This is used to characterize the deviation between the two aggregation models; the final block. Represented as:
[0023] .
[0024] As a further preferred option, in the aforementioned method, the weight of the block is affected by the accuracy of the model corresponding to the transaction within the block body, and the number of times the block is referenced by other transactions.
[0025] Block The weights are calculated as follows:
[0026]
[0027] in, Represents a block The Middle The overall score of the model corresponding to each transaction. It is the number of transactions within the block. This indicates the number of times the block has been referenced by other transactions.
[0028] As a further preferred option, in the aforementioned method, during the local update, the client... First, construct the current main chain, starting from the main chain height of... Main chain blocks The set of successor leaf blocks In the process, combining model accuracy and gradient difference, the aggregated model in one block is selected. To initialize the local model ; will the first The main chain model of the wheel is denoted as ;
[0029] In the During the training rounds, some clients were based on the main chain model. conduct One group of clients updates locally; while another group of clients uses an aggregation model. Start local training, where express The training round in which they are currently training. Indicates round Index of the aggregation model;
[0030] At the start of each training round, the client's local parameters are initialized to the global model parameters. Each node, based on its position in the [number]th [phase], The parameters of the first step are updated by performing stochastic gradient descent on the local loss function, thus obtaining the parameters of the second step. Local model parameters of the step Each node executes in each training round. This is a local update; after After the first iteration, the 1st The local model parameters for the wheel are:
[0031]
[0032] in, It is the local learning rate. Indicated on the client The gradient on the local loss function.
[0033] As a further preferred option, in the aforementioned method, the generation of the aggregation model includes: an aggregator. For the connected A collection of clients The local model in the data is weighted and averaged; assuming the client... In the The initial model in each round of training comes from the aggregated model set. This represents the maximum number of delay rounds that the system can tolerate, i.e., in the twelfth round. When the training round begins, the client Initialize the local model as the first The aggregation model, and perform a local update;
[0034] set up For the main chain model The set of clients used for training is of size [number missing]. ;and For other aggregation models The set of clients used for training is of size [number missing]. ;
[0035] when This indicates the aggregation model of the current round. Primarily based on the main chain model Training; otherwise, it indicates that training primarily relies on other historical aggregation models. ;
[0036] The aggregation process can be formally represented as:
[0037]
[0038] The generation of new blocks includes: an aggregator After completing model aggregation, use its local data to analyze the aggregated model. Perform an accuracy assessment to obtain the accuracy rate. And determine the set of pointers pointing to the referenced block. ;Then, local model collection The corresponding transaction set With aggregation model Package them together to generate a new block. .
[0039] According to a second key aspect of the present invention, an electronic device is provided, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0040] The memory stores a computer program that, when executed by the processor, causes the processor to perform the aforementioned federated learning method for DAG blockchains based on main chain consensus.
[0041] Based on a third key aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed, implements the aforementioned federated learning method for a DAG blockchain based on main chain consensus.
[0042] Compared with existing technologies, this invention can effectively alleviate the model training divergence problem caused by the non-IID characteristics of data in the Internet of Vehicles environment, and improve the global model convergence stability. This invention, through an innovative main chain generation algorithm, guides the client to select an aggregated model from the latest leaf block of the blockchain main chain, combining model accuracy and gradient difference to initialize the local model, avoiding the problem of excessive local model initialization bias in traditional DAG-FL. Simultaneously, a regularized objective function is introduced in the local update phase to further control the model offset caused by non-IID data by limiting the difference between the local model and the initial aggregated model. This dual approach mitigates the negative impact of data heterogeneity from both the initialization and training processes, ensuring that the global model training does not deviate from the convergence direction.
[0043] Secondly, this invention enhances the adaptability of federated learning systems to the highly dynamic nature of client nodes, ensuring the effectiveness of model aggregation. Addressing the issues of random addition and removal of vehicle nodes or communication delays in vehicle-to-everything (V2X) networks, the technical solution of this invention utilizes an edge aggregator to maintain a pool of pending transactions and a latency-tolerant aggregation strategy. This avoids the long-term exclusion of clients with slower training speeds and prevents lagging models from interfering with the current aggregation results. Simultaneously, a transaction selection algorithm that integrates model accuracy and training trends selects high-quality local models for aggregation by quantifying the comprehensive score of transaction models, eliminating models with excessive offset or insufficient accuracy. This ensures that the aggregation process is unaffected by model quality fluctuations caused by dynamic changes in nodes, improving the robustness of global training.
[0044] Furthermore, this invention achieves a balance between reliability and efficiency in model training through the structural design and consensus mechanism of blockchain. In this invention, the blockchain block body uses a Merkel tree to organize transaction data, generating a root hash to ensure the integrity and verifiability of the local model and transaction information; the set of referenced block pointers clearly records the predecessor dependencies of the aggregated model, providing support for model traceability. The main chain consensus mechanism constructs a globally consistent main chain through block weight calculation (balancing model accuracy and reference count), reducing consensus redundancy caused by multiple paths in the DAG structure and improving the efficiency of model parameter synchronization.
[0045] Finally, this invention improves model convergence while further optimizing the accuracy and generalization ability of the global model. The transaction scoring mechanism comprehensively considers model accuracy and gradient drift trend, ensuring that the local models participating in aggregation possess both high performance and consistency with the global model's direction. The edge aggregator employs a weighted average strategy, allocating weights based on the size of the client dataset, allowing the local models with larger and more representative datasets to play a greater role in aggregation. The synergistic effect of these designs enables the final aggregated model to fully integrate the effective features of each client, avoiding local optima and improving adaptability to complex vehicle-to-everything (V2X) scenarios, thus meeting the accuracy requirements of practical applications such as traffic prediction and route selection. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, obtaining other drawings based on these drawings without creative effort still falls within the scope of the present invention.
[0047] Figure 1 The following is an execution flowchart of a federated learning method for a DAG blockchain based on main chain consensus, according to one embodiment of the present invention.
[0048] Figure 2 The overall system composition is shown in one embodiment of the present invention;
[0049] Figure 3 The interactive process of a semi-asynchronous federated learning method in one embodiment of the present invention is illustrated. Detailed Implementation
[0050] The preferred embodiments of the present invention will be described in detail below to provide a clearer understanding of the purpose, features, and advantages of the present invention. It should be understood that the following embodiments are not intended to limit the scope of the present invention, but are merely illustrative of the essential spirit of the technical solution of the present invention.
[0051] In the following description, certain specific details are set forth for the purpose of illustrating various disclosed embodiments in order to provide a thorough understanding of the various disclosed embodiments. However, those skilled in the art will recognize that embodiments may be practiced without one or more of these specific details. In other instances, well-known techniques associated with the invention may not have been shown or described in detail to avoid unnecessarily obscuring the description of the embodiments.
[0052] Throughout this specification, references to "an embodiment" or "an embodiment" indicate that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Therefore, the appearance of "in an embodiment" or "an embodiment" in various places throughout the specification does not necessarily refer to the same embodiment. Furthermore, a particular feature, structure, or characteristic may be combined in any manner in one or more embodiments.
[0053] In the following embodiments or drawings, the technical terms, abbreviations, and their meanings that may be involved in the specific implementation process of the present invention are as follows:
[0054] PDAG Blockchain: The overall blockchain name used in this invention to achieve the purpose of this invention, referring to the specific directed acyclic graph (DAG) structure blockchain designed in this invention.
[0055] PDAG-FL: refers to a semi-asynchronous federated learning method based on the PDAG blockchain. Its core is to solve the problems of non-IID data and node dynamism in the Internet of Vehicles through the main chain consensus and transaction mechanism of the PDAG blockchain.
[0056] DAG (Directed Acyclic Graph): The core underlying structure of the PDAG blockchain, it supports parallel transaction processing of blocks and builds iterative relationships between blocks through parent edges and reference edges.
[0057] Merkel tree: A tree structure used to organize the transaction set in a block body, generate a root hash, and ensure the integrity and verifiability of transaction data.
[0058] Genesis Block: The starting block of the PDAG blockchain, which forms the basis for the main chain construction and block iteration.
[0059] Main chain: Starting from the genesis block, a global consensus path is formed by selecting the sub-blocks with the highest weight layer by layer, corresponding to the number of training rounds of asynchronous federated learning.
[0060] Reference block pointer set: One of the fields in the block header, which records the predecessor blocks referenced by the current block and the number of local models trained based on the predecessor model.
[0061] Parent edge: One type of edge between blocks, with the highest weight, corresponding to the main predecessor model source of the current block's global model.
[0062] Reference edge: One type of edge between blocks, other than the parent edge, used to assist in recording referenced model blocks.
[0063] Block weight: A metric for evaluating block priority, taking into account both the accuracy of the transaction model within the block and the number of times it is referenced.
[0064] Transaction: The basic unit of interaction between the client and the aggregator, encapsulating information related to the local model.
[0065] DAG-FL (DAG Blockchain-based Federated Learning): This is a federated learning scheme based on Directed Acyclic Graph (DAG) blockchain. It is an improvement on existing technologies, but it suffers from problems such as decreased convergence performance and training divergence.
[0066] Semi-asynchronous federated learning: The training mode adopted in this invention involves some clients training based on the main chain model and some training based on the historical aggregation model, which supports latency tolerance and adapts to node dynamics.
[0067] Edge Server: A static full node, including a Base Station (BS) or Road Side Unit (RSU), covering a specific physical area, maintaining the complete PDAG blockchain, and managing the client set.
[0068] Edge aggregator: Responsible for collecting local models from clients, performing weighted aggregation to generate new aggregate models, evaluating model accuracy and packaging them to generate new block entities, and maintaining a pool of transactions to be processed.
[0069] Vehicle (Client): Federated learning client, as a light node, only synchronizes the PDAG blockchain block header, obtains the aggregated model for local training, and uploads the trained model to the edge aggregator.
[0070] Client set: The set of vehicle nodes covered by the edge server or edge aggregator, used for edge server management and aggregator model aggregation, respectively.
[0071] Pending Transaction Pool: A local storage unit maintained by the edge aggregator to continuously synchronize client transactions in the blockchain network and provide a data source for aggregation operations.
[0072] Requesting vehicle: A vehicle that initiates a data sharing request (Req) with the goal of training a global model by sharing a dataset to meet needs such as traffic prediction and route selection.
[0073] Main chain generation algorithm: The core algorithm for clients to build the main chain. It traverses the DAG layer by layer from the genesis block, and selects the sub-block with the "highest weight" at each layer as the next hop of the main chain to form a globally consensus main chain.
[0074] Trading selection algorithm: A screening algorithm that integrates model accuracy and training trend, which selects high-quality local models to participate in aggregation through a trading scoring mechanism, thereby improving the global training convergence.
[0075] Transaction scoring mechanism: A mechanism to evaluate the quality of transaction models, taking into account both model accuracy and gradient difference with the main chain model.
[0076] Delay-tolerant aggregation strategy: The aggregation strategy adopted by the edge aggregator adapts to the differences in client training latency, avoids excluding slow clients or introducing lagging interference models, and balances convergence and participation.
[0077] Weighted average aggregation: A method for edge aggregators to generate aggregation models by assigning weights based on the size of the client's local dataset.
[0078] Local model: The model parameters obtained by the client after τ local updates in the k-th training round.
[0079] Aggregation model: The model generated after aggregation by edge aggregators or servers.
[0080] Main chain model: The aggregated model in the (k-1)th round of the main chain, which is the source of the initialization model trained locally by some clients.
[0081] Non-IID (Non-Independent and Identically Distributed): This is a core characteristic of vehicle network data. The heterogeneous distribution of data across different vehicles is one of the reasons for the divergence in traditional DAG-FL training.
[0082] like Figure 1 As shown, in one embodiment, a federated learning method for a DAG blockchain based on main chain consensus according to the present invention includes the following steps 100-500 executed by a computer system:
[0083] Step 100: In the system, set the edge server as a static full node to maintain the complete DAG blockchain, and the vehicle as a light node to only synchronize the block header and obtain the aggregate model for local training. Each vehicle only connects to the nearest edge server.
[0084] Step 200: The vehicle initiates a data sharing request as a federated learning task, inputting the shared dataset and training requirements;
[0085] Step 300: The vehicle constructs a main chain through the main chain generation algorithm, selects an aggregation model from the latest leaf block set of the main chain to initialize the local model, performs a preset number of local updates, and then uploads the local model to the corresponding edge aggregator.
[0086] Step 400: The edge aggregator collects enough local models, performs weighted aggregation on its client set to generate an aggregated model, evaluates the model accuracy using local data after aggregation, and determines the set of reference blocks.
[0087] Step 500: The edge aggregator matches the transaction set corresponding to the local model set with the aggregated model. Package them together to generate a new block.
[0088] In one embodiment, the overall system composition of the present invention is as follows: Figure 2 As shown, in Figure 2 In the diagram, steps ①-⑥ represent: synchronizing the directed acyclic graph (DAG) ledger, training the local model, broadcasting transactions carrying the local model, updating the transaction pool, aggregating the local model and generating a block, and broadcasting block B7 via the Gossip Protocol.
[0089] The implementation process of the present invention will be further described in detail in the following possible implementations.
[0090] First, in this invention, the overall blockchain used to achieve the objectives of this invention is defined as a PDAG blockchain. In this invention, a PDAG blockchain is represented as a set of blocks. , This is the genesis block. Each block consists of a block header and a block body. Within the block... In the block, the block body contains a set of local transactions. These transactions are organized using a Merkel tree structure and generate a root hash. This is to ensure data integrity and verifiability.
[0091] The block header contains the following field: block number timestamp Aggregation model and its accuracy and the set of pointers to reference blocks. ,in This indicates the total number of predecessor blocks corresponding to the local model contained in the block body.
[0092] Each pointer is defined as , indicating the current block The cited number Block And there are The local model is based on Obtained by training the aggregation model in [the dataset]. Define the block. Aggregation model in With the largest in the referenced block Aggregation model The gradient difference between them is denoted as This is used to characterize the deviation between the two aggregation models. Final block. This can be formally represented as:
[0093]
[0094] In this method, a transaction is the basic unit of interaction between the client and the aggregator. Each client-trained local model is encapsulated in the form of a transaction and published to the blockchain network. Specifically, when a client... Based on blocks Aggregation model in Training to obtain a local model The constructed transaction is then represented as follows:
[0095]
[0096] in, This indicates the precision corresponding to the trading model. Used to characterize the client Based on blocks The aggregation model in the first During training rounds, the local model Compared to its initial aggregation model The differences between them reflect the gradient drift during the training process. This trend information provides important decision-making basis for the subsequent main chain consensus mechanism, and helps to more reasonably evaluate the model quality and convergence direction.
[0097] Apart from the genesis block, each block contains The fields form a set of edges pointing to predecessor blocks, used to represent the iterative relationship between aggregated models. These edges are divided into two categories: parent edges and reference edges. The parent edge is the edge with the largest weight, representing the source of the predecessor model that the global model in the current block mainly depends on; the remaining edges are reference edges, used to help record other referenced model blocks. All parent edges in the DAG together form a parent tree rooted at the genesis block. In this parent tree, from the genesis block to a certain leaf block, this invention selects a path as the main chain. Specifically, starting from the genesis block, it traverses downwards step by step: at each level, it counts the child blocks pointed to by its parent edges, selects the child block with the largest "weight" as the next jump point, until a certain leaf block is reached.
[0098] Assuming the client In time The block set was obtained synchronously. Then it originates from the genesis block. Begin by traversing the entire DAG layer by layer. At each layer, The block with the highest "weight" among the sub-blocks of the current main chain block is selected as the next block of the main chain, thereby constructing a main chain with global consensus. ,in This represents the height of the main chain and also corresponds to the current training round number of the asynchronous federated learning. The "weight" of a block is influenced by the accuracy of the model corresponding to the transaction within the block and the number of times the block is referenced by other transactions. The weights are calculated as follows:
[0099]
[0100] in, Represents a block The Middle The overall score of the model corresponding to each transaction. It represents the number of transactions within a block. This indicates the number of times the block is referenced by other transactions. The weight design balances model quality with the block's propagation influence within the network.
[0101] To mitigate the impact of Non-IID data, this invention designs a multi-factor-based transaction scoring mechanism that comprehensively considers model accuracy and the training trend (i.e., gradient difference) of the previous main chain block. Higher model accuracy results in a higher transaction score; conversely, a larger gradient difference indicates a significant deviation between the local model and the main chain model in that transaction, leading to a lower score. Specifically, for a given transaction... Its overall score is defined as:
[0102]
[0103] in, Used to measure the model's performance compared to the previous mainchain blocks. The gradient difference between aggregate models.
[0104] Figure 3 This invention illustrates the interaction process of a semi-asynchronous federated learning (PDAG-FL) method in one embodiment, mainly including two steps: local update and edge aggregation.
[0105] (1) Local update: client First, construct the current main chain, starting from the main chain height of... Main chain blocks The set of successor leaf blocks In the process, combining model accuracy and gradient difference, the aggregated model in one block is selected. To initialize the local model The present invention will... The main chain model of the wheel is denoted as .
[0106] Due to asynchronous communication, the DAG views maintained by different clients may differ. Therefore, in the... During the training rounds, some clients were based on the main chain model. conduct One group of clients updates locally; while another group of clients uses an aggregation model. Start local training, where express The training round in which they are currently training. Indicates round The index of the aggregated model. At the start of each training round, the client's local parameters are initialized to the global model parameters. Each node, based on its position in the [number]th [phase], The parameters of the first step are updated by performing stochastic gradient descent on the local loss function, thus obtaining the parameters of the second step. Local model parameters of the step This invention specifies that each node performs the following in each training round: This is a local update. After the first iteration, the 1st The local model parameters for the wheel are:
[0107]
[0108] in, It is the local learning rate. Indicated on the client The gradient on the local loss function. To alleviate the Non-IID problem, this invention adds a constraint term to the local subproblem, controlling the degree of model deviation by limiting local updates to move closer to the initial aggregated model. Client During local training, it no longer only minimizes the local objective function. Instead, it optimizes the following constrained objective function. :
[0109]
[0110] in, The regularization coefficient is . This indicates the gap between the current local model and the reference aggregate model.
[0111] (2) Edge aggregation:
[0112] Each edge aggregator maintains a pool of pending transactions to continuously synchronize client transactions from the blockchain network to its local machine. During actual training, due to differences in client computing power and network conditions, some nodes may be unable to promptly attach their local models to the latest block corresponding to the current round, especially under conditions of high training latency. If the aggregator only aggregates local models from the current round's block, clients with slower training speeds will be "excluded" for an extended period, unable to effectively participate in model updates. Conversely, if aggregation is based solely on model submission time, it may introduce lagging models from earlier training rounds that have just been uploaded, thus interfering with the current aggregation results. Therefore, latency-tolerant aggregation strategies are widely adopted in asynchronous federated learning frameworks to improve the system's adaptability to asynchronous and lagging models while ensuring convergence.
[0113] When edge aggregator After collecting a sufficient number of local models, Perform an aggregation operation to combine these models into a new aggregate model. Specifically, aggregators For the connected A collection of clients The local model in the dataset is used for weighted averaging. Assume the client... In the The initial model in each round of training comes from the aggregated model set. This represents the maximum number of delay rounds the system can tolerate. That is, in the [number]th [round]. When the training round begins, the client Initialize the local model as the first The aggregation model, And perform a local update.
[0114] set up For the main chain model The set of clients used for training is of size [number missing]. ;and For other aggregation models The set of clients used for training is of size [number missing]. .when This indicates the aggregation model of the current round. Primarily based on the main chain model Training; otherwise, it indicates that training primarily relies on other historical aggregation models. The aggregation process can be formally represented as:
[0115]
[0116] aggregator After completing model aggregation, use its local data to analyze the aggregated model. Perform an accuracy assessment to obtain the accuracy rate. And determine the set of pointers pointing to the referenced block. .Then, local model collection The corresponding transaction set With aggregation model Package them together to generate a new block. .
[0117] The following specific embodiment provides a semi-asynchronous federated learning method based on DAG blockchain, with the following specific steps:
[0118] Step 100: System Setup Phase
[0119] Edge servers: These include base stations (BS) or roadside units (RSUs). These static nodes each cover a certain range of streets and collectively maintain the DAG blockchain as full nodes. Moving vehicles: Vehicles move on the streets, communicating with edge servers and other vehicles. As light nodes, they only synchronize the block header information of the DAG blockchain and obtain aggregated model parameters for local training. Each vehicle only establishes a connection with its nearest edge server. (Assuming the edge servers...) The set of clients it covers The local models are aggregated, and the aggregated models are submitted to the blockchain.
[0120] Step 200: Training Task Initiation Phase
[0121] vehicle Submitting a request to share certain data, for purposes including traffic prediction or route selection. (This refers to submitting a data sharing request.) vehicles Its goal is to utilize shared data Obtain the calculation and get the result. This invention treats the data sharing process as a computational task. Through dataset Training Model To address the issue from The need for data sharing.
[0122] Step 300: Local Model Training Phase
[0123] Vehicle nodes construct the main chain based on the main chain generation algorithm, and start from the set of successor leaf node blocks of the latest main chain block. In the process, combining model accuracy and gradient difference, the aggregated model in one of the blocks is selected. To initialize the local model Each node performs [the necessary actions] in each training round. This is a local update. After the first iteration, the 1st The local model parameters of the wheel are The updated model is then sent to the edge aggregator.
[0124] Step 400: Edge Model Aggregation Stage
[0125] Edge aggregator After collecting a sufficient number of local models, the aggregator For the connected A collection of clients The local models in the dataset are weighted and averaged to generate the aggregate model. Aggregator After completing model aggregation, use its local data to analyze the aggregated model. Perform an accuracy assessment to obtain the accuracy rate. And determine the set of pointers pointing to the referenced block. .
[0126] Step 500: New Block Generation Stage
[0127] local model collection The corresponding transaction set With aggregation model Package them together to generate a new block. .
[0128] The technical terms, principles, or means related to the technical solutions of the present invention mentioned in the above embodiments, which are not described in detail above, are all well-known technologies or common practices that are known to those skilled in the art.
[0129] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.
Claims
1. A federated learning method for DAG blockchains based on main chain consensus, characterized in that, Includes the following steps: In the system, edge servers are set up as static full nodes to maintain the complete DAG blockchain, while vehicles are light nodes that only synchronize block headers and obtain aggregate models for local training. Each vehicle only connects to the nearest edge server. The vehicle initiates a data sharing request as a federated learning task, inputting the shared dataset and training requirements; The vehicle constructs a main chain through the main chain generation algorithm, selects an aggregate model from the latest leaf block set of the main chain to initialize the local model, performs a preset number of local updates, and then uploads the local model to the corresponding edge aggregator. The edge aggregator collects enough local models, performs weighted aggregation on its client set to generate an aggregated model, evaluates the model accuracy using local data after aggregation, and determines the set of reference blocks. The edge aggregator connects the transaction set corresponding to the local model set with the aggregated model. Package them together to generate a new block; When the vehicle constructs the main chain using the main chain generation algorithm, it represents the blockchain as a set of blocks. , It is the genesis block; each block consists of a block header and a block body; Apart from the genesis block, each block contains The fields form a set of edges pointing to predecessor blocks, used to represent the iterative relationship between aggregated models; these edges are divided into two categories: parent edges and reference edges; among them, the parent edge is the edge with the largest weight, representing the predecessor model source that the global model in the current block mainly depends on; the remaining edges are reference edges, used to help record other referenced model blocks; In a DAG, all parent edges together form a parent tree rooted at the genesis block; in this parent tree, a path is selected from the genesis block to a certain leaf block as the main chain. The main chain path is as follows: starting from the genesis block, it traverses downwards step by step: in each layer, it counts the child blocks that the parent edge points to the current node, selects the child block with the largest weight as the next jump point, until a certain leaf block is reached.
2. The federated learning method for DAG blockchains based on main chain consensus as described in claim 1, characterized in that, The edge server includes a base station or roadside unit. Each edge server covers a physical area within a preset range and maintains a client set consisting of vehicles within the coverage area. The edge server manages the training state synchronization of the local model and the block on-chain interaction through the client set. Vehicles match the nearest edge server through the positioning module and establish a stable communication link.
3. The federated learning method for DAG blockchains based on main chain consensus as described in claim 1, characterized in that, In the block In the block, the block body contains a set of local transactions. The transactions are organized using a Merkel tree structure and a root hash is generated. ; Furthermore, the block header contains the following field: block number. timestamp Aggregation model and its accuracy and the set of pointers to reference blocks. ,in This indicates the total number of predecessor blocks corresponding to the local model contained in the block body; Each pointer is defined as , indicating the current block The cited number Block And there are The local model is based on The aggregation model was trained in the middle; Define block Aggregation model in With the largest in the referenced block Aggregation model The gradient difference between them is denoted as This is used to characterize the deviation between the two aggregation models; the final block. Represented as: 。 4. The federated learning method for DAG blockchain based on main chain consensus according to claim 3, characterized in that, The weight of a block is affected by the accuracy of the model corresponding to the transaction within the block body, and the number of times the block is referenced by other transactions. Block The weights are calculated as follows: in, Represents a block The Middle The overall score of the model corresponding to each transaction. It is the number of transactions within the block. This indicates the number of times the block has been referenced by other transactions.
5. The federated learning method for DAG blockchains based on main chain consensus according to claim 1, characterized in that, During the local update, the client First, construct the current main chain, starting from the main chain height of... Main chain blocks The set of successor leaf blocks In the process, combining model accuracy and gradient difference, the aggregated model in one block is selected. To initialize the local model ; will the first The main chain model of the wheel is denoted as ; In the During the training rounds, some clients were based on the main chain model. conduct One group of clients updates locally; while another group of clients uses an aggregation model. Start local training, where express The training round in which they are currently engaged Indicates round Index of the aggregation model; At the start of each training round, the client's local parameters are initialized to the global model parameters. Each node, based on its position in the [number]th [phase], The parameters of the first step are updated by performing stochastic gradient descent on the local loss function, thus obtaining the parameters of the second step. Local model parameters of the step Each node executes in each training round. This is a local update; after After the first iteration, the 1st The local model parameters for the wheel are: in, It is the local learning rate. Indicated on the client The gradient on the local loss function.
6. The federated learning method for DAG blockchains based on main chain consensus according to claim 1, characterized in that, The generation of the aggregation model includes: an aggregator For the connected A collection of clients The local model in the data is weighted and averaged; assuming the client... In the The initial model in each round of training comes from the aggregated model set. This represents the maximum number of delay rounds that the system can tolerate, i.e., in the twelfth round. When the training round begins, the client Initialize the local model as the first The aggregation model, and perform a local update; set up For the main chain model The set of clients used for training is of size [number missing]. ;and For other aggregation models The set of clients used for training is of size [number missing]. ; when This indicates the aggregation model of the current round. Primarily based on the main chain model Training; otherwise, it indicates that training primarily relies on other historical aggregation models. ; The aggregation process can be formally represented as: The generation of new blocks includes: an aggregator After completing model aggregation, use its local data to analyze the aggregated model. Perform an accuracy assessment to obtain the accuracy rate. And determine the set of pointers pointing to the referenced block. ;Then, local model collection The corresponding transaction set With aggregation model Package them together to generate a new block. .
7. An electronic device, comprising: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory stores a computer program that, when executed by the processor, causes the processor to perform the federated learning method of the DAG blockchain based on main chain consensus as described in any one of claims 1-6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed, it implements the federated learning method of DAG blockchain based on main chain consensus as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Multi-vehicle intelligent driving cooperative training method based on block chain in Internet of Vehicles
CN120197730A