Smart power grid federal learning method driven by block chain

Through the blockchain-driven smart grid federated learning method, the problems of data privacy leakage and low model collaborative training efficiency in smart grids are solved. The improved MMD weight factor and blockchain technology are used to achieve data security and model trustworthiness. degree, prevent malicious attacks, and improve the overall performance and security of the system.

CN118747541AActive Publication Date: 2024-10-08BEIJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202410805661.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-08
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

Smart grid faces problems such as data privacy leakage, low efficiency of model collaborative training, and inability to resist malicious node poisoning attacks.

Method used

Adopting a blockchain-driven smart grid federated learning method, by conducting model training on local devices, only transmitting model update parameters, combined with improved maximum mean deviation (MMD) weight factors and blockchain technology for node certification and model on-chain , ensuring data security and model credibility.

Benefits of technology

It effectively reduces the risk of data leakage, improves the generalization performance and prediction accuracy of the model, prevents attacks from malicious nodes, and enhances the transparency and credibility of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747541A_ABST
    Figure CN118747541A_ABST
Patent Text Reader

Abstract

A blockchain-driven smart power grid federal learning method belongs to the field of smart power grids, and comprises the following steps: describing a smart power grid system; establishing an optimization target of federated learning in the smart power grid; establishing a difference measurement scheme of data in the smart power grid; establishing an adaptive aggregation factor based on improved MMD similarity measurement; and performing node authentication and model uplink. According to the method, each participant in the smart power grid can perform model training on local equipment through federated learning, data islands among the participants are broken, and the risk of local data leakage of the participants is reduced; the generalization ability and the prediction accuracy of the model are improved by improving a federated learning algorithm and introducing an MMD weight factor; the block chain technology is combined with federated learning, malicious node attack and interference are prevented, a local model and a global model generated by federated learning are stored in the block chain, traceability and tampering prevention of the model are realized, and transparency and credibility of the system, data credibility and model security are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of smart grids, and in particular relates to a blockchain-driven smart grid federated learning method. Background Art

[0002] Federated Learning is an advanced machine learning method that aims to address the challenges of model training in a distributed data environment. Unlike traditional centralized machine learning, federated learning allows model training on local devices or nodes, and then aggregates model update parameters 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 be implemented while user data remains locally, thereby solving the problems of data privacy protection and data centralization.

[0003] One of the core advantages of federated learning is its strong data privacy protection capability. In today's information age, data privacy protection has become a critical task, especially in areas involving personal privacy or commercial confidential information, such as healthcare, financial services, and smart grids. By training models on local devices and only sharing model update parameters, federated learning effectively ensures that user data does not leave its local environment, greatly reducing the risk of data leakage and enhancing users' trust in data privacy. In addition to data privacy protection, federated learning can also effectively solve the problem of uneven data distribution. In real scenarios, data may be distributed in different geographical locations, different organizations, or devices, which may cause traditional centralized machine learning methods to be affected by data sampling bias or data skew, thereby reducing the generalization performance of the model. Federated learning, by training models on local devices, enables the model to make full use of the information of distributed data sets, better adapt to the actual distribution of data, and improve the generalization performance and robustness of the model.

[0004] In addition, federated learning has some other advantages. For example, it can reduce the cost of data transmission and storage, because only model parameters rather than raw data are transmitted, reducing the demand for network bandwidth and storage space. In addition, federated learning can also achieve faster model iteration and update, because each local device can independently train the model without waiting for all data to be transmitted to the central server or cloud. Therefore, federated learning is not only of great significance 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 that is considered to be an innovation with revolutionary potential. It realizes decentralized data storage and management by linking data together in the form of blocks and replicating and storing them on multiple nodes in the network to form a growing chain. The core features of blockchain include decentralization, immutability, transparency and trustworthiness, and high security. First of all, the decentralized nature of blockchain means that there is no single manager or central agency controlling the entire system, but it is jointly managed and maintained by multiple nodes in the network. This distributed management model eliminates the single point of failure and trust issues in traditional centralized systems and improves the robustness and reliability of the system. Secondly, 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 feature ensures the integrity and reliability of data, making blockchain an ideal choice for storing value and recording history. In addition, the transparency and credibility of blockchain means that all transactions and operations on the blockchain are open and transparent, and anyone can view and verify them. Each node saves a complete copy of the blockchain data. This distributed data storage and consensus mechanism ensures the consistency and credibility of the data, and enhances the transparency and credibility of the system. Finally, blockchain technology is highly secure. It uses advanced cryptography technology and consensus mechanisms, such as hash functions, public-private key encryption, proof of work (PoW) or proof of stake (PoS), to protect the security of the blockchain network. These security mechanisms prevent data from being maliciously tampered with or attacked, ensuring the stability and secure operation of the blockchain network.

