CN114185988A - Block chain-based global model determination method and device and storage medium - Google Patents
Block chain-based global model determination method and device and storage medium Download PDFInfo
- Publication number
- CN114185988A CN114185988A CN202111305848.1A CN202111305848A CN114185988A CN 114185988 A CN114185988 A CN 114185988A CN 202111305848 A CN202111305848 A CN 202111305848A CN 114185988 A CN114185988 A CN 114185988A
- Authority
- CN
- China
- Prior art keywords
- target
- edge device
- global
- parameter
- global model
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 48
- 238000003860 storage Methods 0.000 title claims abstract description 21
- 238000012549 training Methods 0.000 claims abstract description 101
- 230000002776 aggregation Effects 0.000 claims description 80
- 238000004220 aggregation Methods 0.000 claims description 80
- 239000011159 matrix material Substances 0.000 claims description 57
- 238000012360 testing method Methods 0.000 claims description 44
- 238000012544 monitoring process Methods 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 10
- 238000004422 calculation algorithm Methods 0.000 claims description 9
- 238000009826 distribution Methods 0.000 description 23
- 238000005516 engineering process Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000010801 machine learning Methods 0.000 description 3
- 230000009467 reduction Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 238000009828 non-uniform distribution Methods 0.000 description 2
- 238000012935 Averaging Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000009827 uniform distribution Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/20—Design optimisation, verification or simulation
- G06F30/27—Design optimisation, verification or simulation using machine learning, e.g. artificial intelligence, neural networks, support vector machines [SVM] or training a model
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Evolutionary Computation (AREA)
- Databases & Information Systems (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Computing Systems (AREA)
- Life Sciences & Earth Sciences (AREA)
- Medical Informatics (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Geometry (AREA)
- Image Analysis (AREA)
Abstract
The application discloses a global model determining method and device based on a block chain, a storage medium and computer equipment, wherein the method comprises the following steps: determining a plurality of target edge device nodes participating in local training, sending a local training instruction to the target edge device nodes so that the target edge device nodes can obtain target edge device parameters according to the local training instruction, and writing first target addresses corresponding to the target edge device parameters into a block chain network; acquiring the target edge device parameters from the target edge device nodes based on each first target address, and acquiring a target mean vector and a target variance vector according to the target edge device parameters; and determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
Description
Technical Field
The present application relates to the field of internet technologies, and in particular, to a global model determination method and apparatus based on a block chain, a storage medium, and a computer device.
Background
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. With the rapid development of internet technology, the blockchain technology is being favored by more and more people.
In the block chain technology, in order to ensure data privacy and break data islands, machine learning tasks can be distributed to each terminal equipment node for learning, and then result data generated by learning of all terminal equipment nodes are aggregated to obtain a final training model. The aggregation method generally includes simply averaging result data corresponding to each terminal device node. However, in practice, local data of each terminal device node is distributed in a non-independent and uniform manner, and the final training model obtained by the aggregation method is poor in application effect.
Disclosure of Invention
In view of this, the present application provides a global model determining method and apparatus based on a block chain, a storage medium, and a computer device, which can reduce the influence of data skewness on a target global parameter corresponding to a target global model and improve the accuracy of the target global model under the condition that local data of each target edge device node obeys non-independent and same distribution.
According to an aspect of the present application, there is provided a global model determining method based on a block chain, applied to an aggregation node, including:
determining a plurality of target edge device nodes participating in local training, and sending a local training instruction to the target edge device nodes so that the target edge device nodes obtain target edge device parameters according to the local training instruction, and writing first target addresses corresponding to the target edge device parameters into a block chain network;
acquiring the target edge device parameters from the target edge device nodes based on each first target address, and acquiring a target mean vector and a target variance vector according to the target edge device parameters;
and determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
Optionally, the obtaining a target mean vector and a target variance vector according to the target edge device parameter specifically includes:
determining a target matrix corresponding to the target edge device nodes according to the target edge device parameters, wherein the number of columns of the target matrix is consistent with the number of the target edge device nodes, the number of rows of the target matrix is consistent with the dimension of any target edge device parameter, and the dimension corresponding to any target edge device parameter is the same;
determining a row mean value corresponding to any row element in the target matrix based on the target matrix;
and respectively subtracting the corresponding row mean values from any row element in the target matrix to obtain a target distance matrix, and obtaining a target mean vector and a target variance vector based on the target distance matrix.
Optionally, the determining a target global parameter according to the target mean vector and the target variance vector specifically includes:
and obtaining a target random number vector through a preset random algorithm based on the target mean vector and the target variance vector, and determining a target global parameter based on the target random number vector and the target mean vector.
Optionally, the obtaining a target global model based on the target global parameter specifically includes:
updating preset global parameters corresponding to a preset global model in the aggregation node through the target global parameters to obtain an updated global model;
testing the updated global model through a preset test set, and counting the test accuracy;
when the test accuracy is smaller than or equal to a preset accuracy threshold, taking the updated global model as the target global model;
and when the test accuracy is greater than the preset accuracy threshold, re-determining the target global parameter.
Optionally, when the test accuracy is greater than the preset accuracy threshold, re-determining the target global parameter specifically includes:
when the test accuracy is greater than the preset accuracy threshold, writing a second target address corresponding to the target global parameter into the block chain network, and broadcasting the second target address to the target edge device node, so that the target edge device node obtains the target global parameter based on the second target address, and updates the target edge device parameter based on the target global parameter;
and acquiring the updated target edge device parameters, and re-determining the target global parameters.
According to another aspect of the present application, another global model determining method based on a blockchain is provided, which is applied to a target edge device node, and includes:
receiving a local training instruction sent by an aggregation node, and downloading a preset global model from a block chain network;
training the preset global model based on preset local data, obtaining target edge equipment parameters after the training is finished, and generating a first target address corresponding to the target edge equipment parameters;
writing the first target address into the block chain network so that the aggregation node obtains the target edge device parameters according to the first target address, obtaining a target mean vector and a target variance vector based on the target edge device parameters, determining target global parameters according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameters, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
Optionally, the method further comprises:
monitoring the aggregation node in real time, and acquiring the target global parameter from the aggregation node based on a second target address after monitoring that the aggregation node broadcasts the second target address;
and updating a preset global parameter corresponding to the preset global model in the target edge device node according to the target global parameter, training the updated preset global model according to the preset local data, and updating the target edge device parameter after the training is finished.
According to another aspect of the present application, there is provided a global model determining apparatus based on a block chain, applied to an aggregation node, including:
the node determining module is used for determining a plurality of target edge device nodes participating in local training, sending local training instructions to the target edge device nodes so that the target edge device nodes obtain target edge device parameters according to the local training instructions, and writing first target addresses corresponding to the target edge device parameters into a block chain network;
a parameter obtaining module, configured to obtain the target edge device parameter from the target edge device node based on each first target address, and obtain a target mean vector and a target variance vector according to the target edge device parameter;
and the model determining module is used for determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
Optionally, the parameter obtaining module is specifically configured to:
determining a target matrix corresponding to the target edge device nodes according to the target edge device parameters, wherein the number of columns of the target matrix is consistent with the number of the target edge device nodes, the number of rows of the target matrix is consistent with the dimension of any target edge device parameter, and the dimension corresponding to any target edge device parameter is the same; determining a row mean value corresponding to any row element in the target matrix based on the target matrix; and respectively subtracting the corresponding row mean values from any row element in the target matrix to obtain a target distance matrix, and obtaining a target mean vector and a target variance vector based on the target distance matrix.
Optionally, the model determining module is specifically configured to:
and obtaining a target random number vector through a preset random algorithm based on the target mean vector and the target variance vector, and determining a target global parameter based on the target random number vector and the target mean vector.
Optionally, the model determining module is specifically further configured to:
updating preset global parameters corresponding to a preset global model in the aggregation node through the target global parameters to obtain an updated global model; testing the updated global model through a preset test set, and counting the test accuracy; when the test accuracy is smaller than or equal to a preset accuracy threshold, taking the updated global model as the target global model; and when the test accuracy is greater than the preset accuracy threshold, re-determining the target global parameter.
Optionally, the model determining module is specifically further configured to:
when the test accuracy is greater than the preset accuracy threshold, writing a second target address corresponding to the target global parameter into the block chain network, and broadcasting the second target address to the target edge device node, so that the target edge device node obtains the target global parameter based on the second target address, and updates the target edge device parameter based on the target global parameter; and acquiring the updated target edge device parameters, and re-determining the target global parameters.
According to another aspect of the present application, there is provided a global model determining apparatus based on a block chain, applied to a target edge device node, including:
the model downloading module is used for receiving a local training instruction sent by the aggregation node and downloading a preset global model from the block chain network;
the parameter generation module is used for training the preset global model based on preset local data, obtaining target edge equipment parameters after the training is finished, and generating a first target address corresponding to the target edge equipment parameters;
an address writing module, configured to write the first target address into the blockchain network, so that the aggregation node obtains the target edge device parameter according to the first target address, obtains a target mean vector and a target variance vector based on the target edge device parameter, determines a target global parameter according to the target mean vector and the target variance vector, obtains a target global model based on the target global parameter, writes the target global model into the blockchain network, and broadcasts the target global model to a node in the blockchain network.
Optionally, the apparatus further comprises:
the monitoring module is used for monitoring the aggregation node in real time, and acquiring the target global parameter from the aggregation node based on a second target address after monitoring that the aggregation node broadcasts the second target address;
and the parameter updating module is used for updating a preset global parameter corresponding to the preset global model in the target edge equipment node according to the target global parameter, training the updated preset global model according to the preset local data, and updating the target edge equipment parameter after the training is finished.
According to yet another aspect of the present application, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the above global model determination method based on blockchains.
According to yet another aspect of the present application, there is provided a computer device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, the processor implementing the global model determining method based on block chains as described above when executing the program.
By means of the technical scheme, the block chain-based global model determining method and device, the storage medium and the computer device provided by the application calculate training results corresponding to different target edge device nodes through the aggregation node to obtain a target mean vector and a target variance vector, obtain a target global parameter through the target mean vector and the target variance vector, and obtain the target global model through the target global parameter, so that the influence of data bias on the target global parameter corresponding to the target global model is reduced under the condition that local data of each target edge device node obeys non-independent equal distribution, and the accuracy of the target global model is improved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 illustrates a flowchart of a global model determination method based on a block chain according to an embodiment of the present application;
fig. 2 is a schematic flowchart illustrating another global model determining method based on a blockchain according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart illustrating another global model determining method based on a blockchain according to an embodiment of the present application;
fig. 4 is a schematic structural diagram illustrating a global model determining apparatus based on a block chain according to an embodiment of the present application;
fig. 5 shows a schematic structural diagram of another global model determination apparatus based on a block chain according to an embodiment of the present application.
Detailed Description
The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
In this embodiment, a global model determining method based on a block chain is provided, and is applied to an aggregation node, as shown in fig. 1, the method includes:
in conventional machine learning, data is distributed on the same machine, and data follows independent same distributions, provided that the data is independently sampled from the same distribution. Later, with the rapid and violent growth of data volume, the big data era needs parallel computation by a distributed algorithm, and at the moment, the distributed optimization mainly does parallel computation on big data or big models by using a plurality of machines, including two basic paradigms of model parallel and data parallel, but at the moment, the data on each client is still subjected to independent and same distribution only for accelerating the computation. However, with the large-scale use of the internet of things device, tens of thousands of devices belong to a certain user, an enterprise and a scene, so the data distribution of the devices is often very different, that is, the data is not independently and identically distributed, and the local data corresponding to each node device in the block chain network is subject to the non-independent and identically distributed. Here, the non-independent equal distribution can be understood from two aspects: first, non-uniform distribution. The non-uniform distribution is easy to understand, namely, the data distribution is greatly different; second, not independent. Due to factors such as user groups, regional associations and the like, data distribution of the devices is often associated, i.e. not independent. In addition, the frequency distribution has a fraction of normal distribution and a fraction of skewed distribution. The normal distribution means that most of the frequency distributions are concentrated at the center and the frequency distributions at both ends are approximately symmetrical. The distribution of skewness means that the frequency distribution is asymmetric and the concentration position is deviated to one side. In the prior art, machine learning tasks are distributed to each terminal equipment node for learning, and then result data generated by learning of all terminal equipment nodes are aggregated, the aggregation result is often influenced by data bias caused by non-independent and same distribution of data obeying, and the accuracy of the aggregated final training model is poor. The global model determining method based on the block chain can effectively solve the problems that in the prior art, under the condition that local data in each terminal equipment node obeys non-independent and same distribution, a preset global model is locally trained through the local data of each terminal equipment node, and a final training model obtained after training results are aggregated is influenced by the skewness of the data. First, an aggregation node in the blockchain network may randomly determine a target edge device node participating in local training this time from a plurality of edge device nodes. Here, the local training means that each target edge device node trains a preset global model locally by using preset local data, and the local training enables data in the target edge device node to participate in the construction of the global model on the premise of not leaving the local, so as to ensure the data security of a user. After the target edge device nodes are determined, the aggregation node respectively sends the local training instructions to the target edge device nodes, so that after each target edge device node receives the local training instructions, a preset global model can be obtained from the block chain network according to the local training instructions on the basis of the local training instructions, and the preset global model is trained through preset local data, wherein the preset global model comprises preset global parameters. When the training times reach a preset time threshold value or when the model error corresponding to the model obtained after training is smaller than a preset error threshold value, determining a corresponding target edge device parameter, and generating a first target address corresponding to the target edge device parameter. For example, when the condition that the local training is finished is that the model error is smaller than the preset error threshold, before the model error is smaller than the preset error threshold, the parameter corresponding to the preset global model may be adjusted according to the preset parameter adjustment strategy after each training is finished, wherein the preset global parameter of the preset global model is adjusted after the first training is finished, and until the model error is smaller than the preset error threshold, the parameter corresponding to the preset global model is the target edge device parameter. And then writing a first target address corresponding to the target edge device parameter into the blockchain network, where the first target address may include a local address corresponding to the target edge device node and a storage location of the target edge device parameter in the target edge device node.
102, acquiring the target edge device parameters from the target edge device nodes based on each first target address, and acquiring a target mean vector and a target variance vector according to the target edge device parameters;
in this embodiment, the aggregation node may then find the stored target edge device parameters from the target edge device nodes according to the first target address corresponding to each target edge device parameter, and then the aggregation node may calculate the target mean vector and the target variance vector based on all the target edge device parameters corresponding to different target edge device nodes. Here, compared with directly storing the target edge device parameter in the blockchain network and directly acquiring the target edge device parameter from the blockchain network, the aggregation node acquires the target edge device parameter from the target edge device node through the first target address, and thus the access efficiency of the aggregation node can be greatly improved.
In this embodiment, after obtaining the target mean vector and the target variance vector, the target global parameter may be further determined based on the target mean vector and the target variance vector. Here, the target global parameter is a parameter corresponding to a preset global parameter in the preset global model, and the target global model may be obtained by updating the preset global parameter in the preset global model with the target global parameter. In fact, if there is a high heterogeneity in the preset local data in different target edge device nodes, the target edge device parameters obtained through local training may also have a large difference. If the target global parameters are determined directly by using the target edge device parameters with large differences, the results of the target global parameters are greatly influenced by the target edge device parameters, so that the target global parameters are inaccurate. According to the method and the device, the range of the target global parameters is constrained through the target mean vector and the target variance vector, the target global parameters are kept near the mean value of the target edge device parameters as much as possible, and the influence of data bias on the target global parameters corresponding to the target global model can be reduced under the condition that local data of each target edge device node obeys non-independent uniform distribution. After the target global model is obtained, the target global model can be written into the blockchain network and broadcasted to all nodes of the blockchain network, and therefore the nodes in the blockchain network can directly download the target global model from the blockchain network.
By applying the technical scheme of this embodiment, first, the aggregation node in the blockchain network may randomly determine a target edge device node participating in local training this time from a plurality of edge device nodes, and after determining the target edge device node, the aggregation node sends local training instructions to the target edge device nodes, so that after each target edge device node receives the local training instruction, the corresponding target edge device parameter may be finally determined according to the local training instruction based on the local training instruction, and a first target address corresponding to the target edge device parameter is written into the blockchain network. Then, the aggregation node may find the stored target edge device parameters from the target edge device nodes according to the first target address corresponding to each target edge device parameter, and then the aggregation node may calculate the target mean vector and the target variance vector based on all the target edge device parameters corresponding to different target edge device nodes. After the target mean vector and the target variance vector are obtained, a target global parameter can be further determined by taking the target mean vector and the target variance vector as a basis, and a target global model can be obtained through the target global parameter. After the target global model is obtained, the target global model can be written into the blockchain network and broadcasted to all nodes of the blockchain network. According to the method and the device, the aggregation nodes calculate the training results corresponding to different target edge device nodes to obtain the target mean vector and the target variance vector, the target global parameters are obtained through the target mean vector and the target variance vector, and the target global model is obtained through the target global parameters, so that the influence of data bias on the target global parameters corresponding to the target global model is reduced and the accuracy of the target global model is improved under the condition that the local data of each target edge device node obeys non-independent same distribution.
Further, as a refinement and an extension of the specific implementation of the foregoing embodiment, in order to fully illustrate the specific implementation process of this embodiment, another global model determination method based on a block chain is provided, and is applied to an aggregation node, as shown in fig. 2, the method includes:
in this embodiment, an aggregation node in the blockchain network may randomly determine a target edge device node participating in local training this time from a plurality of edge device nodes, and after determining the target edge device node, the aggregation node sends a local training instruction to the target edge device nodes, so that after each target edge device node receives the local training instruction, the aggregation node may finally determine a corresponding target edge device parameter according to the local training instruction based on the local training instruction, and write a first target address corresponding to the target edge device parameter into the blockchain network. Here, the local training instruction refers to an instruction that requires the target edge device node to perform the model training task locally, and may specifically include the target edge device identifier and the training task information. Then, the aggregation node may find the stored target edge device parameters from the target edge device nodes according to the first target address corresponding to each target edge device parameter.
in this embodiment, based on target edge device parameters corresponding to different target edge device nodes, the target edge device parameters corresponding to any target edge device node are taken as a column, and a target matrix is generated by using the target edge device parameters corresponding to all the target edge device nodes. That is, the number of rows of the target matrix may be the dimension corresponding to each target edge device parameter, and the number of columns of the target matrix may be the number of target edge device nodes. Here, the dimensions of the target edge device parameters corresponding to different target edge device nodes are the same. For example, there are 5 target edge device nodes, node 1 to node 5. Wherein, the target edge device parameter corresponding to the node 1 isThe target edge device parameter corresponding to the node 2 isBy analogy, the target edge device parameter corresponding to the node 5 isThe dimensions of the 5 target edge device parameters are all 4, and the generated target matrix may beThen, based on the target matrix, a row mean value of all elements in each row of the target matrix is determined. For example, for the above target matrix, the row mean value corresponding to the first row element isBy analogy, the mean value of the corresponding row of the fourth row element isFinally, the row mean value corresponding to each row in the target matrix is subtracted from the element corresponding to each row in the target matrix, so that the target distance matrix corresponding to the target matrix can be obtained. For example, the object distance matrix may be represented as:
then, based on the target distance matrix, a target mean vector and a target variance vector can be obtained. The target mean vector may be in a target distance matrix, and the dimension reduction is performed on elements in each row of the target distance matrix, specifically, the dimension reduction may be performed by adding the elements in each row and dividing the added elements by the number of the elements in each row to obtain new row elements after dimension reduction, so as to obtain the target mean vector; the target variance vector can be in a target distance matrix, and elements in each row of the target distance matrix are respectively squared and then added, and then divided by the number of elements in each row to obtain a new row with reduced dimensionAnd obtaining the target mean variance. Here, the target mean vector and the target variance vector may each be a column vector. For example, the target mean vector may beThe target variance vector may be
in this embodiment, after the target mean vector and the target variance vector are obtained through calculation, the target mean vector and the target variance vector may be used as a basis, and a preset random algorithm is used to obtain the target random number vector, where the number of rows of the target random number vector is consistent with the number of rows of the target mean vector and the number of rows of the target variance vector, and elements in the target random number vector are all subject to normal distribution. And then, determining a target global parameter according to the target random number vector and the target mean vector. Specifically, the target random number vector and the target mean vector are added to obtain a vector corresponding to the target global parameter, where each element is the target global parameter.
and step 206, writing the target global model into the block chain network, and broadcasting to the nodes in the block chain network.
In this embodiment, a preset global model is stored in the blockchain network in advance. After the target global parameter is obtained, the aggregation node may update the corresponding preset global parameter in the preset global model based on the target global parameter, and obtain an updated global model. After the updated global model is obtained, the updated global model can be further tested by utilizing a pre-prepared test data set, and after all test data are tested, the test accuracy is counted. When the test accuracy is smaller than or equal to the preset accuracy threshold, it is indicated that the test accuracy of the updated global model is high, the updated global model can be directly used, and then the updated global model can be directly used as the target global model. When the test accuracy is greater than the preset accuracy threshold, it is indicated that the test accuracy of the updated global model cannot meet the requirement, local training needs to be performed again through the target edge device node, that is, the target edge device node is trained by using the updated global model and preset local data, new target edge device parameters are obtained after the training is finished, the aggregation node performs calculation of the target global parameters again through the updated target edge device parameters, a brand-new updated global model is obtained through the target global parameters, and the target global model is obtained until the test accuracy corresponding to the updated global model is smaller than or equal to the preset accuracy threshold. After the target global model is obtained, the target global model can be written into the blockchain network and broadcasted to all nodes of the blockchain network, and therefore the nodes in the blockchain network can directly download the target global model from the blockchain network.
In this embodiment of the present application, optionally, the "re-determining the target global parameter when the test accuracy is greater than the preset accuracy threshold" in step 205 specifically includes: when the test accuracy is greater than the preset accuracy threshold, writing a second target address corresponding to the target global parameter into the block chain network, and broadcasting the second target address to the target edge device node, so that the target edge device node obtains the target global parameter based on the second target address, and updates the target edge device parameter based on the target global parameter; and acquiring the updated target edge device parameters, and re-determining the target global parameters.
In this embodiment, when the test accuracy is greater than the preset accuracy threshold, the aggregation node may write the second target address corresponding to the target global parameter into the blockchain network. Here, the second target address may include a local address corresponding to the aggregation node and a storage location of the target global parameter in the aggregation node. The aggregation node may also broadcast the second target address to the target edge device node. After monitoring the second target address broadcast by the aggregation node, the target edge device node may obtain the target global parameter from the aggregation node according to the second target address. And then, updating the preset global parameters in the preset global model on the basis of the target global parameters, and training the updated preset global model again by using the preset local data to obtain updated target edge equipment parameters. The aggregation node may then obtain the updated target edge device parameters from the target edge device nodes again, and re-determine the target global parameters.
In this embodiment, a global model determining method based on a block chain is provided, and is applied to a target edge device node, as shown in fig. 3, the method includes:
the global model determining method based on the block chain can effectively solve the problems that in the prior art, under the condition that local data in each terminal equipment node obeys non-independent and same distribution, a preset global model is locally trained through the local data of each terminal equipment node, and a final training model obtained after training results are aggregated is influenced by the skewness of the data. First, a target edge device node in the blockchain network may receive a local training instruction sent by the aggregation node, and may download a preset global model from the blockchain network after receiving the local training instruction. Here, the preset global model in the blockchain network may be uploaded by the aggregation node, and specifically may be an initial global model generated by the aggregation node through a random number generation algorithm.
in this embodiment, after downloading the preset global model from the blockchain network, the target edge device node may train the preset global model through the preset local data based on the preset local data, and when the number of times of training reaches a preset number of times threshold or when a model error corresponding to the model obtained after the training is smaller than a preset error threshold, determine a corresponding target edge device parameter and generate a first target address corresponding to the target edge device parameter, where the first target address may include a local address corresponding to the target edge device node and a storage location of the target edge device parameter in the target edge device node.
In this embodiment, the target edge device node may write the generated first target address into the blockchain network, so that the aggregation node may obtain, according to the first target address, a target edge device parameter corresponding to the first target address from the target edge device node, calculate a target mean vector and a target variance vector based on the target edge device parameter, and then obtain the target global parameter based on the target mean vector and the target variance vector. And then the aggregation node can obtain a target global model according to the target global parameters, write the target global model into the block chain network and broadcast the target global model to the nodes in the block chain network.
In this embodiment, optionally, the method further comprises: monitoring the aggregation node in real time, and acquiring the target global parameter from the aggregation node based on a second target address after monitoring that the aggregation node broadcasts the second target address; and updating a preset global parameter corresponding to the preset global model in the target edge device node according to the target global parameter, training the updated preset global model according to the preset local data, and updating the target edge device parameter after the training is finished.
In this embodiment, the target edge device node may also listen to the aggregation node in real time. The aggregation node may calculate a test accuracy corresponding to the target global model after obtaining the target global model according to the target edge device parameter of the target edge device node, and when the test accuracy is greater than a preset accuracy threshold, the aggregation node may write a second target address corresponding to the target global parameter into the block chain network and broadcast the second target address to the target edge device node. After the target edge device node monitors that the aggregation node broadcasts the second target address, the target global parameter can be found from the aggregation node according to the second target address, and the target global parameter is obtained. And then, updating the preset global parameters corresponding to the preset global model in the target edge device node on the basis of the target global parameters. And then, training the updated preset global model by using preset local data in the target edge device node, and after the training is finished, updating the target edge device parameter obtained last time.
In this embodiment, optionally, after the "obtaining the target edge device parameters after training" is completed, the method further includes: and signing the target edge device parameter.
In this embodiment, after the target edge device parameter is obtained, the target edge device parameter is signed, which may indicate that the target edge device parameter is obtained through training of the target edge device node, but is not uploaded by other malicious devices, and availability of the target edge device parameter can be reflected from a side surface.
Further, as a specific implementation of the method in fig. 1, an embodiment of the present application provides a global model determining apparatus based on a block chain, which is applied to an aggregation node, and as shown in fig. 4, the apparatus includes:
the node determining module is used for determining a plurality of target edge device nodes participating in local training, sending local training instructions to the target edge device nodes so that the target edge device nodes obtain target edge device parameters according to the local training instructions, and writing first target addresses corresponding to the target edge device parameters into a block chain network;
a parameter obtaining module, configured to obtain the target edge device parameter from the target edge device node based on each first target address, and obtain a target mean vector and a target variance vector according to the target edge device parameter;
and the model determining module is used for determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
Optionally, the parameter obtaining module is specifically configured to:
determining a target matrix corresponding to the target edge device nodes according to the target edge device parameters, wherein the number of columns of the target matrix is consistent with the number of the target edge device nodes, the number of rows of the target matrix is consistent with the dimension of any target edge device parameter, and the dimension corresponding to any target edge device parameter is the same; determining a row mean value corresponding to any row element in the target matrix based on the target matrix; and respectively subtracting the corresponding row mean values from any row element in the target matrix to obtain a target distance matrix, and obtaining a target mean vector and a target variance vector based on the target distance matrix.
Optionally, the model determining module is specifically configured to:
and obtaining a target random number vector through a preset random algorithm based on the target mean vector and the target variance vector, and determining a target global parameter based on the target random number vector and the target mean vector.
Optionally, the model determining module is specifically further configured to:
updating preset global parameters corresponding to a preset global model in the aggregation node through the target global parameters to obtain an updated global model; testing the updated global model through a preset test set, and counting the test accuracy; when the test accuracy is smaller than or equal to a preset accuracy threshold, taking the updated global model as the target global model; and when the test accuracy is greater than the preset accuracy threshold, re-determining the target global parameter.
Optionally, the model determining module is specifically further configured to:
when the test accuracy is greater than the preset accuracy threshold, writing a second target address corresponding to the target global parameter into the block chain network, and broadcasting the second target address to the target edge device node, so that the target edge device node obtains the target global parameter based on the second target address, and updates the target edge device parameter based on the target global parameter; and acquiring the updated target edge device parameters, and re-determining the target global parameters.
Further, as a specific implementation of the method in fig. 3, an embodiment of the present application provides a global model determining apparatus based on a block chain, which is applied to a target edge device node, and as shown in fig. 5, the apparatus includes:
the model downloading module is used for receiving a local training instruction sent by the aggregation node and downloading a preset global model from the block chain network;
the parameter generation module is used for training the preset global model based on preset local data, obtaining target edge equipment parameters after the training is finished, and generating a first target address corresponding to the target edge equipment parameters;
an address writing module, configured to write the first target address into the blockchain network, so that the aggregation node obtains the target edge device parameter according to the first target address, obtains a target mean vector and a target variance vector based on the target edge device parameter, determines a target global parameter according to the target mean vector and the target variance vector, obtains a target global model based on the target global parameter, writes the target global model into the blockchain network, and broadcasts the target global model to a node in the blockchain network.
Optionally, the apparatus further comprises:
the monitoring module is used for monitoring the aggregation node in real time, and acquiring the target global parameter from the aggregation node based on a second target address after monitoring that the aggregation node broadcasts the second target address;
and the parameter updating module is used for updating a preset global parameter corresponding to the preset global model in the target edge equipment node according to the target global parameter, training the updated preset global model according to the preset local data, and updating the target edge equipment parameter after the training is finished.
It should be noted that other corresponding descriptions of the functional units related to the global model determining apparatus based on the block chain provided in the embodiment of the present application may refer to corresponding descriptions in the methods in fig. 1 to fig. 3, and are not described herein again.
Based on the above methods shown in fig. 1 to 3, correspondingly, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for determining a global model based on a block chain as shown in fig. 1 to 3 is implemented.
Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the implementation scenarios of the present application.
Based on the method shown in fig. 1 to fig. 3 and the virtual device embodiment shown in fig. 4 to fig. 5, in order to achieve the above object, the present application further provides a computer device, which may specifically be a personal computer, a server, a network device, and the like, where the computer device includes a storage medium and a processor; a storage medium for storing a computer program; a processor for executing a computer program to implement the global model determination method based on blockchains as shown in fig. 1 to 3.
Optionally, the computer device may also include a user interface, a network interface, a camera, Radio Frequency (RF) circuitry, sensors, audio circuitry, a WI-FI module, and so forth. The user interface may include a Display screen (Display), an input unit such as a keypad (Keyboard), etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (e.g., a bluetooth interface, WI-FI interface), etc.
It will be appreciated by those skilled in the art that the present embodiment provides a computer device architecture that is not limiting of the computer device, and that may include more or fewer components, or some components in combination, or a different arrangement of components.
The storage medium may further include an operating system and a network communication module. An operating system is a program that manages and maintains the hardware and software resources of a computer device, supporting the operation of information handling programs, as well as other software and/or programs. The network communication module is used for realizing communication among components in the storage medium and other hardware and software in the entity device.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present application can be implemented by software plus a necessary general hardware platform, and can also be implemented by hardware. Firstly, an aggregation node in a blockchain network can randomly determine a target edge device node participating in local training at this time from a plurality of edge device nodes, and after the target edge device node is determined, the aggregation node respectively sends local training instructions to the target edge device nodes, so that after each target edge device node receives the local training instruction, a corresponding target edge device parameter can be finally determined according to the local training instruction based on the local training instruction, and a first target address corresponding to the target edge device parameter is written into the blockchain network. Then, the aggregation node may find the stored target edge device parameters from the target edge device nodes according to the first target address corresponding to each target edge device parameter, and then the aggregation node may calculate the target mean vector and the target variance vector based on all the target edge device parameters corresponding to different target edge device nodes. After the target mean vector and the target variance vector are obtained, a target global parameter can be further determined by taking the target mean vector and the target variance vector as a basis, and a target global model can be obtained through the target global parameter. After the target global model is obtained, the target global model can be written into the blockchain network and broadcasted to all nodes of the blockchain network. According to the method and the device, the aggregation nodes calculate the training results corresponding to different target edge device nodes to obtain the target mean vector and the target variance vector, the target global parameters are obtained through the target mean vector and the target variance vector, and the target global model is obtained through the target global parameters, so that the influence of data bias on the target global parameters corresponding to the target global model is reduced and the accuracy of the target global model is improved under the condition that the local data of each target edge device node obeys non-independent same distribution.
Those skilled in the art will appreciate that the figures are merely schematic representations of one preferred implementation scenario and that the blocks or flow diagrams in the figures are not necessarily required to practice the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario may be distributed in the devices in the implementation scenario according to the description of the implementation scenario, or may be located in one or more devices different from the present implementation scenario with corresponding changes. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above application serial numbers are for description purposes only and do not represent the superiority or inferiority of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of the present application, but the present application is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present application.
Claims (10)
1. A global model determination method based on a block chain is applied to an aggregation node, and is characterized by comprising the following steps:
determining a plurality of target edge device nodes participating in local training, and sending a local training instruction to the target edge device nodes so that the target edge device nodes obtain target edge device parameters according to the local training instruction, and writing first target addresses corresponding to the target edge device parameters into a block chain network;
acquiring the target edge device parameters from the target edge device nodes based on each first target address, and acquiring a target mean vector and a target variance vector according to the target edge device parameters;
and determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
2. The method of claim 1, wherein obtaining a target mean vector and a target variance vector according to the target edge device parameters comprises:
determining a target matrix corresponding to the target edge device nodes according to the target edge device parameters, wherein the number of columns of the target matrix is consistent with the number of the target edge device nodes, the number of rows of the target matrix is consistent with the dimension of any target edge device parameter, and the dimension corresponding to any target edge device parameter is the same;
determining a row mean value corresponding to any row element in the target matrix based on the target matrix;
and respectively subtracting the corresponding row mean values from any row element in the target matrix to obtain a target distance matrix, and obtaining a target mean vector and a target variance vector based on the target distance matrix.
3. The method of claim 2, wherein determining a target global parameter based on the target mean vector and the target variance vector comprises:
and obtaining a target random number vector through a preset random algorithm based on the target mean vector and the target variance vector, and determining a target global parameter based on the target random number vector and the target mean vector.
4. The method according to claim 1, wherein the obtaining a target global model based on the target global parameter specifically includes:
updating preset global parameters corresponding to a preset global model in the aggregation node through the target global parameters to obtain an updated global model;
testing the updated global model through a preset test set, and counting the test accuracy;
when the test accuracy is smaller than or equal to a preset accuracy threshold, taking the updated global model as the target global model;
and when the test accuracy is greater than the preset accuracy threshold, re-determining the target global parameter.
5. The method according to claim 4, wherein the re-determining the target global parameter when the test accuracy is greater than the preset accuracy threshold specifically comprises:
when the test accuracy is greater than the preset accuracy threshold, writing a second target address corresponding to the target global parameter into the block chain network, and broadcasting the second target address to the target edge device node, so that the target edge device node obtains the target global parameter based on the second target address, and updates the target edge device parameter based on the target global parameter;
and acquiring the updated target edge device parameters, and re-determining the target global parameters.
6. A global model determining method based on a block chain is applied to a target edge device node and is characterized by comprising the following steps:
receiving a local training instruction sent by an aggregation node, and downloading a preset global model from a block chain network;
training the preset global model based on preset local data, obtaining target edge equipment parameters after the training is finished, and generating a first target address corresponding to the target edge equipment parameters;
writing the first target address into the block chain network so that the aggregation node obtains the target edge device parameters according to the first target address, obtaining a target mean vector and a target variance vector based on the target edge device parameters, determining target global parameters according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameters, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
7. The method of claim 6, further comprising:
monitoring the aggregation node in real time, and acquiring the target global parameter from the aggregation node based on a second target address after monitoring that the aggregation node broadcasts the second target address;
and updating a preset global parameter corresponding to the preset global model in the target edge device node according to the target global parameter, training the updated preset global model according to the preset local data, and updating the target edge device parameter after the training is finished.
8. A global model determination device based on a block chain is applied to an aggregation node, and is characterized by comprising:
the node determining module is used for determining a plurality of target edge device nodes participating in local training, sending local training instructions to the target edge device nodes so that the target edge device nodes obtain target edge device parameters according to the local training instructions, and writing first target addresses corresponding to the target edge device parameters into a block chain network;
a parameter obtaining module, configured to obtain the target edge device parameter from the target edge device node based on each first target address, and obtain a target mean vector and a target variance vector according to the target edge device parameter;
and the model determining module is used for determining a target global parameter according to the target mean vector and the target variance vector, obtaining a target global model based on the target global parameter, writing the target global model into the block chain network, and broadcasting the target global model to nodes in the block chain network.
9. A storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method of any of claims 1 to 7.
10. A computer device comprising a storage medium, a processor and a computer program stored on the storage medium and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 7 when executing the computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111305848.1A CN114185988A (en) | 2021-11-05 | 2021-11-05 | Block chain-based global model determination method and device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111305848.1A CN114185988A (en) | 2021-11-05 | 2021-11-05 | Block chain-based global model determination method and device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114185988A true CN114185988A (en) | 2022-03-15 |
Family
ID=80540795
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111305848.1A Pending CN114185988A (en) | 2021-11-05 | 2021-11-05 | Block chain-based global model determination method and device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114185988A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109716346A (en) * | 2016-07-18 | 2019-05-03 | 河谷生物组学有限责任公司 | Distributed machines learning system, device and method |
CN112446025A (en) * | 2020-11-23 | 2021-03-05 | 平安科技(深圳)有限公司 | Federal learning defense method and device, electronic equipment and storage medium |
CN113011602A (en) * | 2021-03-03 | 2021-06-22 | 中国科学技术大学苏州高等研究院 | Method and device for training federated model, electronic equipment and storage medium |
CN113139663A (en) * | 2021-04-23 | 2021-07-20 | 深圳市大数据研究院 | Federal edge learning configuration information acquisition method, device, equipment and medium |
-
2021
- 2021-11-05 CN CN202111305848.1A patent/CN114185988A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109716346A (en) * | 2016-07-18 | 2019-05-03 | 河谷生物组学有限责任公司 | Distributed machines learning system, device and method |
CN112446025A (en) * | 2020-11-23 | 2021-03-05 | 平安科技(深圳)有限公司 | Federal learning defense method and device, electronic equipment and storage medium |
CN113011602A (en) * | 2021-03-03 | 2021-06-22 | 中国科学技术大学苏州高等研究院 | Method and device for training federated model, electronic equipment and storage medium |
CN113139663A (en) * | 2021-04-23 | 2021-07-20 | 深圳市大数据研究院 | Federal edge learning configuration information acquisition method, device, equipment and medium |
Non-Patent Citations (1)
Title |
---|
董业: "基于秘密分享和梯度选择的高效安全联邦学习", 计算机研究与发展, 31 October 2020 (2020-10-31) * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11363013B2 (en) | Authentication identity management for mobile device applications | |
CN111598254B (en) | Federal learning modeling method, device and readable storage medium | |
US9934138B1 (en) | Application testing on a blockchain | |
CN111950739A (en) | Data processing method, device, equipment and medium based on block chain | |
US9244994B1 (en) | Idempotency of application state data | |
KR20100033549A (en) | System, game server, terminal, and computer program product for link point scaling in a multiplayer location-aware game | |
CN110166541B (en) | Rendering method based on block chain, related equipment and system | |
CN103530109A (en) | System and method for simultaneously determining settings for a plurality of parameter variations | |
CN107770046B (en) | Method and equipment for picture arrangement | |
WO2017083301A1 (en) | Application testing with experimental layers | |
CN113344776B (en) | Image processing method, model training method, device, electronic equipment and medium | |
CN109447803B (en) | Alliance chain accounting method, equipment, alliance chain and storage medium | |
US11543540B2 (en) | Apparatus and method of selecting airborne position reference node | |
CN109831518A (en) | A kind of map datum method for down loading and device calculate equipment and storage medium | |
CN114185988A (en) | Block chain-based global model determination method and device and storage medium | |
CN110490590A (en) | Activation record querying method, device, equipment and storage medium based on block chain | |
CN111858753B (en) | Training parameter processing method, device and storage medium based on block chain | |
CN111858752A (en) | Artificial intelligence training method and device based on block chain and storage medium | |
JP6542397B2 (en) | Content testing during image production | |
WO2024067159A1 (en) | Video generation method and apparatus, electronic device, and storage medium | |
JP2023504092A (en) | Video playback page display method, apparatus, electronic equipment and medium | |
CN115250247B (en) | Discovery protocol testing method, system, electronic device and readable storage medium | |
CN115374954A (en) | Model training method based on federal learning, terminal and storage medium | |
CN111882325A (en) | Anti-counterfeiting method and device for electronic product, storage medium and electronic equipment | |
CN114255312A (en) | Processing method and device of vegetation image and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |