WO2023185541A1 - 一种模型训练方法及其相关设备 - Google Patents

一种模型训练方法及其相关设备 Download PDF

Info

Publication number
WO2023185541A1
WO2023185541A1 PCT/CN2023/082679 CN2023082679W WO2023185541A1 WO 2023185541 A1 WO2023185541 A1 WO 2023185541A1 CN 2023082679 W CN2023082679 W CN 2023082679W WO 2023185541 A1 WO2023185541 A1 WO 2023185541A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
neuron
layer
trained
neurons
Prior art date
Application number
PCT/CN2023/082679
Other languages
English (en)
French (fr)
Inventor
詹德川
李新春
邵云峰
李秉帅
李银川
宋绍铭
Original Assignee
华为技术有限公司
南京大学
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司, 南京大学 filed Critical 华为技术有限公司
Publication of WO2023185541A1 publication Critical patent/WO2023185541A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Definitions

  • the embodiments of the present application relate to the technical field of artificial intelligence (AI), and in particular to a model training method and related equipment.
  • AI artificial intelligence
  • a federated learning system usually includes a server and multiple clients.
  • the server When training a model, the server first sends the model to be trained to each client. After receiving the model to be trained, each client device uses the training data stored locally to train the model to be trained and obtains an updated model. Each client can then upload the updated model to the server. Finally, the server aggregates the updated models uploaded by each client to obtain the trained model.
  • Embodiments of the present application provide a model training method and related equipment, which can enable the trained model obtained by joint training between the client and the server to have sufficiently excellent functions.
  • the first aspect of the embodiments of this application provides a model training method, which method includes:
  • the model to be trained can be obtained first.
  • the model to be trained contains multiple neurons.
  • each neuron is associated with parameters (i.e., the aforementioned parameter information) and position encoding (position encoding, PE) (i.e., the aforementioned position encoding information).
  • PE position encoding
  • each neuron has parameter and position encoding.
  • different neurons have different position codes.
  • the position code of the neuron can be used to indicate the position of the neuron in the model to be trained.
  • the second layer contains 3 neurons and the third layer contains 4 neurons.
  • the position codes of these 7 neurons can be 1, 2, 3, 4, 5, 6 and 7.
  • the training data can be processed through the parameters of the multiple neurons in the model to be trained and the position coding of the multiple neurons in the model to be trained to update the model to be trained, thereby obtaining the updated model. And to The updated model is sent out to achieve model aggregation to obtain the trained model.
  • the steps of the above model training method can be implemented by a client.
  • the client can be any one of multiple clients of the federated learning system. Then, the client can cooperate with the federated learning system.
  • the server in completes model training.
  • the model training process is as follows:
  • the server When the server needs to obtain a neural network model with data processing functions, it can first obtain the model to be trained and deliver it to multiple clients. For any one of the multiple clients, after receiving the model to be trained sent by the server, the client can use its own stored local data as training data to train the model to be trained.
  • the client can use the local data stored by itself as training data and input it into the model to be trained, so as to process the training data through multiple neurons of the model to be trained. , get the processing results of the training data. It is worth noting that for multiple neurons in the model to be trained, each neuron in the multiple neurons has parameter and position encoding, then these multiple neurons serve as multiple neurons in the model to be trained.
  • the data processing unit can process the training data using its own parameters and position coding to obtain the processing results of the training data.
  • the client can update the parameters of the neurons in the model to be trained based on the processing results of the training data to obtain an updated model.
  • the client can send the updated model to the server, so the server can perform federated aggregation based on the updated model uploaded by the client and the updated models uploaded by other clients, thus Get the trained model.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the training Data processing results. Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the position encoding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be trained, or the position encoding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be trained is determined.
  • the position coding of neurons can be set in a variety of ways: (1) In the model to be trained, for all neurons in the 2nd layer to all neurons in the N-1th layer, these multiple neurons The position coding of the neuron can be determined by the server based on the position of the multiple neurons in the model to be trained, that is, among the multiple neurons, any one The position encoding of a neuron is defined by the server based on the position of the neuron in the model to be trained. (2) In the model to be trained, for all neurons in layer 2 to all neurons in layer N-1, the position encoding of these multiple neurons can be jointly based on multiple neurons by multiple clients and servers. The position in the model to be trained is determined, that is, among the multiple neurons, the position coding of any neuron is agreed in advance by the server and multiple clients based on the position of the neuron in the model to be trained.
  • the model to be trained includes N layers, the first layer is the input layer, the second to N-1th layers are intermediate layers, and the Nth layer is the output layer.
  • Each layer includes at least one Neurons. All neurons in the first layer are used to receive input data, so all neurons in the first layer do not need to have parameters and position codes. All neurons in the second layer to all neurons in the N-1 layer are used for data processing, so All neurons in layer 2 to layer N-1 have parameters (such as weights, biases, etc.) and position codes. All neurons in layer N are used to output the processing results of data, so Nth All neurons in the layer only have parameters (for example, weights, etc.).
  • the client processes the training data through multiple neurons of the model to be trained.
  • the final output of The final output of the j-th neuron in layer N and the final output of all neurons in layer N are the processing results.
  • all neurons in layer 2 can provide input to each neuron in layer 3. Send the final output of all neurons in layer 2,..., and so on, until all neurons in layer N-2 send the final output of all neurons in layer N-2 to each neuron in layer N-1, N
  • the first neuron in layer -1 can perform the first calculation based on its own parameters and the final output of all neurons in layer N-2, and then the initial output of the first neuron in layer N-1 can be obtained.
  • the first neuron in layer 1 uses its own position encoding and its own initial output to perform a second calculation, and the final output of the first neuron in layer N-1 can be obtained.
  • the remaining neurons in layer N-1 can also perform the same operations as the first neuron in layer N-1, thereby obtaining the final output of all neurons in layer N-1.
  • the first neuron in the Nth layer can convert the first neuron in the Nth layer into The parameters and the final output of all neurons in the N-1th layer are first calculated to obtain the final output of the 1st neuron in the Nth layer. Then, the second neuron of the Nth layer can perform a first calculation on the parameters of the second neuron of the Nth layer and the final output of all neurons of the N-1th layer to obtain the final output of the second neuron of the Nth layer. Output,..., and so on, the final output of all neurons in the Nth layer can be obtained.
  • the final output of all neurons in the Nth layer is the output of the model to be trained, which is equivalent to the processing result of the training data.
  • the processing results of the training data are obtained based on the output of each neuron in the model to be trained.
  • the output of the neuron can be obtained by the neuron using its own parameters and position coding to perform data processing operations. , so the neuron is affected by its own position encoding when implementing data processing (that is, realizing the function of the neuron). constraints, and the impact of the neuron's positional encoding can be reflected in the results of processing the training data.
  • the client updates the parameters of the neuron based on the processing results of the training data the function of the neuron can be maintained as unchanged as possible, thereby limiting the rearrangement invariance of the neural network.
  • the client performs a second calculation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the j-th neuron in the i-th layer.
  • the final output includes: the client performs four arithmetic operations on the position coding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; or, the client The client performs a trigonometric function on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; or, the client performs a trigonometric function operation on the j-th neuron in the i-th layer; or, the client performs a trigonometric function on the j-th neuron in the i-th layer
  • the position coding of the j-th neuron in the layer and the initial output of the j-th neuron in the i-th layer are exponentially calculated to obtain the final
  • the second calculation performed by the neuron can be any one of the four arithmetic operations, trigonometric function operations, exponential operations, and logarithmic operations.
  • the restriction of the function of the neuron by position coding can be achieved in a variety of ways. .
  • the client updates the parameters based on the processing results
  • the updated model includes: the client obtains the target loss based on the processing results and the real processing results of the training data, and the target loss is used to indicate the processing results. And the difference between the real processing results; the client updates the parameters and position encoding based on the target loss to obtain the updated model.
  • the update frequency of the position coding is less than the update frequency of the parameters. For example, if there are 5 batches of training data, the client can successively input these 5 batches of training data to the model to be trained. , after processing the parameters and position encoding of the neurons in the model to be trained, the processing results of these five batches of training data can be obtained accordingly.
  • the client will use the processing results of 5 batches of training data to update the parameters of the neurons in the training model 5 times, but only use the processing results of 1 batch of training data to update the position encoding of the neurons in the training model. 1 time. In this way, the rearrangement invariance of the model can be suppressed to a certain extent.
  • the client sends the updated model to the server, including: the client obtains the parameter update amount and the position coding update amount based on the updated model and the model to be trained; the client sends the parameter update amount and the position coding update amount.
  • the parameter update amount and position coding update amount are used by the server to update the model to be trained until the model training conditions are met and the trained model is obtained.
  • the position coding of neurons in the model to be trained is a non-fixed value, so the client and the server can jointly update the parameters and position coding in the model to be trained, so that the model can be customized according to the nature of the specific task (i.e., in In certain business scenarios, users need the model to have certain data processing functions) to learn appropriate position coding, which is conducive to more reasonable alignment of neurons.
  • the client updates the parameters based on the processing results
  • the updated model includes: the client obtains the target loss based on the processing results and the real processing results of the training data, and the target loss is used to indicate the processing results. and the difference between the real processing results; the client updates the parameters based on the target loss and obtains the updated model.
  • the client sends the updated model to the server, including: the client obtains the parameter update amount based on the updated model and the model to be trained; the client sends the parameter update amount to the server, and the parameter update amount is used for the service
  • the terminal updates the model to be trained until the model training conditions are met and the trained model is obtained.
  • the positions of neurons in the model to be trained are encoded as fixed values, so the client and the server can jointly update the parameters in the model to be trained, so that the trained model can have certain data processing functions.
  • the second aspect of the embodiment of the present application provides a model training method.
  • the method includes: sending a model to be trained, where the model to be trained contains multiple neurons, wherein the neurons are associated with parameter information and position coding information, and the neurons and positions are The coding information corresponds one to one; the updated model is obtained and the updated model is aggregated to obtain the trained model.
  • the updated model is obtained by updating the model to be trained based on parameter information, position coding information and training data.
  • the steps of the above model training method can be implemented by a server, which is deployed in a federated learning system.
  • the server can cooperate with multiple clients in the federated learning system to complete model training.
  • the model The training process is as follows:
  • the server sends the model to be trained to the client.
  • the model to be trained contains multiple neurons. Each neuron in the multiple neurons has parameter and position encoding. Neurons at different positions in the multiple neurons have different positions. Coding, multiple neurons of the model to be trained are used by the client to process the training data to obtain the processing results, and update the parameters based on the processing results to obtain the updated model; the server obtains the updated model from the client, and Aggregate the updated models to obtain the trained model.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the processing of the training data. result. Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the position encoding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be processed, or the position encoding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be processed is determined.
  • the server receives the updated model from the client and aggregates the updated model.
  • the obtained trained model includes: the server obtains the parameter update amount and the position coding update amount from the client. , the parameter update amount and the position coding update amount are obtained based on the updated model and the model to be trained; the server updates the model to be trained based on the parameter update amount and the position coding update amount until the model training conditions are met and the trained model is obtained.
  • the server receives the updated model from the client and aggregates the updated model.
  • Obtaining the trained model includes: the server obtains the parameter update amount from the client, and the parameter update amount is based on The updated model and the model to be trained are obtained; the server updates the model to be trained based on the parameter update amount until the model is satisfied. type training conditions to obtain the trained model.
  • the third aspect of the embodiment of the present application provides a model training device.
  • the device includes: an acquisition module, used to acquire a model to be trained.
  • the model to be trained includes multiple neurons, wherein the neuron associated parameters and position codes, the neuron There is a one-to-one correspondence between elements and position codes; the processing module is used to update the model to be trained through parameters, position codes and training data to obtain an updated model; the sending module is used to send the updated model.
  • the device can be any client in the federated learning system.
  • the acquisition module of the client is used to acquire the model to be trained from the server.
  • the model to be trained contains multiple neurons, multiple Each neuron in the neuron has a parameter and position code, and neurons in different positions among multiple neurons have different position codes.
  • the processing module of the client is used to: process the training data through the parameters of multiple neurons in the model to be trained and the parameter position coding of multiple neurons in the model to be trained, and obtain the processing results, different positions in the multiple neurons The neurons have different position codes; based on the processing results, the parameters of multiple neurons in the training model are updated to obtain an updated model.
  • the sending module of the client is used to send the updated model to the server, and the updated model is used to aggregate at the server to obtain the trained model. It can be seen from the client that after a client obtains the model to be trained from the server, the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the training data. process result. Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the position coding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be trained, or the position coding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be trained is determined.
  • the model to be trained includes N layers, the plurality of neurons are all neurons from the 2nd layer to the N-1th layer, and the processing module is used to: convert the jth neuron of the i-th layer
  • Final output, the final output of the j-th neuron in the i-th layer is used to generate the processing result, that is, the final output of all neurons in the N-1th layer is used to generate the processing result.
  • the first layer is the input layer
  • the Nth layer is the output layer
  • the Nth layer is the output layer.
  • the final output of all neurons in the layer is the training data.
  • the parameters of the j-th neuron in the N-th layer are used to perform the first calculation on the final output of all neurons in the N-1 layer to obtain the j-th neuron in the N-th layer.
  • the final output, the final output of all neurons in the Nth layer is the processing result.
  • the processing module is used to: perform four arithmetic operations on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer, to obtain the j-th neuron in the i-th layer.
  • the final output of the neuron or, perform a trigonometric function operation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; Or, perform an exponential operation on the position code of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; or, combine the j-th neuron in the i-th layer with the initial output.
  • the position encoding of j neurons and the initial output of the j-th neuron in the i-th layer are logarithmically operated to obtain the final output of the j-th neuron in the i-th layer.
  • the processing module is used to: obtain a target loss based on the processing result and the real processing result of the training data, and the target loss is used to indicate the difference between the processing result and the real processing result; based on the target loss
  • the parameters and position coding are updated to obtain an updated model.
  • the update frequency of the position coding is smaller than the update frequency of the parameters.
  • the sending module is used to: obtain the parameter update amount and the position coding update amount based on the updated model and the model to be trained; send the parameter update amount and the position coding update amount to the server, and the parameter The update amount and position coding update amount are used by the server to update the model to be trained until the model training conditions are met and the trained model is obtained.
  • the processing module is used to: obtain a target loss based on the processing result and the real processing result of the training data, and the target loss is used to indicate the difference between the processing result and the real processing result; based on the target loss The parameters are updated to obtain the updated model.
  • the sending module is used to: obtain the parameter update amount based on the updated model and the model to be trained; send the parameter update amount to the server, and the parameter update amount is used by the server to update the model to be trained. , until the model training conditions are met and the trained model is obtained.
  • the fourth aspect of the embodiment of the present application provides a model training device.
  • the device includes: a sending module for sending a model to be trained.
  • the model to be trained includes a plurality of neurons, wherein the neuron associated parameters and position codes, the neuron There is a one-to-one correspondence between elements and position codes;
  • the acquisition module is used to obtain the updated model, which is obtained by updating the model to be trained based on parameters, position codes and training data;
  • the aggregation module is used to aggregate the updated model , get the trained model.
  • the device can be a server in the federated learning system, and the sending module of the server is used to send the model to be trained to the client.
  • the model to be trained includes multiple neurons, and multiple neurons Each neuron in the neuron has parameter and position coding. Neurons at different positions in multiple neurons have different position coding. Parameters and position coding are used by the client to process the training data to obtain processing results, and based on the processing results Update the parameters to obtain the updated model; the acquisition module is used to obtain the updated model from the client; the aggregation module is used to aggregate the updated model to obtain the trained model.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the training data. process result. Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • the neuron has parameter and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron can constrain the function of the neuron, and distinguish it from the functions of other neurons.
  • the position encoding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be processed, or the position encoding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be processed is determined.
  • the acquisition module is used to obtain the parameter update amount and position coding update amount from the client, and the parameter update amount and position coding update amount are obtained based on the updated model and the model to be trained; the aggregation module is used Based on the parameter update amount and the position coding update amount, the model to be trained is updated until the model training conditions are met, and the trained model is obtained.
  • the acquisition module is used to obtain the parameter update amount from the client, and the parameter update amount is obtained based on the updated model and the model to be trained; the aggregation module is used to update the model to be trained based on the parameter update amount. , until the model training conditions are met and the trained model is obtained.
  • a fifth aspect of the embodiments of the present application provides a client.
  • the client includes a memory and a processor; the memory stores code, and the processor is configured to execute the code.
  • the client executes the first The method described in any possible implementation manner of the aspect or the first aspect.
  • a sixth aspect of the embodiment of the present application provides a server.
  • the server includes a memory and a processor.
  • the memory stores code
  • the processor is configured to execute the code.
  • the server executes the second step. The method described in any possible implementation manner of the aspect or the second aspect.
  • the seventh aspect of the embodiment of the present application provides a federated learning system, which includes the client as described in the fifth aspect and the server as described in the sixth aspect, and the client and the server are connected for communication.
  • An eighth aspect of the embodiments of the present application provides a circuit system.
  • the circuit system includes a processing circuit configured to perform the first aspect, any one of the possible implementations of the first aspect, or the second aspect. method described.
  • a ninth aspect of the embodiments of the present application provides a chip system.
  • the chip system includes a processor for calling a computer program or computer instructions stored in a memory, so that the processor executes the steps described in the first aspect and the first aspect. any possible implementation manner or the method described in the second aspect.
  • the processor is coupled to the memory through an interface.
  • the chip system further includes a memory, and computer programs or computer instructions are stored in the memory.
  • a tenth aspect of the embodiments of the present application provides a computer storage medium.
  • the computer storage medium stores a computer program.
  • the program When the program is executed by a computer, it makes it possible for the computer to implement any one of the first aspect and the first aspect. or the method described in the second aspect.
  • An eleventh aspect of the embodiments of the present application provides a computer program product.
  • the computer program product stores instructions. When executed by a computer, the instructions make it possible for the computer to implement any one of the first aspect and the first aspect. or the method described in the second aspect.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the processing results of the training data. . Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • Figure 1 is a structural schematic diagram of the main framework of artificial intelligence
  • Figure 2 is a schematic structural diagram of the federated learning system provided by the embodiment of this application.
  • Figure 3 is a schematic diagram of the architecture of the system 100 provided by the embodiment of the present application.
  • Figure 4 is a schematic diagram of an application example of the federated learning system provided by the embodiment of this application.
  • Figure 5 is a schematic diagram of another application example of the federated learning system provided by the embodiment of this application.
  • Figure 6 is a schematic diagram of another application example of the federated learning system provided by the embodiment of this application.
  • Figure 7 is a schematic flow chart of the model training method provided by the embodiment of the present application.
  • Figure 8 is a schematic structural diagram of the federated learning system provided by the embodiment of this application.
  • Figure 9 is a schematic structural diagram of the model to be trained provided by the embodiment of the present application.
  • Figure 10 is another structural schematic diagram of the federated learning system provided by the embodiment of the present application.
  • Figure 11 is another schematic flow chart of the model training method provided by the embodiment of the present application.
  • Figure 12 is a schematic structural diagram of a client provided by an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of the server provided by the embodiment of the present application.
  • Figure 14 is a schematic structural diagram of an execution device provided by an embodiment of the present application.
  • Figure 15 is a schematic structural diagram of the training equipment provided by the embodiment of the present application.
  • Figure 16 is a schematic structural diagram of a chip provided by an embodiment of the present application.
  • Embodiments of the present application provide a model training method and related equipment, which can enable the trained model obtained by joint training between the client and the server to have sufficiently excellent functions.
  • a federated learning system usually includes a server and multiple clients.
  • the server When training a model, the server first sends the model to be trained to each client. After receiving the model to be trained, each client device uses the training data stored locally to train the model to be trained and obtains an updated model. Each client can then upload the updated model to the server. Finally, the server aggregates the updated models uploaded by each client to obtain the trained model.
  • the federated learning system includes server, client 1 and client 2.
  • the first neuron is used to implement function 1
  • the second neuron is used to implement function 2.
  • client 1 inputs local data 1 into the model to be trained, it can obtain the processing result 1, and then updates the parameters of the neurons in the model to be trained based on the processing result 1 to obtain the updated model 1.
  • the updated model 1 the The function of the first neuron in layer 2 is converted to function 2, and the function of the second neuron in layer 2 is converted to function 1.
  • client 2 after client 2 inputs local data 2 into the model to be trained, it can obtain the processing result 2, and then updates the parameters of the neurons in the model to be trained based on the processing result 2 to obtain the updated model 2.
  • the function of the first neuron in layer 2 is still function 1
  • the function of the second neuron in layer 2 is still function 2. It can be seen that compared with the neuron distribution of the model to be trained, the two neurons used to implement function 1 and function 2 in the updated model 1 have exchanged positions, while the two neurons used to implement functions in the updated model 2 have The positions of the two neurons of function 1 and function 2 remain unchanged.
  • client 1 After client 1 obtains the updated model 1, it can obtain the parameter update amount 1 (including the parameter update amount of each neuron in the updated model 1 based on the updated model 1 and the model to be trained, for example, the parameter update amount of each neuron in the second layer The parameter update amount of 1 neuron, the parameter update amount of the second neuron in layer 2, etc.) and sent to the server.
  • client 2 can also obtain the parameter update amount 2 (including the updated parameter update amount of each neuron in model 2, for example, the parameter update amount of the first neuron in layer 2 new quantity, parameter update quantity of the second neuron in layer 2, etc.) and sent to the server.
  • the server can continue to repeat the foregoing process with Client 1 and Client 2 until the model meets the preset model training conditions and the trained model is obtained.
  • the trained model obtained in this way cannot have sufficient data processing capabilities.
  • the server calculates the average parameter update amount of the first neuron in layer 2, it is based on the updated model.
  • the parameter update amount of the first neuron in layer 2 in 1 is calculated from the parameter update amount of the first neuron in layer 2 in model 2 after the update, but the first neuron in layer 2 in model 1 after the update is calculated Neurons are used to implement function 2.
  • the first neuron in the second layer of the updated model 2 is used to implement function 1. Therefore, the model to be trained is updated based on the average parameter update amount of the first neuron in the second layer.
  • the parameters of the first neuron in layer 2 will cause this neuron to become dysfunctional after the parameters are updated. It can be seen that in the trained model, there will be functional disorders of neurons in multiple locations, resulting in the trained model being unable to have excellent data processing functions.
  • embodiments of this application provide a model training method based on federated learning.
  • AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by perceiving the environment, acquiring knowledge and using knowledge.
  • artificial intelligence technology is a branch of computer science that attempts to understand the nature of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence.
  • Using artificial intelligence for data processing is a common application method of artificial intelligence.
  • Figure 1 is a structural schematic diagram of the main framework of artificial intelligence.
  • the following is from the “intelligent information chain” (horizontal axis) and “IT value chain” (vertical axis)
  • the above artificial intelligence theme framework is elaborated on in two dimensions.
  • the "intelligent information chain” reflects a series of processes from data acquisition to processing. For example, it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has gone through the condensation process of "data-information-knowledge-wisdom".
  • the "IT value chain” reflects the value that artificial intelligence brings to the information technology industry, from the underlying infrastructure of human intelligence and information (providing and processing technology implementation) to the systematic industrial ecological process.
  • Infrastructure provides computing power support for artificial intelligence systems, enables communication with the external world, and supports it through basic platforms.
  • computing power is provided by smart chips (hardware acceleration chips such as CPU, NPU, GPU, ASIC, FPGA, etc.);
  • the basic platform includes distributed computing framework and network and other related platform guarantees and support, which can include cloud storage and Computing, interconnection networks, etc.
  • sensors communicate with the outside world to obtain data, which are provided to smart chips in the distributed computing system provided by the basic platform for calculation.
  • Data from the upper layer of the infrastructure is used to represent data sources in the field of artificial intelligence.
  • the data involves graphics, images, voice, and text, as well as IoT data of traditional devices, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
  • Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
  • machine learning and deep learning can perform symbolic and formal intelligent information modeling, extraction, preprocessing, training, etc. on data.
  • Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formal information to perform machine thinking and problem solving based on reasoning control strategies. Typical functions are search and matching.
  • Decision-making refers to the process of decision-making after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
  • some general capabilities can be formed based on the results of further data processing, such as algorithms or a general system, such as translation, text analysis, computer vision processing, speech recognition, and image processing. identification, etc.
  • Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Its application fields mainly include: intelligent terminals, intelligent transportation, Smart healthcare, autonomous driving, smart cities, etc.
  • FIG. 2 is a schematic structural diagram of a federated learning system provided by an embodiment of the present application.
  • the federated learning system includes a server and multiple clients, both of which can be connected through a communication network.
  • the client includes smart terminals such as mobile phones, personal computers, or information processing centers.
  • the server can be a device or server with data processing functions such as a cloud server, network server, application server, and management server.
  • the client and server can collaborate to achieve Training of neural network models.
  • each client can receive the model to be trained from the server through the interactive interface, and then perform machine learning, deep learning, search, and reasoning on the model to be trained through the memory that stores local data and the processor that processes the data.
  • Model training in decision-making and other ways.
  • the updated model can be uploaded to the server, so that the server can aggregate the updated models uploaded by each client, thereby based on the aggregation The result is a local model to be trained on the server.
  • the server can use the updated model obtained by its own training as a new model to be trained, and send it to each client again to perform the second iteration of model training (ie, repeat the aforementioned process).
  • the server determines that the updated model obtained by its last training meets the model training conditions, it can use the updated model obtained by its last training as the trained model (that is, the training is completed) model).
  • the server not only indirectly uses the local data of each client to complete model training, but also ensures the data security of each client, thereby protecting the user's personal privacy.
  • each client can upload the parameter update amount of the model to the server to represent the updated model obtained by each client. Then, the server can average the parameter updates from each client, and then update the parameters of the server's local model to be trained based on the average of the parameter updates to implement the server's own model training.
  • the server and the client can jointly execute the model training method according to the embodiment of the present application.
  • the server obtains the trained model and has data processing functions, so the model can be deployed on each client. Therefore, each client can provide data processing services for users.
  • a client obtains the data to be processed from user input, it can call the trained model to process the user input. Process the data accordingly and return the corresponding processing results to the user.
  • the client can use the trained model obtained by the model training method in the embodiment of the present application to implement the data processing function.
  • Figure 3 is a schematic diagram of the architecture of the system 100 provided by the embodiment of the present application.
  • the execution device 110 is configured with an input/output (I/O) interface 112 for data interaction with external devices.
  • the user Data can be input to the I/O interface 112 through the client device 140.
  • the input data may include: various to-be-scheduled tasks, callable resources, and other parameters.
  • the execution device 110 When the execution device 110 preprocesses the input data, or when the calculation model 111 of the execution device 110 performs calculation and other related processing (such as implementing the function of the neural network in this application), the execution device 110 can call the data storage system 150
  • the data, codes, etc. in the system can be used for corresponding processing, and the data, instructions, etc. obtained by corresponding processing can also be stored in the data storage system 150 .
  • the I/O interface 112 returns the processing results to the client device 140, thereby providing them to the user.
  • the training device 120 can generate corresponding target models/rules based on different training data for different goals or different tasks, and the corresponding target models/rules can be used to achieve the above goals or complete the above tasks. , thereby providing users with the desired results.
  • the training data may be stored in the database 130 and come from training samples collected by the data collection device 160 .
  • the user can manually enter the input data, and the manual input can be operated through the interface provided by the I/O interface 112 .
  • the client device 140 can automatically send input data to the I/O interface 112. If requiring the client device 140 to automatically send input data requires the user's authorization, the user can set corresponding permissions in the client device 140.
  • the user can view the results output by the execution device 110 on the client device 140, and the specific presentation form may be display, sound, action, etc.
  • the client device 140 can also be used as a data collection end to collect the input data of the input I/O interface 112 and the output results of the output I/O interface 112 as new sample data, and store them in the database 130 .
  • the I/O interface 112 directly uses the input data input to the I/O interface 112 and the output result of the output I/O interface 112 as a new sample as shown in the figure.
  • the data is stored in database 130.
  • Figure 3 is only a schematic diagram of a system architecture provided by an embodiment of the present application.
  • the positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation.
  • the data The storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 can also be placed in the execution device 110.
  • the neural network can be trained according to the training device 120.
  • the training device 120 usually refers to the aforementioned server, and the execution device 110 generally refers to the aforementioned client.
  • the training device 120 can cooperate with the execution device 110 to implement model training, that is, Both can implement model training in a federated learning manner.
  • An embodiment of the present application also provides a chip, which includes a neural network processor NPU.
  • the chip can be disposed in the execution device 110 as shown in FIG. 3 to complete the calculation work of the calculation model 111.
  • the chip can also be installed in the training device 120 as shown in Figure 3 to complete the training work of the training device 120 and output the target model/rules.
  • Neural network processor NPU is mounted on the main central processing unit (CPU) (host CPU) as a co-processor, and the main CPU allocates tasks.
  • the core part of the NPU is the arithmetic circuit.
  • the controller controls the arithmetic circuit to extract the data in the memory (weight memory or input memory) and perform operations.
  • the computing circuit includes multiple processing units (PE).
  • PE processing units
  • the arithmetic circuit is a two-dimensional systolic array.
  • the arithmetic circuit may also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition.
  • the arithmetic circuit is a general-purpose matrix processor.
  • the arithmetic circuit fetches the corresponding data of matrix B from the weight memory and caches it on each PE in the arithmetic circuit.
  • the operation circuit takes matrix A data and matrix B from the input memory to perform matrix operations, and the partial result or final result of the obtained matrix is stored in the accumulator (accumulator).
  • the vector calculation unit can further process the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
  • the vector computing unit can be used for network calculations in non-convolutional/non-FC layers in neural networks, such as pooling, batch normalization, local response normalization, etc.
  • the vector computation unit can store the processed output vector into a unified buffer.
  • the vector calculation unit may apply a nonlinear function to the output of the arithmetic circuit, such as a vector of accumulated values, to generate activation values.
  • the vector computation unit generates normalized values, merged values, or both.
  • the processed output vector can be used as an activation input to an arithmetic circuit, such as for use in a subsequent layer in a neural network.
  • Unified memory is used to store input data and output data.
  • the weight data directly transfers the input data in the external memory to the input memory and/or the unified memory through the storage unit access controller (direct memory access controller, DMAC), stores the weight data in the external memory into the weight memory, and transfers the weight data to the unified memory.
  • DMAC direct memory access controller
  • the bus interface unit (BIU) is used to realize the interaction between the main CPU, DMAC and instruction memory through the bus.
  • the instruction fetch buffer connected to the controller is used to store instructions used by the controller
  • the controller is used to call instructions cached in the memory to control the working process of the computing accelerator.
  • the unified memory, input memory, weight memory and instruction memory are all on-chip memories, and the external memory is the memory outside the NPU.
  • the external memory can be double data rate synchronous dynamic random access memory (double data). rate synchronous dynamic random access memory (DDR SDRAM), high bandwidth memory (high bandwidth memory (HBM)) or other readable and writable memory.
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • HBM high bandwidth memory
  • FIG. 4 is a schematic diagram of an application example of the federated learning system provided by the embodiment of the present application.
  • the federated learning system can be applied in the field of smart homes. At this time, multiple clients in the system are located in multiple homes. Smart home devices in multiple homes located in different geographical locations. These multiple smart home devices can communicate with the server in the cloud (i.e., the server) to achieve federated learning.
  • the server in the cloud can implement multiple iterations of model training with multiple smart home devices.
  • each smart home device can receive the model to be trained from the server, update the parameters of the model to be trained through local voice data, and upload the updated model to the server, so that the server can The updated models uploaded by each smart home device are aggregated to train the local model to be trained on the server based on the aggregation results.
  • the server can use the updated model obtained by its own training as a new model to be trained, and send it to each smart home device again to perform the second iteration of model training (ie, repeat the aforementioned process).
  • the server determines that the updated model obtained by its last training meets the model training conditions, it can use the updated model obtained by its last training.
  • the model is deployed on various smart home devices to provide smart home services for each family.
  • FIG. 5 is a schematic diagram of another application example of the federated learning system provided by the embodiment of this application.
  • the federated learning system can be applied in the teaching field.
  • multiple clients in the system are located in multiple schools.
  • teaching equipment for example, personal computers, tablets, etc.
  • these multiple schools are located in different geographical locations.
  • These multiple teaching devices can communicate with the solver developer's server (i.e., the server) to achieve federated learning.
  • the server of the solver developer can implement multiple iterations of model training with multiple teaching devices.
  • each teaching device can receive the model to be trained from the server, update the parameters of the model to be trained through local mathematical data, and upload the updated model to the server, so that the server can The updated models uploaded by the teaching equipment are aggregated to train the local model to be trained on the server based on the aggregation results.
  • the server can use the updated model obtained by its own training as a new model to be trained, and deliver it to each teaching device again to perform the second iteration of model training (ie, repeat the aforementioned process).
  • the server determines that the updated model obtained by its last training meets the model training conditions, it can use the updated model obtained by its last training as a solver and deploy it to each teaching device. , providing teaching services to students and teachers in various schools.
  • FIG. 6 is a schematic diagram of another application example of the federated learning system provided by the embodiment of the present application.
  • the federated learning system can be applied in the field of software services.
  • multiple clients in the system are located in multiple Intelligent terminal equipment used by users or enterprises.
  • These multiple intelligent terminal devices can communicate with the remote software developer's server (i.e., the server) to achieve federated learning.
  • each smart terminal device can implement multiple iterations of model training with multiple smart terminal devices.
  • each smart terminal device can receive the model to be trained from the server, update the parameters of the model to be trained through local image data, and upload the updated model to the server, so that the server can The updated models uploaded by each smart terminal device are aggregated, so as to train the local model to be trained on the server based on the aggregation results.
  • the server can use the updated model obtained by its own training as a new model to be trained, and again deliver it to each smart terminal device to perform the second iteration of model training (ie, repeat the aforementioned process).
  • the server determines that the updated model obtained by its last training meets the model training conditions, it can use the updated model obtained by its last training as image processing software and deploy it to each smart terminal.
  • image processing services are provided for businesses and individuals.
  • the federated learning system can be applied to the smart home field, teaching field and software service field.
  • the federated learning system provided by the embodiments of the present application can also be applied to more fields. I won’t introduce them one by one here.
  • the neural network can be composed of neural units.
  • the neural unit can refer to an arithmetic unit that takes xs and intercept 1 as input.
  • the output of the arithmetic unit can be:
  • s 1, 2,...n, n is a natural number greater than 1
  • Ws is the weight of xs
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer.
  • the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field.
  • the local receptive field can be an area composed of several neural units.
  • W is a weight vector, and each value in the vector represents the weight value of a neuron in the neural network of this layer.
  • This vector W determines the spatial transformation from the input space to the output space described above, that is, the weight W of each layer controls how to transform the space.
  • the purpose of training a neural network is to finally obtain the weight matrix of all layers of the trained neural network (a weight matrix formed by the vector W of many layers). Therefore, the training process of neural network is essentially to learn how to control spatial transformation, and more specifically, to learn the weight matrix.
  • weight vector (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the neural network). For example, if the predicted value of the network is high, adjust the weight vector to make it predict lower Some, constant adjustments are made until the neural network can predict the truly desired target value. Therefore, it is necessary to define in advance "how to compare the difference between the predicted value and the target value". This is the loss function (loss function) or objective function (objective function), which is used to measure the difference between the predicted value and the target value. Important equations. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference. Then the training of the neural network becomes a process of reducing this loss as much as possible.
  • the neural network can use the error back propagation (BP) algorithm to modify the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, forward propagation of the input signal until the output will produce an error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss converges.
  • the backpropagation algorithm is a backpropagation movement dominated by error loss, aiming to obtain the optimal parameters of the neural network model, such as the weight matrix.
  • Federated learning is a machine learning technology used to protect user privacy.
  • the structure of federated learning generally includes a server (central server) and some clients as participants.
  • the technical process mainly includes model distribution and model aggregation processes.
  • the client downloads the model from the server and trains it on local data. After training to a certain extent, the client uploads the model to the server.
  • the server collects the models uploaded by each client and performs model fusion. These two processes will be iterated repeatedly until the model converges, thereby obtaining a trained model.
  • Federated aggregation is a sub-process of federated learning.
  • the main task of the server in federated learning is to aggregate the models uploaded by the client, that is, the process of the server merging multiple models into one model in federated learning.
  • Parameter point-to-point aggregation is the simplest federated aggregation method. This method requires that the models uploaded by multiple clients have the same structure, and the server can average the parameters of neurons at the same position in multiple models.
  • the model training method provided by the embodiment of this application involves data processing.
  • the client can specifically apply data training, machine learning, deep learning and other methods to symbolize the training data (for example, the training data stored locally on the client in this application). through intelligent information modeling, extraction, preprocessing, training, etc., and finally obtain the updated neural network (such as the updated model obtained by the client based on the training data in this application) and return it to the server for aggregation , to obtain the trained neural network (such as the trained model obtained by the server aggregation based on the updated model in this application); and, the trained neural network obtained by the model training method provided by the embodiment of this application , can be deployed by the server at the client, so that the client can implement the data processing function, that is, input the input data into the trained neural network deployed in the client, thereby obtaining the output data (that is, the processing result of the input data).
  • model training method provided by the embodiments of the present application and the model-implemented data processing function obtained based on the model training method are inventions based on the same concept, and can also be understood as two parts of one system, or one There are two stages in the overall process: model training stage and model application stage.
  • FIG. 7 is a schematic flow chart of the model training method provided by the embodiment of the present application.
  • This method can be implemented through the federated learning system shown in Figure 8 (Fig. 8 is a schematic structural diagram of the federated learning system provided by the embodiment of the present application).
  • the system includes: a server and multiple clients. Both the server and the client include computing devices (such as CPU, GPU, etc.) and transmission devices (such as communication interfaces, etc.), where , the computing device is used to train the model to be trained, and the transmission device is used to transfer the model or information related to the model. Therefore, the server and the client can train the model in a federated learning manner.
  • the method includes:
  • the client obtains the model to be trained from the server.
  • the server when the server needs to obtain a neural network model with data processing functions (such as image processing, speech processing, text processing, etc.), it can first obtain the model to be trained (that is, the neural network model that needs to be trained) , and deliver it to multiple clients.
  • data processing functions such as image processing, speech processing, text processing, etc.
  • the model to be trained issued by the server contains N layers (N is an integer greater than or equal to 3).
  • the first layer is the input layer
  • the second layer to the N-1th layer are the intermediate layers
  • the Nth layer The layers are output layers, and each layer contains at least one neuron. All neurons in the first layer are used to receive input data, so all neurons in the first layer do not need to have parameters and position codes.
  • All neurons in the second layer to all neurons in the N-1 layer are used for data processing, so All neurons in layer 2 to all neurons in layer N-1 have parameters (i.e., the aforementioned parameter information, such as weights, biases, etc.) and position coding (i.e., the aforementioned position coding information).
  • All neurons in layer N Neurons are used to output the processing results of data, so all neurons in the Nth layer only Has parameters (e.g., weights, etc.).
  • the position coding of any one neuron is associated with the position of the neuron in the model to be trained, and among these multiple neurons Among neurons, neurons located at different positions usually have different position codes.
  • the position encoding of neurons can be set in a variety of ways, which will be introduced below:
  • the position encoding of these multiple neurons can be encoded by the server based on these multiple neurons in the model to be processed.
  • the position is determined, that is, among these multiple neurons, the position code of any neuron is defined by the server based on the position of the neuron in the model to be trained.
  • the server can
  • the position encoding of the first neuron in layer 2 is defined as 1 and set in the first neuron in layer 2, so the first neuron in layer 2 not only has its own parameters, but also has its own position coding.
  • the server can also define the position code of the second neuron in layer 2 as 2 and set it in the second neuron in layer 2, so the second neuron in layer 2 not only has its own
  • the parameter also has its own position code
  • the server can also define the position code of the fourth neuron in layer 3 as 7, and set it in the fourth neuron in layer 3, so The 4th neuron in layer 3 not only has its own parameters, but also its own position encoding.
  • the server can define the position codes of all neurons in the second layer and the position codes of all neurons in the third layer in the model to be trained, and set them in the corresponding neurons.
  • the position encoding of these multiple neurons can be jointly performed by multiple clients and servers based on multiple neurons.
  • the position of the neuron in the model to be processed is determined, that is, among the multiple neurons, the position coding of any neuron is agreed in advance by the server and multiple clients based on the position of the neuron in the model to be trained.
  • Figure 9 Figure 9 is a schematic structural diagram of the model to be trained provided by the embodiment of the present application.
  • Figure 9 shows the position coding of the neurons, but does not show the parameters of the neurons
  • the federated learning system includes server, client 1 and client 2
  • the model to be trained contains 4 layers
  • the 1st layer is the input layer
  • the 4th layer is the output layer
  • the 2nd layer contains 3 neurons
  • the 4th layer is the output layer.
  • Layer 3 contains 4 neurons.
  • the server, client 1 and client 2 can agree on the position encoding of the first neuron in layer 2 as 1 and set it in the first neuron in layer 2. Therefore, the first neuron in layer 2 not only has its own parameters, but also has its own position encoding.
  • the server, client 1 and client 2 can also define the position code of the second neuron in layer 2 as 2 and set it in the second neuron in layer 2, so the position code of the second neuron in layer 2
  • the server, client 1 and client 2 can also define the position code of the fourth neuron in layer 3 as 7, and is set in the fourth neuron of layer 3, so the fourth neuron of layer 3 not only has its own parameters, but also has its own position encoding.
  • the server, client 1 and client 2 can agree in advance on the position codes of all neurons in the second layer and the position codes of all neurons in the third layer in the model to be trained, and set them in the corresponding neurons.
  • the server delivers the same model to be trained to multiple clients, among these multiple clients, the position codes of multiple neurons in the model to be trained received by any client are different from those received by other clients.
  • the position codes of multiple neurons in the model to be trained are the same set of position codes.
  • each client performs the same operations on the training model, so the following uses one of the multiple clients as an example for schematic explanation.
  • the client after receiving the model to be trained sent by the server, the client can use its own local data stored as training data to train the model to be trained.
  • model to be trained includes two intermediate layers is used as an example for schematic explanation, and the second layer includes three neurons and the third layer includes four neurons is used for schematic explanation. There is no limit to the number of intermediate layers and the number of neurons in the layers of the model to be trained in this application.
  • the position codes of neurons are only 1 to 7 for schematic explanation, and there is no limit to the size of the position codes of neurons.
  • the client processes the training data through multiple neurons of the model to be trained, and obtains processing results.
  • Each neuron among the multiple neurons has parameter and position coding, and neurons at different positions among the multiple neurons have Different location encodings.
  • the client After receiving the model to be trained, the client can use its own local data stored as training data and input it into the model to be trained, so as to process the training data through multiple neurons of the model to be trained to obtain the processing of the training data. result. It should be noted that for all neurons in the second layer to all neurons in the N-1 layer in the model to be trained, each of these multiple neurons has parameter and position coding, then, these multiple neurons Neurons, as multiple data processing units in the model to be processed, can use their own parameters and position coding to process (calculate) the training data to obtain the processing results of the training data.
  • the client can use the model to be trained to obtain the processing results of the training data in the following ways:
  • d 1 is the number of neurons in the input layer, which is equivalent to the dimension of the input training data (that is, the input dimension)
  • d N is the number of neurons in the output layer, which is equivalent to the dimension of the processing result of the training data ( That is the dimension of the output).
  • Wi is the weight of the neuron in the i-th layer
  • b i is the bias of the neuron in the i-th layer.
  • the element of the jth row in W i is the weight of the jth neuron of the ith layer.
  • the element of the j-th row in b i is the bias of the j-th neuron in the i-th layer.
  • the training data is the final output of all neurons in the first layer (including the final output of each neuron in the first layer), so x can also be recorded as h 1 , h 1 contains d 1 elements, that is, h 1 The dimension is d 1 dimension.
  • the final output h 2 of all the neurons in the second layer can be obtained (h 2 contains d 2 elements, that is, the dimension of h 2 is d 2 dimensions , and h 2 contains the final output of each neuron in layer 2), so all neurons in layer 2 can send the final output h 2 of all neurons in layer 2 to each neuron in layer 3,..., and so on, Until all neurons in layer N-2 send the final output h N - 2 of all neurons in layer N-2 to each neuron in layer N-1, each neuron in layer N-1 sends all neurons in layer N-2 After calculating the final output h N-2 of the neuron, the final output h N-1 of all neurons in the N-1 layer can be obtained (h N-1 contains d N-1 elements, that is, the dimension of h N-1 is d N-1 dimension, and h N-1 contains the final output of each neuron in the N-1th layer). It can be seen that
  • h i-1 is the final output of all neurons in layer i-1
  • h i ⁇ is the initial output of all neurons in layer i
  • h i ⁇ (j) is the initial output h i ⁇ of all neurons in layer i
  • the element in the jth row in h i is the initial output of the jth neuron in the i-th layer.
  • h i (j) is the final output of all neurons in the i-th layer.
  • the element in the jth row h i is the j-th element in the i-th layer. the final output of a neuron.
  • the j-th neuron in the i-th layer can first combine the parameters of the j-th neuron in the i-th layer with all the neurons in the i-1th layer. Perform the first calculation on the final output h i-1 of the neuron (the first calculation process can refer to the first line of formula in formula (7)), and obtain the initial output h i ⁇ (j) of the j-th neuron in the i-th layer .
  • the j-th neuron in the i-th layer performs a second calculation using the position encoding g i (j) of the j-th neuron in the i-th layer and the initial output h i ⁇ (j) of the j-th neuron in the i-th layer.
  • the second calculation process can refer to the second line of formula in formula (7)
  • the final output h i (j) of the j-th neuron in the i-th layer is obtained.
  • the same operation as the j-th neuron can also be performed, so the final output h i of all neurons in the i-th layer can be obtained.
  • the first neuron in the Nth layer can The parameters of the first neuron in layer N and the final output h N-1 of all neurons in layer N- 1 are used for the first calculation (the process of the first calculation can refer to the first line of formula in formula (7)), Get the final output h N ⁇ (1) of the first neuron of the Nth layer.
  • the second neuron of the Nth layer can perform the first calculation on the parameters of the second neuron of the Nth layer and the final output h N-1 of all the neurons of the N-1th layer to obtain the second neuron of the Nth layer.
  • the final output h N ⁇ of the neuron is the output of the model to be trained, which is equivalent to the processing result of the training data.
  • the operations of each neuron in the model to be trained can also be regarded as operations of the client.
  • the activation function f N in the first line of formula can be regarded as an identity function, that is, a function whose input is equal to the output.
  • the second calculation can also be one or any combination of the four calculations, that is, the client can multiply the position code of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer. , one or any combination of addition operations, subtraction operations and division operations to obtain the final output of the j-th neuron in the i-th layer.
  • the second calculation can also be a trigonometric function operation, that is, the client can perform a trigonometric function operation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the i-th layer.
  • the final output of the jth neuron can also be an exponential operation, that is, the client performs an exponential operation on the position code of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the j-th neuron in the i-th layer.
  • the final output of the neuron can also be a trigonometric function operation, that is, the client can perform a trigonometric function operation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the i-th layer.
  • the second calculation can also be a logarithmic operation, that is, the client performs a logarithmic operation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the i-th layer. The final output of j neurons.
  • the client updates the parameters of the neurons in the model to be processed based on the processing results, and obtains the updated model.
  • the client can update the parameters of the neurons in the model to be processed based on the processing results of the training data to obtain an updated model.
  • the client can update the parameters of the neurons in the model to be processed based on the processing results in the following ways, thereby obtaining the updated model:
  • the client can first calculate the processing results of the training data output by the training model and the real processing results of the training data through the preset target loss function to obtain the target loss.
  • the target loss is used to indicate the difference between the processing results of the training data output by the model to be trained and the real processing results of the training data.
  • the client After obtaining the target loss, the client updates the parameters of the neurons in the training model (including the parameters of all neurons in layer 2 to all neurons in layer N) based on the target loss, but does not update the position coding of the neurons ( Contains the position codes of all neurons in layer 2 to layer N-1, these position codes are regarded as fixed values), and the updated model is obtained.
  • the client obtains the parameter update amount based on the updated model and the model to be trained.
  • the client sends the parameter update amount to the server, and the parameter update amount is used by the server to update the model to be trained until the model training conditions are met and the trained model is obtained.
  • the client can send the updated model to the server, so the server can perform federated aggregation based on the updated model uploaded by the client and the updated models uploaded by other clients. Get the trained model.
  • the client can upload the updated model in the following ways, so that the server can implement federated aggregation based on the updated model:
  • the client can obtain the relationship between the updated model and the model to be trained based on the two.
  • Parameter update amount which usually refers to the parameter update amount of each neuron in the updated model compared to the model to be trained (hereinafter referred to as the parameter update amount of each neuron in the updated model).
  • the client can compare the parameters of neurons at the same position in the updated model and the model to be trained, thereby obtaining the parameter update amount of the neuron at that position. In this way, The parameter update amount of each neuron of the updated model can be obtained.
  • the updated model 1 obtained by client 1 also contains 4 layers.
  • client 1 can add the first neuron of layer 1 in the model to be trained. Compare the parameters of the first neuron in the first layer of the updated model 1 with the parameters of the first neuron in the first layer of the updated model 1 to obtain the parameter update amount of the first neuron in the first layer of the updated model 1.
  • the client can also update the parameters to be trained Compare the parameters of the second neuron in the first layer in the model with the parameters of the second neuron in the first layer in the updated model 1, and obtain the updated parameter of the second neuron in the first layer in the updated model 1. Amount,..., and so on, the client can obtain the updated parameter update amount of each neuron in model 1.
  • the client can send the parameter update amount of each neuron in the updated model to the server.
  • the server can obtain the parameter update amount of each neuron in the updated model uploaded by each client. And based on this information, average calculation is performed to obtain the average value of the parameter update amount of each neuron in the updated model. Therefore, the server can calculate the locally stored model to be trained based on the average value of the parameter update amount of each neuron. The parameters of each neuron in the model are updated accordingly, and the updated model obtained by the server's own training can be obtained.
  • the server after the server receives the parameter update amount of each neuron in the updated model 1 uploaded by the client 1, and the parameter update amount of each neuron in the updated model 2 uploaded by the client 2, it can Calculate the average parameter update amount of the first neuron in the first layer in the updated model 1 and the parameter update amount of the first neuron in the first layer in the updated model 2 to obtain the first parameter update amount in the first layer.
  • the average parameter update amount of the neuron ..., and so on, the server can obtain the average parameter update amount of each neuron.
  • the server can update the parameters of each neuron in the locally stored model to be trained based on the average parameter update amount of each neuron, that is, using the parameter update amount of the first neuron in the first layer.
  • the average value is used to update the parameters of the first neuron in the first layer of the model to be trained, and the average value of the parameter updates of the second neuron in the first layer is used to update the second neuron in the first layer of the model to be trained.
  • the parameters of the element,..., and so on, can get the updated model trained by the server itself.
  • the server can use the updated model obtained by its own training as a new model to be trained, and again send it to each client for the next iteration of model training (that is, repeat steps 701 to 704) until a certain time
  • the updated model obtained by the server's own training meets the model training requirements (for example, the target loss converges or the number of iterations is greater than the preset number, etc.)
  • the updated model obtained by the server's own training in this iteration can be
  • the updated model is used as the trained model (that is, the neural network model that has completed training).
  • this embodiment is only schematically illustrated by the server calculating the average parameter update amount of each neuron in the updated model uploaded by each client.
  • the server can also calculate the parameter updates of each neuron in the updated model uploaded by each client.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the processing results of the training data. . Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the neurons The positional encoding effectively curbs the rearrangement invariance of the neural network model. Since other clients can also perform the same operations as this client, in the updated model uploaded by each client to the server, neurons with the same functions are in the same position. Therefore, when the server implements aggregation, Neurons in each updated model can be processed by location, and the resulting trained model can have sufficiently excellent functions.
  • the server can use the local data of each client to perform neuron alignment on these models (that is, exchange the positions of the neurons, Thus, neurons with the same function are located at the same location in these models).
  • neuron alignment may leak user privacy, involve a series of data security issues, and introduce additional computing overhead.
  • Figure 10 is another structural schematic diagram of the federated learning system provided by the embodiment of the present application, so there is no need for the server to perform the neuron alignment operation, which can effectively protect user privacy and avoid the occurrence of data security issues. And it can reduce the computing overhead of the server.
  • Figure 11 is another schematic flow chart of the model training method provided by the embodiment of the present application. This method can also be implemented through the federated learning system shown in Figure 8. As shown in Figure 11, the method includes:
  • the client obtains the model to be trained from the server.
  • the position encoding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be processed, or the position encoding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be processed is determined.
  • the client processes the training data through multiple neurons of the model to be trained, and obtains the processing results.
  • Each neuron among the multiple neurons has parameter and position coding, and the neurons at different positions among the multiple neurons have Different location encodings.
  • the model to be trained includes N layers, the first layer is the input layer, the Nth layer is the output layer, and the multiple neurons are all neurons from layer 2 to layer N-1.
  • the client performs a second calculation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the j-th neuron in the i-th layer.
  • the final output includes: the client performs four arithmetic operations on the position coding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; or, the client The client performs a trigonometric function on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer; or, the client performs a trigonometric function operation on the j-th neuron in the i-th layer; or, the client performs a trigonometric function on the j-th neuron in the i-th layer layer Exponential operation is performed on the position code of the j-th neuron and the initial output of the j-th neuron in the i-th layer to obtain the final output of
  • step 1101 and step 1102 please refer to the relevant description of step 701 and step 702 in the embodiment shown in FIG. 7, which will not be described again here.
  • the client updates the parameters and position coding of the neurons in the model to be processed based on the processing results, and obtains the updated model.
  • the client can update the parameters and position coding of the neurons in the model to be processed based on the processing results of the training data to obtain an updated model.
  • the client can update the parameters and position coding of neurons in the model to be processed based on the processing results in the following ways, thereby obtaining the updated model:
  • the client can first calculate the processing results of the training data output by the training model and the real processing results of the training data through the preset target loss function to obtain the target loss.
  • the target loss is used to indicate the difference between the processing results of the training data output by the model to be trained and the real processing results of the training data.
  • the client uses the target loss to encode the parameters of the neurons in the training model (including the parameters of all neurons in layer 2 to all neurons in layer N) and the position coding of the neurons (including all neurons in layer 2).
  • the position codes of all neurons from the neuron to the N-1 layer are updated to obtain the updated model.
  • the client can often obtain multiple batches of training data in advance, so the client can update the model to be trained for multiple rounds (ie, perform multiple rounds of steps 1102 and 1103).
  • the client can input the first batch of training data into the model to be trained, obtain the processing results of the first batch of training data, and update the model to be trained based on the processing results, obtaining The model obtained in the first round.
  • the client can input the second batch of training data into the model obtained in the first round, obtain the processing results of the second batch of training data, and update the second batch of training data based on the processing results.
  • the model obtained in one round is the model obtained in the second round,...and so on.
  • the model obtained in the last round is the updated model.
  • all rounds of updates will update the parameters of the neurons in the model, but only some rounds of updates will update the position codes of the neurons in the model. It can be seen that the update frequency of the position codes is less than the update frequency of the parameters, so that it can be To a certain extent, the rearrangement invariance of the model is suppressed.
  • the client can use the batch of training data to update the model to be trained (that is, for each batch,
  • the client obtains the parameter update amount and the position coding update amount based on the updated model and the model to be trained.
  • the client sends the parameter update amount and the position code update amount to the server.
  • the parameter update amount and the position code update amount are used by the server to update the model to be trained until the model training conditions are met and the trained model is obtained.
  • the client can send the updated model to the server, so the server can perform federated aggregation based on the updated model uploaded by the client and the updated models uploaded by other clients. Get the trained model.
  • the client can upload the updated model in the following ways, so that the server can implement federated aggregation based on the updated model:
  • the client can obtain the parameter update amount and position coding update amount between the updated model and the model to be trained.
  • the parameter update amount usually refers to the updated model compared to the model to be trained.
  • the parameter update amount of each neuron hereinafter referred to as the parameter update amount of each neuron in the updated model
  • the position coding update amount usually refers to the updated model compared to the model to be trained, each The position encoding update amount of the neuron (hereinafter becomes the position encoding update amount of each neuron in the updated model).
  • the client can compare the parameters of the neurons at the same position in the updated model and the model to be trained, thereby obtaining the parameter update amount of the neuron at the position, and compare the parameters of the neurons at the same position. Compare the position coding of the neuron to obtain the position coding update amount of the neuron at that position. In this way, the parameter update amount and position coding update amount of each neuron of the updated model can be obtained. Still as in the above example, since the model to be trained contains 4 layers, the updated model 1 obtained by client 1 also contains 4 layers. Then, client 1 can add the first neuron of layer 1 in the model to be trained.
  • client 1 can also update the parameters to be trained Compare the parameters of the second neuron in the first layer in the model with the parameters of the second neuron in the first layer in the updated model 1, and obtain the updated parameter of the second neuron in the first layer in the updated model 1. Amount,..., and so on, the client can obtain the updated parameter update amount of each neuron in model 1.
  • client 1 can also compare the position code of the first neuron in the first layer of the model to be trained with the position code of the first neuron in the first layer of the updated model 1 to obtain the updated model.
  • the client can also compare the position encoding of the second neuron in layer 1 in the model to be trained with the updated position encoding of the second neuron in layer 1 in model 1. Compare the position codes of the neurons to obtain the position code update amount of the second neuron in the first layer in the updated model 1,..., and so on, the client can obtain the updated position codes of each neuron in the model 1. Position encoding update amount.
  • the client can send the parameter updates and position coding updates of each neuron in the updated model to the server.
  • the server can obtain each neuron in the updated model uploaded by each client.
  • the parameter update amount and position coding update amount are calculated based on this information, so as to obtain the average parameter update amount of each neuron and the average position coding update amount of each neuron in the updated model, so
  • the server can update the parameters of each neuron in the locally stored model to be trained based on the average of the parameter updates of each neuron, and update the locally stored parameters based on the average of the position encoding updates of each neuron.
  • the position coding of each neuron in the model to be trained is updated accordingly, and the updated model obtained by the server's own training can be obtained.
  • the server after the server receives the parameter update amount of each neuron in the updated model 1 uploaded by the client 1, and the parameter update amount of each neuron in the updated model 2 uploaded by the client 2, it can Calculate the average parameter update amount of the first neuron in the first layer in the updated model 1 and the parameter update amount of the first neuron in the first layer in the updated model 2 to obtain the first parameter update amount in the first layer.
  • the average parameter update amount of the neuron ..., and so on, the server can obtain the average parameter update amount of each neuron.
  • the server After the server receives the updated position coding update amount of each neuron in model 1 uploaded by client 1, and the updated position coding update amount of each neuron in model 2 uploaded by client 2, it can Calculate the average position coding update amount of the first neuron in the first layer in the updated model 1 and the position coding update amount of the first neuron in the first layer in the updated model 2 to obtain the position coding update amount of the first neuron in the first layer.
  • the average value of the position coding updates of one neuron,..., and so on, the server can obtain the average value of the position coding updates of each neuron.
  • the server can update the parameters of each neuron in the locally stored model to be trained based on the average parameter update amount of each neuron, that is, using the parameter update amount of the first neuron in the first layer.
  • average value to update the model to be trained The parameters of the first neuron in the first layer are used to update the parameters of the second neuron in the first layer in the model to be trained using the average value of the parameter updates of the second neuron in the first layer,..., and so on.
  • the server can complete the parameter update of each neuron.
  • the server can also update the position encoding of each neuron in the locally stored model to be trained based on the average of the position encoding updates of each neuron, that is, using the position encoding of the first neuron in the first layer.
  • the average value of the position coding update amount is used to update the position code of the first neuron in the first layer of the model to be trained.
  • the average value of the position coding update amount of the second neuron in the first layer is used to update the position code in the model to be trained.
  • the position coding of the second neuron in the first layer,..., and so on, the server can complete the position coding update of each neuron, thereby obtaining the updated model trained by the server itself.
  • the server can use the updated model obtained by its own training as a new model to be trained, and again send it to each client for the next iteration of model training (that is, repeat steps 1101 to 1104) until a certain time
  • the updated model obtained by the server's own training meets the model training requirements (for example, the target loss converges or the number of iterations is greater than the preset number, etc.)
  • the updated model obtained by the server's own training in this iteration can be
  • the updated model is used as the trained model (that is, the neural network model that has completed training).
  • this embodiment is only schematically illustrated by the server calculating the average parameter update amount of each neuron in the updated model uploaded by each client.
  • the server can also calculate the parameter updates of each neuron in the updated model uploaded by each client.
  • this embodiment is only schematically illustrated by the server calculating the average position coding update amount of each neuron in the updated model uploaded by each client.
  • the server can also calculate the update amount of each neuron in the updated model uploaded by each client.
  • the position encoding of each neuron in the updated model uploaded by the client is updated, and a weighted average calculation is performed, etc.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the processing results of the training data. . Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the server can use the local data of each client to perform neuron alignment on these models (that is, exchange the positions of the neurons, Thus, neurons with the same function are located at the same location in these models).
  • neuron alignment may leak user privacy, involve a series of data security issues, and introduce additional computing overhead.
  • embodiments of the present application can also update the position coding of neurons, so that the model can learn appropriate methods according to the nature of the specific task (that is, in a certain business scenario, the user needs the model to have certain data processing functions). Position coding is conducive to more reasonable alignment of neurons.
  • Figure 12 is a schematic structural diagram of a client provided by an embodiment of the present application. As shown in Figure 12, the client includes:
  • the acquisition module 1201 is used to obtain the model to be trained from the server.
  • the model to be trained contains multiple neurons. Each neuron in the multiple neurons has parameters and position codes. Neurons at different positions in the multiple neurons have Different location encodings.
  • the processing module 1202 is used to: process the training data through the parameters of multiple neurons in the model to be trained and the parameter position coding of the multiple neurons in the model to be trained, and obtain the processing results. Neurons at different positions in the multiple neurons The neurons have different position codes; based on the processing results, the parameters of multiple neurons in the training model are updated to obtain an updated model.
  • the sending module 1203 is used to send the updated model to the server, and the updated model is used for aggregation at the server to obtain a trained model.
  • the client processes the local training data through the parameters and position coding of multiple neurons in the model to be trained, and obtains the processing results of the training data. . Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the position coding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be trained, or the position coding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be trained is determined.
  • the model to be trained includes N layers, and multiple neurons are all from the 2nd layer to the N-1th layer.
  • the initial output of the neuron is subjected to a second calculation to obtain the final output of the j-th neuron in the i-th layer.
  • the final output of the j-th neuron in the i-th layer is used to generate the processing result, that is, the output of all neurons in the N-1th layer.
  • the final output is used to generate processing results.
  • the first layer is the input layer
  • the Nth layer is the output layer
  • the final output of all neurons in the first layer is the training data
  • the jth neuron in the Nth layer The parameters of are used to perform the first calculation on the final output of all neurons in the N-1th layer to obtain the final output of the j-th neuron in the Nth layer.
  • the final output of all neurons in the Nth layer is the processing result.
  • the processing module 1202 is used to: perform four arithmetic operations on the position coding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer, to obtain the j-th neuron in the i-th layer.
  • the final output of the j-th neuron in the i-th layer ; or, perform a trigonometric function operation on the position encoding of the j-th neuron in the i-th layer and the initial output of the j-th neuron in the i-th layer to obtain the final output of the j-th neuron in the i-th layer.
  • the processing module 1202 is configured to: obtain a target loss based on the processing results and the real processing results of the training data.
  • the target loss is used to indicate the difference between the processing results and the real processing results; based on the target loss
  • Update the parameters and position coding to obtain an updated model.
  • the update frequency of the position coding is smaller than the update frequency of the parameters.
  • the sending module 1203 is configured to: obtain the parameter update amount and the position coding update amount based on the updated model and the model to be trained; send the parameter update amount and the position coding update amount to the server, The parameter update amount and position coding update amount are used by the server to update the model to be trained until the model training conditions are met and the trained model is obtained.
  • the processing module 1202 is configured to: obtain a target loss based on the processing results and the real processing results of the training data.
  • the target loss is used to indicate the difference between the processing results and the real processing results; based on the target loss Update the parameters to get the updated model.
  • the sending module 1203 is used to: obtain the parameter update amount based on the updated model and the model to be trained; send the parameter update amount to the server, and the parameter update amount is used by the server to update the model to be trained. model until the model training conditions are met and the trained model is obtained.
  • FIG 13 is a schematic structural diagram of a server provided by an embodiment of the present application. As shown in Figure 13, the server includes:
  • the sending module 1301 is used to send the model to be trained to the client.
  • the model to be trained contains multiple neurons. Each neuron in the multiple neurons has parameters and position coding. Neurons at different positions in the multiple neurons. With different position codes, parameters and position codes are used by the client to process the training data to obtain the processing results, and update the parameters based on the processing results to obtain the updated model;
  • the aggregation module 1303 is used to aggregate the updated models to obtain a trained model.
  • the client passes the model to be trained
  • the parameters and position encoding of multiple neurons in the model process the local training data to obtain the processing results of the training data. Then, the client can update the parameters of the multiple neurons in the model to be trained based on the processing results, thereby obtaining an updated model.
  • this neuron has parameters and position coding, and the position coding of this neuron is different from the position coding of other neurons, so the position coding of this neuron Positional coding constrains the function of that neuron and distinguishes it from the functions of other neurons.
  • the position encoding of multiple neurons is determined by the server based on the positions of multiple neurons in the model to be processed, or the position encoding of multiple neurons is determined by the client and the server based on multiple The position of each neuron in the model to be processed is determined.
  • the acquisition module 1302 is used to obtain the parameter update amount and the position coding update amount from the client, which are obtained based on the updated model and the model to be trained; the aggregation module 1303 , used to update the model to be trained based on the parameter update amount and position coding update amount until the model training conditions are met and the trained model is obtained.
  • the acquisition module 1302 is used to obtain the parameter update amount from the client, and the parameter update amount is obtained based on the updated model and the model to be trained; the aggregation module 1303 is used to obtain the parameter update amount based on the parameter update amount. Train the model until the model training conditions are met and the trained model is obtained.
  • FIG. 14 is a schematic structural diagram of the execution device provided by the embodiment of the present application.
  • the execution device 1400 can be embodied as a mobile phone, a tablet, a laptop, a smart wearable device, a server, etc., and is not limited here.
  • the client shown in Figure 8 can be deployed on the execution device 1400 to jointly implement the model training functions in the corresponding embodiments of Figure 4 or Figure 6 in conjunction with subsequent training devices.
  • the execution device 1400 includes: a receiver 1401, a transmitter 1402, a processor 1403 and a memory 1404 (the number of processors 1403 in the execution device 1400 can be one or more, one processor is taken as an example in Figure 14) , wherein the processor 1403 may include an application processor 14031 and a communication processor 14032.
  • the receiver 1401, the transmitter 1402, the processor 1403, and the memory 1404 may be connected by a bus or other means.
  • Memory 1404 may include read-only memory and random access memory and provides instructions and data to processor 1403 .
  • a portion of memory 1404 may also include non-volatile random access memory (NVRAM).
  • Memory 1404 stores processor and operating instructions, executable modules or data structures, or it Their subsets, or their extended sets, wherein the operation instructions may include various operation instructions for implementing various operations.
  • the processor 1403 controls the execution of operations of the device.
  • various components of the execution device are coupled together through a bus system.
  • the bus system may also include a power bus, a control bus, a status signal bus, etc.
  • various buses are called bus systems in the figure.
  • the methods disclosed in the above embodiments of the present application can be applied to the processor 1403 or implemented by the processor 1403.
  • the processor 1403 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 1403 .
  • the above-mentioned processor 1403 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (ASIC), a field programmable Gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA field-programmable gate array
  • the processor 1403 can implement or execute each method, step and logical block diagram disclosed in the embodiment of this application.
  • a general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
  • the steps of the method disclosed in conjunction with the embodiments of the present application can be directly implemented by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field.
  • the storage medium is located in the memory 1404.
  • the processor 1403 reads the information in the memory 1404 and completes the steps of the above method in combination with its hardware.
  • the receiver 1401 may be configured to receive input numeric or character information and generate signal inputs related to performing relevant settings and functional controls of the device.
  • the transmitter 1402 can be used to output numeric or character information through the first interface; the transmitter 1402 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1402 can also include a display device such as a display screen .
  • the processor 1403 can be used to implement the model training method in the corresponding embodiment of Figure 7 or Figure 11, and can also be used to obtain the model training method obtained by the corresponding embodiment of Figure 7 or Figure 11. model to implement corresponding data processing functions.
  • FIG. 15 is a schematic structural diagram of the training device provided by the embodiment of the present application.
  • the training device 1500 is implemented by one or more servers.
  • the training device 1500 can vary greatly due to different configurations or performance, and can include one or more central processing units (CPU) 1514 (eg, one or more processors) and memory 1532, one or more storage media 1530 (eg, one or more mass storage devices) storing applications 1542 or data 1544.
  • the memory 1532 and the storage medium 1530 may be short-term storage or persistent storage.
  • the program stored in the storage medium 1530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device.
  • the central processor 1514 may be configured to communicate with the storage medium 1530 and execute a series of instruction operations in the storage medium 1530 on the training device 1500 .
  • the training device 1500 may also include one or more power supplies 1526, one or more wired or wireless network interfaces 1550, one or more input and output interfaces 1558; or, one or more operating systems 1541, such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • operating systems 1541 such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • the training device can be combined with the aforementioned execution device to jointly execute the model training method in the corresponding embodiment of Figure 4 or Figure 6 .
  • Embodiments of the present application also relate to a computer storage medium.
  • the computer-readable storage medium stores a program for performing signal processing.
  • the program When the program is run on a computer, it causes the computer to perform the steps performed by the aforementioned execution device, or, The computer is caused to perform the steps performed by the aforementioned training device.
  • Embodiments of the present application also relate to a computer program product that stores instructions that, when executed by a computer, cause the computer to perform the steps performed by the foregoing execution device, or cause the computer to perform the steps performed by the foregoing training device. A step of.
  • the execution device, training device or terminal device provided by the embodiment of the present application may specifically be a chip.
  • the chip includes: a processing unit and a communication unit.
  • the processing unit may be, for example, a processor.
  • the communication unit may be, for example, an input/output interface. Pins or circuits, etc.
  • the processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment.
  • the storage unit is a storage unit within the chip, such as a register, cache, etc.
  • the storage unit may also be a storage unit located outside the chip in the wireless access device, such as Read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), etc.
  • ROM Read-only memory
  • RAM random access memory
  • Figure 16 is a schematic structural diagram of a chip provided by an embodiment of the present application.
  • the chip can be represented as a neural network processor NPU 1600.
  • the NPU 1600 serves as a co-processor and is mounted to the host CPU (Host CPU). ), tasks are allocated by the Host CPU.
  • the core part of the NPU is the arithmetic circuit 1603.
  • the arithmetic circuit 1603 is controlled by the controller 1604 to extract the matrix data in the memory and perform multiplication operations.
  • the computing circuit 1603 includes multiple processing units (Process Engine, PE).
  • arithmetic circuit 1603 is a two-dimensional systolic array.
  • the arithmetic circuit 1603 may also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition.
  • arithmetic circuit 1603 is a general-purpose matrix processor.
  • the arithmetic circuit obtains the corresponding data of matrix B from the weight memory 1602 and caches it on each PE in the arithmetic circuit.
  • the operation circuit takes matrix A data and matrix B from the input memory 1601 to perform matrix operations, and the partial result or final result of the matrix is stored in an accumulator (accumulator) 1608 .
  • the unified memory 1606 is used to store input data and output data.
  • the weight data directly passes through the storage unit access controller (Direct Memory Access Controller, DMAC) 1605, and the DMAC is transferred to the weight memory 1602.
  • Input data is also transferred to unified memory 1606 via DMAC.
  • DMAC Direct Memory Access Controller
  • BIU is the Bus Interface Unit, that is, the bus interface unit 1613, which is used for the interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1609.
  • IFB Instruction Fetch Buffer
  • the bus interface unit 1613 (Bus Interface Unit, BIU for short) is used to fetch the memory 1609 to obtain instructions from the external memory, and is also used for the storage unit access controller 1605 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
  • BIU Bus Interface Unit
  • DMAC is mainly used to transfer the input data in the external memory DDR to the unified memory 1606 or the weight data to the weight memory 1602 or the input data to the input memory 1601 .
  • the vector calculation unit 1607 includes multiple arithmetic processing units, and if necessary, further processes the output of the arithmetic circuit 1603, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
  • arithmetic circuit 1603 such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
  • Mainly used in neural networks Non-convolutional/fully connected layer network calculations in the network, such as Batch Normalization (batch normalization), pixel-level summation, upsampling of the predicted label plane, etc.
  • vector calculation unit 1607 can store the processed output vectors to unified memory 1606 .
  • the vector calculation unit 1607 can apply a linear function; or a nonlinear function to the output of the operation circuit 1603, such as linear interpolation on the prediction label plane extracted by the convolution layer, or a vector of accumulated values, to generate an activation value.
  • vector calculation unit 1607 generates normalized values, pixel-wise summed values, or both.
  • the processed output vector can be used as an activation input to the arithmetic circuit 1603, such as for use in a subsequent layer in a neural network.
  • the instruction fetch buffer 1609 connected to the controller 1604 is used to store instructions used by the controller 1604;
  • the unified memory 1606, the input memory 1601, the weight memory 1602 and the fetch memory 1609 are all On-Chip memories. External memory is private to the NPU hardware architecture.
  • the processor mentioned in any of the above places can be a general central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above programs.
  • the device embodiments described above are only illustrative.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physically separate.
  • the physical unit can be located in one place, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • the connection relationship between modules indicates that there are communication connections between them, which can be specifically implemented as one or more communication buses or signal lines.
  • the present application can be implemented by software plus necessary general hardware. Of course, it can also be implemented by dedicated hardware including dedicated integrated circuits, dedicated CPUs, dedicated memories, Special components, etc. to achieve. In general, all functions performed by computer programs can be easily implemented with corresponding hardware. Moreover, the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special-purpose circuits. circuit etc. However, for this application, software program implementation is a better implementation in most cases. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence or that contributes to the existing technology.
  • the computer software product is stored in a readable storage medium, such as a computer floppy disk. , U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including several instructions to cause a computer device (which can be a personal computer, training device, or network device, etc.) to execute the steps described in various embodiments of this application. method.
  • a computer device which can be a personal computer, training device, or network device, etc.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, the computer instructions may be transferred from a website, computer, training device, or data
  • the center transmits to another website site, computer, training equipment or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means.
  • wired such as coaxial cable, optical fiber, digital subscriber line (DSL)
  • wireless such as infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be a computer capable of storing Any available media or data storage devices such as training equipment, data centers, etc. that contain one or more available media integrations.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (Solid State Disk, SSD)), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Medical Informatics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Electrically Operated Instructional Devices (AREA)