[0006] The application areas of blockchain technology are very wide. As blockchain technology continues to develop and improve, it will continue to play an important role in various industries and promote the transformation and upgrading of social economy. From cross-border payments in the financial field to traceability of supply chain management, to patient data management in the medical and health field, blockchain technology is changing people's lifestyles and working methods, and has become one of the important infrastructures of the 21st century.

[0007] Smart grid is a power system based on advanced information and communication technology, which aims to achieve efficient, reliable, safe, environmentally friendly and economically feasible transmission, distribution and utilization of electricity. Smart grid controls and optimizes the operation of power system through real-time monitoring, data collection, multi-party joint modeling, intelligent analysis and decision-making, so as to adapt to the dynamic changes of various power demands and energy resources and improve the overall efficiency and reliability of power system. At present, smart grid faces problems such as data privacy leakage, inefficient model collaborative training, and inability to resist poisoning attacks by malicious nodes. Traditional centralized data storage and processing methods are prone to data leakage risks. At the same time, the efficiency of model collaborative training is limited by the non-independent and identically distributed problem between the data of the participants, and the smart grid system cannot effectively identify malicious nodes.

[0008] Smart grid is a complex system that involves a large amount of data collection, processing and management. The traditional centralized data processing method usually stores all data in a single center, which means that all data needs to be transmitted to the central server or cloud for processing and analysis. This centralized data processing method has some potential risks, the most prominent of which is the risk of data leakage. First, the centralized data processing method makes a large amount of sensitive data gather in a single location. Once the central server or cloud system is attacked or unauthorized, the user's privacy data will be at risk of leakage. This situation has attracted much attention in the current information security environment, because personal privacy data and commercial confidential information may be stolen by hackers or malicious attackers, causing serious losses and consequences. Secondly, the centralized data processing method also increases the risk in the data transmission process. In the process of data transmission from various places to the central server, the data may be threatened by eavesdropping, tampering or interception, resulting in the loss of data integrity and confidentiality. Especially in critical infrastructure such as smart grids, data security is of vital importance, and any data leakage or damage may have a serious impact on the stability and security of the system.

[0009] Each participant in the smart grid environment may have different data distribution characteristics, which is called the non-independent and identically distributed (Non-IID) problem. Traditional federated learning models may not be able to effectively use these data for modeling. The main reason is that traditional federated learning models assume that the data of all participants have the same distribution characteristics, but in the actual smart grid environment, this assumption is often not true. First, since the participants in the smart grid environment may come from different regions, different types of equipment, or different usage situations, their data distribution characteristics may vary greatly. For example, the electricity consumption patterns in urban and rural areas may be different, and different types of equipment may also generate different data characteristics. This difference in data distribution will cause the traditional federated learning model to be unable to fully utilize these heterogeneous data for modeling, thereby affecting the generalization performance and prediction accuracy of the model. Second, the participants in the smart grid environment may have different data volumes and data qualities, which will also lead to the emergence of non-independent and identically distributed problems. Some participants may have a large number of data samples, while others may have less data; some participants may have high data quality, while others may have low data quality. This imbalance in data volume and quality will cause traditional federated learning models to give too much weight to participants with less data or lower data quality when updating the global model, thus affecting the training effect of the model.

[0010] In the smart grid environment, the equipment of each participant is of various types and widely distributed, including generators, transformers, smart meters, etc. These devices may be produced by different manufacturers, which poses a challenge to the security of federated learning. Malicious nodes may threaten the security and stability of the smart grid system by poisoning attacks, tampering with data, interfering with model updates, etc. First, malicious nodes may use poisoning attacks to inject erroneous data or malicious data into the federated learning model to disrupt the model's training and prediction process. This attack may cause the model to produce misleading results, which in turn affects the operation and security of the smart grid system. Secondly, the data transmission and model update process in the smart grid may be threatened by man-in-the-middle attacks. Malicious nodes may disguise themselves as legitimate participants, tamper with the content of data transmission or interfere with the model update process to obtain sensitive information or disrupt the operation of the system. This attack may lead to the leakage, tampering or loss of data, 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 smart grid federated learning method to solve the problems of data privacy leakage, low efficiency of model collaborative training, and inability to resist malicious node poisoning attacks faced by existing smart grids. This invention provides a new solution for data security and joint 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 the present invention to solve the technical problem is as follows:

