Information processing method, device, equipment, storage medium and computer program product
By updating and issuing model weights in federated learning and reducing iterative training steps, the problem of low training speed in federated learning is solved, and rapid convergence and code reuse are achieved.
Patent Information
- Application Number
- CN202110191618.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-20
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2041-02-20
AI Technical Summary
In the existing federated learning, due to the information transmission and scheduling of multiple parties, the global model needs to be continuously iterated, resulting in a low training speed.
In federated learning, the collaborator obtains the model weights sent by each data provider and updates the global model weights, and issues them to the data provider for n+1 training; the data provider obtains the updated global model weights sent by the collaborator. , local training is performed on the global model weights of fixed front n layers to reduce repeated iteration steps.
It improves the training speed of the global model, enables the global model to converge quickly, completes federated learning, reduces the complexity of code development and supports code reuse of multiple role parties.
Smart Images

Figure CN112906864B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing, and in particular to an information processing method, device, equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, more and more scenarios are applied to federated learning. In the scenario of federated learning, there are two or more data owners, that is, multiple institutions. Federated learning can effectively help multiple institutions use data and conduct machine learning modeling while meeting the requirements of user privacy protection, data security, and certain rules.
[0003] In the existing federated learning, since joint learning involves information transmission and scheduling among multiple parties, each participant needs to continuously and iteratively train the global model, resulting in the problem of low training speed. Summary of the invention
[0004] The main purpose of the present invention is to provide an information processing method, apparatus, device, storage medium and computer program product, aiming to solve the problem of low global model training speed in existing federated learning.
[0005] To achieve the above object, the present invention provides an information processing method, which is applied to a first participant among multiple participants participating in federated learning, comprising:
[0006] If the first participant is a collaborator, the model weights obtained after the nth training and sent by each data provider among the multiple participants are obtained, and the global model weights are updated according to the model weights sent by each data provider and sent to each data provider, so that each data provider performs the (n+1)th training on the updated global model weights;
[0007] If the first participant is a data provider, then the global model weights updated after the nth training are obtained from the collaborating party among the multiple participants, and the global model weights of the first n layers are fixed according to the local training samples to obtain the model weights corresponding to the n+1th training and send them to the collaborating party.
[0008] In a possible implementation, updating the global model weight according to the model weight sent by each data provider and sending it to each data provider includes:
[0009] Determine the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight, so as to update the global model weight;
[0010] The average weight of the nth layer of the neural network in the model of each data provider is sent to each data provider.
[0011] In a possible implementation, determining the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight includes:
[0012] For each of the data providers, according to the model weights sent by the data providers and the global model weights, a weight arrangement matrix of the nth layer of the neural network in the model of the data provider is calculated, wherein the weight arrangement matrix is the model weights after matching the model weights sent by the data providers with the global model weights;
[0013] According to the arrangement matrix of the nth layer neural network in the model of the data provider, the average weight of the nth layer neural network in the model of the data provider is calculated, and the average weight of the nth layer neural network in the model of the data provider is the updated global model weight of the nth layer.
[0014] In a possible implementation, the calculating, according to the model weights sent by the data provider and the global model weights, a weight arrangement matrix of the nth layer of the neural network in the model of the data provider includes:
[0015] Obtaining, from the model weights of the data provider, first weights corresponding to the neurons of the nth layer of the neural network in the model of the data provider;
[0016] Obtaining second weights corresponding to respective neurons of the nth layer of the neural network in the global model from the global model weights;
[0017] For each neuron of the nth layer of the neural network in the model of the data provider and each neuron of the nth layer of the neural network in the corresponding global model, calculate the distance between two neurons according to the first weight and the second weight;
[0018] According to the distance between each of the two neurons, the weight arrangement matrix of the nth layer of the neural network in the model of the data provider is determined through matrix transformation.
[0019] In a possible implementation, the updating of the global model weight and sending it to each data provider includes:
[0020] Update the global model weights and determine whether n is less than N, where N is the number of neural network layers in the global model;
[0021] If it is less than N, the updated global model weight is sent to each data provider.
[0022] In a possible implementation, the method further includes:
[0023] Obtaining source code, where the source code is generated based on a computer programming language, and the source code includes code for implementing federated learning;
[0024] The source code is parsed through a computer programming language parsing library to obtain a target code, which includes a code for instructing each participant to perform a corresponding operation.
[0025] In a possible implementation, parsing the source code to obtain the target code includes:
[0026] Parsing the source code to generate an actual calculation graph;
[0027] The actual computation graph is run to generate the target code.
[0028] The present invention also provides an information processing device, applied to a first participant among multiple participants participating in federated learning, the device comprising:
[0029] A first processing module is used for, when the first participant is a collaborator, obtaining the model weights sent by each data provider among the multiple participants after the nth training, updating the global model weights according to the model weights sent by each data provider, and sending the global model weights to each data provider, so that each data provider performs the n+1th training on the updated global model weights;
[0030] The second processing module is used to obtain the global model weights updated after the nth training sent by the collaborating party among the multiple participants when the first participant is the data provider, and train the global model weights of the fixed first n layers according to the local training samples to obtain the model weights corresponding to the n+1th training and send them to the collaborating party.
[0031] The present invention also provides an information processing device, comprising: a memory, a processor, and an information processing program stored in the memory and executable on the processor, wherein the information processing program implements the steps of the information processing method as described in any one of the foregoing when executed by the processor.
[0032] The present invention also provides a computer-readable storage medium, on which an information processing program is stored, and when the information processing program is executed by a processor, the steps of the information processing method as described in any one of the above items are implemented.
[0033] The present invention also provides a computer program product, comprising a computer program, which implements the steps of any of the above-mentioned information processing methods when executed by a processor.
[0034] In the present invention, the first participant among multiple participants participating in federated learning is applied. If the first participant is a collaborator, the model weights obtained after the nth training and sent by each data provider among the multiple participants are obtained. According to the model weights sent by each data provider, the global model weights are updated and sent to each data provider, so that each data provider performs the n+1th training on the updated global model weights. If the first participant is a data provider, the global model weights updated after the nth training and sent by the collaborator among the multiple participants are obtained, and the global model weights of the fixed first n layers are trained according to the local training samples, the model weights corresponding to the n+1th training are obtained and sent to the collaborator. Multiple participants can share a set of codes, which greatly reduces the complexity of code development and supports code reuse of multiple role participants. Then, each data provider trains the global model weights of the fixed first n layers through local training samples, shortens the local model training time, and improves the speed of training the global model, so that the global model can quickly converge and complete federated learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of the principle of federated learning provided by an embodiment of the present invention;
[0036] Figure 2 A flowchart of an information processing method provided by an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of a flow chart of another information processing method provided by an embodiment of the present invention;
[0038] Figure 4 A schematic diagram of an application scenario provided by an embodiment of the present invention;
[0039] Figure 5 A schematic diagram of the structure of an information processing device provided by an embodiment of the present invention;
[0040] Figure 6 A schematic diagram of the structure of an information processing device provided by an embodiment of the present invention.
[0041] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0042] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0043] In many fields, technologies such as machine learning and model training based on big data are constantly developing. By mining big data, a lot of valuable information can be obtained. With the development of technology, the source of raw data is becoming more and more extensive, and there will even be cross-field collaboration.
[0044] In some business scenarios, multiple business platforms collect their own business data. This business data is very valuable and is usually saved as the privacy information of the business platform. Each business platform does not expect to share the original business data with other business platforms. However, in some requirements, multiple business platforms expect to perform collaborative computing without disclosing the business data of each party to improve business processing capabilities. Based on this, methods such as federated machine learning came into being.
[0045] Federated Machine Learning, also known as Federated Learning, can unite all parties to use data and conduct collaborative modeling without leaving the local data, and has gradually become a common method in privacy-preserving computing.
[0046] In the process of federated learning, the privacy data of the participants can be protected through parameter exchange under the encryption mechanism. The data itself will not be transmitted. The participants do not need to expose their own data to other participants, nor can they infer the data of other participants. Therefore, federated learning can well protect user privacy and ensure data security, and can solve the problem of data islands.
[0047] According to different data sets, federated learning can be divided into horizontal federated learning (Horizontal Federated Learning), vertical federated learning (Vertical Federated Learning) and federated transfer learning (Federated Transfer Learning).
[0048] Among them, horizontal federated learning can be applied to scenarios where different data sets have more overlap in user features but less overlap in users. For example, one is a bank in location A and the other is a bank in location B. The two banks are located in different locations and have less overlap in users, but the data of both banks involve users' income and expenditure behaviors, asset data, etc. In this case, data collaborative computing between the two banks can be achieved based on horizontal federated learning.
[0049] Vertical federated learning can be applied to scenarios where different data sets have a large overlap of users but a small overlap of user features. For example, there are two different institutions among the participants, one is a bank in a certain place, and the other is an e-commerce company in that place. Their user groups are likely to include most of the residents in that place, so the user intersection is large. However, since the bank's data involves the user's income and expenditure behavior and asset data, and the e-commerce data involves the user's browsing and purchase history, their user features have a small intersection. In this case, data collaborative computing between banks and e-commerce companies can be achieved based on vertical federated learning.
[0050] Federated transfer learning can be applied to scenarios where users and user features of different data sets have little overlap. For example, there are two different institutions among the participants, one is a bank in location A, and the other is an e-commerce company in location B. The user groups of these two participants have little overlap, and the overlap of user features is also small. In this case, transfer learning needs to be introduced to improve the effect of collaborative computing.
[0051] There are many machine learning algorithms that can be used in federated learning, including but not limited to neural networks, random forests, and other algorithms.
[0052] Figure 1 A schematic diagram of the principle of federated learning provided by an embodiment of the present invention. Figure 1 As shown, the server and k client terminals can participate in the federated learning process (wherein the server here can be a collaborator and the k client terminals can be data providers; in addition, there may be no server participation, one of the k client terminals can be a collaborator and the other client terminals can be data providers, which is not specifically limited here). In the federated learning process, the server sends a global model to each client terminal, and each client terminal uses local data to train the global model sent by the server, and the trained local model is uploaded to the server. The server aggregates the models uploaded by each client terminal to obtain an updated global model, and the above process is repeated in sequence until the aggregated global model converges.
[0053] Assuming that the tth round of iteration is currently in progress, the execution steps of the algorithm are as follows:
[0054] Step 1: The server sends the current global model M tSend to each client terminal C i .
[0055] Optionally, in order to ensure data security, the interactive data between the client terminal and the server may be encrypted during the interaction.
[0056] Step 2: Client Terminal C i The current global model M t Overwriting the local model Right now
[0057] Step 3: Client Terminal C i Using its own local training samples for local training, client terminal C i The local model from becomes Will The model parameters are uploaded to the server.
[0058] Step 4: The server receives the model parameters uploaded by all client terminals Aggregate to obtain the global model.
[0059] Specifically, the aggregated global model can be calculated using the following formula.
[0060]
[0061] In the formula, n represents the total number of client terminals, and pi is the number of client terminals C. i The weight of For client terminal C i The reported model, M t+1 is the global model after aggregation.
[0062] In the existing federated learning, since joint learning involves information transmission and scheduling among multiple parties, each participant needs to continuously and iteratively train the global model, resulting in the problem of low training speed.
[0063] In order to solve this problem, the technical concept of the present invention is to design a set of codes that can be shared by multiple parties, so that the collaborators and data providers can perform corresponding federated learning operations. If the collaborators can continuously obtain the model weights sent by each data provider to update the global model weights and send them to each data provider, if the data provider, each data provider can update the global model weights sent by the collaborators after the nth training, and fix the global model weights of the first n layers, use local training samples to train the global model for the n+1th time, and no longer repeat the iterative training of the global model weights of the first n layers, thereby improving the overall training speed, allowing the global model to converge quickly, and then complete federated learning.
[0064] In the following, some embodiments of the present invention are described in detail in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and features in the embodiments can be combined with each other.
[0065] Figure 2 A flowchart of an information processing method provided for an embodiment of the present invention. The executor of the method in this embodiment may be an information processing device, such as the first participant among multiple participants participating in federated learning. The first participant may be a terminal device or a server, and has an information processing function. Specifically, the first participant may be a collaborator or a data provider. Multiple participants share a set of codes for logical implementation, thereby solving the problem that due to the information transmission and scheduling of multiple parties, it is necessary to explicitly transmit encrypted information in code development, and implement different code logics for each participant with a different role, which leads to high corresponding machine learning development and learning costs and poor experience. At the same time, during the iterative training process of each data provider, by fixing the global model weights of the first n layers that have been trained, only the global model weights of the n+1th layer and subsequent layers are iteratively trained using local training samples, thereby shortening the local model training time and improving the global model training speed, so that the global model can quickly converge and complete federated learning. The method in this embodiment can be implemented by software, hardware, or a combination of software and hardware. Figure 2 As shown, the method may include:
[0066] S201. If the first participant is a collaborative party, then the model weights obtained after the nth training and sent by each data provider among the multiple participants are obtained, and according to the model weights sent by each data provider, the global model weights are updated and sent to each data provider, so that each data provider performs the (n+1)th training on the updated global model weights.
[0067] Among them, if the first participant is a collaborator, it is responsible for data transmission, such as data acquisition, weight update and data distribution during training.
[0068] Specifically, taking the global model with N neural network model layers as an example, it is necessary to continuously obtain the global model weights updated by the data provider. If the current number of training times is n (n is greater than or equal to 1 and less than N), the model weights obtained after the nth training sent by each data provider among the multiple participants are obtained. The collaborating party performs model aggregation based on the model weights obtained after the nth training provided by each data provider, and updates the global model weights. For example, a weight average calculation is performed based on the model weights obtained after the nth training provided by each data provider, combined with the current global model weights. The weight average calculation is obtained by matching the model weights obtained after the nth training provided by each data provider with the weights of the current global model, rather than simply averaging the models of multiple participants. This makes the updated global model weights better, further improving the training speed and computing performance.
[0069] S202. If the first participant is a data provider, then obtain the global model weights updated after the nth training sent by the collaborating party among the multiple participants, and train the global model weights of the fixed first n layers according to the local training samples to obtain the model weights corresponding to the n+1th training and send them to the collaborating party.
[0070] Among them, if the first participant is the data provider, it is responsible for providing data and model training.
[0071] Specifically, taking the global model with N neural network model layers as an example, each data provider is required to continuously update the global model weights. If the current number of training times is n (n is greater than or equal to 1 and less than N), each data provider among multiple participants respectively obtains the global model weights sent by the collaborator after the nth training. Each data provider first fixes the global model weights of the first n layers and no longer trains the global model weights of the first n layers. It only needs to train the global model weights of the remaining layers according to local training samples, which reduces the steps of repeated iterative training of the global model weights of the first n layers, improves the training speed, and sends the model weights corresponding to the n+1th training obtained by the training to the collaborator, so that the collaborator updates the global model according to the model weights corresponding to the n+1th training obtained, and repeats the training in sequence until the global model converges and the federated learning is completed.
[0072] The information processing method provided in this embodiment is applied to the first participant among multiple participants participating in federated learning. If the first participant is a collaborator, the model weights obtained after the nth training sent by each data provider among the multiple participants are obtained. According to the model weights sent by each data provider, the global model weights are updated and sent to each data provider, so that each data provider performs the n+1th training on the updated global model weights. If the first participant is a data provider, the global model weights updated after the nth training sent by the collaborator among the multiple participants are obtained, and the global model weights of the fixed first n layers are trained according to the local training samples, and the model weights corresponding to the n+1th training are obtained and sent to the collaborator. Multiple participants can share a set of codes, which greatly reduces the complexity of code development and supports code reuse of multiple role participants. Then, each data provider trains the global model weights of the fixed first n layers through local training samples, shortens the local model training time, and improves the speed of training the global model, so that the global model can quickly converge and complete federated learning.
[0073] Optionally, how to update the global model weight according to the model weight sent by each data provider and send it to each data provider can be achieved by the following steps:
[0074] Step a1: According to the model weights sent by the data providers and the global model weight, determine the average weight of the nth layer neural network in the model of each data provider to update the global model weight.
[0075] Step a2: Send the average weight of the nth layer of the neural network in the model of each data provider to each data provider.
[0076] In this embodiment, according to the model weights sent by each data provider, combined with the current global model weights, the model weights sent by each data provider are matched with the global model weights, and then the matched model weights are averaged to obtain the average weights. Among them, since the model weights sent by each data provider are the model weights obtained after the nth training, the collaborating party uses the model weights obtained after the nth training sent by each data provider to calculate the average weights in combination with the current global model weights to update the global model weights. The global model weights updated after the nth training are obtained and used as the global model weights of the nth layer. The global model weights of the nth layer are sent to the data provider and used as the average weights of the nth layer neural network in the local model trained by the data provider. Since the average weight is associated with the global model weight and is relatively close to the global model weight, it can save training time during the training process, thereby improving the training speed, so that the global model can converge quickly.
[0077] Specifically, how to determine the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight can be achieved by the following steps:
[0078] Step b1: For each data provider, based on the model weights sent by the data provider and the global model weights, calculate the weight arrangement matrix of the nth layer neural network in the model of the data provider, wherein the weight arrangement matrix is the model weights after matching the model weights sent by the data provider with the global model weights.
[0079] Step b2: Calculate the average weight of the n-th layer of the neural network in the data provider's model based on the arrangement matrix of the n-th layer of the neural network in the data provider's model, and the average weight of the n-th layer of the neural network in the data provider's model is the updated global model weight of the n-th layer.
[0080] In this embodiment, for the model weights sent by each data provider, the correlation relationship between the data provider and the global model weights is calculated, so that the model weights sent by each data provider can be updated to be closer to the global model weights, so that the data provider can train the updated global model weights faster when using local training samples, while ensuring the computing performance of the model.
[0081] Specifically, when calculating the weight arrangement matrix, the model weights of the nth layer (initial n=1) of the model in each data provider are matched with the global model weights, such as changes in the matrix. After obtaining the weight arrangement matrix, the model weights of the same layer corresponding to other data providers are averaged to obtain an updated global model. The average weight of the nth layer neural network in the model of the data provider is the new weight of the nth layer neural network in the model of the data provider. The updated global model weights of the nth layer are distributed to each data provider. Each data provider fixes the global model weights of the first n layers, and continues the n+1th training according to the local training model. The model weights corresponding to the n+1th training are obtained and sent to the collaborating party A.
[0082] Optionally, how to calculate the weight permutation matrix of the nth layer of the neural network in the data provider's model can be achieved by the following steps:
[0083] Step c1: Obtain, from the model weights of the participating data providers, the first weights corresponding to the neurons in each n-th layer of the neural network in the model of the participating data provider.
[0084] Step c2: Obtain, from the global model weight of the federated learning, the second weight corresponding to each neuron of each n-th layer of the neural network in the global model of the federated learning.
[0085] Step c3: for each neuron in each n-th layer of the neural network in the model of the data provider and each neuron in each n-th layer of the corresponding global model of the federated learning, calculate the distance between two neurons based on the first weight and the second weight.
[0086] Step c4, according to the distance between each of the two neurons, through matrix transformation and the permutation matrix formula, a weight permutation matrix of each n-th layer of the neural network in the model of the data providing participant is obtained.
[0087] In this embodiment, it is assumed that there are three parties participating in joint modeling and training of multi-layer neural networks, namely "guest", "host" and "arbiter". The "guest" (hereinafter referred to as "G", "H" and "A") and the "host" have data, the "arbiter" has no data, and A is responsible for calculating the average weight of the model. In this case, A is used as a collaborator, and G and H are both data providers.
[0088] Taking the number of neural network layers of the global model as N as an example, 1) A obtains the model weights {W from J (here J = 2) client terminals, such as G or H j,1 , …, W j,n} J, where, taking a client terminal G as an example (the following steps can be repeated for other client terminals), the collaborating party A and the data provider G perform the following steps:
[0089] 2) Calculate the permutation matrix {Π j,n}J of the nth (initial n = 1) layer, and the formula is as follows:
[0090]
[0091] where, θ i is the ith neuron of the global model, and li represents; w jl is the lth weight of the nth layer of the Jth client terminal; represents; represents; s.t. represents; l represents; j represents; c(w jl , θi) is the distance between two neurons.
[0092] 3) Calculate the weight average W of the nth layer n ; 4) Broadcast W n to the client terminals; 5) The client terminals fix the weights before the nth layer to train the model; 6) If n < N, n = n + 1, jump to step 1). Specifically, for example, to calculate the weight average W2 of the second layer. Among them, both the second-layer neural network models of the data providers G and H contain 3 neurons, and each neuron corresponds to 3 weights. Then the model weights of the second layer are a 3*3 matrix. Combine this 3*3 matrix to calculate the minimum value of the neuron distance. Through matrix transformation, match it with the global model weights to obtain the weight permutation matrix of the second layer of the data provider. Then, average the corresponding weight permutation matrices of the second layer obtained by all data providers to obtain the weight average W2, and broadcast W2 to the client terminals. The client terminals train the global model weights of the fixed first two layers according to the local training samples to obtain the model weights corresponding to the third training and send them to the collaborating party A.
[0093] Optionally, updating the global model weights and distributing them to each of the data providers can be achieved through the following steps:
[0094] Step d1: Update the global model weights and determine whether n is less than N, where N is the number of neural network layers of the global model.
[0095] Step d2: If it is less than N, send the updated global model weights to each of the data providers.
[0096] In this embodiment, as shown in Figure 3 ; Figure 3A flowchart of another information processing method provided by an embodiment of the present invention. First, initialize the models of A and other client terminals, set n = 1, and determine whether n is less than N (N is the number of neural network layers of the global model). If it is less than, obtain the encrypted model weights of the nth layer from J clients, and then perform the above-mentioned average weight calculation process, i.e., the federated matching average algorithm, and broadcast the new nth layer weight. The client terminal trains the model of the first n fixed layers and determines whether n is less than N. If it is less than, continue to repeat the above steps. If it is greater than or equal to, determine whether the training of the global model has reached the stopping condition. If the stopping condition has not been reached, reset n = 1 and continue to repeat the above steps. If the stopping condition is reached, the training stops.
[0097] Therefore, the problem in the prior art that simply averaging multiple models will have an adverse effect on the global model due to the invariant property of the neural network parameters (for any given neural network, its many variations only differ in the order of parameters, constituting practically equivalent local optima) is solved. Based on the federated matching average algorithm, by fixing the global model weights of the first n layers that have been trained and reducing the number of repeated iterations, the training speed can be increased as well as the computational performance of the model.
[0098] Optionally, the operation steps performed in the present invention are performed based on the target code obtained by compiling the source code. How to compile the source code can be achieved by the following steps:
[0099] Step e1: obtaining source code, where the source code is generated based on a computer programming language, and the source code includes code for implementing federated learning;
[0100] Step e2: parsing the source code through a computer programming language parsing library to obtain a target code, wherein the target code includes a code for instructing each participant to perform a corresponding operation.
[0101] In this embodiment, combined with Figure 4 The schematic diagram of an application scenario provided by the present invention is shown. The user writes the source code of federated learning on the user side according to his own business needs, and sends the source code to each participant participating in the federated learning (three participants are shown as an example in the figure, and the specific number of participants depends on the actual scenario). Each participant compiles the source code, implements encryption through the encryption operator, generates and runs executable machine code, and each participant cooperates to implement the process of federated learning. Thereby, the update of the parameters of the federated learning model is realized.
[0102] Specifically, first, a source code generated based on a computer programming language, namely Python, is obtained, and the source code is used to implement federated learning. Then, the source code is parsed by a computer programming language parsing library to generate a target code including instructions for each participant to perform a corresponding operation. Then, each participant executes the target code to implement model training.
[0103] Optionally, how to parse the source code to obtain the target code can be achieved by the following steps:
[0104] Step f1: parse the source code to generate an actual calculation graph.
[0105] Step f2: Run the actual calculation graph to generate the target code.
[0106] In this embodiment, the source code is parsed to generate a dynamic calculation graph; the dynamic calculation graph includes calculation nodes corresponding to the source code; the dynamic calculation graph is used to characterize the data processing logic of federated learning. Then, the preset encryption operator is used to replace the operator of the corresponding calculation node in the dynamic calculation graph to generate an encrypted calculation graph, and the compiled code, i.e., the target code, is generated according to the encrypted calculation graph.
[0107] Specifically, since Python code is easy to write, there is no need to learn additional programming languages, and the conversion rules are relatively fixed patterns, which can avoid bugs caused by human programming conversion that lead to privacy data leakage. Therefore, based on Python's performance, this compilation method is the underlying foundation for supporting source code simplification. Because the compilation method supports encryption of operators in the source code and then compiles the source code into executable code, there is no need to write encryption processes in the source code. This simplifies the source code and reduces the complexity of source code development and the difficulty of later maintenance.
[0108] Figure 5 The following is a schematic diagram of the structure of an information processing device provided by an embodiment of the present invention. Figure 5 As shown, the information processing device is applied to a first participant among multiple participants participating in federated learning, and the device may include:
[0109] The first processing module 501 is used for obtaining the model weights sent by each data provider among the multiple participants after the nth training when the first participant is a collaborative party, and updating the global model weights according to the model weights sent by each data provider, and sending the global model weights to each data provider, so that each data provider performs the n+1th training on the updated global model weights;
[0110] The second processing module 502 is used to obtain the global model weights updated after the nth training sent by the collaborating party among the multiple participants when the first participant is the data provider, and train the global model weights of the fixed first n layers according to the local training samples to obtain the model weights corresponding to the n+1th training and send them to the collaborating party.
[0111] The information processing device provided in this embodiment is configured with a first processing module 501 and a second processing module 502, which are used for applying to a first participant among multiple participants participating in federated learning. If the first participant is a collaborator, the model weights obtained after the nth training and sent by each data provider among the multiple participants are obtained. According to the model weights sent by each data provider, the global model weights are updated and sent to each data provider, so that each data provider performs the n+1th training on the updated global model weights. If the first participant is a data provider, the model weights obtained after the nth training and sent by each data provider are obtained. The global model weights updated after the nth training are sent by the collaborating party among the participants, and the global model weights of the fixed first n layers are trained according to the local training samples, and the model weights corresponding to the n+1th training are obtained and sent to the collaborating party. Multiple participants can share a set of codes, which greatly reduces the complexity of code development and supports code reuse by multiple role participants. Then, each data provider trains the global model weights of the fixed first n layers through local training samples, which shortens the local model training time and improves the speed of training the global model, thereby enabling the global model to converge quickly and complete federated learning.
[0112] The information processing device provided in this embodiment can be used to execute the technical solution provided by any of the aforementioned method embodiments. Its implementation principles and technical effects are similar and will not be repeated here.
[0113] In a possible implementation, the first processing module is specifically configured to:
[0114] Determine the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight, so as to update the global model weight;
[0115] The average weight of the nth layer of the neural network in the model of each data provider is sent to each data provider.
[0116] In a possible implementation, the first processing module is specifically configured to:
[0117] For each data provider, according to the model weights sent by the data provider and the global model weights, a weight arrangement matrix of the nth layer of the neural network in the model of the data provider is calculated, wherein the weight arrangement matrix is the model weights after matching the model weights sent by the data provider with the global model weights;
[0118] According to the arrangement matrix of the nth layer neural network in the model of each data provider, the average weight of the nth layer neural network in the model of each data provider is calculated, and the average weight of the nth layer neural network in the model of the data provider is the updated global model weight of the nth layer.
[0119] In a possible implementation, the first processing module is specifically configured to:
[0120] Obtaining, from the model weights of the data provider, first weights corresponding to the neurons of the nth layer of the neural network in the model of the data provider;
[0121] Obtaining second weights corresponding to respective neurons of the nth layer of the neural network in the global model from the global model weights;
[0122] For each neuron of the nth layer of the neural network in the model of the data provider and each neuron of the nth layer of the neural network in the corresponding global model, calculate the distance between two neurons according to the first weight and the second weight;
[0123] According to the distance between each of the two neurons, the weight arrangement matrix of the nth layer of the neural network in the model of the data provider is determined through matrix transformation.
[0124] In a possible implementation, the first processing module is specifically configured to:
[0125] Update the global model weights and determine whether n is less than N, where N is the number of neural network layers in the global model;
[0126] If it is less than N, the updated global model weight is sent to each data provider.
[0127] In one possible implementation, the device also includes: a compilation model; a compilation module, used to obtain source code, the source code is generated based on a computer programming language, and the source code includes code for implementing federated learning; the source code is parsed through a computer programming language parsing library to obtain a target code, and the target code includes code for instructing each participant to perform a corresponding operation.
[0128] In a possible implementation, the compiling module is specifically used to: parse the source code to generate an actual calculation graph; and run the actual calculation graph to generate the target code.
[0129] The information processing device provided in any of the foregoing embodiments is used to execute the technical solution of any of the foregoing method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0130] Figure 6 A schematic diagram of the structure of an information processing device provided by an embodiment of the present invention. Figure 6 As shown, the device may include: a memory 601, a processor 602, and an information processing program stored in the memory 601 and executable on the processor 602, wherein the information processing program, when executed by the processor 602, implements the steps of the information processing method described in any of the foregoing embodiments.
[0131] Optionally, the memory 601 may be independent or integrated with the processor 602 .
[0132] The implementation principle and technical effects of the device provided in this embodiment can be found in the aforementioned embodiments and will not be described in detail here.
[0133] An embodiment of the present invention further provides a computer-readable storage medium, on which an information processing program is stored. When the information processing program is executed by a processor, the steps of the information processing method described in any of the above embodiments are implemented.
[0134] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.
[0135] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present invention.
[0136] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0137] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0138] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0139] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0140] The present invention also provides a computer program product, including a computer program, which implements the method provided by any embodiment of the present invention when executed by a processor.
[0141] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0142] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0144] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An information processing method, characterized in that: Applied to a first participant among multiple participants participating in federated learning, the method includes: Obtaining source code, where the source code is generated based on a computer programming language, and the source code includes code for implementing federated learning; The source code is parsed by a computer programming language parsing library to generate a dynamic computation graph, wherein the dynamic computation graph includes computation nodes corresponding to the source code; a preset encryption operator is used to replace operators of corresponding computation nodes in the dynamic computation graph to generate an encrypted computation graph; a compiled target code is generated according to the encrypted computation graph; the target code includes codes for instructing each participant to perform the following operations: If the first participant is a collaborator, then the model weights obtained after the nth training and sent by each data provider among the multiple participants are obtained, and the global model weights are updated according to the model weights sent by each data provider and sent to each data provider, so that each data provider uses its own local business data to perform the n+1th training on the updated global model weights; wherein the collaborator is a bank or an e-commerce company, and the data provider is a bank or an e-commerce company; the local business data includes the user's income and expenditure behavior and asset data provided by the bank, or the user's browsing and purchase history data provided by the e-commerce company; If the first participant is a data provider, then obtain the global model weights updated after the nth training sent by the collaborating party among the multiple participants, and train the global model weights of the first n layers fixed according to the local business data of the data provider, obtain the model weights corresponding to the n+1th training and send them to the collaborating party; The collaborating party and the data provider perform collaborative calculation of business data through the trained global model.
2. The method according to claim 1, characterized in that The updating of the global model weight according to the model weight sent by each data provider and sending the global model weight to each data provider includes: Determine the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight, so as to update the global model weight; The average weight of the nth layer of the neural network in the model of each data provider is sent to each data provider.
3. The method according to claim 2, characterized in that The step of determining the average weight of the nth layer of the neural network in the model of each data provider according to the model weight sent by each data provider and the global model weight comprises: For each data provider, according to the model weights sent by the data provider and the global model weights, a weight arrangement matrix of the nth layer of the neural network in the model of the data provider is calculated, wherein the weight arrangement matrix is the model weights after matching the model weights sent by the data provider with the global model weights; According to the arrangement matrix of the nth layer neural network in the model of each data provider, the average weight of the nth layer neural network in the model of each data provider is calculated, and the average weight of the nth layer neural network in the model of the data provider is the updated global model weight of the nth layer.
4. The method according to claim 3, characterized in that The step of calculating the weight arrangement matrix of the nth layer of the neural network in the model of the data provider according to the model weight sent by the data provider and the global model weight comprises: Obtaining, from the model weights of the data provider, first weights corresponding to the neurons of the nth layer of the neural network in the model of the data provider; Obtaining second weights corresponding to respective neurons of the nth layer of the neural network in the global model from the global model weights; For each neuron of the nth layer of the neural network in the model of the data provider and each neuron of the nth layer of the neural network in the corresponding global model, calculate the distance between two neurons according to the first weight and the second weight; According to the distance between each of the two neurons, the weight arrangement matrix of the nth layer of the neural network in the model of the data provider is determined through matrix transformation.
5. The method according to any one of claims 2 to 4, characterized in that: The updating of the global model weight and sending it to each data provider includes: Update the global model weights and determine whether n is less than N, where N is the number of neural network layers in the global model; If it is less than N, the updated global model weight is sent to each data provider.
6. An information processing device, characterized in that: Applied to a first participant among multiple participants participating in federated learning, the device comprises: A compilation module is used to obtain source code, the source code is generated based on a computer programming language, and the source code includes a code for implementing federated learning; the source code is parsed by a computer programming language parsing library to generate a dynamic computation graph, the dynamic computation graph includes computation nodes corresponding to the source code; the operator of the corresponding computation node in the dynamic computation graph is replaced by a preset encryption operator to generate an encrypted computation graph; according to the encrypted computation graph, a compiled target code is generated; the target code includes a code for instructing each participant to perform the following operations: A first processing module is used for, when the first participant is a collaborating party, obtaining the model weights obtained after the nth training and sent by each data provider among the multiple participants, updating the global model weights according to the model weights sent by each data provider and sending them to each data provider, so that each data provider uses their own local business data to perform the n+1th training on the updated global model weights; wherein the collaborating party is a bank or an e-commerce company, and the data provider is a bank or an e-commerce company; the local business data includes the user's income and expenditure behavior and asset data provided by the bank, or the user's browsing and purchase history data provided by the e-commerce company; The second processing module is used to obtain the global model weights updated after the nth training and sent by the collaborating party among the multiple participants when the first participant is the data provider, and train the global model weights of the fixed first n layers according to the local business data of the data provider, to obtain the model weights corresponding to the (n+1)th training and send them to the collaborating party; the collaborating party and the data provider perform collaborative calculation of business data through the trained global model.
7. An information processing device, characterized in that: The information processing device comprises: a memory, a processor, and an information processing program stored in the memory and executable on the processor, wherein the information processing program implements the steps of the information processing method according to any one of claims 1 to 5 when executed by the processor.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an information processing program, and when the information processing program is executed by the processor, the steps of the information processing method according to any one of claims 1 to 5 are implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the information processing method according to any one of claims 1 to 5 are implemented.