Abstract

一种模型训练方法及其相关设备,应用于人工智能技术领域,可使得客户端和服务端联合训练所得到的训练后的模型具备足够优秀的功能。上述模型训练方法包括:当服务端需要获取具备数据处理功能的神经网络模型时,可向客户端下发待训练模型,在待训练模型中的多个神经元中,每个神经元具有参数和位置编码。客户端接收到待训练模型后,可将自身存储的本地数据作为训练数据,并输入至待训练模型中,以通过待训练模型中多个神经元的参数和位置编码对训练数据进行处理,从而实现对待训练模型的更新,得到更新后的模型。此后,客户端可将更新后的模型发送至服务端,故服务端可基于客户端上传的更新后的模型进行聚合,从而得到训练后的模型。

Description

一种模型训练方法及其相关设备
本申请要求于2022年3月26日提交中国专利局、申请号为202210304574.2、发明名称为“一种模型训练方法及其相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及人工智能(artificial intelligence,AI)技术领域,尤其涉及一种模型训练方法及其相关设备。
背景技术
随着用户不断增强的数据安全意识,以及用户的个人隐私数据被频繁泄漏等数据安全问题的出现,使得用户不断提高对涉及个人隐私的数据的保护力度,进而给AI技术的模型训练提出了新的挑战。因此,联邦学习(federated learning)这一模型训练方式应运而生。
联邦学习系统通常包含服务端和多个客户端,在进行模型训练时,服务端先下发待训练模型给各个客户端。各个客户端设备接收到待训练模型后,使用存储在本地的训练数据对待训练模型进行训练,得到更新后的模型。然后,各个客户端可将更新后的模型上传至服务端。最后,服务端将各个客户端上传的更新后的模型进行聚合,以得到训练后的模型。
由于不同客户端对同一个待训练模型所使用的训练数据不同,受到神经网络模型的重排不变性的影响(模型中具备不同功能的某些神经元的位置交换后,模型的输出不会发生改变),相对于待训练模型中的神经元分布而言,在某些客户端所得到的更新后的模型中,具备不同功能的某些神经元发生了位置变化。可见,各个客户端所得到的更新后的模型中,相同功能的神经元并不都处于相同的位置上,而服务端在实现聚合时,是按位置去处理各个更新后的模型中的神经元,将导致所得到的训练后的模型无法具备足够优秀的功能。
发明内容
本申请实施例提供了一种模型训练方法及其相关设备,可使得客户端和服务端联合训练所得到的训练后的模型具备足够优秀的功能。
本申请实施例的第一方面提供了一种模型训练方法,该方法包括:
当需要进行模型训练时,可先获取待训练模型。其中,待训练模型包含多个神经元,在这多个神经元中,每个神经元关联有参数(即前述的参数信息)和位置编码(position encoding,PE)(即前述的位置编码信息),也就是说,每个神经元具有参数和位置编码。在这多个神经元中,不同的神经元具有不同的位置编码,对于任意一个神经元而言,该神经元的位置编码可用于指示该神经元在待训练模型中的位置。例如,在待训练模型的两个中间层中,第2层包含3个神经元,第3层包含4个神经元,这7个神经元的位置编码可依次为1、2、3、4、5、6和7。
得到待训练模型后,可通过待训练模型中多个神经元的参数,待训练模型中多个神经元的位置编码对训练数据进行处理,以对待训练模型进行更新,从而得到更新后的模型,并对 外发送更新后的模型,以实现模型的聚合,从而得到训练后的模型。
在一种可能实现的方式中,上述模型训练方法的步骤可由客户端实现,该客户端可以为联邦学习系统的多个客户端中的任意一个客户端,那么,该客户端可联合联邦学习系统中的服务端完成模型训练,模型训练的过程具体如下:
当服务端需要获取具备数据处理功能的神经网络模型时,可先获取待训练模型,并下发至多个客户端。对于这多个客户端中的任意一个客户端,在接收到服务端发送的待训练模型后,该客户端可利用自身存储的本地数据作为训练数据,以对待训练模型进行训练。
具体地,该客户端接收到待训练模型后,该客户端可将自身存储的本地数据作为训练数据,并输入至待训练模型中,以通过待训练模型的多个神经元对训练数据进行处理,得到训练数据的处理结果。值得注意的是,对于待训练模型中的多个神经元而言,这多个神经元中的每个神经元具有参数和位置编码,那么,这多个神经元作为待训练模型中的多个数据处理单元,可使用自身的参数和位置编码对训练数据进行处理,从而得到训练数据的处理结果。
得到训练数据的处理结果后,该客户端可基于训练数据的处理结果对待训练模型中神经元的参数进行更新,得到更新后的模型。
得到更新后的模型后,该客户端可将更新后的模型发送至服务端,故服务端可基于该客户端上传的更新后的模型以及其余客户端上传的更新后的模型进行联邦聚合,从而得到训练后的模型。
从上述模型训练的过程可以看出:某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能的实现方式中,多个神经元的位置编码由服务端基于多个神经元在待训练模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待训练模型中的位置确定。前述实现方式中,神经元的位置编码可通过多种方式进行设置:(1)在待训练模型中,对于第2层所有神经元至第N-1层所有神经元而言,这多个神经元的位置编码可由服务端基于这多个神经元在待训练模型中的位置确定,即在这多个神经元中,任意一个 神经元的位置编码是由服务端基于该神经元在待训练模型中的位置来定义的。(2)在待训练模型中,对于第2层所有神经元至第N-1层所有神经元而言,这多个神经元的位置编码可由多个客户端和服务端共同基于多个神经元在待训练模型中的位置确定,即在这多个神经元中,任意一个神经元的位置编码是由服务端和多个客户端基于该神经元在待训练模型中的位置来事先约定的。
在一种可能的实现方式中,待训练模型包含N层,第1层为输入层,第2层至第N-1层为中间层,第N层为输出层,每一层均包含至少一个神经元。第1层所有神经元均用于接收输入的数据,故第1层所有神经元可不具有参数以及位置编码,第2层所有神经元至第N-1层所有神经元均用于数据处理,故第2层所有神经元至第N-1层所有神经元均具有参数(例如,权重、偏置等等)以及位置编码,第N层所有神经元均用于输出数据的处理结果,故第N层所有神经元仅具有参数(例如,权重等等),客户端通过待训练模型的多个神经元对训练数据进行处理,得到处理结果包括:客户端将第i层第j个神经元的参数和第i-1层所有神经元的最终输出进行第一计算,得到第i层第j个神经元的初始输出,i=2,...,N-1,j=1,...,M,N≥3,M≥1;客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出;其中,第1层所有神经元的最终输出为训练数据,第N层第j个神经元的参数用于对第N-1层所有神经元的最终输出进行第一计算,得到第N层第j个神经元的最终输出,第N层所有神经元的最终输出为处理结果。前述实现方式中,该客户端将训练数据输入待训练模型后,待训练模型中第1层所有神经元可向第2层各个神经元发送第1层所有神经元的最终输出,第1层所有神经元的最终输出即训练数据。接着,第2层第1个神经元可基于自身的参数和第1层所有神经元的最终输出进行第一计算后,可得到第2层第1个神经元的初始输出,第2层第1个神经元再利用自身的位置编码和自身的初始输出进行第二计算,可得到第2层第1个神经元的最终输出。第2层其余神经元也可执行如同第2层第1个神经元所执行的操作,从而得到第2层所有神经元的最终输出,故第2层所有神经元可向第3层各个神经元发送第2层所有神经元的最终输出,…,以此类推,直至第N-2层所有神经元向第N-1层各个神经元发送第N-2层所有神经元的最终输出,第N-1层第1个神经元可基于自身的参数和第N-2层所有神经元的最终输出进行第一计算后,可得到第N-1层第1个神经元的初始输出,第N-1层第1个神经元再利用自身的位置编码和自身的初始输出进行第二计算,可得到第N-1层第1个神经元的最终输出。第N-1层其余神经元也可执行如同第N-1层第1个神经元所执行的操作,从而得到第N-1层所有神经元的最终输出。由于待训练模型中第N层的神经元不具备位置编码,故得到第N-1层所有神经元的最终输出后,第N层第1个神经元可将第N层第1个神经元的参数和第N-1层所有神经元的最终输出进行第一计算,得到第N层第1个神经元的最终输出。然后,第N层第2个神经元可将第N层第2个神经元的参数和第N-1层所有神经元的最终输出进行第一计算,得到第N层第2个神经元的最终输出,…,以此类推,可得到第N层所有神经元的最终输出,第N层所有神经元的最终输出即为待训练模型的输出,相当于训练数据的处理结果。由此可见,训练数据的处理结果基于待训练模型中各个神经元的输出得到,对于任意一个神经元而言,该神经元的输出可由该神经元使用自身的参数以及位置编码执行数据处理操作得到,故该神经元在实现数据处理时(也就是实现该神经元的功能)受到了自身的位置编码的 约束,且该神经元的位置编码所产生的影响可体现在训练数据的处理结果中。那么,当客户端基于训练数据的处理结果来更新该神经元的参数时,可尽量地维持该神经元的功能不变,从而限制神经网络的重排不变性。
在一种可能的实现方式中,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出包括:客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行四则运算,得到第i层第j个神经元的最终输出;或,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行三角函数运算,得到第i层第j个神经元的最终输出;或,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行指数运算,得到第i层第j个神经元的最终输出;或,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行对数运算,得到第i层第j个神经元的最终输出。前述实现方式中,神经元所执行的第二计算可以是四则运算、三角函数运算、指数运算和对数运算中的任意一种,可通过多种方式来实现位置编码对神经元的功能的约束。
在一种可能的实现方式中,客户端基于处理结果对参数进行更新,得到更新后的模型包括:客户端基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;客户端基于目标损失对参数和位置编码进行更新,得到更新后的模型。值得注意的是,客户端在更新待训练模型时,对位置编码的更新频率小于对参数的更新频率,例如,设存在5批训练数据,客户端可向待训练模型先后输入这5批训练数据,经过待训练模型中神经元的参数和位置编码的处理后,可相应得到这5批训练数据的处理结果。那么,客户端会利用5批训练数据的处理结果,对待训练模型中神经元的参数先后更新5次,但只对利用其中1批训练数据的处理结果,对待训练模型中神经元的位置编码更新1次。如此一来,可以在一定程度上抑制模型的重排不变性。
进一步地,客户端将更新后的模型发送至服务端包括:客户端基于更新后的模型以及待训练模型,获取参数更新量以及位置编码更新量;客户端将参数更新量和位置编码更新量发送至服务端,参数更新量和位置编码更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。前述实现方式中,待训练模型中神经元的位置编码为非固定值,故客户端和服务端可联合对待训练模型中的参数和位置编码进行更新,使得模型可根据具体任务的性质(即在某种业务场景中,用户需要模型具备某种数据处理功能)来学习合适的位置编码,有利于对神经元进行更加合理的对齐处理。
在一种可能的实现方式中,客户端基于处理结果对参数进行更新,得到更新后的模型包括:客户端基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;客户端基于目标损失对参数进行更新,得到更新后的模型。
进一步地,客户端将更新后的模型发送至服务端包括:客户端基于更新后的模型以及待训练模型,获取参数更新量;客户端将参数更新量发送至服务端,参数更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。前述实现方式中,待训练模型中神经元的位置编码为固定值,故客户端和服务端可联合对待训练模型中的参数进行更新,使得训练后的模型可具备某种数据处理功能。
本申请实施例的第二方面提供了一种模型训练方法,该方法包括:发送待训练模型,待训练模型包含多个神经元,其中,神经元关联参数信息和位置编码信息,神经元与位置编码信息一一对应;获取更新后的模型,并对更新后的模型进行聚合,得到训练后的模型,更新后的模型基于参数信息,位置编码信息和训练数据对待训练模型进行更新得到。
在一种可能的实现方式中,上述模型训练方法的步骤可由服务端实现,该服务端部署于为联邦学习系统中,该服务端可联合联邦学习系统中的多个客户端完成模型训练,模型训练的过程具体如下:
服务端将待训练模型发送至客户端,待训练模型包含多个神经元,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码,待训练模型的多个神经元用于客户端对训练数据进行处理得到处理结果,并基于处理结果对参数进行更新,得到更新后的模型;服务端获取来自客户端的更新后的模型,并对更新后的模型进行聚合,得到训练后的模型。
从上述方法可以看出:某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能的实现方式中,多个神经元的位置编码由服务端基于多个神经元在待处理模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待处理模型中的位置确定。
在一种可能的实现方式中,服务端接收来自客户端的更新后的模型,并对更新后的模型进行聚合,得到训练后的模型包括:服务端获取来自客户端的参数更新量和位置编码更新量,参数更新量和位置编码更新量基于更新后的模型以及待训练模型获取;服务端基于参数更新量和位置编码更新量,更新待训练模型,直至满足模型训练条件,得到训练后的模型。
在一种可能的实现方式中,服务端接收来自客户端的更新后的模型,并对更新后的模型进行聚合,得到训练后的模型包括:服务端获取来自客户端的参数更新量,参数更新量基于更新后的模型以及待训练模型获取;服务端基于参数更新量,更新待训练模型,直至满足模 型训练条件,得到训练后的模型。
本申请实施例的第三方面提供了一种模型训练装置,该装置包括:获取模块,用于获取待训练模型,待训练模型包含多个神经元,其中,神经元关联参数和位置编码,神经元与位置编码一一对应;处理模块,用于通过参数,位置编码和训练数据,对待训练模型进行更新,得到更新后的模型;发送模块,用于发送更新后的模型。
在一种可能实现的方式中,该装置可以为联邦学习系统中的任意一个客户端,该客户端的获取模块,用于获取来自服务端的待训练模型,待训练模型包含多个神经元,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码。该客户端的处理模块,用于:通过待训练模型中多个神经元的参数和待训练模型中多个神经元的参数位置编码对训练数据进行处理,得到处理结果,多个神经元中不同位置的神经元具有不同的位置编码;基于处理结果对训练模型中多个神经元的参数进行更新,得到更新后的模型。该客户端的发送模块,用于将更新后的模型发送至服务端,更新后的模型用于在服务端处进行聚合,得到训练后的模型。从该客户端可以看出:某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能实现的方式中,多个神经元的位置编码由服务端基于多个神经元在待训练模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待训练模型中的位置确定。
在一种可能实现的方式中,待训练模型包含N层,多个神经元为第2层至第N-1层所有神经元,处理模块,用于:将第i层第j个神经元的参数和第i-1层所有神经元的最终输出进行第一计算,得到第i层第j个神经元的初始输出,i=2,...,N-1,j=1,...,M,N≥3,M≥1;将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出,第i层第j个神经元的最终输出用于生成处理结果,即第N-1层所有神经元的最终输出用于生成处理结果。
在一种可能实现的方式中,在待训练模型中,第1层为输入层,第N层为输出层,第1 层所有神经元的最终输出为训练数据,第N层第j个神经元的参数用于对第N-1层所有神经元的最终输出进行第一计算,得到第N层第j个神经元的最终输出,第N层所有神经元的最终输出为处理结果。
在一种可能实现的方式中,处理模块,用于:将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行四则运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行三角函数运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行指数运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行对数运算,得到第i层第j个神经元的最终输出。
在一种可能实现的方式中,处理模块,用于:基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;基于目标损失对参数和位置编码进行更新,得到更新后的模型,位置编码的更新频率小于参数的更新频率。
在一种可能实现的方式中,发送模块,用于:基于更新后的模型以及待训练模型,获取参数更新量以及位置编码更新量;将参数更新量和位置编码更新量发送至服务端,参数更新量和位置编码更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
在一种可能实现的方式中,处理模块,用于:基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;基于目标损失对参数进行更新,得到更新后的模型。
在一种可能实现的方式中,发送模块,用于:基于更新后的模型以及待训练模型,获取参数更新量;将参数更新量发送至服务端,参数更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
本申请实施例的第四方面提供了一种模型训练装置,该装置包括:发送模块,用于发送待训练模型,待训练模型包含多个神经元,其中,神经元关联参数和位置编码,神经元与位置编码一一对应;获取模块,用于获取更新后的模型,更新后的模型基于参数,位置编码和训练数据对待训练模型进行更新得到;聚合模块,用于对更新后的模型进行聚合,得到训练后的模型。
在一种可能的实现方式中,该装置可以为联邦学习系统中的服务端,该服务端的发送模块,用于将待训练模型发送至客户端,待训练模型包含多个神经元,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码,参数和位置编码用于客户端对训练数据进行处理得到处理结果,并基于处理结果对参数进行更新,得到更新后的模型;获取模块,用于获取来自客户端的更新后的模型;聚合模块,用于对更新后的模型进行聚合,得到训练后的模型。从该服务端可以看出:某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经 元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能的实现方式中,多个神经元的位置编码由服务端基于多个神经元在待处理模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待处理模型中的位置确定。
在一种可能的实现方式中,获取模块,用于获取来自客户端的参数更新量和位置编码更新量,参数更新量和位置编码更新量基于更新后的模型以及待训练模型获取;聚合模块,用于基于参数更新量和位置编码更新量,更新待训练模型,直至满足模型训练条件,得到训练后的模型。
在一种可能的实现方式中,获取模块,用于获取来自客户端的参数更新量,参数更新量基于更新后的模型以及待训练模型获取;聚合模块,用于基于参数更新量,更新待训练模型,直至满足模型训练条件,得到训练后的模型。
本申请实施例的第五方面提供了一种客户端,客户端包括存储器和处理器;存储器存储有代码,处理器被配置为执行代码,当代码被执行时,所述客户端执行如第一方面或第一方面任意一种可能的实现方式所述的方法。
本申请实施例的第六方面提供了一种服务端,服务端包括存储器和处理器;存储器存储有代码,处理器被配置为执行代码,当代码被执行时,所述服务端执行如第二方面或第二方面任意一种可能的实现方式所述的方法。
本申请实施例的第七方面提供了一种联邦学习系统,该系统包含如第五方面所述的客户端以及如第六方面所述的服务端,客户端和服务端通信连接。
本申请实施例的第八方面提供了一种电路系统,该电路系统包括处理电路,该处理电路配置为执行如第一方面、第一方面中的任意一种可能的实现方式或第二方面所述的方法。
本申请实施例的第九方面提供了一种芯片系统,该芯片系统包括处理器,用于调用存储器中存储的计算机程序或计算机指令,以使得该处理器执行如第一方面、第一方面中的任意一种可能的实现方式或第二方面所述的方法。
在一种可能的实现方式中,该处理器通过接口与存储器耦合。
在一种可能的实现方式中,该芯片系统还包括存储器,该存储器中存储有计算机程序或计算机指令。
本申请实施例的第十方面提供了一种计算机存储介质,该计算机存储介质存储有计算机程序,该程序在由计算机执行时,使得计算机实施如第一方面、第一方面中的任意一种可能的实现方式或第二方面所述的方法。
本申请实施例的第十一方面提供了一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时,使得计算机实施如第一方面、第一方面中的任意一种可能的实现方式或第二方面所述的方法。
本申请实施例中,某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
附图说明
图1为人工智能主体框架的一种结构示意图;
图2为本申请实施例提供的联邦学习系统的一个结构示意图;
图3为本申请实施例提供的系统100架构的一个示意图;
图4为本申请实施例提供的联邦学习系统的一个应用例示意图;
图5为本申请实施例提供的联邦学习系统的另一个应用例示意图;
图6为本申请实施例提供的联邦学习系统的另一个应用例示意图
图7为本申请实施例提供的模型训练方法的一个流程示意图;
图8为本申请实施例提供的联邦学习系统的一个结构示意图;
图9为本申请实施例提供的待训练模型的一个结构示意图;
图10为本申请实施例提供的联邦学习系统的另一结构示意图;
图11为本申请实施例提供的模型训练方法的另一流程示意图;
图12为本申请实施例提供的客户端的一个结构示意图;
图13为本申请实施例提供的服务端的一个结构示意图;
图14为本申请实施例提供的执行设备的一个结构示意图;
图15为本申请实施例提供的训练设备的一个结构示意图;
图16为本申请实施例提供的芯片的一个结构示意图。
具体实施方式
本申请实施例提供了一种模型训练方法及其相关设备,可使得客户端和服务端联合训练所得到的训练后的模型具备足够优秀的功能。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
随着用户不断增强的数据安全意识,以及用户的个人隐私数据被频繁泄漏等数据安全问题的出现,使得用户不断提高对涉及个人隐私的数据的保护力度,进而给AI技术的模型训练提出了新的挑战。因此,联邦学习(federated learning)这一模型训练方式应运而生。
联邦学习系统通常包含服务端和多个客户端,在进行模型训练时,服务端先下发待训练模型给各个客户端。各个客户端设备接收到待训练模型后,使用存储在本地的训练数据对待训练模型进行训练,得到更新后的模型。然后,各个客户端可将更新后的模型上传至服务端。最后,服务端将各个客户端上传的更新后的模型进行聚合,以得到训练后的模型。
由于不同客户端对同一个待训练模型所使用的训练数据不同,受到神经网络模型的重排不变性的影响(模型中具备不同功能的某些神经元的位置交换后,模型的输出不会发生改变),相对于待训练模型中的神经元分布而言,在某些客户端所得到的更新后的模型中,具备不同功能的某些神经元发生了位置变化。可见,各个客户端所得到的更新后的模型中,相同功能的神经元并不都处于相同的位置上,而服务端在实现聚合时,是按位置去处理各个更新后的模型中的神经元,将导致所得到的训练后的模型无法具备足够优秀的数据处理功能。
例如,设联邦学习系统包含服务端、客户端1和客户端2。在服务端下发的待训练模型的第2层中,第1个神经元用于实现功能1,第2个神经元用于实现功能2。客户端1将本地数据1输入待训练模型后,可得到处理结果1,接着基于处理结果1更新待训练模型中神经元的参数,得到更新后的模型1,在更新后的模型1中,第2层第1个神经元的功能变换为功能2,第2层第2个神经元的功能变换为功能1。同理,客户端2将本地数据2输入待训练模型后,可得到处理结果2,接着基于处理结果2更新待训练模型中神经元的参数,得到更新后的模型2,在更新后的模型2中,第2层第1个神经元的功能依旧为功能1,第2层第2个神经元的功能依旧为功能2。可见,相较于待训练模型的神经元分布,更新后的模型1中分别用于实现功能1和功能2的两个神经元发生了位置交换,而更新后的模型2中分别用于实现功能1和功能2的两个神经元的位置则保持不变。
客户端1得到更新后的模型1后,可基于更新后的模型1和待训练模型,获取参数更新量1(包含更新后的模型1中各个神经元的参数更新量,例如,第2层第1个神经元的参数更新量、第2层第2个神经元的参数更新量等等),并发送至服务端。同样地,客户端2也可得到参数更新量2(包含更新后的模型2中各个神经元的参数更新量,例如,第2层第1个神经元的参数更 新量、第2层第2个神经元的参数更新量等等),并发送至服务端。客户端得到参数更新量1和参数更新量2后,可进行求平均计算,得到参数更新量的平均值(包含各个神经元的参数更新量的平均值,例如,第2层第1个神经元的参数更新量的平均值、第2层第2个神经元的参数更新量的平均值等等)。由于服务端本地存储有待训练模型,故可基于参数更新量的平均值,对待训练模型中各个神经元的参数进行相应的更新。
此后,服务端还可继续和客户端1、客户端2重复执行前述过程,直至模型满足预置的模型训练条件,得到训练后的模型。然而,此种方式所得到的训练后的模型无法具备足够优秀的数据处理功能,例如,服务端在计算第2层第1个神经元的参数更新量的平均值时,是基于更新后的模型1中第2层第1个神经元的参数更新量和更新后的模型2中第2层第1个神经元的参数更新量计算得到的,但更新后的模型1中第2层第1个神经元用于实现功能2,更新后的模型2中第2层第1个神经元用于实现功能1,故基于第2层第1个神经元的参数更新量的平均值去更新待训练模型中第2层第1个神经元参数,将导致这一个神经元在参数更新后,发生功能紊乱。可见,训练后的模型中,会有多个位置上的神经元出现功能紊乱这一情况,导致训练后的模型无法具备优秀的数据处理功能。
为了解决上述问题,本申请实施例提供了一种基于联邦学习的模型训练方法,
该方法可结合人工智能(artificial intelligence,AI)技术实现。AI技术是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能的技术学科,AI技术通过感知环境、获取知识并使用知识获得最佳结果。换句话说,人工智能技术是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。利用人工智能进行数据处理是人工智能常见的一个应用方式。
首先对人工智能系统总体工作流程进行描述,请参见图1,图1为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。
(1)基础设施
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能芯片进行计算。
(2)数据
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。
(3)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(4)通用能力
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。
(5)智能产品及行业应用
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。
接下来介绍几种本申请的应用场景。
图2为本申请实施例提供的联邦学习系统的一个结构示意图,该联邦学习系统包括服务端以及多个客户端,二者可通过通信网络实现连接。其中,客户端包括手机、个人电脑或者信息处理中心等智能终端,服务端可以是云服务器、网络服务器、应用服务器以及管理服务器等具有数据处理功能的设备或服务器,客户端和服务端可协同实现神经网络模型的训练。
多个客户端和服务端之间可实现多次迭代的模型训练。具体地,在首次迭代中,各个客户端可通过交互接口接收来自服务端的待训练模型,再通过存储本地数据的存储器以及处理数据的处理器对待训练模型进行机器学习,深度学习,搜索,推理,决策等方式的模型训练。各个客户端完成模型训练后(即对待训练模型的参数进行了更新),可将更新后的模型上传到服务端,以使得服务端将各个客户端上传的更新后的模型进行聚合,从而基于聚合结果训练服务端本地的待训练模型。然后,服务端可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个客户端中,以执行第二次迭代的模型训练(即重复执行前述过程)。如此一来,经过多次迭代后,服务端确定自身最后一次训练得到的更新后的模型满足模型训练条件后,可将自身最后一次训练得到的更新后的模型作为训练后的模型(即完成训练的模型)。如此一来,服务端既间接地利用了各个客户端的本地数据完成了模型训练,还能确保各个客户端的数据安全,从而保护用户个人隐私。
需要说明的是,为了进一步保证数据安全,在每次迭代中,各个客户端可向服务端上传模型的参数更新量,以代表各个客户端所得到的更新后的模型。那么,服务端可将来自各个客户端的参数更新量进行求平均,再基于参数更新量的平均值,来更新服务端本地的待训练模型的参数,以实现服务端自身的模型训练。
在图2中,服务端和客户端可以共同执行本申请实施例的模型训练方法。
此外,本申请实施例提供的联邦学习系统中,服务端得到训练后的模型,具备数据处理功能,故可将该模型部署在各个客户端上。因此,各个客户端可以为用户提供数据处理服务,当某个客户端获取来自用户输入的待处理数据后,可调用训练好的模型,对用户输入的待处 理数据进行相应的处理,并向用户返回相应的处理结果。
在图2中,客户端可以利用本申请实施例的模型训练方法所得到的训练后的模型,实现数据处理功能。
图3为本申请实施例提供的系统100架构的一个示意图,在图3中,执行设备110配置输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:各个待调度任务、可调用资源以及其他参数。
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模型111执行计算等相关的处理(比如进行本申请中神经网络的功能实现)过程中,执行设备110可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统150中。
最后,I/O接口112将处理结果返回给客户设备140,从而提供给用户。
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练数据生成相应的目标模型/规则,该相应的目标模型/规则即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。其中,训练数据可以存储在数据库130中,且来自于数据采集设备160采集的训练样本。
在图3中所示情况下,用户可以手动给定输入数据,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送输入数据,如果要求客户设备140自动发送输入数据需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看执行设备110输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,采集如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果作为新的样本数据,并存入数据库130。当然,也可以不经过客户设备140进行采集,而是由I/O接口112直接将如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果,作为新的样本数据存入数据库130。
值得注意的是,图3仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图3中,数据存储系统150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储系统150置于执行设备110中。如图3所示,可以根据训练设备120训练得到神经网络。
需要说明的是,本申请实施例中,训练设备120通常指前述的服务端,执行设备110通常指前述的客户端,训练设备120在训练模型时,可联合执行设备110一起实现模型训练,即二者可以联邦学习的方式来实现模型训练。
本申请实施例还提供的一种芯片,该芯片包括神经网络处理器NPU。该芯片可以被设置在如图3所示的执行设备110中,用以完成计算模型111的计算工作。该芯片也可以被设置在如图3所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则。
神经网络处理器NPU,NPU作为协处理器挂载到主中央处理器(central processing unit,CPU)(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路,控制器控制运算电路提取存储器(权重存储器或输入存储器)中的数据并进行运算。
在一些实现中,运算电路内部包括多个处理单元(process engine,PE)。在一些实现中, 运算电路是二维脉动阵列。运算电路还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)中。
向量计算单元可以对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。
在一些实现种,向量计算单元能将经处理的输出的向量存储到统一缓存器。例如,向量计算单元可以将非线性函数应用到运算电路的输出,例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元生成归一化的值、合并值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路的激活输入,例如用于在神经网络中的后续层中的使用。
统一存储器用于存放输入数据以及输出数据。
权重数据直接通过存储单元访问控制器(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器和/或统一存储器、将外部存储器中的权重数据存入权重存储器,以及将统一存储器中的数据存入外部存储器。
总线接口单元(bus interface unit,BIU),用于通过总线实现主CPU、DMAC和取指存储器之间进行交互。
与控制器连接的取指存储器(instruction fetch buffer),用于存储控制器使用的指令;
控制器,用于调用指存储器中缓存的指令,实现控制该运算加速器的工作过程。
一般地,统一存储器,输入存储器,权重存储器以及取指存储器均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。
此外,本申请实施例提供的联邦学习系统还可应用于多种领域中,下文将分别进行介绍。图4为本申请实施例提供的联邦学习系统的一个应用例示意图,如图4所示,联邦学习系统可应用于智能家居领域中,此时,系统中的多个客户端为位于多个家庭中的智能家居设备,这多个家庭位于不同的地理位置上。这多个智能家居设备可与云端的服务器(即服务端)实现通信,以实现联邦学习。
云端的服务器为了在各个智能家居设备上部署具备语音识别功能的神经网络模型,可与多个智能家居设备实现多次迭代的模型训练。在首次迭代中,各个智能家居设备可通过接收来自服务器的待训练模型,再通过本地的语音数据对待训练模型对待训练模型的参数进行更新,并将更新后的模型上传到服务器,以使得服务器将各个智能家居设备上传的更新后的模型进行聚合,从而基于聚合结果训练服务器本地的待训练模型。然后,服务器可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个智能家居设备中,以执行第二次迭代的模型训练(即重复执行前述过程)。如此一来,经过多次迭代后,服务器确定自身最后一次训练得到的更新后的模型满足模型训练条件后,可将自身最后一次训练得到的更新后的 模型作为能够实现语音识别功能的神经网络模型,部署到各个智能家居设备上,为各个家庭提供智能家居服务。
图5为本申请实施例提供的联邦学习系统的另一个应用例示意图,如图5所示,联邦学习系统可应用于教学领域中,此时,系统中的多个客户端为位于多个学校中的教学设备(例如,个人电脑、平板电脑等等),这多个学校位于不同的地理位置上。这多个教学设备可与求解器开发者的服务器(即服务端)实现通信,以实现联邦学习。
求解器开发者的服务器为了在各个教学设备上部署求解器,即具备求解方程功能的神经网络模型,可与多个教学设备实现多次迭代的模型训练。在首次迭代中,各个教学设备可通过接收来自服务器的待训练模型,再通过本地的数学数据对待训练模型对待训练模型的参数进行更新,并将更新后的模型上传到服务器,以使得服务器将各个教学设备上传的更新后的模型进行聚合,从而基于聚合结果训练服务器本地的待训练模型。然后,服务器可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个教学设备中,以执行第二次迭代的模型训练(即重复执行前述过程)。如此一来,经过多次迭代后,服务器确定自身最后一次训练得到的更新后的模型满足模型训练条件后,可将自身最后一次训练得到的更新后的模型作为求解器,部署到各个教学设备上,为各个学校中的学生和教师提供教学服务。
图6为本申请实施例提供的联邦学习系统的另一个应用例示意图,如图6所示,联邦学习系统可应用于软件服务领域中,此时,系统中的多个客户端为位于多个用户或企业所使用的智能终端设备。这多个智能终端设备可与远端的软件开发商的服务器(即服务端)实现通信,以实现联邦学习。
软件开发商的服务器为了在各个智能终端设备上部署图像处理软件,即具备图像分类的神经网络模型,可与多个智能终端设备实现多次迭代的模型训练。在首次迭代中,各个智能终端设备可通过接收来自服务器的待训练模型,再通过本地的图像数据对待训练模型对待训练模型的参数进行更新,并将更新后的模型上传到服务器,以使得服务器将各个智能终端设备上传的更新后的模型进行聚合,从而基于聚合结果训练服务器本地的待训练模型。然后,服务器可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个智能终端设备中,以执行第二次迭代的模型训练(即重复执行前述过程)。如此一来,经过多次迭代后,服务器确定自身最后一次训练得到的更新后的模型满足模型训练条件后,可将自身最后一次训练得到的更新后的模型作为图像处理软件,部署到各个智能终端设备上,为企业和个人提供图像处理服务。
应理解,以上仅以联邦学习系统可应用于智能家居领域、教学领域以及软件服务领域进行示意性介绍,在实际应用中,本申请实施例提供的联邦学习系统还可应用到更多领域中,此处不做一一介绍。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs和截距1为输入的运算单元,该运算单元的输出可以为:
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入。激活函数可以是sigmoid函数。神经网络是将许多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
神经网络中的每一层的工作可以用数学表达式y=a(Wx+b)来描述:从物理层面神经网络中的每一层的工作可以理解为通过五种对输入空间(输入向量的集合)的操作,完成输入空间到输出空间的变换(即矩阵的行空间到列空间),这五种操作包括:1、升维/降维;2、放大/缩小;3、旋转;4、平移;5、“弯曲”。其中1、2、3的操作由Wx完成,4的操作由+b完成,5的操作则由a()来实现。这里之所以用“空间”二字来表述是因为被分类的对象并不是单个事物,而是一类事物,空间是指这类事物所有个体的集合。其中,W是权重向量,该向量中的每一个值表示该层神经网络中的一个神经元的权重值。该向量W决定着上文所述的输入空间到输出空间的空间变换,即每一层的权重W控制着如何变换空间。训练神经网络的目的,也就是最终得到训练好的神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。因此,神经网络的训练过程本质上就是学习控制空间变换的方式,更具体的就是学习权重矩阵。
因为希望神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断的调整,直到神经网络能够预测出真正想要的目标值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么神经网络的训练就变成了尽可能缩小这个loss的过程。
(2)反向传播算法
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。
(3)联邦学习
联邦学习是一种用于保护用户隐私的机器学习技术,联邦学习结构上一般包括一个服务端(中心服务器)和一些客户端作为参与方,技术流程主要包括模型下发和模型聚合过程。 在模型下发过程中,客户端从服务端下载模型,并在本地数据上训练,训练到一定程度后上传模型到服务端。在模型聚合过程中,服务端会收集各个客户端上传的模型,并进行模型融合。这两个过程会反复迭代直至模型收敛,从而得到训练好的模型。
(4)联邦聚合
联邦聚合是联邦学习的一个子过程,联邦学习中服务端的主要任务就是对客户端上传的模型进行聚合,即联邦学习中服务器将多个模型融合为一个模型的过程。
(5)参数点对点聚合
参数点对点聚合是一种最简单的联邦聚合方式,该方式要求多个客户端上传的模型具有一样的结构,服务端可对多个模型同一位置上的神经元的参数进行平均。
下面从神经网络的训练侧和神经网络的应用侧对本申请提供的方法进行描述。
本申请实施例提供的模型训练方法,涉及数据的处理,客户端具体可以应用数据训练、机器学习、深度学习等方法,对训练数据(例如,本申请中客户端本地存储的训练数据)进行符号化和形式化的智能信息建模、抽取、预处理、训练等,最终得到更新后的神经网络(如本申请中客户端基于训练数据所得到的更新后的模型)并返回至服务端进行聚合,以得到训练好的神经网络(如本申请中服务端基于更新后的模型进行聚合所得到的训练好的模型);并且,本申请实施例提供的模型训练方法所得到的训练好的神经网络,可被服务端部署在客户端处,以使得客户端实现数据处理功能,即将输入数据输入到客户端中部署的训练好的神经网络,从而得到输出数据(也就是输入数据的处理结果)。需要说明的是,本申请实施例提供的模型训练方法和基于该模型训练方法得到的模型实现数据处理功能是基于同一个构思产生的发明,也可以理解为一个系统中的两个部分,或一个整体流程的两个阶段:如模型训练阶段和模型应用阶段。
图7为本申请实施例提供的模型训练方法的一个流程示意图,该方法可通过如图8所示的联邦学习系统实现(图8为本申请实施例提供的联邦学习系统的一个结构示意图),如图8所示,该系统包括:服务端和多个客户端,服务端和客户端均包含计算设备(例如,CPU、GP U等等)和传输设备(例如,通信接口等等),其中,计算设备用于对待训练模型进行训练,传输设备用于传递模型或跟模型相关的信息,故服务端和客户端可以联邦学习的方式训练模型,为了进一步了解该过程,下文结合图7对该过程作进一步的介绍。如图7所示,该方法包括:
701、客户端获取来自服务端的待训练模型。
本实施例中,当服务端需要获取具备数据处理功能(例如,图像处理、语音处理、文本处理等等)的神经网络模型时,可先获取待训练模型(即需要进行训练的神经网络模型),并下发至多个客户端。
值得注意的是,服务端所下发的待训练模型包含N层(N为大于或等于3的整数),第1层为输入层,第2层至第N-1层为中间层,第N层为输出层,每一层均包含至少一个神经元。第1层所有神经元均用于接收输入的数据,故第1层所有神经元可不具有参数以及位置编码,第2层所有神经元至第N-1层所有神经元均用于数据处理,故第2层所有神经元至第N-1层所有神经元均具有参数(即前述的参数信息,例如,权重、偏置等等)以及位置编码(即前述的位置编码信息),第N层所有神经元均用于输出数据的处理结果,故第N层所有神经元仅 具有参数(例如,权重等等)。其中,在第2层所有神经元至第N-1层所有神经元这多个神经元中,任意一个神经元的位置编码与该神经元在待训练模型中的位置相关联,且在这多个神经元中,位于不同位置上的神经元通常具有不同的位置编码。
具体地,神经元的位置编码可通过多种方式进行设置,下文将分别进行介绍:
在一种可能的实现方式中,对于第2层所有神经元至第N-1层所有神经元而言,这多个神经元的位置编码可由服务端基于这多个神经元在待处理模型中的位置确定,即在这多个神经元中,任意一个神经元的位置编码是由服务端基于该神经元在待训练模型中的位置来定义的。例如,设待训练模型包含4层,第1层为输入层,第4层为输出层,其中,第2层包含3个神经元,第3层包含4个神经元,那么,服务端可将第2层第1个神经元的位置编码定义为1,并设置在第2层第1个神经元中,故第2层第1个神经元不仅具有其自身的参数,还具有其自身的位置编码。同样地,服务端还可将第2层第2个神经元的位置编码定义为2,并设置在第2层第2个神经元中,故第2层第2个神经元不仅具有其自身的参数,还具有其自身的位置编码,…,以此类推,服务端还可将第3层第4个神经元的位置编码定义为7,并设置在第3层第4个神经元中,故第3层第4个神经元不仅具有其自身的参数,还具有其自身的位置编码。如此一来,服务端可定义待训练模型中第2层所有神经元的位置编码和第3层所有神经元的位置编码,并设置在相应的神经元中。
在另一种可能的实现方式中,对于第2层所有神经元至第N-1层所有神经元而言,这多个神经元的位置编码可由多个客户端和服务端共同基于多个神经元在待处理模型中的位置确定,即在这多个神经元中,任意一个神经元的位置编码是由服务端和多个客户端基于该神经元在待训练模型中的位置来事先约定的。例如,如图9所示(图9为本申请实施例提供的待训练模型的一个结构示意图,需要说明的是,图9进示意出神经元的位置编码,而未示意出神经元的参数),设联邦学习系统包含服务端、客户端1和客户端2,待训练模型包含4层,第1层为输入层,第4层为输出层,其中,第2层包含3个神经元,第3层包含4个神经元,那么,服务端、客户端1和客户端2可将第2层第1个神经元的位置编码约定为1,并设置在第2层第1个神经元中,故第2层第1个神经元不仅具有其自身的参数,还具有其自身的位置编码。同样地,服务端、客户端1和客户端2还可将第2层第2个神经元的位置编码定义为2,并设置在第2层第2个神经元中,故第2层第2个神经元不仅具有其自身的参数,还具有其自身的位置编码,…,以此类推,服务端、客户端1和客户端2还可将第3层第4个神经元的位置编码定义为7,并设置在第3层第4个神经元中,故第3层第4个神经元不仅具有其自身的参数,还具有其自身的位置编码。如此一来,服务端、客户端1和客户端2可事先约定待训练模型中第2层所有神经元的位置编码和第3层所有神经元的位置编码,并设置在相应的神经元中。
由于服务端向多个客户端下发的是同一个待训练模型,故在这多个客户端中,任意一个客户端接收到的待训练模型中多个神经元的位置编码与其余客户端接收到的待训练模型中多个神经元的位置编码是同一套位置编码。
在多个客户端中,每个客户端对待训练模型所执行的操作都是相同的,故下文以多个客户端中的其中一个客户端为例进行示意性说明。对于某一个客户端,接收到服务端发送的待训练模型后,该客户端可利用自身存储的本地数据作为训练数据,以对待训练模型进行训练。
应理解,前述例子中,仅以待训练模型包含2个中间层为例进行示意性说明,且以第2层包含3个神经元,第3层包含4个神经元为例进行示意性说明,并不对本申请中待训练模型的中间层的数量和层中神经元的数量构成限制。
还应理解,前述例子中,仅以神经元的位置编码为1至7为例进行示意性说明,并不对神经元的位置编码的大小构成限制。
702、客户端通过待训练模型的多个神经元对训练数据进行处理,得到处理结果,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码。
接收到待训练模型后,该客户端可将自身存储的本地数据作为训练数据,并输入至待训练模型中,以通过待训练模型的多个神经元对训练数据进行处理,得到训练数据的处理结果。需要说明的是,对于待训练模型中第2层所有神经元至第N-1层所有神经元而言,这多个神经元中的每个神经元具有参数和位置编码,那么,这多个神经元作为待处理模型中的多个数据处理单元,可使用自身的参数和位置编码对训练数据进行处理(计算),从而得到训练数据的处理结果。
具体地,该客户端可通过以下方式,利用待训练模型来获取训练数据的处理结果:
由于待训练模型包含N层,可先记每一层的神经元数量为:
di,i=1,2,...,N      (2)
上式中,d1为输入层的神经元数量,相当于输入的训练数据的维度(也就是输入的维度),dN为输出层的神经元数量,相当于训练数据的处理结果的维度(也就是输出的维度)。
然后,记每一层的参数为:
上式中,Wi为第i层中神经元的权重,bi为第i层中神经元的偏置。其中,Wi中第j行的元素,即第i层第j个神经元的权重。bi中第j行的元素,即第i层第j个神经元的偏置,这两者可视为第i层第j个神经元的参数。
随后,记第i层中第j个神经元的位置编码为:
gi(j),j=1,2,...,di        (4)
上式中,由于待训练模型中仅中间层(即第2层至第N-1层)的神经元具有位置编码,故i=2,...,N-1。
接着,记中间层(即第2层至第N-1层)的激活函数为:
fi,i=2,...,N-1       (5)
然后,记输入待训练模型的训练数据为:
上式中,训练数据为第1层所有神经元的最终输出(包含第1层各个神经元的最终输出),故x也可以记为h1,h1包含d1个元素,即h1的维度为d1维。
那么,该客户端将训练数据x输入待训练模型后,待训练模型中第1层所有神经元可向第2层各个神经元发送第1层所有神经元的最终输出h1,第2层各个神经元分别对第1层所有神经元的最终输出h1进行计算后,可得到第2层所有神经元的最终输出h2(h2包含d2个元素,即h2的维度为d2维,且h2包含第2层各个神经元的最终输出),故第2层所有神经元可向第3层各个神经元发送第2层所有神经元的最终输出h2,…,以此类推,直至第N-2层所有神经元向第N-1层各个神经元发送第N-2层所有神经元的最终输出hN-2,第N-1层各个神经元对第N-2层所有神经元的最终输出hN-2进行计算后,可得到第N-1层所有神经元的最终输出hN-1(hN-1包含dN-1个元素,即hN-1的维度为dN-1维,且hN-1包含第N-1层各个神经元的最终输出)。可见,第i层所进行的计算如以下公式所示:
上式中,i=2,...,N-1。hi-1为第i-1层所有神经元的最终输出,hi`为第i层所有神经元的初始输出,hi`(j)为第i层所有神经元的初始输出hi`中第j行的元素,即第i层第j个神经元的初始输出,hi(j)为第i层所有神经元的最终输出hi中第j行的元素,即第i层第j个神经元的最终输出。j=1,...,M,M为第i层的神经元数量,M的值随着i变化而变化,例如,当i=2时,M为d2,当i=N-1时,M为dN-1
基于公式(7)可知,当i=2,...,N-1时,第i层第j个神经元可先将第i层第j个神经元的参数和第i-1层所有神经元的最终输出hi-1进行第一计算(第一计算的过程可参考公式(7)中的第一行公式),得到第i层第j个神经元的初始输出hi`(j)。然后,第i层第j个神经元再将第i层第j个神经元的位置编码gi(j)和第i层第j个神经元的初始输出hi`(j)进行第二计算(第二计算的过程可参考公式(7)中的第二行公式),得到第i层第j个神经元的最终输出hi(j)。对于第i层中除第j个神经元之外的其余神经元,也可执行如同第j个神经元的操作,故可得到第i层所有神经元的最终输出hi
由于待训练模型中第N层的神经元不具备位置编码,故第N层各个神经元得到第N-1层所有神经元的最终输出hN-1后,第N层第1神经元可将第N层第1个神经元的参数和第N-1层所有神经元的最终输出hN-1进行第一计算(第一计算的过程可参考公式(7)中的第一行公式),得到第N层第1个神经元的最终输出hN`(1)。然后,第N层第2神经元可将第N层第2个神经元的参数和第N-1层所有神经元的最终输出hN-1进行第一计算,得到第N层第2个神经元的最终输出hN`(2),…,以此类推,可得到第N层所有神经元的初始输出hN`,第N层所 有神经元的最终输出hN`即为待训练模型的输出,相当于训练数据的处理结果。
应理解,本实施例中,客户端通过待训练模型对训练数据进行处理时,待训练模型中各个神经元的操作也可视为客户端的操作。
还应理解,由于待训练模型中第N层(输出层)并不具备激活函数,故前述第N层的神经元在进行第一计算时,即第N层的神经元按公式(7)中的第一行公式进行计算时,可将第一行公式中的激活函数fN视为恒等函数,即输入等于输出的函数。
还应理解,本实施例仅以第二计算为相乘运算进行示意性说明,并不对第二计算的类型构成限制。例如,第二计算还可以是四则计算中的一种或任意组合,即客户端可将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行相乘运算、相加运算、相减运算和相除运算中的一种或任意组合,得到第i层第j个神经元的最终输出。又如,第二计算还可以是三角函数运算,即客户端可将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行三角函数运算,得到第i层第j个神经元的最终输出。再如,第二计算还可以是指数运算,即客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行指数运算,得到第i层第j个神经元的最终输出。还如,第二计算还可以是对数运算,即客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行对数运算,得到第i层第j个神经元的最终输出。
703、客户端基于处理结果对待处理模型中神经元的参数进行更新,得到更新后的模型。
得到训练数据的处理结果后,该客户端可基于训练数据的处理结果对待处理模型中神经元的参数进行更新,得到更新后的模型。
具体地,该客户端可通过以下方式,来基于处理结果对待处理模型中神经元的参数进行更新,从而获取更新后的模型:
由于训练数据的真实处理结果是已知的,该客户端可先通过预置的目标损失函数,对待训练模型输出的训练数据的处理结果以及训练数据的真实处理结果进行计算,得到目标损失,该目标损失用于指示待训练模型输出的训练数据的处理结果以及训练数据的真实处理结果之间的差异。
得到目标损失后,该客户端基于目标损失对待训练模型中神经元的参数(包含第2层所有神经元至第N层所有神经元的参数)进行更新,但不对神经元的位置编码进行更新(包含第2层所有神经元至第N-1层所有神经元的位置编码,这些位置编码视为固定值),得到更新后的模型。
704、客户端基于更新后的模型以及待训练模型,获取参数更新量。
705、客户端将参数更新量发送至服务端,参数更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
得到更新后的模型后,该客户端可将更新后的模型发送至服务端,故服务端可基于该客户端上传的更新后的模型以及其余客户端上传的更新后的模型进行联邦聚合,以得到训练后的模型。
具体地,该客户端可通过以下方式,来上传更新后的模型,以使得服务端基于更新后的模型实现联邦聚合:
得到更新后的模型后,该客户端可基于更新后的模型以及待训练模型,获取二者之间的 参数更新量,该参数更新量通常指更新后的模型相较于待训练模型而言,各个神经元的参数更新量(下文成为更新后的模型中各个神经元的参数更新量)。需要说明的是,该客户端可在更新后的模型以及待训练模型中,将同一位置上的神经元的参数进行比较,从而获取该位置上的神经元的参数更新量,如此一来,就可以获取更新后的模型各个神经元的参数更新量。依旧如上述例子,由于待训练模型包含4层,故客户端1所得到的更新后的模型1同样也包含4层,那么,客户端1可将待训练模型中第1层第1个神经元的参数与更新后的模型1中第1层第1个神经元的参数进行比较,得到更新后的模型1中第1层第1个神经元的参数更新量,该客户端还可将待训练模型中第1层第2个神经元的参数与更新后的模型1中第1层第2个神经元的参数进行比较,得到更新后的模型1中第1层第2个神经元的参数更新量,…,以此类推,该客户端可得到更新后的模型1中各个神经元的参数更新量。
然后,该客户端可将更新后的模型中各个神经元的参数更新量发送至服务端,如此一来,服务端可以得到各个客户端上传的更新后的模型中各个神经元的参数更新量,并基于这些信息进行求平均计算,从而得到更新后的模型中各个神经元的参数更新量的平均值,故服务端可基于各个神经元的参数更新量的平均值,对本地存储的待训练模型中各个神经元的参数进行相应的更新,可得到服务端自身训练得到的更新后的模型。依旧如上述例子,服务端接收到客户端1上传的更新后的模型1中各个神经元的参数更新量,以及客户端2上传的更新后的模型2中各个神经元的参数更新量后,可将更新后的模型1中第1层第1个神经元的参数更新量与更新后的模型2中第1层第1个神经元的参数更新量进行求平均计算,得到第1层第1个神经元的参数更新量的平均值,…,以此类推,服务端可得到各个神经元的参数更新量的平均值。那么,服务端可基于各个神经元的参数更新量的平均值,对本地存储的待训练模型中各个神经元的参数进行相应的更新,即利用第1层第1个神经元的参数更新量的平均值,来更新待训练模型中第1层第1个神经元的参数,利用第1层第2个神经元的参数更新量的平均值,来更新待训练模型中第1层第2个神经元的参数,…,以此类推,可得到服务端自身训练得到的更新后的模型。
此后,服务端可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个客户端中进行下一次迭代的模型训练(即重复执行步骤701至步骤704),直至某一次迭代的模型训练中,服务端自身训练得到的更新后的模型满足模型训练要求(例如,目标损失收敛或迭代次数大于预设的次数等等),可将该次迭代中服务端自身训练得到的更新后的模型,作为训练后的模型(即完成训练的神经网络模型)。
应理解,本实施例仅以服务端对各个客户端上传的更新后的模型中各个神经元的参数更新量进行求平均计算进行示意性说明,在实际应用中,服务端还可对各个客户端上传的更新后的模型中各个神经元的参数更新量,进行加权平均计算等等。
本申请实施例中,某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元 分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
进一步地,在某些相关技术中,服务端在接收到各个客户端上传的更新后的模型后,可利用各个客户端的本地数据,来对这些模型进行神经元对齐(即调换神经元的位置,从而使得这些模型中,相同功能的神经元位于相同的位置上)。然而,这样的对齐方式可能泄露用户隐私,涉及一系列的数据安全问题,还会引入额外的计算开销。在本申请实施例提供的方案中,各个客户端在利用各自的本地数据对待训练模型进行训练的过程中,由于待训练模型中神经元的位置编码的存在,可实现神经元的预对齐(如图10所示,图10为本申请实施例提供的联邦学习系统的另一结构示意图),故不需要服务端来执行神经元的对齐操作,可有效保护用户隐私,避免数据安全问题的出现,且能够降低服务端的计算开销。
图11为本申请实施例提供的模型训练方法的另一流程示意图,该方法也可通过如图8所示的联邦学习系统实现,如图11所示,该方法包括:
1101、客户端获取来自服务端的待训练模型。
在一种可能的实现方式中,多个神经元的位置编码由服务端基于多个神经元在待处理模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待处理模型中的位置确定。
1102、客户端通过待训练模型的多个神经元对训练数据进行处理,得到处理结果,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码。
在一种可能的实现方式中,待训练模型包含N层,第1层为输入层,第N层为输出层,多个神经元为第2层至第N-1层所有神经元,客户端通过待训练模型的多个神经元对训练数据进行处理,得到处理结果包括:客户端将第i层第j个神经元的参数和第i-1层所有神经元的最终输出进行第一计算,得到第i层第j个神经元的初始输出,i=1,...,N,j=1,...,M,N≥3,M≥1;客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出;其中,第1层所有神经元的最终输出为训练数据,第N层所有神经元的初始输出为处理结果。
在一种可能的实现方式中,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出包括:客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行四则运算,得到第i层第j个神经元的最终输出;或,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行三角函数运算,得到第i层第j个神经元的最终输出;或,客户端将第i层 第j个神经元的位置编码和第i层第j个神经元的初始输出进行指数运算,得到第i层第j个神经元的最终输出;或,客户端将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行对数运算,得到第i层第j个神经元的最终输出。
关于步骤1101和步骤1102的介绍,可参考图7所示实施例中步骤701和步骤702的相关说明部分,此处不再赘述。
1103、客户端基于处理结果对待处理模型中神经元的参数和位置编码进行更新,得到更新后的模型。
得到训练数据的处理结果后,该客户端可基于训练数据的处理结果对待处理模型中神经元的参数和位置编码进行更新,得到更新后的模型。
具体地,该客户端可通过以下方式,来基于处理结果对待处理模型中神经元的参数和位置编码进行更新,从而获取更新后的模型:
由于训练数据的真实处理结果是已知的,该客户端可先通过预置的目标损失函数,对待训练模型输出的训练数据的处理结果以及训练数据的真实处理结果进行计算,得到目标损失,该目标损失用于指示待训练模型输出的训练数据的处理结果以及训练数据的真实处理结果之间的差异。
得到目标损失后,该客户端基于目标损失对待训练模型中神经元的参数(包含第2层所有神经元至第N层所有神经元的参数)和神经元的位置编码(包含第2层所有神经元至第N-1层所有神经元的位置编码,这些位置编码视为非固定值)进行更新,得到更新后的模型。
值得注意的是,该客户端往往可提前获取多批训练数据,故该客户端可对待训练模型实现多轮次的更新(即执行多轮次的步骤1102和步骤1103)。具体地,在第一轮次的更新中,该客户端可将第一批训练数据输入到待训练模型,得到第一批训练数据的处理结果,并基于该处理结果来更新待训练模型,得到第一轮次所得到的模型。接着,在第二轮次的更新中,该客户端可将第二批训练数据输入到第一轮次所得到的模型,得到第二批训练数据的处理结果,并基于该处理结果来更新第一轮次所得到的模型,得到第二轮次所得到的模型,...,以此类推,完成最后轮次的更新后,最后轮次所得到的模型即为更新后的模型。然而,所有轮次的更新均会更新模型中神经元的参数,但只有部分轮次的更新会更新模型中神经元的位置编码,可见,位置编码的更新频率小于参数的更新频率,这样可以在一定程度上去抑制模型的重排不变性。
对于任意一批训练数据,该客户端可利用该批训练数据来对待训练模型进行更新(即每一批,
1104、客户端基于更新后的模型以及待训练模型,获取参数更新量以及位置编码更新量。
1105、客户端将参数更新量和位置编码更新量发送至服务端,参数更新量和位置编码更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
得到更新后的模型后,该客户端可将更新后的模型发送至服务端,故服务端可基于该客户端上传的更新后的模型以及其余客户端上传的更新后的模型进行联邦聚合,以得到训练后的模型。
具体地,该客户端可通过以下方式,来上传更新后的模型,以使得服务端基于更新后的模型实现联邦聚合:
得到更新后的模型后,该客户端可基于更新后的模型以及待训练模型,获取二者之间的参数更新量和位置编码更新量,该参数更新量通常指更新后的模型相较于待训练模型而言,各个神经元的参数更新量(下文成为更新后的模型中各个神经元的参数更新量),该位置编码更新量通常指更新后的模型相较于待训练模型而言,各个神经元的位置编码更新量(下文成为更新后的模型中各个神经元的位置编码更新量)。需要说明的是,该客户端可在更新后的模型以及待训练模型中,将同一位置上的神经元的参数进行比较,从而获取该位置上的神经元的参数更新量,并将同一位置上的神经元的位置编码进行比较,从而获取该位置上的神经元的位置编码更新量如此一来,就可以获取更新后的模型各个神经元的参数更新量和位置编码更新量。依旧如上述例子,由于待训练模型包含4层,故客户端1所得到的更新后的模型1同样也包含4层,那么,客户端1可将待训练模型中第1层第1个神经元的参数与更新后的模型1中第1层第1个神经元的参数进行比较,得到更新后的模型1中第1层第1个神经元的参数更新量,该客户端还可将待训练模型中第1层第2个神经元的参数与更新后的模型1中第1层第2个神经元的参数进行比较,得到更新后的模型1中第1层第2个神经元的参数更新量,…,以此类推,该客户端可得到更新后的模型1中各个神经元的参数更新量。同理,客户端1还可将待训练模型中第1层第1个神经元的位置编码与更新后的模型1中第1层第1个神经元的位置编码进行比较,得到更新后的模型1中第1层第1个神经元的位置编码更新量,该客户端还可将待训练模型中第1层第2个神经元的位置编码与更新后的模型1中第1层第2个神经元的位置编码进行比较,得到更新后的模型1中第1层第2个神经元的位置编码更新量,…,以此类推,该客户端可得到更新后的模型1中各个神经元的位置编码更新量。
然后,该客户端可将更新后的模型中各个神经元的参数更新量和位置编码更新量发送至服务端,如此一来,服务端可以得到各个客户端上传的更新后的模型中各个神经元的参数更新量和位置编码更新量,并基于这些信息进行求平均计算,从而得到更新后的模型中各个神经元的参数更新量的平均值和各个神经元的位置编码更新量的平均值,故服务端可基于各个神经元的参数更新量的平均值,对本地存储的待训练模型中各个神经元的参数进行相应的更新,并基于各个神经元的位置编码更新量的平均值,对本地存储的待训练模型中各个神经元的位置编码进行相应的更新,可得到服务端自身训练得到的更新后的模型。依旧如上述例子,服务端接收到客户端1上传的更新后的模型1中各个神经元的参数更新量,以及客户端2上传的更新后的模型2中各个神经元的参数更新量后,可将更新后的模型1中第1层第1个神经元的参数更新量与更新后的模型2中第1层第1个神经元的参数更新量进行求平均计算,得到第1层第1个神经元的参数更新量的平均值,…,以此类推,服务端可得到各个神经元的参数更新量的平均值。同样地,服务端接收到客户端1上传的更新后的模型1中各个神经元的位置编码更新量,以及客户端2上传的更新后的模型2中各个神经元的位置编码更新量后,可将更新后的模型1中第1层第1个神经元的位置编码更新量与更新后的模型2中第1层第1个神经元的位置编码更新量进行求平均计算,得到第1层第1个神经元的位置编码更新量的平均值,…,以此类推,服务端可得到各个神经元的位置编码更新量的平均值。那么,服务端可基于各个神经元的参数更新量的平均值,对本地存储的待训练模型中各个神经元的参数进行相应的更新,即利用第1层第1个神经元的参数更新量的平均值,来更新待训练模型中 第1层第1个神经元的参数,利用第1层第2个神经元的参数更新量的平均值,来更新待训练模型中第1层第2个神经元的参数,…,以此类推,服务端可完成各个神经元的参数更新。同样地,服务端还可基于各个神经元的位置编码更新量的平均值,对本地存储的待训练模型中各个神经元的位置编码进行相应的更新,即利用第1层第1个神经元的位置编码更新量的平均值,来更新待训练模型中第1层第1个神经元的位置编码,利用第1层第2个神经元的位置编码更新量的平均值,来更新待训练模型中第1层第2个神经元的位置编码,…,以此类推,服务端可完成各个神经元的位置编码更新,从而得到服务端自身训练得到的更新后的模型。
此后,服务端可将自身训练得到的更新后的模型作为新的待训练模型,再次下发到各个客户端中进行下一次迭代的模型训练(即重复执行步骤1101至步骤1104),直至某一次迭代的模型训练中,服务端自身训练得到的更新后的模型满足模型训练要求(例如,目标损失收敛或迭代次数大于预设的次数等等),可将该次迭代中服务端自身训练得到的更新后的模型,作为训练后的模型(即完成训练的神经网络模型)。
应理解,本实施例仅以服务端对各个客户端上传的更新后的模型中各个神经元的参数更新量进行求平均计算进行示意性说明,在实际应用中,服务端还可对各个客户端上传的更新后的模型中各个神经元的参数更新量,进行加权平均计算等等。
还应理解,本实施例仅以服务端对各个客户端上传的更新后的模型中各个神经元的位置编码更新量进行求平均计算进行示意性说明,在实际应用中,服务端还可对各个客户端上传的更新后的模型中各个神经元的位置编码更新量,进行加权平均计算等等。
本申请实施例中,某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
进一步地,在某些相关技术中,服务端在接收到各个客户端上传的更新后的模型后,可利用各个客户端的本地数据,来对这些模型进行神经元对齐(即调换神经元的位置,从而使得这些模型中,相同功能的神经元位于相同的位置上)。然而,这样的对齐方式可能泄露用户隐私,涉及一系列的数据安全问题,还会引入额外的计算开销。在本申请实施例提供的方案 中,各个客户端在利用各自的本地数据对待训练模型进行训练的过程中,由于待训练模型中神经元的位置编码的存在,可实现神经元的预对齐(如图5所示,图5为本申请实施例提供的联邦学习系统的另一结构示意图),故不需要服务端来执行神经元的对齐操作,可有效保护用户隐私,避免数据安全问题的出现,且能够降低服务端的计算开销。
更进一步地,本申请实施例还可对神经元的位置编码进行更新,使得模型可根据具体任务的性质(即在某种业务场景中,用户需要模型具备某种数据处理功能)来学习合适的位置编码,有利于对神经元进行更加合理的对齐处理。
以上是对本申请实施例提供的模型训练方法所进行的详细说明,以下将对本申请实施例提供的模型训练装置进行介绍。图12为本申请实施例提供的客户端的一个结构示意图,如图12所示,该客户端包括:
获取模块1201,用于获取来自服务端的待训练模型,待训练模型包含多个神经元,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码。
处理模块1202,用于:通过待训练模型中多个神经元的参数和待训练模型中多个神经元的参数位置编码对训练数据进行处理,得到处理结果,多个神经元中不同位置的神经元具有不同的位置编码;基于处理结果对训练模型中多个神经元的参数进行更新,得到更新后的模型。
发送模块1203,用于将更新后的模型发送至服务端,更新后的模型用于在服务端处进行聚合,得到训练后的模型。
本申请实施例中,某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能实现的方式中,多个神经元的位置编码由服务端基于多个神经元在待训练模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待训练模型中的位置确定。
在一种可能实现的方式中,待训练模型包含N层,多个神经元为第2层至第N-1层所有 神经元,处理模块1202,用于:将第i层第j个神经元的参数和第i-1层所有神经元的最终输出进行第一计算,得到第i层第j个神经元的初始输出,i=2,...,N-1,j=1,...,M,N≥3,M≥1;将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行第二计算,得到第i层第j个神经元的最终输出,第i层第j个神经元的最终输出用于生成处理结果,即第N-1层所有神经元的最终输出用于生成处理结果。
在一种可能实现的方式中,在待训练模型中,第1层为输入层,第N层为输出层,第1层所有神经元的最终输出为训练数据,第N层第j个神经元的参数用于对第N-1层所有神经元的最终输出进行第一计算,得到第N层第j个神经元的最终输出,第N层所有神经元的最终输出为处理结果。
在一种可能实现的方式中,处理模块1202,用于:将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行四则运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行三角函数运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行指数运算,得到第i层第j个神经元的最终输出;或,将第i层第j个神经元的位置编码和第i层第j个神经元的初始输出进行对数运算,得到第i层第j个神经元的最终输出。
在一种可能实现的方式中,处理模块1202,用于:基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;基于目标损失对参数和位置编码进行更新,得到更新后的模型,位置编码的更新频率小于参数的更新频率。
在一种可能实现的方式中,发送模块1203,用于:基于更新后的模型以及待训练模型,获取参数更新量以及位置编码更新量;将参数更新量和位置编码更新量发送至服务端,参数更新量和位置编码更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
在一种可能实现的方式中,处理模块1202,用于:基于处理结果以及训练数据的真实处理结果,获取目标损失,目标损失用于指示处理结果以及真实处理结果之间的差异;基于目标损失对参数进行更新,得到更新后的模型。
在一种可能实现的方式中,发送模块1203,用于:基于更新后的模型以及待训练模型,获取参数更新量;将参数更新量发送至服务端,参数更新量用于服务端更新待训练模型,直至满足模型训练条件,得到训练后的模型。
图13为本申请实施例提供的服务端的一个结构示意图,如图13所示,该服务端包括:
发送模块1301,用于将待训练模型发送至客户端,待训练模型包含多个神经元,多个神经元中的每个神经元具有参数和位置编码,多个神经元中不同位置的神经元具有不同的位置编码,参数和位置编码用于客户端对训练数据进行处理得到处理结果,并基于处理结果对参数进行更新,得到更新后的模型;
获取模块1302,用于获取来自客户端的更新后的模型;
聚合模块1303,用于对更新后的模型进行聚合,得到训练后的模型。
本申请实施例中,某个客户端获取来自服务端的待训练模型后,该客户端通过待训练模 型中多个神经元的参数和位置编码对本地的训练数据进行处理,得到训练数据的处理结果。然后,该客户端可基于该处理结果对待训练模型中这多个神经元的参数进行更新,从而得到更新后的模型。其中,对于待训练模型的多个神经元中的任意一个神经元而言,该神经元具有参数和位置编码,且该神经元的位置编码与其余神经元的位置编码不同,故该神经元的位置编码可约束该神经元的功能,并区别于其余神经元的功能。相对于待训练模型中的神经元分布而言,若更新后的模型中某些位置上的神经元的功能发生了变化(也就是具备不同功能的某些神经元发生了位置变化),由于这些位置上的神经元的位置编码保持不变(因为位置编码仅与神经元的位置相关),将导致发生位置变化的模型的输出与未发生位置变化的模型的输出不相同,致使模型训练过程的不稳定,从而影响训练后的模型的性能,故客户端在更新待训练模型中各个神经元的参数时,将尽量保持各个位置上的神经元的功能不发生变化,以保证更新后的模型的输出尽可能稳定,可见,神经元的位置编码有效遏制了神经网络模型的重排不变性。由于其余客户端也可执行如同该客户端所执行的操作,故各个客户端上传至服务端的更新后的模型中,相同功能的神经元都处于相同的位置上,故服务端在实现聚合时,可按位置去处理各个更新后的模型中的神经元,所得到的训练后的模型可具备足够优秀的功能。
在一种可能的实现方式中,多个神经元的位置编码由服务端基于多个神经元在待处理模型中的位置确定,或,多个神经元的位置编码由客户端和服务端基于多个神经元在待处理模型中的位置确定。
在一种可能的实现方式中,获取模块1302,用于获取来自客户端的参数更新量和位置编码更新量,参数更新量和位置编码更新量基于更新后的模型以及待训练模型获取;聚合模块1303,用于基于参数更新量和位置编码更新量,更新待训练模型,直至满足模型训练条件,得到训练后的模型。
在一种可能的实现方式中,获取模块1302,用于获取来自客户端的参数更新量,参数更新量基于更新后的模型以及待训练模型获取;聚合模块1303,用于基于参数更新量,更新待训练模型,直至满足模型训练条件,得到训练后的模型。
需要说明的是,上述装置各模块/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其带来的技术效果与本申请方法实施例相同,具体内容可参考本申请实施例前述所示的方法实施例中的叙述,此处不再赘述。
本申请实施例还涉及一种执行设备,图14为本申请实施例提供的执行设备的一个结构示意图。如图14所示,执行设备1400具体可以表现为手机、平板、笔记本电脑、智能穿戴设备、服务器等,此处不做限定。其中,执行设备1400上可部署有图8所示的客户端,用于联合后续的训练设备共同实现图4或图6对应实施例中模型训练的功能。具体的,执行设备1400包括:接收器1401、发射器1402、处理器1403和存储器1404(其中执行设备1400中的处理器1403的数量可以一个或多个,图14中以一个处理器为例),其中,处理器1403可以包括应用处理器14031和通信处理器14032。在本申请的一些实施例中,接收器1401、发射器1402、处理器1403和存储器1404可通过总线或其它方式连接。
存储器1404可以包括只读存储器和随机存取存储器,并向处理器1403提供指令和数据。存储器1404的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器1404存储有处理器和操作指令、可执行模块或者数据结构,或者它 们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。
处理器1403控制执行设备的操作。具体的应用中,执行设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。
上述本申请实施例揭示的方法可以应用于处理器1403中,或者由处理器1403实现。处理器1403可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器1403中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器1403可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器,还可进一步包括专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器1403可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1404,处理器1403读取存储器1404中的信息,结合其硬件完成上述方法的步骤。
接收器1401可用于接收输入的数字或字符信息,以及产生与执行设备的相关设置以及功能控制有关的信号输入。发射器1402可用于通过第一接口输出数字或字符信息;发射器1402还可用于通过第一接口向磁盘组发送指令,以修改磁盘组中的数据;发射器1402还可以包括显示屏等显示设备。
本申请实施例中,在一种情况下,处理器1403,可用于实现图7或图11对应实施例中的模型训练方法,还可用于通过图7或图11对应实施例所得到的训练后的模型,实现相应的数据处理功能。
本申请实施例还涉及一种训练设备,图15为本申请实施例提供的训练设备的一个结构示意图。如图15所示,训练设备1500由一个或多个服务器实现,训练设备1500可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1514(例如,一个或一个以上处理器)和存储器1532,一个或一个以上存储应用程序1542或数据1544的存储介质1530(例如一个或一个以上海量存储设备)。其中,存储器1532和存储介质1530可以是短暂存储或持久存储。存储在存储介质1530的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对训练设备中的一系列指令操作。更进一步地,中央处理器1514可以设置为与存储介质1530通信,在训练设备1500上执行存储介质1530中的一系列指令操作。
训练设备1500还可以包括一个或一个以上电源1526,一个或一个以上有线或无线网络接口1550,一个或一个以上输入输出接口1558;或,一个或一个以上操作系统1541,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
具体的,训练设备可以联合前述的执行设备,共同执行图4或图6对应实施例中的模型训练方法。
本申请实施例还涉及一种计算机存储介质,该计算机可读存储介质中存储有用于进行信号处理的程序,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例还涉及一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例提供的执行设备、训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,所述处理单元例如可以是处理器,所述通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的数据处理方法,或者,以使训练设备内的芯片执行上述实施例描述的数据处理方法。可选地,所述存储单元为所述芯片内的存储单元,如寄存器、缓存等,所述存储单元还可以是所述无线接入设备端内的位于所述芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
具体的,请参阅图16,图16为本申请实施例提供的芯片的一个结构示意图,所述芯片可以表现为神经网络处理器NPU 1600,NPU 1600作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路1603,通过控制器1604控制运算电路1603提取存储器中的矩阵数据并进行乘法运算。
在一些实现中,运算电路1603内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路1603是二维脉动阵列。运算电路1603还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路1603是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器1602中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器1601中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)1608中。
统一存储器1606用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)1605,DMAC被搬运到权重存储器1602中。输入数据也通过DMAC被搬运到统一存储器1606中。
BIU为Bus Interface Unit即,总线接口单元1613,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)1609的交互。
总线接口单元1613(Bus Interface Unit,简称BIU),用于取指存储器1609从外部存储器获取指令,还用于存储单元访问控制器1605从外部存储器获取输入矩阵A或者权重矩阵B的原数据。
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器1606或将权重数据搬运到权重存储器1602中或将输入数据数据搬运到输入存储器1601中。
向量计算单元1607包括多个运算处理单元,在需要的情况下,对运算电路1603的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网 络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对预测标签平面进行上采样等。
在一些实现中,向量计算单元1607能将经处理的输出的向量存储到统一存储器1606。例如,向量计算单元1607可以将线性函数;或,非线性函数应用到运算电路1603的输出,例如对卷积层提取的预测标签平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元1607生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路1603的激活输入,例如用于在神经网络中的后续层中的使用。
控制器1604连接的取指存储器(instruction fetch buffer)1609,用于存储控制器1604使用的指令;
统一存储器1606,输入存储器1601,权重存储器1602以及取指存储器1609均为On-Chip存储器。外部存储器私有于该NPU硬件架构。
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的 任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。

Claims (19)

  1. 一种模型训练方法,其特征在于,所述方法包括:
    获取待训练模型,所述待训练模型包含多个神经元,其中,所述神经元关联参数信息和位置编码信息,所述神经元与所述位置编码信息一一对应;
    通过所述参数信息,所述位置编码信息和训练数据,对所述待训练模型进行更新,得到更新后的模型;
    发送所述更新后的模型。
  2. 根据权利要求1所述的方法,其特征在于,所述多个神经元的位置编码信息是基于所述多个神经元在所述待训练模型中的位置确定的。
  3. 根据权利要求1或2所述的方法,其特征在于,所述通过所述参数信息,所述位置编码信息和训练数据,对所述待训练模型进行更新,得到更新后的模型包括:
    通过所述参数信息和所述位置编码信息对训练数据进行处理,得到处理结果;
    基于所述处理结果对所述参数信息进行更新,得到更新后的模型。
  4. 根据权利要求3所述的方法,其特征在于,所述待训练模型包含N层,所述多个神经元为第2层至第N-1层所有神经元,通过所述参数信息和所述位置编码信息对训练数据进行处理,得到处理结果包括:
    将第i层第j个神经元的参数信息和第i-1层所有神经元的最终输出进行第一计算,得到所述第i层第j个神经元的初始输出,i=2,...,N-1,j=1,...,M,N≥3,M≥1;
    将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行第二计算,得到所述第i层第j个神经元的最终输出,所述第i层第j个神经元的最终输出用于生成处理结果。
  5. 根据权利要求4所述的方法,其特征在于,在所述待训练模型中,第1层为输入层,第N层为输出层,第1层所有神经元的最终输出为所述训练数据,第N层第j个神经元的参数信息用于对第N-1层所有神经元的最终输出进行第一计算,得到第N层第j个神经元的最终输出,第N层所有神经元的最终输出为处理结果。
  6. 根据权利要求4或5所述的方法,其特征在于,将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行第二计算,得到所述第i层第j个神经元的最终输出包括:
    将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行四则运算,得到所述第i层第j个神经元的最终输出;或,
    将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行三角函数运算,得到所述第i层第j个神经元的最终输出;或,
    将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行指数运算,得到所述第i层第j个神经元的最终输出;或,
    将第i层第j个神经元的位置编码信息和第i层第j个神经元的初始输出进行对数运算,得到所述第i层第j个神经元的最终输出。
  7. 根据权利要求3至6任意一项所述的方法,其特征在于,基于所述处理结果对所述参数信息进行更新,得到更新后的模型包括:
    基于所述处理结果以及所述训练数据的真实处理结果,获取目标损失,所述目标损失用于指示所述处理结果以及所述真实处理结果之间的差异;
    基于所述目标损失对所述参数信息和所述位置编码信息进行更新,得到更新后的模型,所述位置编码信息的更新频率小于所述参数信息的更新频率。
  8. 根据权利要求7所述的方法,其特征在于,发送更新后的模型包括:
    基于所述更新后的模型以及所述待训练模型,获取参数信息更新量以及位置编码信息更新量;
    发送所述参数信息更新量和所述位置编码信息更新量。
  9. 根据权利要求3至6任意一项所述的方法,其特征在于,基于所述处理结果对所述参数信息进行更新,得到更新后的模型包括:
    基于所述处理结果以及所述训练数据的真实处理结果,获取目标损失,所述目标损失用于指示所述处理结果以及所述真实处理结果之间的差异;
    基于所述目标损失对所述参数信息进行更新,得到更新后的模型。
  10. 根据权利要求9所述的方法,其特征在于,发送所述更新后的模型包括:
    基于所述更新后的模型以及所述待训练模型,获取参数信息更新量;
    发送所述参数信息更新量。
  11. 一种模型训练方法,其特征在于,所述方法包括:
    发送待训练模型,所述待训练模型包含多个神经元,其中,所述神经元关联参数信息和位置编码信息,所述神经元与所述位置编码信息一一对应;
    获取更新后的模型,并对所述更新后的模型进行聚合,得到训练后的模型,所述更新后的模型基于所述参数信息,所述位置编码信息和训练数据对所述待训练模型进行更新得到。
  12. 根据权利要求11所述的方法,其特征在于,所述多个神经元的位置编码信息是基于所述多个神经元在所述待训练模型中的位置确定的。
  13. 根据权利要求11或12所述的方法,其特征在于,所述获取更新后的模型,并对所述更新后的模型进行聚合,得到训练后的模型包括:
    获取参数信息更新量和位置编码信息更新量,所述参数信息更新量和所述位置编码信息更新量基于所述更新后的模型以及所述待训练模型获取;
    基于所述参数信息更新量和所述位置编码信息更新量,更新所述待训练模型,直至满足模型训练条件,得到训练后的模型。
  14. 根据权利要求11或12所述的方法,其特征在于,所述获取更新后的模型,并对所述更新后的模型进行聚合,得到训练后的模型包括:
    获取参数信息更新量,所述参数信息更新量基于所述更新后的模型以及所述待训练模型获取;
    基于所述参数信息更新量,更新所述待训练模型,直至满足模型训练条件,得到训练后的模型。
  15. 一种模型训练装置,其特征在于,所述装置包括:
    获取模块,用于获取待训练模型,所述待训练模型包含多个神经元,其中,所述神经元关联参数信息和位置编码信息,所述神经元与所述位置编码信息一一对应;
    处理模块,用于通过所述参数信息,所述位置编码信息和训练数据,对所述待训练模型进行更新,得到更新后的模型;
    发送模块,用于发送所述更新后的模型。
  16. 一种模型训练装置,其特征在于,所述装置包括:
    发送模块,用于发送待训练模型,所述待训练模型包含多个神经元,其中,所述神经元关联参数信息和位置编码信息,所述神经元与所述位置编码信息一一对应;
    获取模块,用于获取更新后的模型,所述更新后的模型基于所述参数信息,所述位置编码信息和训练数据对所述待训练模型进行更新得到;
    聚合模块,用于对所述更新后的模型进行聚合,得到训练后的模型。
  17. 一种模型训练装置,其特征在于,所述模型训练装置包括存储器和处理器;
    所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述模型训练装置执行如权利要求1至14任一项所述的方法。
  18. 一种计算机存储介质,其特征在于,所述计算机存储介质存储有计算机程序,该程序由计算机执行时,使得所述计算机实施权利要求1至14任一项所述的方法。
  19. 一种计算机程序产品,其特征在于,所述计算机程序产品存储有指令,所述指令在由计算机执行时,使得所述计算机实施权利要求1至14任一项所述的方法。
PCT/CN2023/082679 2022-03-26 2023-03-21 一种模型训练方法及其相关设备 WO2023185541A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210304574.2 2022-03-26
CN202210304574.2A CN114841361A (zh) 2022-03-26 2022-03-26 一种模型训练方法及其相关设备

Publications (1)

Publication Number Publication Date
WO2023185541A1 true WO2023185541A1 (zh) 2023-10-05

Family

ID=82563158

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/082679 WO2023185541A1 (zh) 2022-03-26 2023-03-21 一种模型训练方法及其相关设备

Country Status (2)

Country Link
CN (1) CN114841361A (zh)
WO (1) WO2023185541A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114841361A (zh) * 2022-03-26 2022-08-02 华为技术有限公司 一种模型训练方法及其相关设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112396191A (zh) * 2020-12-29 2021-02-23 支付宝(杭州)信息技术有限公司 一种基于联邦学习进行模型参数更新的方法、系统及装置
CN113159283A (zh) * 2021-03-31 2021-07-23 华为技术有限公司 一种基于联邦迁移学习的模型训练方法及计算节点
WO2021204040A1 (zh) * 2020-10-29 2021-10-14 平安科技(深圳)有限公司 联邦学习数据处理方法、装置、设备及存储介质
CN113723619A (zh) * 2021-08-31 2021-11-30 南京大学 一种基于训练阶段感知策略的联邦学习训练方法
CN113989561A (zh) * 2021-10-29 2022-01-28 河海大学 基于异步联邦学习的参数聚合更新方法、设备及系统
CN114841361A (zh) * 2022-03-26 2022-08-02 华为技术有限公司 一种模型训练方法及其相关设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021204040A1 (zh) * 2020-10-29 2021-10-14 平安科技(深圳)有限公司 联邦学习数据处理方法、装置、设备及存储介质
CN112396191A (zh) * 2020-12-29 2021-02-23 支付宝(杭州)信息技术有限公司 一种基于联邦学习进行模型参数更新的方法、系统及装置
CN113159283A (zh) * 2021-03-31 2021-07-23 华为技术有限公司 一种基于联邦迁移学习的模型训练方法及计算节点
CN113723619A (zh) * 2021-08-31 2021-11-30 南京大学 一种基于训练阶段感知策略的联邦学习训练方法
CN113989561A (zh) * 2021-10-29 2022-01-28 河海大学 基于异步联邦学习的参数聚合更新方法、设备及系统
CN114841361A (zh) * 2022-03-26 2022-08-02 华为技术有限公司 一种模型训练方法及其相关设备

Also Published As

Publication number Publication date
CN114841361A (zh) 2022-08-02

Similar Documents

Publication Publication Date Title
WO2022022274A1 (zh) 一种模型训练方法及装置
WO2022083536A1 (zh) 一种神经网络构建方法以及装置
WO2021238281A1 (zh) 一种神经网络的训练方法、图像分类系统及相关设备
WO2021159714A1 (zh) 一种数据处理方法及相关设备
WO2022116933A1 (zh) 一种训练模型的方法、数据处理的方法以及装置
WO2022001805A1 (zh) 一种神经网络蒸馏方法及装置
WO2024041479A1 (zh) 一种数据处理方法及其装置
WO2022111387A1 (zh) 一种数据处理方法及相关装置
WO2024001806A1 (zh) 一种基于联邦学习的数据价值评估方法及其相关设备
WO2022179586A1 (zh) 一种模型训练方法及其相关联设备
WO2023231954A1 (zh) 一种数据的去噪方法以及相关设备
WO2021169366A1 (zh) 数据增强方法和装置
WO2021036397A1 (zh) 目标神经网络模型的生成方法和装置
WO2023185541A1 (zh) 一种模型训练方法及其相关设备
WO2024046144A1 (zh) 一种视频处理方法及其相关设备
WO2024094094A1 (zh) 一种模型训练方法及装置
WO2023246735A1 (zh) 一种项目推荐方法及其相关设备
WO2023197857A1 (zh) 一种模型切分方法及其相关设备
CN113627421A (zh) 一种图像处理方法、模型的训练方法以及相关设备
WO2024017282A1 (zh) 一种数据处理方法及其装置
WO2023197910A1 (zh) 一种用户行为预测方法及其相关设备
WO2023045949A1 (zh) 一种模型训练方法及其相关设备
CN116739154A (zh) 一种故障预测方法及其相关设备
WO2023020185A1 (zh) 一种图像分类方法及其相关设备
WO2023231796A1 (zh) 一种视觉任务处理方法及其相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23777914

Country of ref document: EP

Kind code of ref document: A1