[0013] A blockchain-driven smart grid federated learning method of the present invention mainly includes the following steps:

[0014] Step S1: describing the smart grid system;

[0015] Step S2: Establishing the optimization goal of federated learning in smart grid;

[0016] Step S3: Establish a difference measurement scheme for data in smart grid;

[0017] Step S4: establishing an adaptive aggregation factor based on the improved MMD similarity metric;

[0018] Step S5: Node authentication and model uploading.

[0019] Furthermore, the smart grid system consists of a power equipment layer and a security computing layer; the power equipment layer is used to provide data perception, collection, transmission and local training of joint models; the security computing layer is used to verify the legitimacy of access nodes, store uploaded local models, calculate adaptive aggregation factors and generate global models.

[0020] Furthermore, the specific operation process of step S2 is as follows:

[0021] The goal of federated learning is to train a global model for a specific task through a large number of devices in the smart grid. Each Device M k Holds a local dataset D k ={(x 1 ,y 1 ),(x 2 ,y 2 ),...,(x m ,y m )}, when executing a federated learning task, the Device connects to the BS through the Station, and first initializes the federated learning task. The committee leader broadcasts the task and the initialized global model Upon receiving the initialized global model After that, DeviceM k Using its data Dk Update local model parameters ω k (τ) to find the optimal parameters that minimize the loss function. For each Device M k , and its loss function is as follows:

[0022]

[0023] in The model parameters are The jth data sample (x j ,y j )’s loss function;

[0024] The objective function to be optimized Defined as:

[0025]

[0026] Furthermore, the local data set D k is all the training data D = {∪D k}.

[0027] Furthermore, the specific operation process of step S3 is as follows:

[0028] Device collects local data and adds random disturbances that do not affect the data distribution. These extremely small amounts of data are sent to the secure computing layer at regular intervals as data samples of this node, and are used to characterize the data distribution of the node, recorded as Sample Data SD. k ={x 1 ,...x n}, using MMD to measure the data distribution differences between different nodes, so that the objective function Minimize under non-independent and identically distributed data, that is:

[0029]

[0030] The constraint represents a type of non-independent and identically distributed problem in the distributed federated learning scenario, that is, there are two nodes k in the same task. 1 and k 2 , and the two nodes hold and The MMD values ​​all exceed the threshold ξ 1 ; or there is a node k 3 Held The mean of the sampled data set of the joint modeling participants The MMD value exceeds the threshold ξ 2 .

[0031] Furthermore, the specific operation process of step S4 is as follows:

[0032] For any two sample data and Associated with different nodes respectively, assuming and They are and The probability distribution of , through the function Ψ (·) to map the data to RKHS H, and The improved MMD between them is defined as:

[0033]

[0034] in and Represents the probability distribution and Expectations, ||Ψ|| H ≤1 defines a set of functions in the unit ball of RKHSH; and The biased empirical estimate of MMD is calculated on the solution of , namely:

[0035]

[0036] in:

[0037]

[0038] where Ψ(·) represents the kernel-induced feature map, Ψ(a)=k(a,·); where Ψ(·) represents the kernel-induced feature map, Ψ(a)=k(a,·); a i Indicates that from the distribution The i-th sample is sampled from b i Indicates that from the distribution The i-th sample is sampled from a i′ Indicates that from the distribution The i'th sample is sampled from b i′ Indicates that from the distribution The i'th sample is sampled from n 1 Indicates that from the distribution The number of samples to be drawn, n 2 Indicates that from the distribution The number of samples to be drawn, K (s,s) Indicates that in the sample set The kernel matrix calculated internally, K(s,t) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,s) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,t) Indicates that in the sample set The kernel matrix calculated internally, k(a,b)=<Ψ(a),Ψ(b)>;

[0039] Adaptive aggregation factor δ for node k k Calculated as:

[0040]

[0041] in, is an adjustable hyperparameter, The distribution of the data set related to the base station that initiates the calculation task, τ, the total model per round Calculated as:

