A blockchain-driven federated learning method for smart grid
By employing a blockchain-driven federated learning approach, local model training and parameter uploading are performed in smart grids. Combining improved MMD weighting factors and blockchain technology, this approach addresses data privacy leaks and malicious node attacks in smart grids, thereby enhancing model generalization performance and system security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2024-06-21
- Publication Date
- 2026-05-29
AI Technical Summary
Smart grids face problems such as data privacy leaks, low efficiency of model collaborative training, and inability to resist malicious node poisoning attacks.
By employing a blockchain-driven federated learning approach, model training is performed on local devices and model update parameters are uploaded. Combined with an improved maximum mean deviation (MMD) weighting factor and blockchain technology for node authentication and model on-chaining, this approach addresses the issues of non-independent and identically distributed models and malicious node attacks in smart grids.
Effectively protect data privacy, improve model generalization performance and prediction accuracy, enhance system transparency and credibility, prevent model tampering, and improve the security and reliability of smart grid systems.
Smart Images

Figure CN118747541B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of smart grid technology, specifically relating to a blockchain-driven smart grid federated learning method. Background Technology
[0002] Federated learning is an advanced machine learning approach designed to address the challenges of training models in distributed data environments. Unlike traditional centralized machine learning, federated learning allows models to be trained locally on devices or nodes, and then the updated parameters are aggregated in an encrypted and secure manner to form an improved version of the global model. This distributed learning approach enables the model training process to occur while user data remains locally, thus solving the problems of data privacy protection and data centralization.
[0003] One of the core advantages of federated learning lies in its robust data privacy protection capabilities. In today's information age, data privacy protection has become a crucial task, especially in areas involving personal privacy or trade secrets, such as healthcare, financial services, and smart grids. By training models on local devices and sharing only model update parameters, federated learning effectively ensures that user data does not leave its local environment, significantly reducing the risk of data leakage and enhancing users' trust in data privacy. Beyond data privacy protection, federated learning can also effectively address the problem of uneven data distribution. In real-world scenarios, data may be distributed across different geographical locations, organizations, or devices. This can cause traditional centralized machine learning methods to be affected by data sampling bias or skew, thus reducing the model's generalization performance. Federated learning, by training models on local devices, allows the model to fully utilize the information from distributed datasets, better adapt to the real-world data distribution, and improve the model's generalization performance and robustness.
[0004] In addition, federated learning offers several other advantages. For example, it reduces data transmission and storage costs because only model parameters, rather than the raw data, are transmitted, reducing the need for network bandwidth and storage space. Furthermore, federated learning enables faster model iteration and updates because each local device can train the model independently, without waiting for all data to be transmitted to a central server or the cloud. Therefore, federated learning is not only significant in protecting data privacy but also provides new opportunities and possibilities for the development of distributed machine learning and intelligent systems.
[0005] Blockchain technology is a decentralized distributed ledger technology, considered a revolutionary innovation. It achieves decentralized data storage and management by linking data together in the form of blocks, replicating and storing them across multiple nodes in the network to form a continuously growing chain. The core characteristics of blockchain include decentralization, immutability, transparency, trustworthiness, and high security. First, the decentralized nature of blockchain means that there is no single manager or central authority controlling the entire system; instead, it is managed and maintained jointly by multiple nodes in the network. This distributed management model eliminates single points of failure and trust issues in traditional centralized systems, improving the system's robustness and reliability. Second, the immutability of blockchain is one of its most important features. Once data is written to the blockchain, it cannot be tampered with or deleted. Each block contains the hash value of the previous block, forming an irreversible data chain. This characteristic guarantees data integrity and reliability, making blockchain an ideal choice for storing value and recording history. Furthermore, the transparency and trustworthiness of blockchain means that all transactions and operations on the blockchain are public and transparent, and anyone can view and verify them. Each node maintains a complete copy of the blockchain data. This distributed data storage and consensus mechanism ensures data consistency and trustworthiness, enhancing the system's transparency and reliability. Finally, blockchain technology boasts high security. It employs advanced cryptographic techniques and consensus mechanisms, such as hash functions, public-private key encryption, and Proof-of-Work (PoW) or Proof-of-Stake (PoS), to protect the blockchain network's security. These security mechanisms prevent malicious data tampering or attacks, ensuring the stable and secure operation of the blockchain network.
[0006] The applications of blockchain technology are extremely broad. As blockchain technology continues to develop and improve, it will continue to play a vital role in various industries, driving the transformation and upgrading of the social economy. From cross-border payments in the financial sector to traceability in supply chain management, and then to patient data management in the healthcare sector, blockchain technology is changing people's lifestyles and work methods, becoming one of the important infrastructures of the 21st century.
[0007] A smart grid is a power system based on advanced information and communication technologies, aiming to achieve efficient, reliable, safe, environmentally friendly, and economically viable transmission, distribution, and utilization of electricity. Smart grids control and optimize power system operation through real-time monitoring, data acquisition, multi-party collaborative modeling, and intelligent analysis and decision-making to adapt to dynamic changes in various electricity demands and energy resources, thereby improving the overall efficiency and reliability of the power system. Currently, smart grids face challenges such as data privacy breaches, low efficiency in model collaborative training, and inability to resist malicious node poisoning attacks. Traditional centralized data storage and processing methods are prone to data leakage risks, while the efficiency of model collaborative training is limited by the non-independent and identically distributed nature of the data among participating parties, and smart grid systems cannot effectively identify malicious nodes.
[0008] The smart grid is a complex system involving the collection, processing, and management of massive amounts of data. Traditional centralized data processing methods typically store all data in a single center, meaning all data must be transmitted to a central server or cloud for processing and analysis. This centralized approach carries several potential risks, the most prominent being data breaches. First, centralized data processing concentrates large amounts of sensitive data in a single location. If this central server or cloud system is attacked or subjected to unauthorized access, users' privacy data is at risk of being leaked. This is particularly concerning in today's information security environment, as personal privacy data and trade secrets could be stolen by hackers or malicious attackers, causing serious losses and consequences. Second, centralized data processing also increases the risks during data transmission. As data travels from various locations to the central server, it may be subject to eavesdropping, tampering, or interception, compromising its integrity and confidentiality. Especially in critical infrastructure like smart grids, data security is paramount; any data breach or damage could severely impact the system's stability and security.
[0009] In a smart grid environment, different participants may possess varying data distribution characteristics, a situation known as the Non-Independent Identical Distribution (Non-IID) problem. Traditional federated learning models may fail to effectively utilize this data for modeling, primarily because they assume all participants have the same data distribution characteristics. However, this assumption often fails in real-world smart grid environments. First, because participants in a smart grid environment may originate from different regions, use different types of equipment, or employ different usage scenarios, their data distribution characteristics can vary significantly. For example, electricity consumption patterns may differ between urban and rural areas, and different types of equipment may generate data with varying characteristics. This data distribution variation prevents traditional federated learning models from fully leveraging this heterogeneous data, thus impacting the model's generalization performance and prediction accuracy. Second, participants in a smart grid environment may possess varying amounts and qualities of data, which also contributes to the Non-Independent IID problem. Some participants may have large data samples, while others may have smaller data volumes; some participants may have high-quality data, while others may have low-quality data. This imbalance in data quantity and quality can cause traditional federated learning models to assign excessive weights to participants with less or lower-quality data during global model updates, thus affecting the model's training performance.
[0010] In a smart grid environment, the diverse and widely distributed equipment of various participants, including generators, transformers, and smart meters, may be manufactured by different companies, posing challenges to the security of federated learning. Malicious nodes can threaten the security and stability of the smart grid system through poisoning attacks, data tampering, and interference with model updates. First, malicious nodes may use poisoning attacks to inject erroneous or malicious data into the federated learning model, disrupting the model's training and prediction processes. This attack may cause the model to produce misleading results, thereby affecting the operational effectiveness and security of the smart grid system. Second, data transmission and model update processes in the smart grid may be vulnerable to man-in-the-middle attacks. Malicious nodes may impersonate legitimate participants, tampering with the content of data transmission or interfering with the model update process to obtain sensitive information or disrupt system operation. This attack may lead to data leakage, tampering, or loss, posing serious security risks to the smart grid system. Summary of the Invention
[0011] The purpose of this invention is to provide a blockchain-driven federated learning method for smart grids, addressing the problems of data privacy leaks, low efficiency in collaborative model training, and inability to resist malicious node poisoning attacks faced by existing smart grids. This invention offers a novel solution for data security and collaborative modeling tasks in smart grids, and is expected to promote the further development and application of smart grid systems.
[0012] The technical solution adopted by this invention to solve the technical problem is as follows:
[0013] The present invention provides a blockchain-driven smart grid federated learning method, which mainly includes the following steps:
[0014] Step S1: Describe the smart grid system;
[0015] Step S2: Establish the optimization objective for federated learning in smart grids;
[0016] Step S3: Establish a data discrepancy measurement scheme in the smart grid;
[0017] Step S4: Establish an adaptive aggregation factor based on an improved MMD similarity metric;
[0018] Step S5: Node authentication and model on-chain.
[0019] Furthermore, the smart grid system consists of a power equipment layer and a secure computing layer; the power equipment layer is used to provide data sensing, acquisition, transmission, and local training of joint models; the secure computing layer is used to verify the legitimacy of access nodes, store uploaded local models, calculate adaptive aggregation factors, and generate a global model.
[0020] Furthermore, the specific operation process of step S2 is as follows:
[0021] The goal of federated learning is to train a global model using a large number of devices in a smart grid for a specific task. Each Device M k Holding a local dataset D k ={(x1,y1),(x2,y2),...,(x m ,y m When performing a federated learning task, the Device connects to the BS via the Station. First, the federated learning task is initialized, and the committee leader broadcasts the task and the initialized global model. Upon receiving the initialized global model After that, DeviceM k Using its data D k Update local model parameters ω k(τ) is used to find the optimal parameters that minimize the loss function for each Device M. k Its loss function is as follows:
[0022]
[0023] in The model parameters are: The j-th data sample (x) j ,y j The loss function;
[0024] Optimize the objective function Defined as:
[0025]
[0026] Furthermore, the local dataset D k It is all the training data D={∪D k A subset of}.
[0027] Furthermore, the specific operation procedure for step S3 is as follows:
[0028] The device collects local data and adds random perturbations that do not affect the data distribution. These extremely small amounts of data are periodically sent to the secure computing layer as data samples for this node, and this is used to characterize the node's data distribution, denoted as Sample Data SD. k ={x1,...x n The objective function is to use MMD to measure the differences in data distribution between different nodes. Minimize under non-independent and identically distributed data, i.e.:
[0029]
[0030] Here, the constraint represents a class of non-independent and identically distributed problems in the distributed federated learning scenario, namely, there exist two nodes k1 and k2 in the same task, and these two nodes hold... and All MMD values exceed the threshold ξ1; or there exists a node k3 holding a value that exceeds the threshold ξ1. Mean of the sampled dataset from joint modeling participants The MMD value exceeds the threshold ξ2.
[0031] Furthermore, the specific operation procedure for step S4 is as follows:
[0032] For any two sample data and They are associated with different nodes respectively, assuming and They are and The probability distribution is mapped to RKHS H using the function Ψ(·). and The improved MMD definition between them is:
[0033]
[0034] in and Representing probability distributions respectively and The expectation, ||Ψ|| H ≤1 defines a set of functions in the unit sphere of RKHSH; in and The biased empirical estimate of MMD is calculated on the solution, i.e.:
[0035]
[0036] in:
[0037]
[0038] Where Ψ(·) represents the kernel-induced eigenmap, Ψ(a) = k(a,·); where Ψ(·) represents the kernel-induced eigenmap, Ψ(a) = k(a,·); a i Indicates from distribution The i-th sample obtained by sampling from the middle, b i Indicates from distribution The i-th sample obtained by sampling from the middle, a i′ Indicates from distribution The i'th sample obtained by sampling from the middle. b i′ Indicates from distribution The i'th sample obtained by sampling from the middle. n1 represents the distribution The number of samples in the middle sampling. n2 represents the distribution The number of samples in the middle sampling. K (s,s) Indicates in the sample set The kernel matrix obtained through internal calculation, K (s,t) Indicates in the sample set and sample set The kernel matrix calculated between them K (t,s) Indicates in the sample set and sample set The kernel matrix calculated between them K (t,t) Indicates in the sample set The kernel matrix obtained through internal calculation, k(a,b) = <Ψ(a),Ψ(b)>;
[0039] For the adaptive aggregation factor δ of node k k The calculation is as follows:
[0040]
[0041] in, These are adjustable hyperparameters. To initiate the computation task, the distribution of the base station-related dataset, τ is the total model in each round. The calculation is as follows:
[0042]
[0043] Where K is the total number of participants, ω k This refers to the local model submitted by the k-th participant.
[0044] Furthermore, the Gaussian kernel function k(a,b) is used to calculate the MMD value, which is defined as follows:
[0045]
[0046] Where σ represents the width of the Gaussian kernel.
[0047] Furthermore, in step S5, before the task begins, each participant generates a registration request and submits the registration request to a smart contract in the blockchain network for processing. The smart contract verifies the legality of the registration request. If the verification is successful, the node information is written into the blockchain; otherwise, the registration request is rejected.
[0048] Furthermore, in step S5, after the training task begins, each participant trains the model locally and generates updated model parameters; each node uploads the updated model parameters to the blockchain network; the smart contract verifies the legitimacy of the nodes, waits to receive all local models, and then performs aggregation by combining the MMD weight factor to obtain the global model, and writes all local models, the global model, and the hash values of all models into the blockchain block.
[0049] The beneficial effects of this invention are:
[0050] (1) Traditional centralized data processing methods in smart grids can easily lead to data being stored in a single center, increasing the potential risk of data leakage.
[0051] To address the aforementioned issues, this invention applies federated learning to smart grids. This method allows each participant in the smart grid to train its model locally, transmitting only the updated parameters to a central server for aggregation. This avoids centralized storage and transmission of raw data and breaks down data silos between participants through model interaction, effectively reducing the risk of local data leakage. This mechanism enables participants in the smart grid to protect their privacy while sharing data, promoting secure data sharing and enhancing the reliability of the smart grid system.
[0052] (2) In the smart grid environment, the data of each participant may exhibit different distribution characteristics, leading to the problem of non-independent and identically distributed data. Traditional federated learning models may not be able to effectively utilize these data for modeling.
[0053] To address the issue of non-independent and identically distributed data in smart grid environments, this invention improves the generalization ability and performance of federated learning algorithms. Specifically, it proposes an improved Maximum Mean Deviation (MMD) weighting factor to enhance the quality of joint modeling tasks. By introducing the MMD weighting factor, more precise control over data distribution differences is achieved during federated learning, thereby improving the model's generalization performance and prediction accuracy. This improvement helps optimize data joint modeling tasks in smart grids, enhancing the overall system performance and efficiency.
[0054] (3) The smart grid environment is complex, with a wide variety of heterogeneous equipment, which poses challenges to the application of federated learning. It may encounter problems such as malicious node poisoning attacks and tampering of local and global models, thereby affecting the efficiency and performance of joint modeling tasks.
[0055] To address the security challenges of federated learning applications in smart grid environments, this invention combines blockchain technology with federated learning to register and authenticate participating devices in federated learning tasks within smart grids, preventing malicious node attacks and interference. Simultaneously, storing the local and global models generated by federated learning on the blockchain enables model traceability and tamper-proofing, enhancing system transparency and credibility, and improving data reliability and model security.
[0056] This invention can effectively address the security challenges faced by federated learning applications in a smart grid environment and promote the development and application of smart grid systems. Attached Figure Description
[0057] Figure 1 This is a diagram of the smart grid system architecture proposed in this invention. Detailed Implementation
[0058] The present invention will be further described in detail below with reference to the accompanying drawings.
[0059] This invention provides a blockchain-driven federated learning method for smart grids, combining blockchain with federated learning to solve technical problems in the smart grid field. The key to this invention lies in applying blockchain to the management and sharing of smart grid data, and combining it with adaptive federated learning to achieve collaborative model training. In specific implementation, each node in the smart grid trains its model using federated learning. Each node trains its model locally and uploads updated model parameters to the blockchain. The blockchain committee leader is responsible for calculating the adaptive aggregation factor and generating the global model. Other nodes can obtain updated model parameters through the blockchain and further train their models, thus achieving collaborative model training. Data exchange and sharing between local models via the blockchain ensures data security and immutability. Furthermore, since data storage and model training are performed locally and securely shared through the blockchain network, problems such as data privacy leaks and low efficiency in collaborative model training can be effectively solved.
[0060] This invention provides a blockchain-driven smart grid federated learning method, which mainly includes the following steps:
[0061] Step S1: Description of the smart grid system;
[0062] The smart grid system architecture proposed in this invention is as follows: Figure 1 As shown, it mainly consists of a power equipment layer and a security computing layer.
[0063] Power Equipment Layer: The main function of the power equipment layer is to provide data sensing, acquisition, transmission, and local training of joint models. In this invention, power equipment is divided into four parts: power generation, transmission, distribution, and consumption. The power generation part mainly includes power generation equipment such as hydropower stations, nuclear power plants, and thermal power plants; the transmission part mainly includes transmission equipment such as high-voltage power lines and substations; the distribution part mainly includes distribution equipment such as distribution lines and distribution transformers; and the consumption part mainly includes household electricity, industrial electricity, and commercial electricity consumption equipment. These four parts, along with their associated sensors, network devices, storage devices, and computing devices, together constitute the power equipment layer.
[0064] Each independently operating station is called a Station, such as a substation, thermal power plant, factory with its own electricity meter, or home user. Each node with monitoring, recording, and transmission capabilities is called a Device, such as a temperature and humidity sensor, camera, voltmeter, or ammeter. Each Station is considered a collection of Devices. Devices use the storage devices within their Stations to store the monitored data and captured images. They also utilize the computing power within the Stations to perform local computations and train local models to ensure privacy. After the blockchain verifies the legitimacy of the nodes, the data is uploaded to the secure computing layer via a wireless base station (BaseStation, BS).
[0065] Secure Computation Layer: The main functions of the secure computation layer are to verify the legitimacy of access nodes, store uploaded local models, calculate adaptive aggregation factors, and generate a global model. The blockchain is maintained by Base Stations (BSs) equipped with computing and caching resources. These BSs hold a distributed database with data synchronization capabilities, storing access node registration information, key features, and federated learning parameters collected by power devices, and are responsible for verifying the legitimacy of access nodes. During task execution, a committee is formed by Stations performing joint modeling tasks. Each Station uploads the hash value of its device's local model to the blockchain via the BS for verification and traceability by other nodes. In addition, Stations upload their local models to the blockchain, where the committee leader (Leader Station) scores them and combines this with the calculated adaptive aggregation factors to perform global model aggregation. All BSs execute the blockchain's consensus process to achieve consistency in the global model.
[0066] Step S2: Establish the optimization objective for federated learning in smart grids;
[0067] In smart grids, when resource-constrained grid devices (such as cameras, sensors, monitors, and industrial robots) need to perform tasks, such as fault detection, they typically use their own datasets to collaboratively train a global model based on federated learning. For example, a device monitors the environment in real time and collects a large amount of production data, training its local model. Then, each device uploads its local model (which may differ from each other due to the heterogeneity of the dataset) to the BS via a station. After verification and recording by the blockchain run by the BS, the Leader Station aggregates and submits it to relevant experts for decision-making, returning the updated global model to each device. Each device repeats the next iteration until the entire training process converges. Through device collaboration based on federated learning, the service quality of the smart grid can be improved.
[0068] Each Device M kHolding a local dataset D k ={(x1,y1),(x2,y2),...,(x m ,y m )},D k It is all the training data D={∪D k A subset of}, when performing learning tasks, the Device connects to the BS via the Station. The goal is to train a global model through learning.
[0069] The first step in federated learning is task initialization, where the Leader Station broadcasts the task and initializes the global model. Then, upon receiving the initialized global model After that, Device M k Using its data D k Update local model parameters ω k (τ) is used to find the optimal parameters that minimize the loss function for each Device M. k Its loss function is as follows:
[0070]
[0071] in The model parameters are: The j-th data sample (x) j ,y j The loss function.
[0072] This invention will optimize the objective function Defined as:
[0073]
[0074] In a smart grid environment, the heterogeneity of data held by different power devices greatly affects the accuracy and efficiency of learning tasks.
[0075] To address the problems arising from centralized data processing in smart grids, this invention introduces federated learning, an emerging technology that allows devices or nodes in the grid to train models locally and then aggregate the updated parameters to form an improved global model. This distributed learning approach not only protects user data privacy and reduces the risk of data leakage but also improves data security and reliability.
[0076] Step S3: Establish a data discrepancy measurement scheme in the smart grid;
[0077] In smart grids, due to the complex and heterogeneous power equipment and the dynamically changing grid environment, even devices performing the same task may exhibit non-independent and identically distributed (Non.IID) data. Therefore, this invention designs a data dissimilarity measurement scheme. First, the device collects local data and adds random perturbations that do not affect the data distribution. These extremely small amounts of data are periodically sent to the secure computing layer as data samples for this node, and this is used to characterize the node's data distribution, denoted as Sample Data SD. k ={x1,...x n The maximum mean deviation (MMD) is used to measure the difference in data distribution between different nodes. The smaller the MMD, the more similar the data distribution, and the smaller the impact on model accuracy.
[0078] In this invention, the goal of federated learning is to train a global model using a large number of devices in a smart grid for a specific task. Make the objective function Minimizing this problem on non-independent and identically distributed (Non.IID) data is an optimization problem, namely:
[0079]
[0080] Here, the constraint represents a class of non-independent identically distributed (Non.IID) problems in distributed federated learning scenarios, namely, there exist two nodes k1 and k2 in the same task, and these two nodes hold... and All MMD values exceed the threshold ξ1; or there exists a node k3 holding a value that exceeds the threshold ξ1. SD of the sampled dataset from joint modeling participants k The MMD value exceeds the threshold ξ2. The thresholds ξ1 and ξ2 can be given empirically under different joint modeling tasks.
[0081] Step S4: Establish an adaptive aggregation factor based on an improved MMD similarity metric;
[0082] If the data distribution held by a local device differs significantly from that of other devices, resulting in low accuracy of the local model, then over-reliance on that particular local model will lead to a decrease in the accuracy of the global model. An adaptive aggregation factor based on an improved MMD similarity metric is designed to assign appropriate weights to newly arriving local models.
[0083] For any two sample data They are associated with different nodes respectively, assuming and They are and The probability distribution is mapped to the reproducing kernel Hilbert space RKHS H by the function Ψ(·). and SD k2 The improved MMD definition between them is:
[0084]
[0085] in and Representing probability distributions respectively and The expectation, ||Ψ|| H ≤1 defines a set of functions in the unit sphere of RKHS H. and The biased empirical estimate of MMD can be calculated from the solution, i.e.:
[0086]
[0087] in:
[0088]
[0089] Where Ψ(·) represents the kernel-induced eigenmap, Ψ(a) = k(a,·); where Ψ(·) represents the kernel-induced eigenmap, Ψ(a) = k(a,·); a i Indicates from distribution The i-th sample obtained by sampling from the middle, b i Indicates from distribution The i-th sample obtained by sampling from the middle, a i′ Indicates from distribution The i'th sample obtained by sampling from the middle. b i′ Indicates from distribution The i'th sample obtained by sampling from the middle. n1 represents the distribution The number of samples in the middle sampling. n2 represents the distribution The number of samples in the middle sampling. K (s,s) Indicates in the sample set The kernel matrix obtained through internal calculation, K (s,t) Indicates in the sample set and sample set The kernel matrix calculated between them K (t,s) Indicates in the sample set and sample set The kernel matrix calculated between them K (t,t) Indicates in the sample set The kernel matrix obtained through internal calculation,
[0090] Note that k(a,b) = <Ψ(a),Ψ(b)>. This invention uses the Gaussian kernel function k(a,b) to calculate the MMD value, which is defined as follows:
[0091]
[0092] Where σ represents the width of the Gaussian kernel.
[0093] For the adaptive aggregation factor δ of node k k The calculation is as follows:
[0094]
[0095] in, These are adjustable hyperparameters. To initiate the computation task, the distribution of the base station-related dataset, τ is the total model in each round. The calculation is as follows:
[0096]
[0097] Where K is the total number of participants, ω k This refers to the local model submitted by the k-th participant.
[0098] This invention proposes an improved Maximum Mean Difference (MMD) weighting algorithm to measure the degree of deviation between the datasets held by each participant and assign corresponding weights to their local models. This optimizes the non-independent and identically distributed problem in smart grid environments, thereby improving the application effect of federated learning models in smart grids. This invention adjusts the weights of each local model in the global model aggregation from the perspective of data distribution, significantly improving the accuracy and convergence of the global model.
[0099] Step S5: Node authentication and model on-chain;
[0100] Before the task begins, each participant generates a registration request, including the device's identity information, public key, etc. The registration request is submitted to a smart contract on the blockchain network for processing. The smart contract verifies the legitimacy of the registration request, including checking the validity of the identity information and public key. If the verification passes, the node information is written to the blockchain; otherwise, the registration request is rejected.
[0101] After the training task begins, each participant trains the model locally and generates updated model parameters. Each node uploads the updated model parameters to the blockchain network. The smart contract verifies the legitimacy of the nodes, waits to receive all local models, and then performs aggregation using the MMD weight factor to obtain the global model. Finally, it writes all local models, the global model, and the hash values of all models into a block on the blockchain.
[0102] This invention leverages the characteristics of blockchain to ensure the immutability of data stored on the blockchain. Once model parameters are written into the blockchain, they cannot be modified or deleted, thus achieving model traceability and tamper-proofing. All model parameters are stored on the blockchain and can be accessed and verified by all participants. Participants can obtain the correct model parameters through the blockchain network, ensuring the integrity and credibility of the model training process.
[0103] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A blockchain-driven federated learning method for smart grids, characterized in that, Includes the following steps: Step S1: Describe the smart grid system; Step S2: Establish the optimization objective for federated learning in smart grids; Step S3: Establish a data discrepancy measurement scheme in the smart grid; Step S4: Establish an adaptive aggregation factor based on an improved MMD similarity metric; For any two sample data and Each is associated with a different node, assuming and They are and The probability distribution, through the function Mapping data to RKHS , and The improved MMD definition between them is: ; in and Representing probability distributions respectively and Expectations RKHS is defined A set of functions in the unit sphere; and The biased empirical estimate of MMD is calculated on the solution, i.e.: ; in: ; in Represents the kernel-induced eigenmap. ; Indicates from distribution The first sample obtained from the middle One sample, ; Indicates from distribution The first sample obtained from the middle One sample, ; Indicates from distribution The first sample obtained from the middle One sample, ; Indicates from distribution The first sample obtained from the middle One sample, ; Indicates from distribution The number of samples in the middle sampling. ; Indicates from distribution The number of samples in the middle sampling. ; Indicates in the sample set The kernel matrix obtained through internal calculation, ; Indicates in the sample set and sample set The kernel matrix calculated between them ; Indicates in the sample set and sample set The kernel matrix calculated between them ; Indicates in the sample set The kernel matrix obtained through internal calculation, ; ; For nodes Adaptive aggregation factor The calculation is as follows: ; in, These are adjustable hyperparameters. To initiate the distribution of base station-related datasets for computation tasks, Total Model for Each Round The calculation is as follows: ; in, The total number of participants. For the first The local models submitted by each participant; Step S5: Node authentication and model on-chain.
2. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, The smart grid system consists of a power equipment layer and a secure computing layer. The power equipment layer is used to provide data sensing, acquisition, transmission, and local training of joint models. The secure computing layer is used to verify the legitimacy of access nodes, store uploaded local models, calculate adaptive aggregation factors, and generate a global model.
3. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, The specific operation procedure for step S2 is as follows: The goal of federated learning is to train a global model using a large number of devices in a smart grid for a specific task. Each Device Holding a local dataset When performing a federated learning task, the Device connects to the BS via the Station. First, the federated learning task is initialized, and the committee leader broadcasts the task and the initialized global model. Upon receiving the initialized global model After that, Device Utilizing its data Update local model parameters To find the optimal parameters that minimize the loss function for each Device Its loss function is as follows: ; in The model parameters are: The Data samples The loss function; Optimize the objective function Defined as: ; in For all training data.
4. The blockchain-driven smart grid federated learning method according to claim 3, characterized in that, The local dataset All training data A subset of.
5. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, The specific operation procedure for step S3 is as follows: The device collects local data and adds random perturbations that do not affect the data distribution. These extremely small amounts of data are periodically sent to the secure computing layer as data samples for this node, and this sample data is used to characterize the node's data distribution. This sample data is denoted as Sample Data. MMD is used to measure the differences in data distribution between different nodes, making the objective function... Minimize under non-independent and identically distributed data, i.e.: ; Here, the constraint represents a class of non-independent and identically distributed problems in the distributed federated learning scenario, that is, there are two nodes in the same task. and And the two nodes hold and The MMD values all exceeded the threshold. ; or there may be a node The holdings Mean of the sampled dataset from joint modeling participants The MMD value exceeds the threshold .
6. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, Using Gaussian kernel function The MMD value is calculated as follows: ; in, This represents the width of the Gaussian kernel.
7. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, In step S5, before the task begins, each participant generates a registration request and submits it to a smart contract in the blockchain network for processing. The smart contract verifies the legality of the registration request. If the verification is successful, the node information is written into the blockchain; otherwise, the registration request is rejected.
8. The blockchain-driven smart grid federated learning method according to claim 1, characterized in that, In step S5, after the training task begins, each participant trains the model locally and generates updated model parameters; each node uploads the updated model parameters to the blockchain network; the smart contract verifies the legitimacy of the nodes, waits to receive all local models, and then performs aggregation by combining the MMD weight factor to obtain the global model, and writes all local models, the global model, and the hash values of all models into the blockchain block.