Federated learning method and device
By using virtual servers and candidate servers in blockchain systems to decentralize the training process of federated learning tasks, the problem of low data security in the existing technology is solved, and higher data security and lower data leakage risks are achieved.
Patent Information
- Application Number
- CN202011018370.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-24
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2040-09-24
AI Technical Summary
In the prior art, the server aggregates all training data during the federated learning process, resulting in a higher risk of data leakage and lower data security.
By using virtual servers in the blockchain system, creating federated learning tasks and selecting different servers from multiple candidate servers for training, avoiding aggregation of all data on a single server.
It reduces the risk of data leakage, improves data security, and ensures the secure transmission of data between various servers through the aggregation process of dispersing training data.
Smart Images

Figure CN113919511B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning, and in particular to a federated learning method and device. Background Art
[0002] Federated learning, also known as federated machine learning, is a machine learning framework. Federated learning can effectively help multiple devices use data and perform machine learning modeling while meeting the requirements of user privacy protection, data security, and government regulations. Federated learning, as a distributed machine learning, can effectively solve the problem of data silos, allowing participants to jointly model without sharing data, technically breaking data silos and realizing artificial intelligence (AI) collaboration.
[0003] In the prior art, the server-client (Master-Client) structure is a commonly used federated learning framework, and the server is at the core of the entire architecture. Specifically, a single server connects to multiple data clients, and the server manages the entire federated learning training, performs data aggregation and task dispatching.
[0004] However, since the server is located at the core node, it will perform data aggregation during the training process. A single server will obtain all the training data of federated learning. For the client, this may cause the risk of data leakage, resulting in lower data security. Summary of the invention
[0005] The embodiments of the present application provide a federated learning method and device to solve the problem of low data security in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a federated learning method, which is applied to a virtual server in a blockchain system, where the virtual server is any candidate server in the blockchain system, and the method includes:
[0007] Creating a federated learning task, wherein the federated learning task includes a plurality of algorithms to be trained;
[0008] Determine a first server from the multiple candidate servers, where the first server is used to initiate training for a first training algorithm among the multiple algorithms to be trained to multiple clients in the blockchain system;
[0009] Sending a training instruction of the first training algorithm to the first server.
[0010] In an optional implementation manner, determining the first server from the multiple candidate servers includes:
[0011] A first server is determined from the plurality of candidate servers using an election algorithm.
[0012] In an optional implementation manner, before determining the first server from the plurality of candidate servers, the method further includes:
[0013] receiving a first message sent by a second server among the candidate servers, where the first message is used to indicate that a failure occurs in the second server;
[0014] The step of using an election algorithm to determine a first server from the plurality of candidate servers includes:
[0015] The election algorithm is used to determine a first server from the multiple candidate servers except the second server.
[0016] In an optional implementation manner, the creating a federated learning task includes:
[0017] A federated learning task is created according to the information of the multiple clients.
[0018] In an optional implementation manner, after creating the federated learning task, the method further includes:
[0019] According to the information of the multiple clients, training parameters corresponding to the first training algorithm are selected from a database, and the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
[0020] In an optional implementation, the training instruction includes training parameters corresponding to the first training algorithm.
[0021] In an optional implementation, after sending the training instruction of the first training algorithm to the first server, the method further includes:
[0022] The training instructions of the first training algorithm are stored in the blockchain system.
[0023] In an optional implementation manner, the method further includes:
[0024] Receiving a joining request initiated by a to-be-joined terminal, wherein the joining request is used to request to join the blockchain system, and the to-be-joined terminal is a to-be-joined candidate server terminal or a to-be-joined client terminal;
[0025] According to the joining request, the terminal to be joined is added to the blockchain system.
[0026] In an optional implementation manner, the joining request includes a key of the end to be joined.
[0027] In an optional implementation manner, the step of adding the terminal to be added to the blockchain system includes:
[0028] If the key of the terminal to be joined passes the verification, the terminal to be joined is added to the blockchain system.
[0029] In an optional implementation, the algorithm to be trained is a machine learning algorithm.
[0030] In a second aspect, an embodiment of the present application provides a federated learning method, which is applied to a candidate server in a blockchain system, and the method includes:
[0031] Receiving a training instruction sent by a virtual server in the blockchain system, wherein the training instruction is used to instruct the candidate server to jointly train a first training algorithm with multiple clients in the blockchain system, and the virtual server is composed of multiple candidate servers in the blockchain system;
[0032] Sending the training task of the first training algorithm to the multiple clients through the blockchain system;
[0033] Receive intermediate data sent by the multiple clients through the blockchain system, where the intermediate data is data of the first training algorithm trained with sample data in the clients.
[0034] In a third aspect, an embodiment of the present application provides a federated learning method, which is applied to a client in a blockchain system, and the method includes:
[0035] Receiving a training task of a first training algorithm sent by a candidate server in the blockchain system through the blockchain system;
[0036] Using the sample data in the client to train the first training algorithm to generate the first training algorithm intermediate data;
[0037] The intermediate data is sent to the candidate server through the blockchain system.
[0038] In a fourth aspect, an embodiment of the present application provides a federated learning device, the device comprising:
[0039] A processing module, configured to create a federated learning task, wherein the federated learning task includes a plurality of algorithms to be trained; determine a first server from a plurality of candidate servers, wherein the first server is configured to initiate training for a first training algorithm among the plurality of algorithms to be trained to a plurality of clients in a blockchain system;
[0040] A sending module is used to send a training instruction of the first training algorithm to the first server.
[0041] In an optional implementation, the processing module is specifically configured to determine the first server from the multiple candidate servers using an election algorithm.
[0042] In an optional implementation, the device further includes:
[0043] A receiving module, configured to receive a first message sent by a second server among the candidate servers, wherein the first message is used to indicate that a failure occurs in the second server;
[0044] The processing module is specifically configured to use the election algorithm to determine the first server from the multiple candidate servers except the second server.
[0045] In an optional implementation, the processing module is further used to create a federated learning task based on the information of the multiple clients.
[0046] In an optional implementation, the processing module is further used to select training parameters corresponding to the first training algorithm from a database based on the information of the multiple clients, and the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
[0047] In an optional implementation, the training instruction includes training parameters corresponding to the first training algorithm.
[0048] In an optional implementation, the processing module is further used to save the training instructions of the first training algorithm in the blockchain system.
[0049] In an optional implementation, the receiving module is further used to receive a joining request initiated by a to-be-joined terminal, the joining request is used to request to join the blockchain system, and the to-be-joined terminal is a candidate server terminal to be joined or a to-be-joined client terminal;
[0050] The processing module is further configured to add the terminal to be added to the blockchain system according to the joining request.
[0051] In an optional implementation manner, the joining request includes a key of the end to be joined.
[0052] In an optional implementation, the processing module is specifically used to add the end to be added to the blockchain system if the key of the end to be added passes the verification.
[0053] In an optional implementation, the algorithm to be trained is a machine learning algorithm.
[0054] In a fifth aspect, an embodiment of the present application provides a federated learning device, the device comprising:
[0055] A receiving module, configured to receive a training instruction sent by a virtual server in the blockchain system, wherein the training instruction is used to instruct the federated learning device to jointly train a first training algorithm with multiple clients in the blockchain system, and the virtual server is composed of multiple federated learning devices in the blockchain system;
[0056] A sending module, configured to send the training task of the first training algorithm to the multiple clients through the blockchain system;
[0057] The receiving module is further used to receive intermediate data sent by the multiple clients through the blockchain system, where the intermediate data is data of the first training algorithm trained with sample data in the clients.
[0058] In a sixth aspect, an embodiment of the present application provides a federated learning device, the device comprising:
[0059] A receiving module, configured to receive a training task of a first training algorithm sent by a candidate server in the blockchain system through the blockchain system;
[0060] A processing module, configured to train the first training algorithm using the sample data in the client to generate intermediate data of the first training algorithm;
[0061] A sending module is used to send the intermediate data to the candidate server through the blockchain system.
[0062] In a seventh aspect, the present application further provides an electronic device, including:
[0063] Processor; and
[0064] a memory for storing a computer program for the processor;
[0065] The processor is configured to implement any possible method in the first to sixth aspects by executing the computer program.
[0066] In an eighth aspect, the present invention further provides a non-transitory computer-readable storage medium storing computer instructions, on which a computer program is stored, and when the computer program is executed by a processor, any possible method in the first to sixth aspects is implemented.
[0067] In the federated learning method and device provided in the embodiment of the present application, a virtual server creates a federated learning task, which includes multiple algorithms to be trained. Subsequently, the virtual server determines a first server from multiple candidate servers, and the first server is used to initiate training for a first training algorithm among the algorithms to be trained to multiple clients in the blockchain system. Finally, the virtual server sends a training instruction for the first training algorithm to the first server. Compared with the prior art, since the candidate server used by each training algorithm is determined from multiple candidate servers through the virtual server, a single server cannot aggregate all data, thereby reducing the risk of data leakage and improving data security. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0069] Figure 1 A schematic diagram of a scenario of a federated learning method provided in an embodiment of the present application;
[0070] Figure 2 A signaling interaction diagram of a federated learning method provided in an embodiment of the present application;
[0071] Figure 3 A flowchart of a federated learning method provided in an embodiment of the present application;
[0072] Figure 4 A signaling interaction diagram of another federated learning method provided in an embodiment of the present application;
[0073] Figure 5 A schematic diagram of the structure of a federated learning device provided in an embodiment of the present application;
[0074] Figure 6 A schematic diagram of the structure of another federated learning device provided in an embodiment of the present application;
[0075] Figure 7 A schematic diagram of the structure of another federated learning device provided in an embodiment of the present application;
[0076] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0078] In the prior art, the server-client (Master-Client) structure is a commonly used federated learning framework, and the server is at the core of the entire architecture. Specifically, a single server connects to multiple data clients, and the server manages the entire federated learning training, performs data aggregation and task dispatching.
[0079] However, since the server is located at the core node, it will perform data aggregation during the training process. A single server will obtain all the training data of federated learning. For the client, this may cause the risk of data leakage, resulting in lower data security.
[0080] To solve the above problems, the present application provides a federated learning method and device to improve data security. Since the risk of data leakage in the prior art is caused by aggregating all training data in the federated learning task on one server. In the present application, different servers are selected for different training algorithms in the training task, so that different training tasks can be aggregated on different servers, thereby reducing the risk of data leakage and improving data security.
[0081] The application scenarios involved in the embodiments of the present application are described below.
[0082] Figure 1 A schematic diagram of a federated learning method provided in an embodiment of the present application. Figure 1 A blockchain system is provided, which is composed of multiple candidate servers 101 and multiple clients 102. Any of the multiple candidate servers 101 can be a virtual server. The virtual server is used to create a federated learning task and assign the training algorithm in the federated learning task to the candidate server 101. Subsequently, the candidate server 101 and multiple clients 102 in the blockchain system train the assigned training algorithm.
[0083] The server 101 may be, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of computers or network servers.
[0084] The client 102 may be a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in a smart home, etc. In the embodiment of the present application, the device for realizing the function of the client may be a terminal device, or a device capable of supporting the client to realize the function, such as a chip system, which may be installed in the client. In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.
[0085] It should be noted that the application scenarios of the technical solution of this application can be Figure 1 The federated learning scenario in this paper is not limited to this, and can also be applied to other scenarios that require distributed data processing.
[0086] It can be understood that the above-mentioned federated learning method can be implemented by the federated learning device provided in the embodiment of the present application. The federated learning device can be part or all of a certain device, such as a chip of the above-mentioned candidate server, virtual server or client.
[0087] The following takes the candidate server, virtual server and client integrated or installed with relevant execution code as an example to describe the technical solution of the embodiment of the present application in detail with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0088] Figure 2 This is a signaling interaction diagram of a federated learning method provided in an embodiment of the present application. This embodiment involves the process of how to perform federated learning. Figure 2 As shown, the blockchain system involved in the method includes multiple candidate servers and multiple clients, any candidate server may be a virtual server, and the method includes:
[0089] S201. The virtual server creates a federated learning task, which includes multiple algorithms to be trained.
[0090] In this step, if federated learning is required, the virtual server needs to first create a federated learning task, which includes the algorithm to be trained.
[0091] Among them, the embodiments of the present application do not limit the type of training algorithm. Exemplarily, the algorithm to be trained is a machine learning algorithm.
[0092] The embodiment of the present application does not limit the number of algorithms to be trained. For example, there may be two or three algorithms to be trained. Since there are multiple algorithms to be trained, one algorithm to be trained is trained in each iteration of the blockchain system.
[0093] In addition, the embodiments of the present application do not limit how the virtual server creates a federated learning task. In some embodiments, the virtual server can obtain information about each client from multiple clients and create a federated learning task based on the information of the multiple clients.
[0094] The information of the client may include at least one of the following: the type of the client, the amount of sample data in the client, the processing capability of the client, etc.
[0095] In other embodiments, after creating a federated learning task, the virtual server may also select training parameters corresponding to the first training algorithm from a database based on information of multiple clients, and the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
[0096] S202: The virtual server determines a first server from multiple candidate servers, where the first server is used to initiate training of a first training algorithm among multiple algorithms to be trained to multiple clients in the blockchain system.
[0097] In this step, after creating the federated learning task, the virtual server may also determine a first server corresponding to the first training algorithm from multiple candidate servers.
[0098] In some embodiments, since there are multiple algorithms to be learned in the federated learning task, the virtual server determines a corresponding candidate server for each algorithm to be trained in each round of iteration.
[0099] The embodiment of the present application does not limit how to randomly determine the first server, and a suitable method can be selected according to actual conditions. For example, an election algorithm can be used to determine the first server from multiple candidate servers.
[0100] Among them, the embodiments of the present application do not limit the type of election algorithm. For example, it can be a domineering election algorithm or a ring election algorithm.
[0101] In some other embodiments, before determining the first server from multiple candidate servers, the virtual server may also receive a first message sent by a second server among the candidate servers, the first message being used to indicate that the second server has failed. Subsequently, the virtual server uses an election algorithm to determine the first server from multiple candidate servers other than the second server.
[0102] In this way, the election algorithm will automatically avoid problematic candidate servers, ensuring that the candidate server selected each time is always available.
[0103] S203: The virtual server sends a training instruction of a first training algorithm to the first server.
[0104] In this step, after the virtual server determines the first server, it may send a training instruction of the first training algorithm to the server.
[0105] The training instruction is used to instruct the first server to train the first training algorithm in conjunction with multiple clients.
[0106] In some embodiments, if there are multiple algorithms to be learned in the federated learning task, a corresponding training instruction is sent for each algorithm to be trained in each round of iteration.
[0107] In some embodiments, after creating a federated learning algorithm, the virtual server can select training parameters corresponding to the first training algorithm from the database based on information from multiple clients. The virtual server can also carry the training parameters corresponding to the first training algorithm in the training instructions, so that the first server uses the training parameters corresponding to the first training algorithm to assist in training the first training algorithm.
[0108] In other embodiments, after sending the training instruction of the first training algorithm to the first server, the virtual server may also save the training instruction of the first training algorithm in the blockchain system.
[0109] In this way, the interaction process between the virtual server and the first server can be saved on the blockchain system. Due to the characteristics of the blockchain system such as non-forgeability and full traceability, subsequent illegal requests can be avoided.
[0110] S204: The first server sends the training task of the first training algorithm to multiple clients through the blockchain system.
[0111] In this step, after the first server receives the training instruction of the first training algorithm sent by the virtual server, the first server can send the training task of the first training algorithm to multiple clients through the blockchain system.
[0112] In some embodiments, the first server may assign a corresponding training task to each client, so that each client uses its own sample data to train the first training algorithm.
[0113] It should be noted that in the embodiments of the present application, the interaction between the first server and the client needs to be through the blockchain system. In some embodiments, the interaction between the first server and the client can also be saved on the blockchain.
[0114] In this application, due to the characteristics of blockchain such as non-forgeability and full traceability, illegal requests can be avoided, thereby preventing man-in-the-middle attacks. In addition, since federated learning itself alarms for data anomalies, the security of the entire training process can be guaranteed.
[0115] S205: The client uses the sample data in the client to train the first training algorithm to generate first training algorithm intermediate data.
[0116] In this step, after receiving the training task of the first training algorithm, the client may use the sample data in the client to train the first training algorithm to generate the first training algorithm intermediate data.
[0117] The intermediate data may be data of the first training algorithm trained with sample data in the client.
[0118] The embodiment of the present application does not limit how the client trains the first training algorithm, and the training can be performed in a suitable manner.
[0119] S206. The client sends the intermediate data to the first server through the blockchain system.
[0120] In the federated learning method provided in the embodiment of the present application, a virtual server creates a federated learning task, and the federated learning task includes an algorithm to be trained. Subsequently, the virtual server determines a first server from multiple candidate servers, and the first server is used to initiate training for a first training algorithm among multiple algorithms to be trained to multiple clients in the blockchain system. Finally, the virtual server sends a training instruction for the first training algorithm to the first server. Compared with the prior art, since the candidate server used by each training algorithm is determined from multiple candidate servers through the virtual server, a single server cannot aggregate all data, thereby reducing the risk of data leakage and improving data security.
[0121] Based on the above embodiment, the process of creating a federated learning task and sending a training instruction is described in detail below. Figure 3 A flowchart of a federated learning method provided in an embodiment of the present application is shown in FIG. 1 . The execution subject of this embodiment is a virtual server, such as Figure 3 As shown, the method includes:
[0122] S301. Create a federated learning task based on information of multiple clients, where the federated learning task includes an algorithm to be trained.
[0123] The information of the client may include at least one of the following: the type of the client, the amount of sample data in the client, the processing capability of the client, etc.
[0124] S302: Select training parameters corresponding to a first training algorithm from a database according to information of multiple clients, where the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
[0125] In this step, after the virtual server creates a federated learning task according to the information of multiple clients, it can also select training parameters corresponding to the first training algorithm from the database according to the information of multiple clients.
[0126] In the present application, the above database can be stored in the blockchain system, and the database can be provided with a mapping relationship between the client information and the training parameters corresponding to the first training algorithm. The virtual server then determines the training parameters corresponding to the first training algorithm through the mapping relationship.
[0127] In addition, in other embodiments, the virtual server may receive indication information from the user, where the indication information is used to indicate training parameters corresponding to the training algorithm, so that the virtual server may directly determine the training parameters corresponding to the first training algorithm based on the indication information.
[0128] S303: Determine a first server from multiple candidate servers using an election algorithm, where the first server is used to initiate training for a first training algorithm among the algorithms to be trained to multiple clients in the blockchain system.
[0129] The embodiments of the present application do not limit the type of election algorithm. For example, it can be a hegemonic election algorithm or a ring election algorithm.
[0130] S304: Send a training instruction of the first training algorithm to the first server, where the training instruction includes training parameters corresponding to the first training algorithm.
[0131] The technical terms, technical effects, technical features, and optional implementation methods of S304 can be found in Figure 2 The solution of S203 shown is not repeated here for the repeated contents.
[0132] Based on the above embodiments, the process of how to join the blockchain system is specifically described below. Figure 4A signaling interaction diagram of another federated learning method provided in an embodiment of the present application, wherein the execution subjects of this embodiment are a virtual server and a to-be-joined end, wherein the to-be-joined end is a candidate server to be joined or a to-be-joined client, such as Figure 4 As shown, the method includes:
[0133] S401. The terminal to be joined sends a joining request to the virtual server. The joining request is used to request to join the blockchain system. The terminal to be joined is a candidate server to be joined or a client to be joined.
[0134] In some optional implementations, the joining request includes a key of the end to be joined.
[0135] S402. According to the joining request, the virtual server joins the terminal to be joined into the blockchain system.
[0136] In some optional implementations, the virtual server may verify the key of the terminal to be joined in the joining request, and if the key of the terminal to be joined passes the verification, the terminal to be joined is added to the blockchain system.
[0137] Among them, in the embodiment of the present application, the end to be joined can be a server or a client. No matter it is a server or a client, it needs to send a joining request for verification.
[0138] In addition, the embodiments of the present application do not limit the type of the key, which may be a symmetric key or an asymmetric key. In some embodiments, the key may specifically be pre-configured key information (KEY).
[0139] In other embodiments, if the key of the terminal to be joined fails to pass the verification, the virtual server may also feedback an error prompt to the terminal to be joined, to prompt the terminal to be joined that it cannot join the blockchain system.
[0140] In this application, since each terminal that joins the blockchain system needs to be verified, it can be ensured that risk terminals that have not joined the blockchain system cannot read any information of federated learning.
[0141] In the federated learning method provided in the embodiment of the present application, a virtual server creates a federated learning task, and the federated learning task includes multiple algorithms to be trained. Subsequently, the virtual server determines a first server from multiple candidate servers, and the first server is used to initiate training for a first training algorithm in the algorithms to be trained to multiple clients in the blockchain system. Finally, the virtual server sends a training instruction for the first training algorithm to the first server. Compared with the prior art, since the candidate server used by each training algorithm is determined from multiple candidate servers through the virtual server, a single server cannot aggregate all data, thereby reducing the risk of data leakage and improving data security.
[0142] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.
[0143] Figure 5 The structure diagram of a federated learning device provided in an embodiment of the present application. The federated learning device can be implemented by software, hardware, or a combination of both, such as the virtual server device or the chip of the virtual server in the above embodiment to execute the communication method in the above embodiment. Figure 5 As shown, the federated learning device 500 includes:
[0144] The processing module 501 is used to create a federated learning task, which includes multiple algorithms to be trained; determine a first server from multiple candidate servers, and the first server is used to initiate training for a first training algorithm among the multiple algorithms to be trained to multiple clients in the blockchain system;
[0145] The sending module 502 is used to send a training instruction of the first training algorithm to the first server.
[0146] In an optional implementation manner, the processing module 501 is specifically configured to determine a first server from multiple candidate servers using an election algorithm.
[0147] In an optional embodiment, the device further includes:
[0148] A receiving module 503 is used to receive a first message sent by a second server among the candidate servers, where the first message is used to indicate that a failure occurs in the second server;
[0149] The processing module 501 is specifically configured to determine a first server from a plurality of candidate servers except the second server by using an election algorithm.
[0150] In an optional implementation, the processing module 501 is further configured to create a federated learning task based on information of multiple clients.
[0151] In an optional implementation, the processing module 501 is further used to select training parameters corresponding to the first training algorithm from the database according to information of multiple clients, and the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
[0152] In an optional implementation, the training instruction includes training parameters corresponding to the first training algorithm.
[0153] In an optional implementation, the processing module 501 is further used to save the training instructions of the first training algorithm in the blockchain system.
[0154] In an optional implementation, the receiving module 503 is further used to receive a joining request initiated by the to-be-joined terminal, where the joining request is used to request to join the blockchain system, and the to-be-joined terminal is a candidate server terminal to be joined or a client terminal to be joined;
[0155] The processing module 501 is also used to add the terminal to be added to the blockchain system according to the joining request.
[0156] In an optional implementation manner, the joining request includes the key of the end to be joined.
[0157] In an optional implementation, the processing module 501 is specifically used to add the end to be added to the blockchain system if the key of the end to be added passes the verification.
[0158] In an optional implementation, the algorithm to be trained is a machine learning algorithm.
[0159] Need to explain, Figure 5 The federated learning device provided in the illustrated embodiment can be used to execute the virtual server method provided in any of the above embodiments. The specific implementation method and technical effect are similar and will not be described in detail here.
[0160] Figure 6 A schematic diagram of the structure of another federated learning device provided in an embodiment of the present application. The federated learning device can be implemented by software, hardware, or a combination of both, such as the candidate server device or the chip of the candidate server in the above embodiment to execute the communication method in the above embodiment. Figure 5 As shown, the federated learning device 600 includes:
[0161] A receiving module 601 is used to receive a training instruction sent by a virtual server in the blockchain system, where the training instruction is used to instruct the federated learning device to jointly train a first training algorithm with multiple clients in the blockchain system, and the virtual server is composed of multiple federated learning devices in the blockchain system;
[0162] A sending module 602 is used to send the training task of the first training algorithm to multiple clients through the blockchain system;
[0163] The receiving module 601 is also used to receive intermediate data sent by multiple clients through the blockchain system, where the intermediate data is data of the first training algorithm trained with sample data in the client.
[0164] Need to explain, Figure 6The federated learning device provided in the illustrated embodiment can be used to execute the candidate server method provided in any of the above embodiments. The specific implementation method and technical effect are similar and will not be described in detail here.
[0165] Figure 7 The structural diagram of another federated learning device provided in the embodiment of the present application. The federated learning device can be implemented by software, hardware or a combination of both, such as the client device or the client chip in the above embodiment to execute the communication method in the above embodiment. Figure 7 As shown, the federated learning device 700 includes:
[0166] A receiving module 701 is used to receive a training task of a first training algorithm sent by a candidate server in the blockchain system through the blockchain system;
[0167] The processing module 702 is used to train the first training algorithm using the sample data in the client to generate the first training algorithm intermediate data;
[0168] The sending module 703 is used to send the intermediate data to the candidate server through the blockchain system.
[0169] Need to explain, Figure 7 The federated learning device provided in the illustrated embodiment may be used to execute the client method provided in any of the above embodiments. The specific implementation method and technical effect are similar and will not be described in detail here.
[0170] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device may include: a processor 801 and a memory 802 . Figure 8 An electronic device is shown using a processor as an example.
[0171] The memory 802 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer operation instructions.
[0172] The memory 802 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as a disk memory.
[0173] The processor 801 is used to execute the computer execution instructions stored in the memory 802 to implement the above-mentioned federated learning method;
[0174] The processor 801 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0175] Optionally, in a specific implementation, if the communication interface, the memory 802 and the processor 801 are implemented independently, the communication interface, the memory 802 and the processor 801 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0176] Optionally, in a specific implementation, if the communication interface, the memory 802 and the processor 801 are integrated on a chip, the communication interface, the memory 802 and the processor 801 can communicate through an internal interface.
[0177] The present application embodiment also provides a chip, including a processor and an interface. The interface is used to input and output data or instructions processed by the processor. The processor is used to execute the method provided in the above method embodiment. The chip can be applied to a federated learning device.
[0178] The present application also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores program information, and the program information is used for the above-mentioned federated learning method.
[0179] An embodiment of the present application also provides a program, which, when executed by a processor, is used to execute the federated learning method provided in the above method embodiment.
[0180] An embodiment of the present application also provides a program product, such as a computer-readable storage medium, which stores instructions. When the program product is run on a computer, it enables the computer to execute the federated learning method provided by the above method embodiment.
[0181] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0182] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A federated learning method, characterized in that: A virtual server end applied to a blockchain system, wherein the virtual server end is any candidate server end in the blockchain system, and the method includes: Creating a federated learning task, wherein the federated learning task includes a plurality of algorithms to be trained; Determine a first server from the plurality of candidate servers, where the first server is used to initiate training for a first training algorithm among the plurality of algorithms to be trained to a plurality of clients in the blockchain system; Sending a training instruction of the first training algorithm to the first server.
2. The method according to claim 1, characterized in that The determining of the first server from the plurality of candidate servers comprises: A first server is determined from the plurality of candidate servers using an election algorithm.
3. The method according to claim 2, characterized in that Before determining the first server from the plurality of candidate servers, the method further includes: receiving a first message sent by a second server among the candidate servers, where the first message is used to indicate that a failure occurs in the second server; The step of using an election algorithm to determine a first server from the plurality of candidate servers includes: The election algorithm is used to determine a first server from the multiple candidate servers except the second server.
4. The method according to claim 1, characterized in that: The creation of a federated learning task includes: A federated learning task is created according to the information of the multiple clients.
5. The method according to claim 4, characterized in that After creating the federated learning task, the method further includes: According to the information of the multiple clients, training parameters corresponding to the first training algorithm are selected from a database, and the training parameters corresponding to the first training algorithm are used to assist in training the first training algorithm.
6. The method according to claim 5, characterized in that The training instruction includes training parameters corresponding to the first training algorithm.
7. The method according to claim 1, characterized in that After sending the training instruction of the first training algorithm to the first server, the method further includes: The training instructions of the first training algorithm are stored in the blockchain system.
8. The method according to claim 1, characterized in that: The method further comprises: Receiving a joining request initiated by a to-be-joined terminal, wherein the joining request is used to request to join the blockchain system, and the to-be-joined terminal is a to-be-joined candidate server terminal or a to-be-joined client terminal; According to the joining request, the terminal to be joined is added to the blockchain system.
9. The method according to claim 8, characterized in that The joining request includes the key of the terminal to be joined.
10. The method according to claim 9, characterized in that The step of adding the terminal to be added to the blockchain system includes: If the key of the terminal to be joined passes the verification, the terminal to be joined is added to the blockchain system.
11. The method according to any one of claims 1 to 10, characterized in that: The algorithm to be trained is a machine learning algorithm.
12. A federated learning method, characterized in that: Applied to a candidate server in a blockchain system, the method comprises: Receiving a training instruction sent by a virtual server in the blockchain system, wherein the training instruction is used to instruct the candidate server to jointly train a first training algorithm with multiple clients in the blockchain system, and the virtual server is composed of multiple candidate servers in the blockchain system; Sending the training task of the first training algorithm to the multiple clients through the blockchain system; Receive intermediate data sent by the multiple clients through the blockchain system, where the intermediate data is data of the first training algorithm trained with sample data in the clients.
13. A federated learning method, characterized in that: Applied to a client in a blockchain system, the method includes: Receiving a training task of a first training algorithm sent by a candidate server in the blockchain system through the blockchain system; wherein the training task is sent by the candidate server in the blockchain system after receiving a training instruction sent by a virtual server in the blockchain system; the training instruction is used to instruct the candidate server to jointly train the first training algorithm with multiple clients in the blockchain system, and the virtual server is composed of multiple candidate servers in the blockchain system; Using the sample data in the client to train the first training algorithm to generate the first training algorithm intermediate data; The intermediate data is sent to the candidate server through the blockchain system.
14. A federated learning device, characterized in that: The device comprises: A processing module, configured to create a federated learning task, wherein the federated learning task includes a plurality of algorithms to be trained; determine a first server from a plurality of candidate servers, wherein the first server is configured to initiate training for a first training algorithm among the plurality of algorithms to be trained to a plurality of clients in a blockchain system; A sending module is used to send a training instruction of the first training algorithm to the first server.
15. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the federated learning method according to any one of claims 1 to 13; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
16. A computer-readable storage medium, characterized in that: The computer storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer executes the federated learning method according to any one of claims 1 to 13.