[0042]

[0043] Where K is the total number of participants, ω k is the local model submitted by the kth participant.

[0044] Furthermore, the Gaussian kernel function k(a,b) is used to calculate the MMD value, which is defined as follows:

[0045]

[0046] Here, σ represents the width of the Gaussian kernel.

[0047] Furthermore, in step S5, before the task starts, each participant generates a registration request and submits the registration request to the smart contract in the blockchain network for processing; the smart contract verifies the legitimacy of the registration request. If the verification passes, the node information is written into the blockchain, otherwise the registration request is rejected.

[0048] Furthermore, in step S5, after the training task starts, 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 node, waits for all local models to be received, and then performs aggregation based on 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 blocks of the blockchain.

[0049] The beneficial effects of the present invention are:

[0050] (1) The traditional centralized data processing method in smart grids easily leads to the centralized storage of data in a single center, increasing the potential risk of data leakage.

[0051] In order to solve the above problems, the present invention applies federated learning in smart grids. Through federated learning, each participant in the smart grid can perform model training on local devices, and only transmit the model update parameters to the central server for aggregation, avoiding the centralized storage and transmission of original data. Through model interaction, the data islands between participants are broken, thereby effectively reducing the risk of local data leakage of participants. This mechanism enables each participant in the smart grid to protect its privacy while sharing data, promoting the secure sharing of data and the reliability of the smart grid system.

[0052] (2) The data of each participant in the smart grid environment may show different distribution characteristics, resulting in non-independent and identically distributed problems. Traditional federated learning models may not be able to effectively utilize these data for modeling.

[0053] In view of the non-IID problem in the smart grid environment, the present invention improves the generalization ability and performance of the model by improving the federated learning algorithm. The present invention proposes an improved maximum mean deviation (MMD) weight factor to improve the quality of the joint modeling task. By introducing the MMD weight factor, the data distribution difference is more finely controlled during the federated learning process, thereby improving the generalization performance and prediction accuracy of the model. This improvement measure helps to optimize the data joint modeling task in the smart grid and improve the overall performance and efficiency of the system.

[0054] (3) The smart grid environment is complex, with a wide variety of heterogeneous devices, which poses challenges to the application of federated learning. It may encounter problems such as poisoning attacks by malicious nodes and tampering of local and global models, thus affecting the efficiency and performance of the joint modeling task.

[0055] In order to solve the security issues faced by federated learning applications in smart grid environments, the present invention combines blockchain technology with federated learning to register and authenticate the devices participating in the federated learning tasks in smart grids to prevent malicious node attacks and interference. At the same time, the local model and global model generated by federated learning are stored in the blockchain, which can realize the traceability and tamper-proof of the model, enhance the transparency and credibility of the system, and improve the credibility of the data and the security of the model.

[0056] The present invention can effectively address the security challenges faced by federated learning applications in smart grid environments and promote the development and application of smart grid systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 This is a diagram of the smart grid system architecture proposed in the present invention. DETAILED DESCRIPTION

[0058] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0059] The present invention provides a blockchain-driven smart grid federated learning method, which combines blockchain with federated learning to solve technical problems in the field of smart grids. The key point of the present invention is to apply blockchain to the management and sharing of smart grid data, and to realize the collaborative training of models in combination with adaptive federated learning. In specific implementation, each node in the smart grid adopts a federated learning method to train the model. Each node trains the model locally and uploads the updated model parameters to the blockchain. The leader of the blockchain committee is responsible for calculating the adaptive aggregation factor and generating the global model. Other nodes can obtain the updated model parameters through the blockchain and further train the model, thereby realizing the collaborative training of the model; each local model exchanges and shares data through the blockchain, ensuring the security and non-tamperability of the data. At the same time, since the data storage and model training processes are both carried out locally and securely shared through the blockchain network, it can effectively solve the problems of data privacy leakage and low efficiency of model collaborative training.

[0060] The present invention provides a blockchain-driven smart grid federated learning method, which mainly includes the following steps:

[0061] Step S1: Smart grid system description;

[0062] The smart grid system architecture proposed by the present invention is as follows: Figure 1 As shown, it is mainly composed of the power equipment layer and the security computing layer.

