Block chain-based Internet of things personalized federal learning methodTechnical Field
The invention relates to the field of block chains, in particular to a block chain-based Internet of things personalized federal learning method.
Background
The federated learning system is used as a learning method for collaboratively training a unified model by contributing local data by a plurality of clients, and has the limitation that the model only depends on a single central server and is easily influenced by server faults. The purpose of traditional federal learning is to obtain a globally shared model for all participants. However, when the data distribution of each participant is inconsistent, the global model cannot meet the performance requirement of each federal learning participant, and some participants cannot even obtain a model better than a model trained by only using local data.
Based on the method, the personalized federal learning method of the Internet of things based on the block chain is provided, the problem of heterogeneity in the environment of the Internet of things is solved, the federal learning byzantine fault tolerance is improved, and the privacy of data is improved.
Disclosure of Invention
In view of the above defects in the prior art, the technical problem to be solved by the present invention is to provide a personalized federal learning method for internet of things based on a blockchain, which is provided by the present invention, in view of the needs and disadvantages of the current technical development.
Firstly, the invention provides a block chain-based federal learning incentive method, and the technical scheme adopted for solving the technical problems is as follows:
s01, registering and authenticating terminal equipment and edge computing equipment, registering each terminal equipment and edge computing equipment to a block chain, authenticating each equipment by the block chain, and issuing a certificate;
s02, creating a federal learning task by a block chain intelligent contract, and initializing a training model and parameters;
s03, loading the data sample by the terminal equipment, unloading the data sample to the edge computing equipment, and carrying out local model training;
s04, the edge computing equipment encrypts the local training model parameters and uploads the parameters to a block chain, and after the block chain link points are identified together, a new block is generated;
s05, the intelligent contract aggregates the model parameters, aggregates the model parameters and updates the whole model; the intelligent contract judges whether a preset convergence condition of the model is reached, if not, the next round of training is carried out, and if so, the federal learning task is terminated;
and S06, training the personalized model by the edge computing equipment based on the global model information and combining the data of the edge computing equipment.
Specifically, the related internet of things equipment can be various intelligent terminals, such as mobile phones, glasses, watches, cameras, monitoring equipment and the like. The client side is authenticated through the block chain, and the authentication mode can be a digital certificate, token authentication and other authentication modes. The blockchain may be a public chain, a federation chain, or a private chain. The intelligent contracts are run on a block chain, and a user can create a federal learning task through a template. The loading data samples of the terminal equipment are unloaded to the edge computing equipment and are transmitted in an encryption mode, and the local model training is a gradient training method. The encryption mode can be an asymmetric encryption algorithm such as an RSA algorithm, a DSA algorithm, an ECC algorithm, a DH algorithm and the like. The model parameters are aggregated according to the records on the block chain by an intelligent contract, and the integral model is updated. The received model parameter updating method can use weighted average, and can also be median value. And the block chain transmits the updated model to each participating edge computing device, so that a new round of training and learning is started. Each device redefines the global model according to local data of the device to obtain an individualized model, wherein the global model comprises low-level parameters and high-level parameters, and the individualized model learns the specific characteristics of the device by finely adjusting the high-level parameters of the global model through the local data.
Drawings
Some specific embodiments of the invention will be described in detail hereinafter, by way of illustration and not limitation, with reference to the accompanying drawings. The same reference numbers in the drawings identify the same or similar elements or components. Those skilled in the art will appreciate that the drawings are not necessarily drawn to scale. The objects and features of the present invention will become more apparent in view of the following description taken in conjunction with the accompanying drawings, in which:
fig. 1 is a block chain-based personalized federal learning flow chart of the internet of things.
FIG. 2 is a schematic diagram of the system architecture of the present invention.
Detailed Description
In order to make the present invention more comprehensible with respect to its gist, the present invention will be further described with reference to the accompanying drawings and examples. In the following description, numerous specific details and specific examples are set forth in order to provide a more thorough understanding of the present invention and to provide a thorough understanding of the present invention. While this invention is susceptible of embodiment in many different forms than that described herein, there will be many equivalents to those skilled in the art which incorporate such variations and modifications without departing from the spirit and scope of the invention as defined by the appended claims and their equivalents.
The technology of the present invention will be described in detail below with reference to the accompanying drawings in conjunction with specific embodiments.
The embodiment of the invention provides an Internet of things personalized federal learning method based on a block chain, which comprises the following implementation processes:
s1, terminal devices C1, C2, C3 and C4 and edge computing devices E1, E2, E3 and E4 are respectively registered with a blockchain B, the blockchain B verifies registration information of the devices, and certificates are issued to the devices after the certificates are authenticated.
S2, a user U1 creates an intelligent contract S1 according to the intelligent contract template learned by the federation, the intelligent contract S1 runs on a block chain B, a federated learning task T is created, and a training model M and a parameter omega are initialized.
S3, the edge computing devices E1, E2, E3 and E4 download a training model M and a parameter omega from the block chain B respectively, the terminal devices C1, C2, C3 and C4 load data samples respectively and unload the data samples to the edge computing devices connected respectively, the training is carried out through local computing by executing a program P, a gradient descent method is adopted for training, and the gradient computing formula is as follows:
and locally updating the model parameters omega, and uploading the updated parameters omega to the block chain B in an encrypted manner.
And S4, after encrypting the local training model parameters respectively by the edge computing equipment E1, E2, E3 and E4, uploading the parameters to a block chain B, and after passing consensus, generating a new block.
S5, the intelligent contract S1 aggregates the model parameters, aggregates the model parameters omega, and updates the whole model M; the polymerization formula is as follows:
and the intelligent contract judges whether a preset convergence condition of the model is reached, if not, the next round of training is carried out, and if so, the federal learning task is terminated.
And S6, training the personalized model M by the edge computing devices E1, E2, E3 and E4 based on the information of the global model M and the data of the edge computing devices.