[0063] Power equipment layer: The main function of the power equipment layer is to provide data perception, collection, transmission and local training of joint models. In the present invention, power equipment is divided into four parts: power generation, transmission, distribution and power consumption. The power generation part mainly includes power generation equipment such as hydropower stations, nuclear power stations, and thermal power stations. The transmission part mainly includes power transmission equipment such as high-voltage wires and substations. The distribution part mainly includes distribution lines, distribution transformers and other distribution equipment. The power consumption part mainly includes household electricity, industrial electricity, commercial electricity and other power consumption equipment. These four parts plus their corresponding sensors, network equipment, storage equipment, computing equipment, etc. together constitute the power equipment layer.

[0064] Among them, each independently working site is recorded as a Station, such as a substation, a thermal power station, a factory with an independent electricity meter, and a household user. Each node with monitoring, recording, and transmission capabilities is recorded as a Device, such as a temperature and humidity sensor, a camera, a voltmeter, an ammeter, etc. Each Station is regarded as a collection of a series of Devices. The Device uses the storage device in the Station to which it belongs to store the monitored data and captured images, and uses the computing power equipment in the Station to perform local calculations and train local models to ensure privacy. After the blockchain verifies the legitimacy of the node, it is uploaded to the secure computing layer through the wireless base station BaseStation (BS).

[0065] Secure computing layer: The main functions of the secure computing layer are to verify the legitimacy of access nodes, store uploaded local models, calculate adaptive aggregation factors and generate global models. The blockchain is maintained by a BS equipped with computing and caching resources. It holds a distributed database with data synchronization functions, stores the registration information of access nodes, key features and federated learning parameters collected by power equipment, etc., and is responsible for the legitimacy verification of access nodes. When performing tasks, a committee is formed by the Stations that perform joint modeling tasks. The Station uploads the hash value of the local model of the Device to the blockchain through the BS for verification and traceability by other nodes. In addition, the Station uploads the local model to the blockchain, which is scored by the leader of the committee, and the global model is aggregated in combination with the calculated adaptive aggregation factor. All BSs execute the consensus process of the blockchain to achieve consistency of the global model.

[0066] Step S2: Establishing the optimization goal of federated learning in smart grid;

[0067] In smart grids, when resource-constrained grid devices (such as cameras, sensors, monitors, industrial robots, etc.) need to complete tasks, such as fault detection, they usually use their own data sets to collaboratively train global models based on federated learning. For example, Device monitors the environment in real time and collects a large amount of production data, and trains its local model. Then, each Device uploads its local model (which may be different from each other due to the heterogeneity of the data set) to the BS through the Station. After verification and recording by the blockchain run by the BS, it is aggregated by the committee leader Leader Station and submitted to relevant experts for decision-making, and the updated global model is returned to each Device. Each Device repeats the next iteration until the entire training process converges. The service quality of the smart grid can be improved through device collaboration based on federated learning.

[0068] Each Device M kHolds a local dataset D k ={(x 1 ,y 1 ),(x 2 ,y 2 ),...,(x m ,y m )},D k is all the training data D = {∪D k}, when performing learning tasks, the Device connects to the BS through the Station. The goal is to train a global model through learning

[0069] The first step of federated learning is task initialization. The committee leader Station broadcasts the task and the initialized global model. Then, upon receiving the initialized global model After that, Device M k Using its data D k Update local model parameters ω k (τ) to find the optimal parameters that minimize the loss function. For each Device M k , and its loss function is as follows:

[0070]

[0071] in The model parameters are The jth data sample (x j ,y j ) is the loss function of .

[0072] The present invention optimizes the objective function Defined as:

[0073]

[0074] In the smart grid environment, the heterogeneity of data held by different power devices greatly affects the accuracy and efficiency of learning tasks.

[0075] In order to solve the problems caused by the centralized data processing method in the smart grid, the present invention introduces the emerging technology of federated learning, which allows devices or nodes in the power grid to train models locally, and then aggregate the model update parameters to form an improved version of the global model. This distributed learning method not only protects the privacy of user data and reduces the risk of data leakage, but also improves the security and reliability of data.

[0076] Step S3: Establish a difference measurement scheme for data in smart grid;

[0077] In smart grids, due to the complex and heterogeneous power equipment and the dynamic and changeable power grid environment, even in devices performing the same task, there is a non-independent and identically distributed (Non.IID) situation in the data. Therefore, the present invention designs a data difference 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 sent to the secure computing layer at regular intervals as the data sample of this node, and this is used to characterize the data distribution of the node, recorded as Sample Data SD k ={x 1 ,...x n}, the maximum mean deviation (MMD) is used to measure the data distribution differences between different nodes. The smaller the MMD, the more similar the data distribution is, that is, the smaller the impact on model accuracy.

[0078] In this invention, the goal of federated learning is to train a global model for a specific task through a large number of devices in the smart grid. Make the objective function Minimization under non-independent and identically distributed (Non.IID) data is an optimization problem, namely:

[0079]

[0080] The constraint represents a type of non-independent and identically distributed (Non.IID) problem in the distributed federated learning scenario, that is, there are two nodes k in the same task. 1 and k 2 , and the two nodes hold and The MMD values ​​all exceed the threshold ξ 1 ; or there is a node k 3 Held The mean SD of the sampled data set of the joint modeling participants k The MMD value exceeds the threshold ξ 2 , threshold ξ 1 and threshold ξ 2 It can be given based on experience under different joint modeling tasks.

[0081] Step S4: establishing an adaptive aggregation factor based on the improved MMD similarity metric;

[0082] If the data distribution held by a local device is far different from that of other devices, resulting in a low local model accuracy, relying too much on this specific local model will lead to a decrease in the accuracy of the global model. The adaptive aggregation factor based on the improved MMD similarity metric is designed to assign appropriate weights to the newly arrived local models.

[0083] For any two sample data, Associated with different nodes respectively, assuming and They are and The probability distribution of , through the function Ψ (·) to map the data to the reproducing kernel Hilbert space RKHS H, and SD k2 The improved MMD between them is defined as:

[0084]

[0085] in and Represents the probability distribution and Expectations, ||Ψ|| H ≤1 defines a set of functions in the unit ball of RKHS H. and The biased empirical estimate of MMD can be calculated on the solution of , namely:

[0086]

[0087] in:

[0088]

[0089] where Ψ(·) represents the kernel-induced feature map, Ψ(a)=k(a,·); where Ψ(·) represents the kernel-induced feature map, Ψ(a)=k(a,·); a i Indicates that from the distribution The i-th sample is sampled from b i Indicates that from the distribution The i-th sample is sampled from a i′ Indicates that from the distribution The i'th sample is sampled from b i′ Indicates that from the distribution The i'th sample is sampled from n 1 Indicates that from the distribution The number of samples to be drawn, n 2 Indicates that from the distribution The number of samples to be drawn, K (s,s) Indicates that in the sample set The kernel matrix calculated internally, K (s,t) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,s) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,t) Indicates that in the sample set The kernel matrix calculated internally,

[0090] Note that k(a,b)=<Ψ(a),Ψ(b)>. The present invention uses the Gaussian kernel function k(a,b) to calculate the MMD value, which is defined as follows:

[0091]

[0092] Here, σ represents the width of the Gaussian kernel.

[0093] Adaptive aggregation factor δ for node k k Calculated as:

[0094]

[0095] in, is an adjustable hyperparameter, The distribution of the data set related to the base station that initiates the calculation task, τ, the total model per round Calculated as:

[0096]

[0097] Where K is the total number of participants, ω k is the local model submitted by the kth participant.

[0098] The present invention proposes an improved maximum mean difference (MMD) weight algorithm to measure the degree of deviation between the data sets held by each participant, and assign corresponding weights to the local models held to optimize the non-independent and identically distributed problem in the smart grid environment, thereby improving the application effect of the federated learning model in the smart grid. The present invention adjusts the weight 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 uploading;

[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 the smart contract in 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 is successful, the node information is written into 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 node, waits for all local models to be received, and then aggregates them with the MMD weight factor to obtain the global model. The hash values ​​of all local models, global models, and all models are written into the blockchain block.

[0102] The present invention uses the characteristics of blockchain to ensure that the data stored on the blockchain cannot be tampered with. Once the model parameters are written into the blockchain, they cannot be modified or deleted, thereby achieving traceability and tamper-proofing of the model. 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 is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A blockchain-driven smart grid federated learning method, characterized in that: The following steps are involved: Step S1: describing the smart grid system; Step S2: Establishing the optimization goal of federated learning in smart grid; Step S3: Establish a difference measurement scheme for data in smart grid; Step S4: establishing an adaptive aggregation factor based on the improved MMD similarity metric; Step S5: Node authentication and model uploading.

2. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: The smart grid system consists of an electric power equipment layer and a secure computing layer; the electric power equipment layer is used to provide data perception, collection, 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 global models.

3. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: The specific operation process of step S2 is as follows: The goal of federated learning is to train a global model for a specific task through a large number of devices in the smart grid. Each Device M k Holds a local dataset D k ={(x1,y1),(x2,y2),...,(x m ,y m )}, when executing a federated learning task, the Device connects to the BS through the Station, and first initializes the federated learning task. 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 (τ) to find the optimal parameters that minimize the loss function. For each Device M k , and its loss function is as follows: in The model parameters are The jth data sample (x j ,y j )’s loss function; The objective function to be optimized Defined as:

4. A blockchain-driven smart grid federated learning method according to claim 3, characterized in that: The local dataset D k is all the training data D = {∪D k }.

5. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: The specific operation process of step S3 is as follows: Device collects local data and adds random disturbances that do not affect the data distribution. These extremely small amounts of data are sent to the secure computing layer at regular intervals as data samples of this node, and are used to characterize the data distribution of the node, recorded as Sample Data SD. k ={x1,...x n }, using MMD to measure the data distribution differences between different nodes, so that the objective function Minimize under non-independent and identically distributed data, that is: Among them, the constraint represents a type of non-independent and identically distributed problem in the distributed federated learning scenario, that is, there are two nodes k1 and k2 in the same task, and the two nodes hold and The MMD values ​​of all nodes exceed the threshold ξ1; or there is a node k3 holding The mean of the sampled data set of the joint modeling participants The MMD value exceeds the threshold ξ2.

6. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: The specific operation process of step S4 is as follows: For any two sample data and Associated with different nodes respectively, assuming and They are and The probability distribution of , the data is mapped to RKHSH through the function Ψ(·), and The improved MMD between them is defined as: in and Represents the probability distribution and Expectations, ||Ψ|| H ≤1 defines a set of functions in the unit ball of RKHSH; and The biased empirical estimate of MMD is calculated on the solution of , namely: in: where Ψ(·) represents the kernel-induced feature map, Ψ(a) = k(a,·); a i Indicates that from the distribution The i-th sample is sampled from b i Indicates that from the distribution The i-th sample is sampled from a i′ Indicates that from the distribution The i'th sample is sampled from b i′ Indicates that from the distribution The i'th sample is sampled from n1 represents the distribution The number of samples to be sampled, n2 represents the distribution The number of samples to be sampled, K (s,s) Indicates that in the sample set The kernel matrix calculated internally, K (s,t) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,s) Indicates that in the sample set and sample set The kernel matrix calculated between K (t,t) Indicates that in the sample set The kernel matrix calculated internally, k(a,b)=<Ψ(a),Ψ(b)>; Adaptive aggregation factor δ for node k k Calculated as: in, is an adjustable hyperparameter, The distribution of the data set related to the base station that initiates the calculation task, τ, the total model per round Calculated as: Where K is the total number of participants, ω k is the local model submitted by the kth participant.

7. A blockchain-driven smart grid federated learning method according to claim 6, characterized in that: The Gaussian kernel function k(a,b) is used to calculate the MMD value, which is defined as follows: Here, σ represents the width of the Gaussian kernel.

8. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: In step S5, before the task starts, each participant generates a registration request and submits the registration request to the smart contract in the blockchain network for processing; the smart contract verifies the legitimacy of the registration request. If the verification passes, the node information is written into the blockchain, otherwise the registration request is rejected.

9. A blockchain-driven smart grid federated learning method according to claim 1, characterized in that: In step S5, after the training task starts, 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 node, waits for all local models to be received, and then performs aggregation based on 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 block of the blockchain.

Citation Information

Patent Citations

  • User electricity consumption prediction method based on IPFS and federated learning

    CN116384552A

  • Robust federated learning privacy protection system based on block chain

    CN117113413A

  • Credible federal learning method based on intelligent contract incentive mechanism

    CN117829266A

  • Federal learning privacy protection system and method based on block chain and privacy computing technology

    CN117852068A

  • Computer implemented multi-layer federated learning method based on distributed clustering and non-transitory computer readable medium thereof

    US20240054352A1

Cited By

  • Network intrusion detection method and device, computer equipment and storage medium

    CN120018138A

  • Network intrusion detection method and device, computer device and storage medium

    CN120018138B