WO2022267036A1 - 神经网络模型训练方法和装置、数据处理方法和装置 - Google Patents

神经网络模型训练方法和装置、数据处理方法和装置 Download PDF

Info

Publication number
WO2022267036A1
WO2022267036A1 PCT/CN2021/102480 CN2021102480W WO2022267036A1 WO 2022267036 A1 WO2022267036 A1 WO 2022267036A1 CN 2021102480 W CN2021102480 W CN 2021102480W WO 2022267036 A1 WO2022267036 A1 WO 2022267036A1
Authority
WO
WIPO (PCT)
Prior art keywords
gradient
neural network
data
network model
parameters
Prior art date
Application number
PCT/CN2021/102480
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 华为技术有限公司
Priority to CN202180099427.XA priority Critical patent/CN117501245A/zh
Priority to PCT/CN2021/102480 priority patent/WO2022267036A1/zh
Publication of WO2022267036A1 publication Critical patent/WO2022267036A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/10Interfaces, programming languages or software development kits, e.g. for simulating neural networks

Definitions

  • the present application relates to the field of artificial intelligence, and more specifically, to a neural network model training method and device, and a data processing method and device.
  • Artificial intelligence is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
  • artificial intelligence is the branch of computer science that attempts to understand the nature of intelligence and produce a new class of intelligent machines that respond in ways similar to human intelligence.
  • Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
  • Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, basic AI theory, etc.
  • the neural network model is trained in a distributed parallel manner, and multiple computing nodes are trained in parallel to the neural network model, which can shorten the time required for training and improve training efficiency.
  • the neural network model on each computing node there is idle time for calculation, and the idle time for calculation leads to low overall training efficiency.
  • the present application provides a neural network model training method and device, a data processing method and device, which shorten the computing idle time of computing nodes after the computation of the back propagation (BP) algorithm is completed during the neural network model training process, Improve training efficiency and improve training performance.
  • BP back propagation
  • a method for training a neural network model based on a computing system includes a first computing node and a second computing node, the method includes: the first computing node acquires a training data set, and the training The data set includes a plurality of training data and label information corresponding to each training data; the first calculation node uses the initial neural network model to process the training data to obtain training information corresponding to the training data; the second A calculation node processes the difference between the training information corresponding to the training data and the label information corresponding to the training data by using the backpropagation BP algorithm to determine a first gradient data set, the first gradient data set including the first Gradient data and second gradient data, the first gradient data is used to indicate the gradient of the parameters in the first layer set, the first layer set includes one or more layers in the initial neural network model, the The second gradient data is used to indicate the gradient of the parameters in the second layer set, the second layer set includes the input layer of the initial neural network model; the first calculation node obtains the second
  • each computing node is in the process of using the BP algorithm to determine the parameter gradient of the initial neural network model, and sends the gradient of the parameters of the partial layers of the initial neural network model that have been calculated to other computing nodes, so that other computing nodes can adjust the parameters of the partial layers according to the gradients of the parameters of the partial layers that have received the initial neural network model after using the BP algorithm to calculate the gradient calculation in the initial neural network model, shortening
  • the calculation idle time of the nodes after the calculation using the BP algorithm is completed, which improves the training efficiency and improves the training performance.
  • the first computing node may adjust the parameters of the second layer set after adjusting the parameters of the first layer set.
  • the second data set includes fourth gradient data, where the fourth gradient data is used to indicate the gradient of parameters in the second layer set, and the first The computation node obtaining the second gradient data set calculated by the second computation node includes: during the process of the first computation node adjusting the parameters of the first layer set, the first computation node obtains the Fourth gradient data.
  • the first computing node can obtain it during the process of adjusting the parameters of the first layer set, so that the first computing node can be in the process of adjusting
  • the parameters of the second layer set can be adjusted immediately, which can eliminate the idle time of the first computing node after the calculation of the BP algorithm is completed during the training process of the neural network model, and further improve Improve training efficiency and improve training performance.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using It is obtained by processing the adjusted initial neural network model
  • j is a positive integer
  • the first computing node Since the first computing node acquires the gradient data sets of other computing nodes during the operation of the first computing node, it is not necessary to set a separate time for the transmission of the gradient data sets. Therefore, even if the calculation time required by each computing node to calculate the gradient data set has a certain difference, as long as the first computing node completes the calculation of the first gradient data set, it can receive the second gradient from other computing nodes. Part of the calculation results of the data set can immediately adjust the parameters corresponding to the part of the calculation results in the initial neural network model. Therefore, in the case of gradient data transmission in a synchronous manner, it is possible to reduce the impact on the training time caused by differences in the time required for each computing node to process different training data and their label information.
  • the first calculation node adjusts the parameters of the initial neural network model according to the first gradient data set and the second gradient data set, including:
  • the first computing node adjusts the parameters of the initial neural network model by using a gradient pruning algorithm.
  • the first calculation node adjusts the parameters of the initial neural network model according to the first gradient data set and the second gradient data set, including: After the first computing node determines the first gradient data set, the first computing node adjusts parameters of the initial neural network model.
  • a data processing method comprising: acquiring data to be processed; processing the data to be processed by using a neural network model, the neural network model is based on the first gradient data set of the first calculation node, And the second gradient data set is obtained by adjusting the parameters of the initial neural network model, wherein the adjustment of the parameters of the first layer set and the second layer set is to determine the first gradient data set at the first calculation node Afterwards, the first layer set includes one or more layers in the initial neural network model, the second layer set includes the input layer of the neural network model, and the first gradient data set is the The first calculation node uses the backpropagation BP algorithm to process the difference between the training information corresponding to the training data and the label information corresponding to the training data, and the training information corresponding to the training data is obtained by the first calculation obtained by processing the training data by the node using the initial neural network model, the first gradient data set includes first gradient data and second gradient data, and the first gradient data is used to indicate that the first layer
  • the gradient node uses the backpropagation
  • the second data set includes fourth gradient data, where the fourth gradient data is used to indicate the gradient of parameters in the second layer set, and the first Acquisition of the fourth gradient data by the computing node is performed during the process of the first computing node adjusting the parameters of the first layer set.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using It is obtained by processing the adjusted initial neural network model
  • j is a positive integer
  • the first calculation node adjusts the parameters of the initial neural network model by using a gradient pruning algorithm.
  • the first computing node adjusts the parameters of the initial neural network model after the first computing node determines the first gradient data set.
  • a training device for a neural network model includes: an acquisition module and a processing module.
  • the acquisition module is used to acquire a training data set, the training data set includes a plurality of training data and label information corresponding to each training data;
  • the processing module is used to perform the training data on the training data by using the initial neural network model Processing to obtain the training information corresponding to the training data;
  • the processing module is also used to process the difference between the training information corresponding to the training data and the label information corresponding to the training data by using the backpropagation BP algorithm,
  • the first gradient data set includes first gradient data and second gradient data, the first gradient data is used to indicate the gradient of the parameters in the first layer set, the first layer
  • the set includes one or more layers in the initial neural network model, the second gradient data is used to indicate the gradient of the parameters in the second set of layers, the second set of layers includes the input of the initial neural network model layer;
  • the obtaining module is also used to obtain the second gradient data set calculated by the second
  • the second data set includes fourth gradient data
  • the fourth gradient data is used to indicate the gradient of parameters in the second layer set
  • the acquiring module It is specifically used to acquire the fourth gradient data during the process of adjusting the parameters of the first layer set by the processing module.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using It is obtained by processing the adjusted initial neural network model
  • j is a positive integer
  • the processing module is configured to adjust parameters of the initial neural network model by using a gradient clipping algorithm.
  • the processing module is configured to, after the processing module determines the first gradient data set, adjust parameters of the initial neural network model.
  • a data processing device including: an acquisition module and a processing module.
  • the acquisition module is used to acquire the data to be processed; the processing module is used to process the data to be processed by using a neural network model, the neural network model is the first computing node according to the first gradient data set, and
  • the second gradient data set is obtained by adjusting the parameters of the initial neural network model, wherein the adjustment of the parameters of the first layer set and the second layer set is after the first computing node determines the first gradient data set
  • the first layer set includes one or more layers in the initial neural network model, the second layer set includes the input layer of the neural network model, and the first gradient data set is the
  • the first calculation node uses the backpropagation BP algorithm to process the difference between the training information corresponding to the training data and the label information corresponding to the training data, and the training information corresponding to the training data is the first calculation node obtained by processing the training data using the initial neural network model, the first gradient data set includes first gradient data and second gradient data, and the first gradient data is used to
  • the second data set includes fourth gradient data, where the fourth gradient data is used to indicate the gradient of parameters in the second layer set, and the first Acquisition of the fourth gradient data by the computing node is performed during the process of the first computing node adjusting the parameters of the first layer set.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using It is obtained by processing the adjusted initial neural network model
  • j is a positive integer
  • the first calculation node adjusts the parameters of the initial neural network model by using a gradient pruning algorithm.
  • the first computing node adjusts the parameters of the initial neural network model after the first computing node determines the first gradient data set.
  • an electronic device including a memory and a processor, the memory is used to store program instructions; when the program instructions are executed in the processor, the processor is used to execute the first aspect or the second The method described in the two aspects.
  • the processor in the fifth aspect above may include a central processing unit (central processing unit, CPU), or a combination of a CPU and a neural network processing processor.
  • CPU central processing unit
  • a computer-readable medium stores program code for execution by a device, where the program code includes a method for executing the method in the first aspect or the second aspect.
  • a computer program product containing instructions is provided, and when the computer program product is run on a computer, it causes the computer to execute the method in the first aspect or the second aspect above.
  • a chip in an eighth aspect, includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface, and executes the method in the first aspect or the second aspect above.
  • the chip may further include a memory, the memory stores instructions, the processor is configured to execute the instructions stored in the memory, and when the instructions are executed, the The processor is configured to execute the first aspect or the method in any one implementation manner of the first aspect.
  • the aforementioned chip may specifically be a field-programmable gate array (field-programmable gate array, FPGA) or an application-specific integrated circuit (application-specific integrated circuit, ASIC).
  • FPGA field-programmable gate array
  • ASIC application-specific integrated circuit
  • the method in the first aspect may specifically refer to the first aspect and the method in any of the various implementation manners in the first aspect.
  • FIG. 1 is a schematic structural diagram of a system architecture provided by an embodiment of the present application.
  • FIG. 2 is a schematic structural diagram of a convolutional neural network provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of another convolutional neural network provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a hardware structure of a chip provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • Fig. 6 is a schematic flowchart of a neural network model training method.
  • Fig. 7 is a schematic flowchart of a method for training a neural network model based on a computing system provided by an embodiment of the present application.
  • FIG. 8 is a schematic flowchart of a training method for a neural network model provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a computing system provided by an embodiment of the present application.
  • Fig. 10 is a schematic flowchart of a data processing method provided by an implementation example of the present application.
  • Fig. 11 is a schematic structural diagram of a neural network model training device provided by an embodiment of the present application.
  • Fig. 12 is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of a hardware structure of a data processing device according to an embodiment of the present application.
  • FIG. 14 is a schematic diagram of a hardware structure of a neural network model training device according to an embodiment of the present application.
  • a neural network can be composed of neural units, and a neural unit can refer to an operation unit that takes x s and an intercept 1 as input, and the output of the operation unit can be:
  • W s is the weight of x s
  • b is the bias of the neuron 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 the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting multiple above-mentioned single neural units, 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 with 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.
  • Deep neural network also known as multi-layer neural network
  • DNN can be understood as a neural network with multiple hidden layers.
  • DNN is divided according to the position of different layers, and the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer.
  • the first layer is the input layer
  • the last layer is the output layer
  • the layers in the middle are all hidden layers.
  • the layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
  • DNN looks very complicated, it is actually not complicated in terms of the work of each layer.
  • it is the following linear relationship expression: in, is the input vector, is the output vector, Is the offset vector, W is the weight matrix (also called coefficient), and ⁇ () is the activation function.
  • Each layer is just an input vector After such a simple operation to get the output vector Due to the large number of DNN layers, the coefficient W and the offset vector The number is also higher.
  • DNN The definition of these parameters in DNN is as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the fourth neuron of the second layer to the second neuron of the third layer is defined as The superscript 3 represents the layer number where the coefficient W is located, and the subscript corresponds to the output index 2 of the third layer and the input index 4 of the second layer.
  • the coefficient from the kth neuron of the L-1 layer to the jth neuron of the L layer is defined as
  • the input layer has no W parameter.
  • more hidden layers make the network more capable of describing complex situations in the real world. Theoretically speaking, a model with more parameters has a higher complexity and a greater "capacity", which means that it can complete more complex learning tasks.
  • Training the deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix formed by the vector W of many layers).
  • Convolutional neural network is a deep neural network with a convolutional structure.
  • the convolutional neural network contains a feature extractor composed of a convolutional layer and a subsampling layer, which can be regarded as a filter.
  • the convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network.
  • a neuron can only be connected to some adjacent neurons.
  • a convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units of the same feature plane share weights, and the shared weights here are convolution kernels. Shared weight can be understood as the way to extract data information is independent of location.
  • the convolution kernel can be initialized in the form of a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network.
  • the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
  • the forward propagation algorithm also known as the forward propagation algorithm, is an algorithm that performs calculations from front to back. Using the forward propagation algorithm, starting from the input layer, it calculates backward layer by layer until the operation reaches the output layer to obtain the output result. The forward propagation algorithm obtains the result of the output layer through a layer-by-layer operation from front to back.
  • the neural network can use the error back propagation (back propagation, BP) algorithm to correct 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, passing the input signal forward until the output will generate an error loss, and updating the parameters in the initial neural network model 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.
  • Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
  • machine learning and deep learning can symbolize and formalize intelligent information modeling, extraction, preprocessing, training, etc. of data.
  • Reasoning refers to the process of simulating human intelligent reasoning in a computer or intelligent system, and using formalized information to carry out machine thinking and solve problems according to reasoning control strategies.
  • the 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.
  • Distributed parallel training can also be called data parallel training.
  • a copy of the entire neural network model is kept on each computing node, and a different subset of the training data set is processed on each worker machine.
  • a large number of computing nodes are used to train the neural network model, and the output of each computing node is sorted out to obtain the trained neural network model.
  • Each computing node may be a computer node in a large-scale computer cluster network.
  • Each computing node can use the same computing process to iteratively process the training data set.
  • the calculation process includes the processing of training data by the initial neural network model, backpropagation, gradient aggregation and optimizer calculation.
  • the processing of the training data by the initial neural network model can be realized by means of forward propagation.
  • Backpropagation is used to determine the gradient of parameter sizes in the initial neural network model based on the error loss of the initial neural network model.
  • the gradient of the parameter size is the partial derivative of the loss function to that parameter.
  • Gradient aggregation is used to send the data obtained by the backpropagation of this computing node to other computing nodes, and receive the data obtained by backpropagation sent by other computing nodes.
  • the optimizer calculation is used to adjust the parameters of the initial neural network model according to the data obtained by the backpropagation of each computing node, so as to reduce the error loss.
  • the embodiment of the present application provides a system architecture 100 .
  • the data collection device 160 is used to collect training data.
  • the training data may include a plurality of training input data and a training identifier corresponding to each training input data.
  • the data collection device 160 After collecting the training data, the data collection device 160 stores the training data in the database 130 , and the training device 120 obtains the target model/rule 101 based on training data maintained in the database 130 .
  • the training device 120 obtains the target model/rule 101 based on the training data as follows.
  • the training device 120 processes the input training input data, and compares the output result with the training identification corresponding to the training input data until the training device 120 The difference between the output result of 120 and the training flag is less than a certain threshold, thus completing the training of the target model/rule 101 .
  • the above target model/rule 101 can be used to implement the data processing method of the embodiment of the present application.
  • the target model/rule 101 in the embodiment of the present application may specifically be a neural network.
  • the training data maintained in the database 130 may not all be collected by the data collection device 160, but may also be received from other devices.
  • the training device 120 does not necessarily perform the training of the target model/rules 101 based entirely on the training data maintained by the database 130, and it is also possible to obtain training data from the cloud or other places for model training. Limitations of the Examples.
  • the target model/rules 101 trained according to the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. Laptop, augmented reality (augmented reality, AR) AR/virtual reality (virtual reality, VR), vehicle terminal, etc., can also be a server or cloud, etc.
  • an execution device 110 is configured with an input/output (input/output, I/O) interface 112 for data interaction with an external device, and a user may input data to the I/O interface 112 through a client device 140, the described
  • the input data in this embodiment of the application may include: data to be processed input by the client device.
  • the preprocessing module 113 and the preprocessing module 114 are used to perform preprocessing according to the input data (such as data to be processed) received by the I/O interface 112.
  • the input data such as data to be processed
  • the execution device 110 When the execution device 110 preprocesses the input data, or in the calculation module 111 of the execution device 110 performs calculation and other related processing, the execution device 110 can call the data, codes, etc. in the data storage system 150 for corresponding processing , the correspondingly processed data and instructions may also be stored in the data storage system 150 .
  • the I/O interface 112 returns the processing result, such as the processing result of the data obtained above, to the client device 140, thereby providing it to the user.
  • the training device 120 can generate corresponding target models/rules 101 based on different training data for different goals or different tasks, and the corresponding target models/rules 101 can be used to achieve the above goals or complete above tasks, thereby providing the desired result to the user.
  • the user can manually specify the input data, and the manual specification can be operated through the interface provided by the I/O interface 112 .
  • the client device 140 can automatically send the input data to the I/O interface 112 . If the client device 140 is required to automatically send the input data to obtain the user's authorization, the user can set the corresponding authority 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 specific ways such as display, sound, and action.
  • the client device 140 can also be used as a data collection terminal, collecting the input data input to the I/O interface 112 as shown in the figure and the output results of the output I/O interface 112 as new sample data, and storing them in the database 130 .
  • the client device 140 may not be used for collection, but the I/O interface 112 directly uses the input data input to the I/O interface 112 as shown in the figure and the output result of the output I/O interface 112 as a new sample.
  • the data is stored in database 130 .
  • FIG. 1 is only a schematic diagram of a system architecture provided by the embodiment of the present application, and the positional relationship between 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 , and in other cases, the data storage system 150 may also be placed in the execution device 110 .
  • the target model/rule 101 is obtained according to the training of the training device 120.
  • the target model/rule 101 in the embodiment of the present application may be the neural network in the present application.
  • the neural network used in the embodiment of the present application can be For CNN, deep convolutional neural networks (deep convolutional neural networks, DCNN), recurrent neural network (recurrent neural network, RNN) and so on.
  • CNN is a very common neural network
  • a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning (deep learning) architecture. Multiple levels of learning are performed on the abstraction level.
  • CNN is a feed-forward artificial neural network in which individual neurons can respond to data input into it.
  • a convolutional neural network (CNN) 200 may include an input layer 210 , a convolutional/pooling layer 220 (where the pooling layer is optional), and a neural network layer 230 .
  • the input layer 210 can obtain the data to be processed, and pass the obtained data to be processed by the convolutional layer/pooling layer 220 and the subsequent neural network layer 230 to obtain the processing result of the data.
  • the internal layer structure of the CNN 200 in FIG. 2 will be described in detail below.
  • the convolutional layer/pooling layer 220 may include layers 221-226 as examples, for example: in one implementation, the 221st layer is a convolutional layer, the 222nd layer is a pooling layer, and the 223rd layer is a volume Layers, 224 are pooling layers, 225 are convolutional layers, and 226 are pooling layers; in another implementation, 221 and 222 are convolutional layers, 223 are pooling layers, and 224 and 225 are convolutional layers Layer, 226 is a pooling layer. That is, the output of the convolutional layer can be used as the input of the subsequent pooling layer, or as the input of another convolutional layer to continue the convolution operation.
  • the convolution layer 221 may include many convolution operators, which are also called kernels, and their role in data processing is equivalent to a filter for extracting specific information from the input data matrix.
  • the convolution operators are essentially Can be a weight matrix, which is usually predefined.
  • weight values in these weight matrices need to be obtained through a lot of training in practical applications, and each weight matrix formed by the weight values obtained through training can be used to extract information from the input data, so that the convolutional neural network 200 can make correct predictions .
  • the initial convolutional layer (such as 221) often extracts more general features, which can also be referred to as low-level features;
  • the features extracted by the later convolutional layers (such as 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
  • one layer of convolutional layers can be followed by one layer
  • the pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers.
  • the sole purpose of the pooling layer is to reduce the size of the data.
  • the convolutional neural network 200 After being processed by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as mentioned earlier, the convolutional layer/pooling layer 220 only extracts features and reduces the parameters brought by the input data. However, in order to generate the final output information (required class information or other relevant information), the convolutional neural network 200 needs to use the neural network layer 230 to generate one or a group of outputs with the required number of classes. Therefore, the neural network layer 230 may include multiple hidden layers (231, 232 to 23n as shown in FIG. 2 ) and an output layer 240, and the parameters contained in the multi-layer hidden layers may be based on specific task types. Relevant training data are obtained through pre-training, for example, the task type may include recognition, classification, and so on.
  • the output layer 240 which has a loss function similar to the classification cross entropy, and is specifically used to calculate the prediction error.
  • a convolutional neural network (CNN) 200 may include an input layer 210 , a convolutional/pooling layer 220 (where the pooling layer is optional), and a neural network layer 230 .
  • CNN convolutional neural network
  • FIG. 3 Compared with FIG. 2 , multiple convolutional layers/pooling layers in the convolutional layer/pooling layer 220 in FIG. 3 are parallelized, and the extracted features are input to the neural network layer 230 for processing.
  • the convolutional neural network shown in Figure 2 and Figure 3 is only an example of two possible convolutional neural networks for the data processing method of the embodiment of the application.
  • the application implements
  • the convolutional neural network used in the data processing method of the example can also exist in the form of other network models.
  • FIG. 4 is a hardware structure of a chip provided by an embodiment of the present application, and the chip includes a neural network processor 50 .
  • the chip can be set in the execution device 110 shown in FIG. 1 to complete the computing work of the computing module 111 .
  • the chip can also be set in the training device 120 shown in FIG. 1 to complete the training work of the training device 120 and output the target model/rule 101 .
  • the algorithms of each layer in the convolutional neural network shown in Figure 2 and Figure 3 can be implemented in the chip shown in Figure 4 .
  • the neural network processor NPU 50 is mounted on the main central processing unit (central processing unit, CPU) (host CPU) as a coprocessor, and the tasks are assigned by the main CPU.
  • the core part of the NPU is the operation circuit 503, and the controller 504 controls the operation circuit 503 to extract data in the memory (weight memory or input memory) and perform operations.
  • the operation circuit 503 includes multiple processing units (process engine, PE).
  • arithmetic circuit 503 is a two-dimensional systolic array.
  • the arithmetic circuit 503 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition.
  • arithmetic circuit 503 is a general-purpose matrix processor.
  • the operation circuit fetches the data corresponding to the matrix B from the weight memory 502, and caches it in each PE in the operation circuit.
  • the operation circuit fetches the data of matrix A from the input memory 501 and performs matrix operation with matrix B, and the obtained partial results or final results of the matrix are stored in the accumulator 508 .
  • the vector computing unit 507 can further process the output of the computing circuit, such as vector multiplication, vector addition, exponent operation, logarithmic operation, size comparison and so on.
  • the vector calculation unit 507 can be used for network calculations of non-convolution/non-FC layers in neural networks, such as pooling (pooling), batch normalization (batch normalization), local response normalization (local response normalization), etc. .
  • the vector computation unit can 507 store the vector of the processed output to the unified buffer 506 .
  • the vector calculation unit 507 may apply a non-linear function to the output of the operation circuit 503, such as a vector of accumulated values, to generate activation values.
  • the vector computation unit 507 generates normalized values, merged values, or both.
  • the vector of processed outputs can be used as an activation input to arithmetic circuitry 503, for example for use in subsequent layers in a neural network.
  • the unified memory 506 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 501 and/or unified memory 506 through the storage unit access controller 505 (direct memory access controller, DMAC), stores the weight data in the external memory into the weight memory 502, And store the data in the unified memory 506 into the external memory.
  • DMAC direct memory access controller
  • a bus interface unit (bus interface unit, BIU) 510 is configured to implement interaction between the main CPU, DMAC and instruction fetch memory 509 through the bus.
  • An instruction fetch buffer (instruction fetch buffer) 509 connected to the controller 504 is used to store instructions used by the controller 504;
  • the controller 504 is configured to invoke instructions cached in the memory 509 to control the operation process of the computing accelerator.
  • the unified memory 506, the input memory 501, the weight memory 502, and the instruction fetch memory 509 are all on-chip (On-Chip) memories
  • the external memory is a memory outside the NPU
  • the external memory can be a double data rate synchronous dynamic random Memory (double data rate synchronous dynamic random access memory, referred to as DDR SDRAM), high bandwidth memory (high bandwidth memory, HBM) or other readable and writable memory.
  • DDR SDRAM double data rate synchronous dynamic random Memory
  • HBM high bandwidth memory
  • each layer in the convolutional neural network shown in FIG. 2 and FIG. 3 can be performed by the operation circuit 503 or the vector calculation unit 507 .
  • the execution device 110 in Figure 1 introduced above can execute the various steps of the data processing method of the embodiment of the application, the CNN model shown in Figure 2 and Figure 3 and the chip shown in Figure 4 can also be used to execute the implementation of the application Each step of the data processing method of the example.
  • the neural network training method and the data processing method of the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
  • the embodiment of the present application provides a system architecture 300 .
  • the system architecture includes a local device 301, a local device 302, an execution device 110, and a data storage system 150, wherein the local device 301 and the local device 302 are connected to the execution device 110 through a communication network.
  • Execution device 110 may be implemented by one or more servers.
  • the execution device 110 may be used in cooperation with other computing devices, such as data storage, routers, load balancers and other devices.
  • Execution device 110 may be arranged on one physical site, or distributed on multiple physical sites.
  • the execution device 110 may use the data in the data storage system 150 or call the program code in the data storage system 150 to implement the data processing method of the embodiment of the present application.
  • Each local device can represent any computing device, such as a personal computer, computer workstation, smartphone, tablet, smart camera, smart car or other type of cellular phone, media consumption device, wearable device, set-top box, game console, etc.
  • Each user's local device can interact with the execution device 110 through any communication mechanism/communication standard communication network, and the communication network can be a wide area network, a local area network, a point-to-point connection, etc., or any combination thereof.
  • the communication network can be a wide area network, a local area network, a point-to-point connection, etc., or any combination thereof.
  • the local device 301 and the local device 302 obtain relevant parameters of the target neural network from the execution device 110, deploy the target neural network on the local device 301 and the local device 302, and use the target neural network to perform data classification Or identify and so on.
  • the target neural network can be directly deployed on the execution device 110, and the execution device 110 obtains the data to be processed from the local device 301 and the local device 302, and classifies the data to be processed or other types of data according to the target neural network deal with.
  • the aforementioned execution device 110 may also be a cloud device. In this case, the execution device 110 may be deployed on the cloud; or, the aforementioned execution device 110 may also be a terminal device. In this case, the execution device 110 may be deployed on the user terminal side. This is not limited.
  • neural network models are widely used in many fields such as image, video, and voice, showing the ability to surpass traditional methods.
  • the neural network model In the process of training a neural network model, as the complexity of the model increases, the number of samples to be processed increases. In order to reduce the training time of the neural network model, the neural network model can be trained in a distributed parallel training manner.
  • Fig. 6 is a schematic flowchart of a neural network model training method.
  • FIG. 6 shows the structure of a computing node 600 therein. It should be understood that each computing node may have the same structure.
  • each computing node can obtain a subset of the training data set.
  • the subset obtained by each computing node includes multiple training data and label information corresponding to each training data.
  • Computing node 600 includes a computing unit and a communication unit.
  • the computing unit includes an initial neural network model 610 , a BP 620 , and an optimizer 640 .
  • the calculation unit is used to realize the calculation function of the calculation node 600, which is also the calculation core of deep learning training.
  • the performance of the computing unit has an important impact on the training time of the neural network model.
  • the communication unit includes an aggregation (all reduce, AR) module 630.
  • the communication unit is used to implement information transmission between computing nodes.
  • the initial neural network model 610 is used to perform calculations such as forward propagation on the training data to obtain training information.
  • the BP 620 can use the backpropagation algorithm to perform calculations to obtain the gradient of the parameters in the initial neural network model.
  • BP 620 can calculate the error generated by each layer according to the training information and label information, as well as the parameter values of each layer in the initial neural network model 610. BP 620 can also calculate the partial derivative of the loss function to the parameters of each layer according to the error generated by each layer and the output of the layer during the processing of the training data by the initial neural network model.
  • the partial derivative of the loss function to the parameter is the gradient of the parameter.
  • Parameters for each layer can include weights and biases. Therefore, the partial derivative of the loss function to the parameters of each layer includes the partial derivative of the weight and the partial derivative of the bias.
  • AR 630 is used to transmit the gradient of parameters in the initial neural network model calculated by each computing node after the operation of BP 620 is completed.
  • AR 630 can send gradient data calculated by BP 620 to computing nodes, and can receive gradient data calculated by other computing nodes.
  • the gradient data sent by the AR 630 includes the gradient of each parameter in the initial neural network model 610.
  • the optimizer 640 is configured to, after the AR 630 receives the gradient data sent by each of the multiple computing units except the computing device 600, according to the gradient data determined by the multiple computing units, optimize the initial neural network
  • the parameters in the model 610 are adjusted to obtain an adjusted neural network model.
  • the adjusted neural network model can be used as the initial neural network model to process other training data.
  • a trained neural network model After each of the multiple computing nodes performs iterative processing on each training data and its corresponding label information, a trained neural network model can be obtained.
  • the calculation unit When the calculation result of the communication unit to the calculation unit is transmitted among the various calculation nodes, the calculation unit is in an idle state, resulting in low overall efficiency of the training process.
  • an embodiment of the present application provides a training method for a neural network model.
  • Fig. 7 is a schematic flowchart of a method for training a neural network model based on a computing system provided by an embodiment of the present application.
  • Training method 700 may be performed by training device 120 .
  • the training method 700 includes S710 to S750.
  • the computing system includes a first computing node and at least one second computing node.
  • the first computing node acquires a training data set, where the training data set includes a plurality of training data and label information corresponding to each training data.
  • each computing node performs parallel computing
  • the training time of the neural network model can be shortened and the training efficiency can be improved. Therefore, each computing node in the first computing node and the at least one second computing node can obtain the training data set.
  • the training data sets acquired by each computing node may be different.
  • the first computing node uses the initial neural network model to process the training data to obtain training information corresponding to the training data.
  • the initial neural network models in each computing node may have the same parameters.
  • the first calculation node processes the difference between the training information corresponding to the training data and the label information corresponding to the training data using the backpropagation BP algorithm to determine a first gradient data set, the first The gradient data set includes first gradient data and second gradient data, the first gradient data is used to indicate the gradient of the parameters in the first layer set, the first layer set includes one of the initial neural network models or A plurality of layers, the second gradient data is used to indicate the gradient of the parameters in the second layer set, the second layer set includes the input layer of the initial neural network model.
  • the difference between the training information corresponding to the training data and the labeled information can be represented by the loss value.
  • Different layer sets may include different layers of the initial neural network model. That is, the first set of layers does not include the input layer of the initial neural network model.
  • the parameter gradient of each layer is calculated in the reverse order of the operation of the initial neural network model.
  • the second gradient data is used to indicate the gradient of the parameters in the second layer set, and the second layer set includes the input layer of the neural network model.
  • the second set of layers may also include a preset number of layers after the input layer. Therefore, among the gradient data in the first gradient data set, the second gradient data is calculated last.
  • the first computing node acquires the second gradient data set calculated by the second computing node, the second gradient data set is used to indicate the gradient of the parameter of the initial neural network model, and the second gradient
  • the data set includes third gradient data, the third gradient data is used to indicate the gradient of the parameters in the first layer set, and the acquisition of the third gradient data by the first computing node is in the first It is performed during the process that the calculation node uses the BP algorithm to process the difference.
  • the first computing node acquires the third gradient data. It can be understood that, in the process of using the BP algorithm to process the difference, the first computing node starts to acquire the third gradient data, and acquires the third gradient data before using the BP algorithm to process the difference. Three gradient data.
  • the first computing node may receive the second gradient data set sent by the second computing node, and may also send the first gradient data set to the second computing node for adjustment of the initial neural network model by the second computing node.
  • the first computing node may receive the third gradient data sent by the second computing node, or may send the third gradient data to the second computing node first gradient data.
  • the first computing node adjusts the parameters of the initial neural network model according to the first gradient data set and the second gradient data set to obtain a trained neural network model, wherein the The first computing node adjusts the parameters of the first layer set and the second layer set after the first computing node determines the first gradient data set.
  • the first computing node adjusts parameters of the first layer set and the second layer set.
  • the first computing node may obtain the second gradient data set of each second computing node, and at S750, the first computing node may obtain the second gradient data set according to the first computing node A gradient data set and each second gradient data set are used to adjust the parameters of the initial neural network model.
  • the gradient data corresponding to the same layer set in each second gradient data set may be acquired by the first computing node in the same time period.
  • Each computing node in the computing system can serve as the first computing node, that is, each computing node can execute the method 700 .
  • each computing node performs processing using the BP algorithm to determine the parameter gradient of the initial neural network model, for the partial layers of the initial neural network model that have been calculated
  • the gradient of the parameters is sent to other computing nodes, so that other computing nodes can use the BP algorithm to calculate the gradient calculation in the initial neural network model, according to the gradient of the parameters of the partial layer that has received the initial neural network model, the partial layer
  • the parameters are adjusted to shorten the computing idle time of the computing nodes after the computation using the BP algorithm is completed during the training process of the neural network model, improve the training efficiency, and improve the training performance.
  • the second data set may include fourth gradient data.
  • the fourth gradient data is used to indicate gradients of parameters in the second layer set.
  • Obtaining the second gradient data set calculated by the second computing node by the first computing node may include: during the process of the first computing node adjusting the parameters of the first layer set, the first computing node obtains The fourth gradient data.
  • the acquisition of the fourth gradient data of each computing node by the first computing node is performed during the process of adjusting the parameters of the first layer set by the first computing node.
  • the first computing node can obtain it during the process of adjusting the parameters of the first layer set, so that the first computing node can be in the process of adjusting
  • the parameters of the second layer set can be adjusted immediately, which can eliminate the idle time of the first computing node after the calculation of the BP algorithm is completed during the training process of the neural network model, and further improve Improve training efficiency and improve training performance.
  • the first gradient data set may include a plurality of gradient data, and each gradient data may be used to indicate the gradient of a parameter in a layer set, and each layer set includes one or more layers in the initial neural network model. That is to say, the first gradient data set may also include other gradient data besides the first gradient data and the second gradient data.
  • the gradient data of the first gradient data set and the second gradient data set may be in one-to-one correspondence.
  • the corresponding gradient data in the first gradient data set and the second gradient data set are used to indicate the same layer set in the initial neural network model.
  • the first layer set can be set so that the time required for the first computing node to adjust the parameters of the first layer set is greater than or equal to the time required for the first computing node to obtain the fourth data. The time required for the data.
  • the parameter gradient of each layer is calculated in the reverse order of the operation of the initial neural network model.
  • a neural network model generally has a large number of layers.
  • the second set of layers can be set to include fewer layers, such as 1/2, 1/3, 1/5, 1/10, 1/20, 1/50 or even less of the total number of layers in the neural network model , thus avoiding the need for a large amount of time for the first computing node to obtain the fourth layer set, and avoiding that the time required for the first computing node to start adjusting the parameters of the initial neural network model layer set other than the second layer set is less than the first A case of calculating the time required for nodes to acquire the fourth layer set.
  • the first computing node after the first computing node determines the first gradient data set, the first computing node adjusts the parameters of the initial neural network model.
  • Each computing node can be used as the first computing node, and the method 700 is used to train the initial neural network model.
  • the adjusted initial neural network model can be used as the initial neural network model, and S720-S750 can be performed again to process other training data, thereby completing the adjustment of the parameters of the initial neural network model, and obtaining neural network model.
  • S720-S750 when the number of times of performing S720-S750 (that is, the number of iterations) reaches a preset value, or when the training information obtained by processing the training data with the initial neural network model and the label information corresponding to the training data When the difference gradually converges, S720-S750 is no longer performed.
  • each computing node can adjust the parameters of the initial neural network model in the same adjustment manner.
  • each computing node can transmit gradient data synchronously or asynchronously.
  • the first computing node uses the initial neural network model adjusted for j times to obtain training information during the process of acquiring and performing the j+1th iteration.
  • the second gradient data set calculated by the second computing node obtained by the first computing node is the latest gradient data set calculated by the second computing node using the BP algorithm.
  • each second gradient data set is obtained by processing the initial neural network model after j times of adjustment, where j is positive integer. That is to say, during the j+1th iteration of the first computing node, the acquired second gradient data set of each second computing node is obtained by performing j iterations of the second computing node after j It is obtained by processing the training data with the adjusted initial neural network model.
  • Parallel training of the initial neural network model in a synchronous manner can improve training efficiency and shorten training time.
  • the first computing node acquires the gradient data sets of other computing nodes during the operation of the first computing node, it is not necessary to set a separate time for the transmission of the gradient data sets. Therefore, even if the calculation time required by each computing node to calculate the gradient data set has a certain difference, as long as the first computing node completes the calculation of the first gradient data set in S730, it can receive the second calculation from other computing nodes.
  • the partial calculation results of the gradient data set can be immediately performed in S740.
  • the first computing node may use a gradient pruning algorithm to adjust parameters of the initial neural network model.
  • the first computing node may use a gradient pruning algorithm to perform gradient pruning on each gradient in the first gradient data set, and obtain a second gradient data set after gradient pruning.
  • the first computing node may also use a gradient pruning algorithm to perform gradient pruning on each gradient in the first gradient data set and the second gradient data set.
  • the initial neural network model can determine the aggregation gradient of each parameter in the initial neural network model according to the pruned first gradient data set and the second gradient data set, and adjust the parameters in the initial neural network model according to the aggregation gradient .
  • the first computing node can also determine the aggregation gradient of each parameter according to the gradient of each parameter in the first gradient data set and the second gradient data set, and then use the gradient pruning algorithm to trim the aggregation gradient, and use the adjusted aggregation gradient
  • the gradient adjusts the parameters of the initial neural network model.
  • FIG. 8 is a schematic flowchart of a training method for a neural network model provided by an embodiment of the present application.
  • the training method of the neural network model is executed by each computing node in the computing system.
  • Each computing node includes a computing unit and a communication unit. Computing units are used to perform calculations and processing.
  • the communication unit is used for communicating with other computing nodes, so as to realize the information transmission between various computing nodes.
  • FIG. 8 illustrates a training method of a neural network model by taking a processing system 800 utilized by a computing node in the computing system as an example.
  • the processing system 800 includes an initial neural network model, modules BP 821 to BP 824, modules AR 831 to AR 832, optimizers 841 to 842.
  • the initial neural network model is used to realize the function of the initial neural network model 610
  • the modules BP 821 to BP 824 are used to realize the function of BP 620
  • the modules AR 831 to AR 832 are used to realize the function of AR 630
  • the optimizer 842 is used to implement the function of the optimizer 640.
  • the computing node may obtain a training data set, and the training data set includes training data and label information corresponding to each training data.
  • Annotation information may also be referred to as a label.
  • Each training data can be marked manually to obtain a label corresponding to each training data.
  • the calculation unit uses the initial neural network model to process the training data to obtain training information corresponding to the training data.
  • the initial neural network model can use the forward propagation algorithm to process the training data.
  • the initial neural network model may include multiple layer sets, each layer set including one or more layers. Each layer set can be understood as an FP module.
  • Figure 8 takes the initial neural network model including modules FP 811 and FP 812 as an example for illustration.
  • the calculation unit uses the backpropagation algorithm to calculate the gradient of the parameters of each layer in the initial neural network model according to the training information and label information corresponding to the training data.
  • the computing unit can use multiple BP modules to perform backpropagation operations.
  • module BP 822 and module BP 824 are used to calculate the gradient of parameters.
  • module BP 821 can be used to calculate the resulting errors of various layers in FP 812.
  • the module BP 822 can be used to calculate the gradient of the parameters of each layer in the FP 812 according to the calculation result of the module BP 821.
  • Module BP 823 can be used to calculate the resulting errors of various layers in FP 811.
  • Module BP 824 can be used to calculate the gradient of the parameters of each layer in FP 811 according to the calculation result of module BP 823.
  • the communication unit can send the gradient of the parameters of each layer in the FP 812 to other computing nodes.
  • the computing capabilities of each computing node are similar, and the time required for each computing node to calculate the gradient of the parameters of each layer in FP 812 is basically the same.
  • each other calculation node can send the gradient of the parameters of each layer in the FP 812.
  • the communication unit in the calculation node can receive the gradient of the parameters of each layer in the FP 812 sent by other calculation nodes during the calculation process of the module BP 823 and/or the module BP 824.
  • the communication unit can be in an idle state during the calculation process of the module BP 821 and the module BP 822.
  • the communication unit may use the AR module to receive parameter gradients sent by other calculation units, and send parameter gradients to other calculation units. That is to say, the AR module is used to realize the aggregation of parameter gradients calculated by each computing node.
  • the communication unit can utilize the module AR 831 for aggregation of parameter gradients in FP 812.
  • the communication unit is used to realize the transmission of the gradient of the parameters of each layer in the FP 812 between each computing node. From time t1 to t2, each computing node synchronizes the parameter gradients in FP 812 calculated by each computing node, and each computing node obtains the parameter gradients in FP 812 calculated by other computing nodes.
  • the calculation unit adjusts the parameters of the initial neural network model.
  • the computing unit can utilize the optimizer 841 to adjust the parameters of the FP 812.
  • the optimizer can calculate the gradient average of a parameter in the model in the initial neural network calculated by each computing node. And adjust the value of the parameter in the model in the initial neural network according to the average gradient.
  • the communication unit can send the parameter gradient in FP 811 calculated by module BP 824 to other calculation nodes, and can also receive the FP calculated by other calculation nodes. Parameter gradients in 811.
  • the communication unit can utilize the module AR 832 for aggregation of parameter gradients in FP 812.
  • the calculation unit can use the optimizer 842 to adjust the parameters of the FP 811 after using the optimizer 841 to adjust the parameters of the FP 812.
  • each optimizer on the last module BP 824 of the backpropagation operation can be increased, that is to say, the operation of each optimizer is executed after the operation of the module BP 824.
  • the calculation unit serially uses modules FP, BP, and optimizer to perform various operations and processing. That is to say, the operation of each module is carried out serially.
  • the calculation node completes an iteration from time t0 to t3, uses the adjusted initial neural network model as the initial neural network model, repeats the processing from time t0 to t3, and completes the training of the neural network model.
  • the computing unit outputs the gradient of the parameters of each layer in the initial neural network model in the reverse order of the layers of the initial neural network model during the backpropagation operation.
  • the communication unit transmits the calculated parameter gradient to other calculation nodes, and receives the calculated parameter gradient sent by other calculation nodes.
  • the parameters of the neural network model can be adjusted according to the received parameter gradients calculated by each calculation unit, and at the same time, the communication unit continues to transmit the parameter gradients. Therefore, the idle time of the computing unit during each iteration can be reduced or even eliminated, the utilization rate of the computing unit can be improved, the time required for training the neural network model can be reduced, and the training efficiency can be improved.
  • processing time required by each module may be the same or different, and is determined by the actual processing time required.
  • the method provided by the embodiment of the present application is used to train the neural network model , the gradient data is transmitted while the calculation unit is performing operations, which can reduce or even eliminate the idle time of the calculation unit during each iteration without increasing the amount of calculation.
  • the optimizer or BP module can perform clipping gradient.
  • the initial neural network model cannot be effectively updated. If the gradient of the parameters is large, that is, the gradient explodes, it may cause the initial neural network model to skip the optimal solution and fail to converge.
  • gradient pruning can be performed.
  • Gradient clipping can also be called gradient clipping.
  • a preset range can be set, and when the gradient exceeds the preset range, the parameters of the neural network model are adjusted using the boundary value of the preset range as the gradient.
  • the gradient can be pruned according to the norm of the gradient.
  • the average value preset range or the variance preset range of the gradient of multiple parameters can be set. When the gradient of the multiple parameters does not meet the average value preset range or variance preset range, the multiple The gradient is pruned so that the pruned gradient satisfies the preset range of the mean value or the preset range of the variance.
  • the BP module can perform gradient pruning on the gradient of the calculated parameters.
  • the optimizer may calculate the gradient of the parameters obtained by each computing node, or the optimizer may average the gradients of the parameters calculated by each computing node, and perform gradient pruning on the average value of the gradients.
  • FIG. 9 is a schematic structural diagram of a computing system provided by an embodiment of the present application.
  • the computing system includes a plurality of computing nodes, and each computing node can perform the training method of the neural network model shown in FIG. 7 or 8, thereby realizing distributed parallel training.
  • the multiple computing nodes can be located in the same or different computing devices.
  • Each computing node can only be directly connected to some computing nodes.
  • the direct connection between computing nodes that is, the communication interface between computing nodes, can transmit information without forwarding the information through other computing nodes.
  • Information between computing nodes that are not directly connected can be forwarded by other computing nodes.
  • information transmission between computing nodes can be realized through ring aggregation (ring all reduce, ring AR).
  • Ring aggregation can also be called a ring.
  • Each computing node forms a ring, and each computing node is only directly connected to two adjacent computing nodes, so that the information transmission between computing nodes can be realized through the forwarding of information by computing nodes.
  • all computing nodes may be directly connected to each other.
  • One-way or two-way information transmission can be carried out through the communication interface of two computing nodes.
  • FIG. 10 is a schematic flowchart of a data processing method provided by an embodiment of the present application.
  • the data processing method 1000 includes S1010 to S1020.
  • the neural network model is obtained by adjusting the parameters of the initial neural network model by the first calculation node according to the first gradient data set and the second gradient data set wherein, the adjustment of the parameters of the first layer set and the second layer set is performed after the first calculation node determines the first gradient data set, and the first layer set includes the initial neural network model One or more layers in , the second set of layers includes the input layer of the neural network model.
  • the first gradient data set is obtained by the first calculation node using the backpropagation BP algorithm to process the difference between the training information corresponding to the training data and the label information corresponding to the training data, and the training
  • the training information corresponding to the data is obtained by processing the training data by the first computing node using the initial neural network model
  • the first gradient data set includes first gradient data and second gradient data
  • the first gradient data set includes first gradient data and second gradient data.
  • a gradient data is used to indicate the gradient of the parameters in the first layer set
  • the second gradient data is used to indicate the gradient of the parameters in the second layer set.
  • the second gradient data set is calculated by the second computing node, the second gradient data set is used to indicate the gradient of the parameters of the initial neural network model, the second gradient data set includes third gradient data, The third gradient data is used to indicate the gradient of the parameters in the first layer set, and the acquisition of the third gradient data by the first computing node is performed by using the BP algorithm on the first computing node The differences are processed during the process.
  • the second data set includes fourth gradient data
  • the fourth gradient data is used to indicate the gradient of the parameters in the second layer set
  • the first computing node is responsible for the fourth gradient data The acquisition of is performed when the first computing node adjusts the parameters of the first layer set.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using the initial neural network model after j times of adjustment
  • j is a positive integer
  • the first calculation node adjusts the parameters of the initial neural network model by using a gradient pruning algorithm.
  • the first computing node adjusts the parameters of the initial neural network model after the first computing node determines the first gradient data set.
  • the neural network model used to process the data to be processed may be obtained through the training method of the neural network model shown in FIG. 7 or FIG. 8 .
  • the data processing system, neural network model training method, and data processing method provided by the embodiment of the present application are described above in conjunction with FIG. 1 to FIG. 9 .
  • the device embodiment of the embodiment of the present application is described below in conjunction with FIG. 11 to FIG. 15 . It should be understood that the descriptions of the neural network model training method and the data processing method correspond to the descriptions of the device embodiments, therefore, reference may be made to the above description for parts not described in detail.
  • Fig. 11 is a schematic structural diagram of a neural network model training device provided by an embodiment of the present application.
  • the neural network model training apparatus 3000 may be located in the training device 120 shown in FIG. 1 or other devices.
  • the neural network model training device 3000 includes an acquisition module 3010 and a processing module 3020 .
  • the acquiring module 3010 is configured to acquire a training data set, where the training data set includes a plurality of training data and label information corresponding to each training data.
  • the processing module 3020 is configured to use the initial neural network model to process the training data to obtain training information corresponding to the training data.
  • the processing module 3020 is used to process the difference between the training information corresponding to the training data and the label information corresponding to the training data by using the backpropagation BP algorithm, so as to determine a first gradient data set, and the first gradient data set Including first gradient data and second gradient data, the first gradient data is used to indicate the gradient of the parameters in the first layer set, the first layer set includes one or more layers in the initial neural network model , the second gradient data is used to indicate the gradient of the parameters in the second layer set, the second layer set includes the input layer of the initial neural network model.
  • the obtaining module 3010 is configured to obtain a second gradient data set calculated by the second computing node, the second gradient data set is used to indicate the gradient of the parameters of the initial neural network model, and the second gradient data set includes third gradient data, where the third gradient data is used to indicate gradients of parameters in the first layer set.
  • the obtaining module 3010 is specifically configured to obtain the third gradient data during the process of processing the difference by the processing module using the BP algorithm.
  • the processing module 3020 is configured to adjust the parameters of the initial neural network model according to the first gradient data set and the second gradient data set, so as to obtain a trained neural network model.
  • the processing module 3020 is specifically configured to, after the processing module determines the first gradient data set, adjust parameters of the first layer set and the second layer set.
  • each second data set includes fourth gradient data used to indicate gradients of parameters in the second layer set.
  • the obtaining module 3010 is specifically configured to obtain the fourth gradient data during the process of adjusting the parameters of the first layer set by the processing module.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using the initial neural network model after j times of adjustment
  • j is a positive integer.
  • the processing module 3020 is configured to adjust the parameters of the initial neural network model by using a gradient clipping algorithm.
  • the processing module 3020 is configured to, after the processing module determines the first gradient data set, adjust parameters of the initial neural network model.
  • Fig. 12 is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
  • the data processing apparatus 2000 may be located in the execution device 110 shown in FIG. 1 or other devices.
  • the data processing device 2000 includes an acquisition module 2010 and a processing module 2020 .
  • the acquiring module 2010 is configured to acquire data to be processed.
  • the processing module 2020 is used to process the data to be processed by using the neural network model
  • the neural network model is the parameters of the initial neural network model by the first calculation node according to the first gradient data set and the second gradient data set obtained by performing adjustment, wherein the adjustment of the parameters of the first layer set and the second layer set is performed after the first calculation node determines the first gradient data set
  • the first layer set includes the initial One or more layers in a neural network model, the second set of layers comprising an input layer of the neural network model.
  • the first gradient data set is obtained by processing the difference between the training information corresponding to the training data and the label information corresponding to the training data by the first calculation node using the backpropagation BP algorithm, and the training data corresponds to
  • the training information of is obtained by processing the training data by the first computing node using the initial neural network model, the first gradient data set includes first gradient data and second gradient data, and the first gradient The data is used to indicate the gradient of the parameters in the first layer set, and the second gradient data is used to indicate the gradient of the parameters in the second layer set.
  • the second gradient data set is calculated by the second computing node, the second gradient data set is used to indicate the gradient of the parameters of the initial neural network model, the second gradient data set includes third gradient data, The third gradient data is used to indicate the gradient of the parameters in the first layer set, and the acquisition of the third gradient data by the first computing node is performed by using the BP algorithm on the first computing node The differences are processed during the process.
  • the second data set includes fourth gradient data
  • the fourth gradient data is used to indicate the gradient of the parameters in the second layer set
  • the first computing node is responsible for the fourth gradient data The acquisition of is performed when the first computing node adjusts the parameters of the first layer set.
  • the training information is obtained by processing the initial neural network model after j times of adjustment
  • the second gradient data set is obtained by the second computing node using the initial neural network model after j times of adjustment
  • j is a positive integer
  • the first calculation node adjusts the parameters of the initial neural network model by using a gradient pruning algorithm.
  • the first computing node adjusts the parameters of the initial neural network model after the first computing node determines the first gradient data set.
  • FIG. 13 is a schematic diagram of a hardware structure of a data processing device according to an embodiment of the present application.
  • the data processing device 4000 shown in FIG. 13 includes a memory 4001, a processor 4002, a communication interface 4003, and a bus 4004. Wherein, the memory 4001 , the processor 4002 , and the communication interface 4003 are connected to each other through a bus 4004 .
  • the memory 4001 can be ROM, static storage device and RAM.
  • the memory 4001 may store programs, and when the programs stored in the memory 4001 are executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute various steps of the data processing method of the embodiment of the present application.
  • the processor 4002 may be a general-purpose CPU, microprocessor, ASIC, GPU or one or more integrated circuits for executing related programs, so as to realize the functions required by the units in the data processing device of the embodiment of the present application, Or execute the data processing method in the method embodiment of the present application.
  • the processor 4002 may also be an integrated circuit chip with signal processing capabilities, for example, it may be the chip shown in FIG. 4 .
  • each step of the data processing method in the embodiment of the present application may be completed by an integrated logic circuit of hardware in the processor 4002 or instructions in the form of software.
  • the aforementioned processor 4002 may also be a general processor, DSP, ASIC, FPGA or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and combines its hardware to complete the functions required by the units included in the data processing device of the embodiment of the present application, or execute the data processing of the method embodiment of the present application method.
  • the communication interface 4003 implements communication between the apparatus 4000 and other devices or communication networks by using a transceiver device such as but not limited to a transceiver.
  • a transceiver device such as but not limited to a transceiver.
  • the image to be processed can be obtained through the communication interface 4003 .
  • the bus 4004 may include a pathway for transferring information between various components of the device 4000 (eg, memory 4001, processor 4002, communication interface 4003).
  • FIG. 14 is a schematic diagram of a hardware structure of a neural network model training device according to an embodiment of the present application. Similar to the above-mentioned device 4000 , the neural network model training device 5000 shown in FIG. 14 includes a memory 5001 , a processor 5002 , a communication interface 5003 and a bus 5004 . Wherein, the memory 5001 , the processor 5002 , and the communication interface 5003 are connected to each other through a bus 5004 .
  • the initial neural network model can be trained by the neural network model training apparatus 5000 shown in FIG. 14 , and the trained neural network model can be used to execute the data processing method of the embodiment of the present application.
  • the device shown in FIG. 14 can obtain the training data set and the initial neural network model required for training from the outside through the communication interface 5003, and then the processor performs training of the neural network model according to the training data set and the initial neural network model.
  • the device 4000 and device 5000 may also include other devices.
  • the apparatus 4000 and the apparatus 5000 may also include hardware devices for implementing other additional functions.
  • the device 4000 and the device 5000 may also only include the devices necessary to realize the embodiment of the present application, and do not necessarily include all the devices shown in FIG. 13 and FIG. 14 .
  • the processor in the embodiment of the present application may be a central processing unit (central processing unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the memory in the embodiments of the present application may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory can be random access memory (RAM), which acts as external cache memory.
  • RAM random access memory
  • static random access memory static random access memory
  • DRAM dynamic random access memory
  • DRAM synchronous dynamic random access memory Access memory
  • SDRAM synchronous dynamic random access memory
  • double data rate synchronous dynamic random access memory double data rate SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • serial link DRAM SLDRAM
  • direct memory bus random access memory direct rambus RAM, DR RAM
  • the above-mentioned embodiments may be implemented in whole or in part by software, hardware, firmware or other arbitrary combinations.
  • the above-described embodiments may be implemented in whole or in part in the form of computer program products.
  • the computer program product comprises one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part.
  • the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server, or data center Transmission to another website site, computer, server or data center by wired (such as infrared, wireless, microwave, etc.).
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center that includes one or more sets of available media.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media.
  • the semiconductor medium may be a solid state drive.
  • At least one means one or more, and “multiple” means two or more.
  • At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items.
  • at least one item (piece) of a, b, or c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, c can be single or multiple .
  • sequence numbers of the above-mentioned processes do not mean the order of execution, and the execution order of the processes should be determined by their functions and internal logic, and should not be used in the embodiments of the present application.
  • the implementation process constitutes any limitation.
  • the disclosed systems, devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disc and other media that can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

本申请公开了人工智能领域中的一种神经网络模型训练方法与装置、数据处理方法与装置。神经网络模型训练方法包括:第一计算节点在利用反向传播BP算法对初始神经网络模型的参数进行梯度计算的过程中,获取第二计算节点已经计算完成的初始神经网络模型的部分层的参数的梯度,从而可以在梯度计算完成之后,根据已经接收的部分层的参数的梯度,对该部分层进行参数的调整,缩短第一计算节点在梯度计算之后的运算空闲时间,提高提升训练效率,提升训练性能。

Description

神经网络模型训练方法和装置、数据处理方法和装置 技术领域
本申请涉及人工智能领域,更具体地,涉及一种神经网络模型训练方法和装置、数据处理方法和装置。
背景技术
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式作出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。人工智能领域的研究包括机器人,自然语言处理,计算机视觉,决策与推理,人机交互,推荐与搜索,AI基础理论等。
利用分布式并行的方式训练神经网络模型,多个计算节点并行神经网络模型的训练,进行能够缩短训练所需的时间,提高训练效率。在各个计算节点进行神经网络模型的训练过程中,存在运算的空闲时间,运算空闲时间导致整体的训练效率较低。
发明内容
本申请提供一种神经网络模型训练方法和装置、数据处理方法和装置,缩短在神经网络模型训练过程中计算节点在利用反向传播(back propagation,BP)算法的计算完成之后的运算空闲时间,提高提升训练效率,提升训练性能。
第一方面,提供一种基于计算系统的神经网络模型训练方法,所述计算系统包括第一计算节点和第二计算节点,该方法包括:所述第一计算节点获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息;所述第一计算节点利用初始神经网络模型对所述训练数据进行处理,以得到所述训练数据对应的训练信息;所述第一计算节点利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层;所述第一计算节点获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的;所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初 始神经网络模型的参数进行调整,以得到训练后的神经网络模型,其中,所述第一计算节点对所述第一层集合和所述第二层集合的参数的调整在所述第一计算节点确定所述第一梯度数据集合之后进行的。
在并行进行神经网络模型的计算系统中,各个计算节点在利用BP算法进行处理以确定初始神经网络模型的参数梯度的过程中,对于已经计算完成初始神经网络模型的部分层的参数的梯度发送至其他计算节点,从而,其他计算节点可以在利用BP算法计算初始神经网络模型中的梯度计算之后,根据已经接收初始神经网络模型的部分层的参数的梯度,对该部分层的参数进行调整,缩短在神经网络模型训练过程中计算节点在利用BP算法的计算完成之后的运算空闲时间,提高提升训练效率,提升训练性能。
应当理解,第一计算节点可以在对第一层集合的参数进行调整之后,对第二层集合的参数进行调整。
结合第一方面,在一些可能的实现方式中,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点获取所述第二计算节点计算的第二梯度数据集合,包括:在所述第一计算节点对所述第一层集合的参数进行调整的过程中,所述第一计算节点获取所述第四梯度数据。
对于第二计算节点对于利用BP算法的计算过程中最后得到的第四梯度数据,第一计算节点可以对第一层集合的参数进行调整的过程中进行获取,从而,第一计算节点可以在对第一层集合的参数进行调整之后,立即开始对第二层集合的参数的调整,能够消除在神经网络模型训练过程中第一计算节点在利用BP算法的计算完成之后的运算空闲时间,进一步提高提升训练效率,提升训练性能。
结合第一方面,在一些可能的实现方式中,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
由于第一计算节点对其他计算节点梯度数据集合的获取是在第一计算节点的进行运算的过程中进行的,并不需要为梯度数据集合的传输设置单独的时间。因此,即使各个计算节点对梯度数据集合进行计算所需的计算时间具有一定的差异,只要在第一计算节点完成对第一梯度数据集合的计算之前,能够收到其他各个计算节点对第二梯度数据集合的部分计算结果,就能够立即对初始神经网络模型中该部分计算结果对应的参数进行调整。因此,在采用同步的方式进行梯度数据传输的情况下,可以降低各个计算节点对不同训练数据及其标注信息进行处理所需时间的差异对训练时间造成的影响。
结合第一方面,在一些可能的实现方式中,所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,包括:所述第一计算节点利用梯度修剪算法,对所述初始神经网络模型的参数进行调整。
通过梯度修剪,可以避免梯度消失和/或梯度爆炸情况的发生。
结合第一方面,在一些可能的实现方式中,所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,包括:在所述第一计算节点确定所述第一梯度数据集合之后,所述第一计算节点对所述初始神经网络模型的参数的进行调整。
从而,无需确定第一计算节点获取第四数据所需的时间,就能够尽可能减小第一计算 节点在神经网络模型训练过程中的运算空闲时间,较为简便。
第二方面,提供一种数据处理方法,该方法包括:获取待处理数据;利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层,所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度,所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
结合第二方面,在一些可能的实现方式中,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算节点对所述第一层集合的参数进行调整的过程中进行的。
结合第二方面,在一些可能的实现方式中,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
结合第二方面,在一些可能的实现方式中,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
结合第二方面,在一些可能的实现方式中,所述第一计算节点对所述初始神经网络模型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
第三方面,提供一种神经网络模型训练装置,所述装置包括:获取模块和处理模块。所述获取模块用于,获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息;所述处理模块用于,利用初始神经网络模型对所述训练数据进行处理,以得到所述训练数据对应的训练信息;所述处理模块还用于,利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层;所述获取模块还用于,获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述获取模块具体用于,在所述处理模块利用所述BP算法对 所述差异进行处理的过程中,获取所述第三梯度数据;所述处理模块还用于,根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,以得到训练后的神经网络模型,所述处理模块具体用于,在所述处理模块确定所述第一梯度数据集合之后,对所述第一层集合和所述第二层集合的参数进行调整。
结合第三方面,在一些可能的实现方式中,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述获取模块具体用于,在所述处理模块对所述第一层集合的参数进行调整的过程中,获取所述第四梯度数据。
结合第三方面,在一些可能的实现方式中,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
结合第三方面,在一些可能的实现方式中,所述处理模块用于,利用梯度裁剪算法,对所述初始神经网络模型的参数进行调整。
结合第三方面,在一些可能的实现方式中,所述处理模块用于,在所述处理模块确定所述第一梯度数据集合之后,对所述初始神经网络模型的参数的进行调整。
第四方面,提供一种数据处理装置,包括:获取模块和处理模块。所述获取模块用于,获取待处理数据;所述处理模块用于,利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层,所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度,所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
结合第四方面,在一些可能的实现方式中,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算节点对所述第一层集合的参数进行调整的过程中进行的。
结合第四方面,在一些可能的实现方式中,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
结合第四方面,在一些可能的实现方式中,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
结合第四方面,在一些可能的实现方式中,所述第一计算节点对所述初始神经网络模 型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
第五方面,提供一种电子设备,包括存储器和处理器,所述存储器用于存储程序指令;当所述程序指令在所述处理器中执行时,所述处理器用于执行第一方面或第二方面所述的方法。
上述第五方面中的处理器既可以包括中央处理器(central processing unit,CPU),也可以包括CPU与神经网络运算处理器的组合。
第六方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面或第二方面中的方法。
第七方面,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述第一方面或第二方面中的方法。
第八方面,提供一种芯片,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,执行上述第一方面或第二方面中的方法。
可选地,作为一种实现方式,所述芯片还可以包括存储器,所述存储器中存储有指令,所述处理器用于执行所述存储器上存储的指令,当所述指令被执行时,所述处理器用于执行第一方面或第一方面中的任意一种实现方式中的方法。
上述芯片具体可以是现场可编程门阵列(field-programmable gate array,FPGA)或者专用集成电路(application-specific integrated circuit,ASIC)。
应理解,本申请中,第一方面的方法具体可以是指第一方面以及第一方面中各种实现方式中的任意一种实现方式中的方法。
附图说明
图1是本申请实施例提供的一种系统架构的结构示意图。
图2是本申请实施例提供的一种卷积神经网络的结构示意图。
图3是本申请实施例提供的另一种卷积神经网络的结构示意图。
图4是本申请实施例提供的一种芯片的硬件结构示意图。
图5是本申请实施例提供的一种系统架构的示意图。
图6是一种神经网络模型训练方法的示意性流程图。
图7是本申请实施例提供的一种基于计算系统的神经网络模型的训练方法的示意性流程图。
图8是本申请实施例提供的一种神经网络模型的训练方法的示意性流程图。
图9是本申请实施例提供的一种计算系统的示意性结构图。
图10是本申请实施实例提供的一种数据处理方法的示意性流程图。
图11是本申请实施例提供的一种神经网络模型训练装置的示意性结构图。
图12是本申请实施例提供的一种数据处理装置的示意性结构图。
图13是本申请实施例的数据处理装置的硬件结构示意图。
图14是本申请实施例的神经网络模型训练装置的硬件结构示意图。
具体实施方式
下面将结合附图,对本申请中的技术方案进行描述。下面将结合本申请实施例中的附 图,对本申请实施例中的技术方案进行描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例可能涉及的神经网络的相关术语和概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以x s和截距1为输入的运算单元,该运算单元的输出可以为:
Figure PCTCN2021102480-appb-000001
其中,s=1、2、……n,n为大于1的自然数,W s为x s的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
(2)深度神经网络
深度神经网络(deep neural network,DNN),也称多层神经网络,可以理解为具有多层隐含层的神经网络。按照不同层的位置对DNN进行划分,DNN内部的神经网络可以分为三类:输入层,隐含层,输出层。一般来说第一层是输入层,最后一层是输出层,中间的层数都是隐含层。层与层之间是全连接的,也就是说,第i层的任意一个神经元一定与第i+1层的任意一个神经元相连。
虽然DNN看起来很复杂,但是就每一层的工作来说,其实并不复杂,简单来说就是如下线性关系表达式:
Figure PCTCN2021102480-appb-000002
其中,
Figure PCTCN2021102480-appb-000003
是输入向量,
Figure PCTCN2021102480-appb-000004
是输出向量,
Figure PCTCN2021102480-appb-000005
是偏移向量,W是权重矩阵(也称系数),α()是激活函数。每一层仅仅是对输入向量
Figure PCTCN2021102480-appb-000006
经过如此简单的操作得到输出向量
Figure PCTCN2021102480-appb-000007
由于DNN层数多,系数W和偏移向量
Figure PCTCN2021102480-appb-000008
的数量也比较多。这些参数在DNN中的定义如下所述:以系数W为例:假设在一个三层的DNN中,第二层的第4个神经元到第三层的第2个神经元的线性系数定义为
Figure PCTCN2021102480-appb-000009
上标3代表系数W所在的层数,而下标对应的是输出的第三层索引2和输入的第二层索引4。
综上,第L-1层的第k个神经元到第L层的第j个神经元的系数定义为
Figure PCTCN2021102480-appb-000010
需要注意的是,输入层是没有W参数的。在深度神经网络中,更多的隐含层让网络更能够刻画现实世界中的复杂情形。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。
(3)卷积神经网络
卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经 网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取数据信息的方式与位置无关。卷积核可以以随机大小的矩阵的形式初始化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。
(4)损失函数
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断地调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。
(5)前向传播算法
前向传播算法,也可以称为正向传播算法,是由前向后进行计算的算法。利用前向传播算法,从输入层开始,一层层向后计算,直到运算到输出层,得到输出结果。前向传播算法通过一层层从前向后的运算,得到输出层结果。
(6)反向传播算法
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。
(7)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(8)分布式并行训练
分布式并行训练也可以称为数据并行训练,在每个计算节点上保留整个神经网络模型的副本,在每个工作机器上处理训练数据集的不同子集。利用大量计算节点进行神经网络 模型的训练,对各个计算节点的输出进行整理,可以得到训练后的神经网络模型。每个是计算节点可以是大规模计算机集群组网中的一个计算机节点。
各个计算节点可以采用相同的计算流程对训练数据集合进行迭代处理。该计算流程包括初始神经网络模型对训练数据的处理、反向传播、梯度聚合和优化器计算。
初始神经网络模型对训练数据的处理可以采用前向传播的方式实现。
反向传播用于根据初始神经网络模型的误差损失确定初始神经网络模型中参数大小的梯度。参数大小的梯度即损失函数对该参数的偏导。
梯度聚合用于将本计算节点反向传播得到的数据发送至其他计算节点,并接收其他各个计算节点发送的反向传播得到的数据。
优化器计算用于根据各个计算节点反向传播得到的数据,调整初始神经网络模型的参数,以降低误差损失。
如图1所示,本申请实施例提供了一种系统架构100。在图1中,数据采集设备160用于采集训练数据。针对本申请实施例的数据处理方法来说,训练数据可以包括多个训练输入数据和每个训练输入数据对应的训练标识。
在采集到训练数据之后,数据采集设备160将这些训练数据存入数据库130,训练设备120基于数据库130中维护的训练数据训练得到目标模型/规则101。
下面对训练设备120基于训练数据得到目标模型/规则101进行描述,训练设备120对输入的训练输入数据进行处理,将输出的结果与该训练输入数据对应的训练标识进行对比,直到根据训练设备120输出的结果与该训练标识的差值小于一定的阈值,从而完成目标模型/规则101的训练。
上述目标模型/规则101能够用于实现本申请实施例的数据处理方法。本申请实施例中的目标模型/规则101具体可以为神经网络。需要说明的是,在实际的应用中,所述数据库130中维护的训练数据不一定都来自于数据采集设备160的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备120也不一定完全基于数据库130维护的训练数据进行目标模型/规则101的训练,也有可能从云端或其他地方获取训练数据进行模型训练,上述描述不应该作为对本申请实施例的限定。
根据训练设备120训练得到的目标模型/规则101可以应用于不同的系统或设备中,如应用于图1所示的执行设备110,所述执行设备110可以是终端,如手机终端,平板电脑,笔记本电脑,增强现实(augmented reality,AR)AR/虚拟现实(virtual reality,VR),车载终端等,还可以是服务器或者云端等。在图1中,执行设备110配置输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:客户设备输入的待处理数据。
预处理模块113和预处理模块114用于根据I/O接口112接收到的输入数据(如待处理数据)进行预处理,在本申请实施例中,也可以没有预处理模块113和预处理模块114(也可以只有其中的一个预处理模块),而直接采用计算模块111对输入数据进行处理。
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模块111执行计算等相关的处理过程中,执行设备110可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统150中。
最后,I/O接口112将处理结果,如上述得到的数据的处理结果返回给客户设备140,从而提供给用户。
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练数据生成相应的目标模型/规则101,该相应的目标模型/规则101即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。
在图1中所示情况下,用户可以手动给定输入数据,该手动给定可以通过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。
值得注意的是,图1仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图1中,数据存储系统150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储系统150置于执行设备110中。
如图1所示,根据训练设备120训练得到目标模型/规则101,该目标模型/规则101在本申请实施例中可以是本申请中的神经网络,具体的,本申请实施例使用神经网络可以为CNN,深度卷积神经网络(deep convolutional neural networks,DCNN),循环神经网络(recurrent neural network,RNN)等等。
由于CNN是一种非常常见的神经网络,下面结合图2重点对CNN的结构进行详细的介绍。如上文的基础概念介绍所述,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入其中的数据作出响应。
本申请实施例的数据处理方法具体采用的神经网络的结构可以如图2所示。在图2中,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及神经网络层230。其中,输入层210可以获取待处理数据,并将获取到的待处理数据交由卷积层/池化层220以及后面的神经网络层230进行处理,可以得到数据的处理结果。下面对图2中的CNN 200中内部的层结构进行详细的介绍。
卷积层/池化层220:
卷积层:
如图2所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另一个卷 积层的输入以继续进行卷积操作。
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在数据处理中的作用相当于一个从输入数据矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义。
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入数据中提取信息,从而使得卷积神经网络200进行正确的预测。
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。
池化层:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图2中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在数据处理过程中,池化层的唯一目的就是减少数据的空间大小。
神经网络层230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前所述,卷积层/池化层220只会提取特征,并减少输入数据带来的参数。然而为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需要利用神经网络层230来生成一个或者一组所需要的类的数量的输出。因此,在神经网络层230中可以包括多层隐含层(如图2所示的231、232至23n)以及输出层240,该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括识别、分类等等。
在神经网络层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整个卷积神经网络200的前向传播(如图2由210至240方向的传播为前向传播)完成,反向传播(如图2由240至210方向的传播为反向传播)就会开始更新前面提到的各层的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。
本申请实施例的数据处理方法具体采用的神经网络的结构可以如图3所示。在图3中,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及神经网络层230。与图2相比,图3中的卷积层/池化层220中的多个卷积层/池化层并行,将分别提取的特征均输入给神经网络层230进行处理。
需要说明的是,图2和图3所示的卷积神经网络仅作为一种本申请实施例的数据处理方法的两种可能的卷积神经网络的示例,在具体的应用中,本申请实施例的数据处理方法所采用的卷积神经网络还可以以其他网络模型的形式存在。
图4为本申请实施例提供的一种芯片的硬件结构,该芯片包括神经网络处理器50。 该芯片可以被设置在如图1所示的执行设备110中,用以完成计算模块111的计算工作。该芯片也可以被设置在如图1所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则101。如图2和图3所示的卷积神经网络中各层的算法均可在如图4所示的芯片中得以实现。
神经网络处理器NPU 50作为协处理器挂载到主中央处理器(central processing unit,CPU)(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路503,控制器504控制运算电路503提取存储器(权重存储器或输入存储器)中的数据并进行运算。
在一些实现中,运算电路503内部包括多个处理单元(process engine,PE)。在一些实现中,运算电路503是二维脉动阵列。运算电路503还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路503是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器502中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器501中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)508中。
向量计算单元507可以对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元507可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。
在一些实现中,向量计算单元能507将经处理的输出的向量存储到统一缓存器506。例如,向量计算单元507可以将非线性函数应用到运算电路503的输出,例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元507生成归一化的值、合并值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路503的激活输入,例如用于在神经网络中的后续层中的使用。
统一存储器506用于存放输入数据以及输出数据。
权重数据直接通过存储单元访问控制器505(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器501和/或统一存储器506、将外部存储器中的权重数据存入权重存储器502,以及将统一存储器506中的数据存入外部存储器。
总线接口单元(bus interface unit,BIU)510,用于通过总线实现主CPU、DMAC和取指存储器509之间进行交互。
与控制器504连接的取指存储器(instruction fetch buffer)509,用于存储控制器504使用的指令;
控制器504,用于调用指存储器509中缓存的指令,实现控制该运算加速器的工作过程。
一般地,统一存储器506,输入存储器501,权重存储器502以及取指存储器509均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,简称DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。
其中,图2和图3所示的卷积神经网络中各层的运算可以由运算电路503或向量计算单元507执行。
上文中介绍的图1中的执行设备110能够执行本申请实施例的数据处理方法的各个步骤,图2和图3所示的CNN模型和图4所示的芯片也可以用于执行本申请实施例的数据处理方法的各个步骤。下面结合附图对本申请实施例的神经网络训练的方法和本申请实施例的数据处理方法进行详细的介绍。
如图5所示,本申请实施例提供了一种系统架构300。该系统架构包括本地设备301、本地设备302以及执行设备110和数据存储系统150,其中,本地设备301和本地设备302通过通信网络与执行设备110连接。
执行设备110可以由一个或多个服务器实现。可选的,执行设备110可以与其它计算设备配合使用,例如:数据存储器、路由器、负载均衡器等设备。执行设备110可以布置在一个物理站点上,或者分布在多个物理站点上。执行设备110可以使用数据存储系统150中的数据,或者调用数据存储系统150中的程序代码来实现本申请实施例的数据处理的方法。
用户可以操作各自的用户设备(例如本地设备301和本地设备302)与执行设备110进行交互。每个本地设备可以表示任何计算设备,例如个人计算机、计算机工作站、智能手机、平板电脑、智能摄像头、智能汽车或其他类型蜂窝电话、媒体消费设备、可穿戴设备、机顶盒、游戏机等。
每个用户的本地设备可以通过任何通信机制/通信标准的通信网络与执行设备110进行交互,通信网络可以是广域网、局域网、点对点连接等方式,或它们的任意组合。
在一种实现方式中,本地设备301、本地设备302从执行设备110获取到目标神经网络的相关参数,将目标神经网络部署在本地设备301、本地设备302上,利用该目标神经网络进行数据分类或者识别等等。
在另一种实现中,执行设备110上可以直接部署目标神经网络,执行设备110通过从本地设备301和本地设备302获取待处理数据,并根据目标神经网络对待处理数据进行分类或者其他类型的数据处理。
上述执行设备110也可以为云端设备,此时,执行设备110可以部署在云端;或者,上述执行设备110也可以为终端设备,此时,执行设备110可以部署在用户终端侧,本申请实施例对此并不限定。
目前,神经网络模型广泛应用到了图像、视频、语音等多个领域,展现出超越传统方法的能力。
在训练神经网络模型的过程中,随着模型复杂度增大,所需处理的样本量增加。为了降低神经网络模型的训练时间,可以利用分布式并行训练的方式进行神经网络模型的训练。
图6是一种神经网络模型训练方法的示意性流程图。
利用分布式并行训练的方式进行神经网络模型的训练的过程中,多个计算节点并行进行数据处理。图6示出了其中计算节点600的结构。应当理解,各个计算节点可以具有相同的结构。
在多个计算节点中,每个计算节点可以获取训练数据集合的子集。每个计算节点获取 的子集包括多个训练数据和每个训练数据对应的标注信息。
计算节点600包括计算单元和通信单元。计算单元包括初始神经网络模型610、BP620、优化器640。计算单元用于实现计算节点600的运算功能,这也是深度学习训练的计算核心。计算单元的性能对神经网络模型的训练时间产生重要影响。
通信单元包括聚合(all reduce,AR)模块630。通信单元用于实现各个计算节点间的信息传输。
将训练数据输入初始神经网络模型610,以得到训练信息。初始神经网络模型610用于对训练数据进行前向传播等计算,以得到训练信息。
将训练信息和标注信息输入BP 620。BP 620可以利用反向传播算法进行运算,得到初始神经网络模型中参数的梯度。
具体地,BP 620可以根据训练信息和标注信息,以及初始神经网络模型610中各个层的参数值,计算各个层的产生的误差。BP 620还可以根据每个层产生的误差以及初始神经网络模型对训练数据进行处理过程中该层的输出,计算损失函数对每个层的参数的偏导。损失函数对参数的偏导,即为参数的梯度。
每个层的参数可以包括权重和偏置。因此,损失函数对每个层的参数的偏导包括权重的偏导和偏置的偏导。
AR 630用于,在BP 620的运算完成之后,对各个计算节点计算得到的初始神经网络模型中参数的梯度进行传输。AR 630可以向计算节点发送BP 620计算得到的梯度数据,并可以接收其他各个计算节点计算得到的梯度数据。AR 630发送的梯度数据包括初始神经网络模型610中各个参数的梯度。
优化器640用于,在AR 630接收到该多个计算单元中除计算设备600之外的其他每个计算单元发送的梯度数据后,根据该多个计算单元确定的梯度数据,对初始神经网络模型610中的参数进行调整,以得到调整后的神经网络模型。
调整后的神经网络模型可以作为初始神经网络模型,对其他训练数据进行处理。
经过该多个计算节点中的每个计算节点对各个训练数据及其对应的标注信息的迭代处理,可以得到训练后的神经网络模型。
在通信单元对计算单元的计算结果在各个计算节点之间进行传输时,计算单元处于空闲状态,导致训练过程整体的效率较低。
为了解决上述问题,本申请实施例提供了一种神经网络模型的训练方法。
图7是本申请实施例提供的一种基于计算系统的神经网络模型的训练方法的示意性流程图。
训练方法700可以由训练设备120执行。训练方法700包括S710至S750。
所述计算系统包括第一计算节点和至少一个第二计算节点。
在S710,所述第一计算节点获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息。
在各个计算节点进行并行运算的情况下,可以缩短神经网络模型的训练时间,提高训练的效率。因此,第一计算节点与至少一个第二计算节点中的每个计算节点可以获取训练数据集合。每个计算节点获取的训练数据集合可以不同。
在S720,所述第一计算节点利用初始神经网络模型对所述训练数据进行处理,以得 到所述训练数据对应的训练信息。
各个计算节点中的初始神经网络模型可以具有相同的参数。
在S730,所述第一计算节点利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层。
训练数据对应的训练信息与标注信息的差异,可以通过损失值表示。
不同的层集合中可以包括初始神经网络模型不同层。也就是说,第一层集合不包括初始神经网络模型的输入层。
根据BP算法的运算原理,按照与初始神经网络模型运算相反的顺序,计算各个层的参数梯度。在通过反向传播BP算法处理得到的第一梯度数据集合中,第二梯度数据用于指示第二层集合中的参数的梯度,第二层集合包括所述神经网络模型的输入层。第二层集合还可以包括位于输入层之后的预设数量的层。因此,在第一梯度数据集合的各个梯度数据中,第二梯度数据是最后计算得到的。
在S740,所述第一计算节点获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
也就是说,在S740,在第一计算节点利用BP算法对该差异进行处理的过程中,第一计算节点获取所述第三梯度数据。可以理解为,在利用所述BP算法对所述差异进行处理的过程中,第一计算节点开始获取所述第三梯度数据,并在利用所述BP算法对所述差异的处理结束前获取第三梯度数据。
第一计算节点可以接收第二计算节点发送的第二梯度数据集合,也可以向第二计算节点发送第一梯度数据集合,用于第二计算节点对初始神经网络模型的调整。
具体地,在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中,第一计算节点可以接收第二计算节点发送的第三梯度数据,也可以向第二计算节点发送第一梯度数据。
在S750,所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,以得到训练后的神经网络模型,其中,所述第一计算节点对所述第一层集合和所述第二层集合的参数的调整在所述第一计算节点确定所述第一梯度数据集合之后进行的。
也就是说,在S750,在第一计算节点确定所述第一梯度数据集合之后,第一计算节点对所述第一层集合和所述第二层集合的参数进行调整。
应当理解,在计算系统包括多个第二计算节点的情况下,在S740,第一计算节点可以获取每个第二计算节点的第二梯度数据集合,并在S750,第一计算节点可以根据第一梯度数据集合以及各个第二梯度数据集合,对所述初始神经网络模型的参数进行调整。
第一计算节点对于各个第二梯度数据集合中对应于相同的层集合的梯度数据可以是在相同的时间段获取的。
计算系统中的各个计算节点均可以作为第一计算节点,也就是说,每个计算节点均可以执行方法700。
通过S710-S750,在并行进行神经网络模型的计算系统中,各个计算节点在利用BP算法进行处理以确定初始神经网络模型的参数梯度的过程中,对于已经计算完成初始神经网络模型的部分层的参数的梯度发送至其他计算节点,从而,其他计算节点可以在利用BP算法计算初始神经网络模型中的梯度计算之后,根据已经接收初始神经网络模型的部分层的参数的梯度,对该部分层的参数进行调整,缩短在神经网络模型训练过程中计算节点在利用BP算法的计算完成之后的运算空闲时间,提高提升训练效率,提升训练性能。
进一步地,第二数据集合可以包括第四梯度数据。第四梯度数据用于指示所述第二层集合中的参数的梯度。第一计算节点获取所述第二计算节点计算的第二梯度数据集合可以包括:在所述第一计算节点对所述第一层集合的参数进行调整的过程中,所述第一计算节点获取所述第四梯度数据。
也就是说,所述第一计算节点对每个计算节点的第四梯度数据的获取是在所述第一计算节点对第一层集合的参数进行调整的过程中进行的。
对于第二计算节点对于利用BP算法的计算过程中最后得到的第四梯度数据,第一计算节点可以对第一层集合的参数进行调整的过程中进行获取,从而,第一计算节点可以在对第一层集合的参数进行调整之后,立即开始对第二层集合的参数的调整,能够消除在神经网络模型训练过程中第一计算节点在利用BP算法的计算完成之后的运算空闲时间,进一步提高提升训练效率,提升训练性能。
第一梯度数据集合可以包括多个梯度数据,每个梯度数据可以用于指示一个层集合中的参数的梯度,每个层集合包括所述初始神经网络模型中的一个或多个层。也就是说,第一梯度数据集合还可以包括第一梯度数据、第二梯度数据之外的其他梯度数据。
第一梯度数据集合与第二梯度数据集合可以一一对应的梯度数据。第一梯度数据集合与第二梯度数据集合中相对应的梯度数据用于指示初始神经网络模型中相同的层集合。
可以根据第一计算节点获取第四数据所需的时间,设置第一层集合,以使得第一计算节点对第一层集合的参数进行调整所需的时间大于或等于第一计算节点获取第四数据所需的时间。
根据BP算法的运算原理,按照与初始神经网络模型运算相反的顺序,计算各个层的参数梯度。神经网络模型一般具有较多的层数。可以将第二层集合设置为包括具有较少的层数,如神经网络模型总层数的1/2、1/3、1/5、1/10、1/20、1/50甚至更少,从而,避免第一计算节点对第四层集合获取需要大量时间,避免出现第一计算节点开始对初始神经网络模型除第二层集合之外的层集合的参数进行调整所需的时间小于第一计算节点对第四层集合的获取所需时间的情况。
在一些实施例中,可以在所述第一计算节点确定所述第一梯度数据集合之后,第一计算节点对所述初始神经网络模型的参数的进行调整。
从而,无需确定第一计算节点获取第四数据所需的时间,就能够尽可能减小第一计算节点在神经网络模型训练过程中的运算空闲时间,较为简便。
一般情况下,计算系统中各个计算节点的运算能力之间的差异较小。各个计算节点均可以作为第一计算节点,采用方法700,对初始神经网络模型进行训练。
在进行S710至S750之后,可以将调整后的初始神经网络模型作为初始神经网络模型,重新进行S720-S750,对其他训练数据进行处理,从而完成对初始神经网络模型的参数的调整,得到训练后的神经网络模型。
例如,可以在进行S720-S750的次数(即迭代次数)达到预设值的情况下,或者,在初始神经网络模型对训练数据进行处理得到的训练信息与该训练数据对应的标注信息之间的差异逐渐收敛的情况下,不再进行S720-S750。
应当理解,各个计算节点可以采用相同的调整方式对初始神经网络模型的参数进行调整。
在多次迭代过程中,各个计算节点可以采用同步或异步的方式进行梯度数据的传输。
异步的方式,第一计算节点在获取进行第j+1次迭代的过程中,利用经过j次调整后的初始神经网络模型进行处理以得到训练信息。第一计算节点获取的第二计算节点计算的第二梯度数据集合是第二计算节点利用BP算法计算得到的最新的梯度数据集合。
同步的方式,即所述训练信息是经过j次调整后的初始神经网络模型处理得到的,每个第二梯度数据集合是利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。也就是说,在第一计算节点进行第j+1次迭代的过程中,获取的各个第二计算结点的第二梯度数据集合都是根据第二计算结点进行j次迭代得到的经过j次调整后的初始神经网络模型对训练数据进行处理得到的。
采用同步的方式对初始神经网络模型进行并行训练,能够提高训练效率,缩短训练时间。
由于第一计算节点对其他计算节点梯度数据集合的获取是在第一计算节点的进行运算的过程中进行的,并不需要为梯度数据集合的传输设置单独的时间。因此,即使各个计算节点对梯度数据集合进行计算所需的计算时间具有一定的差异,只要在第一计算节点完成S730对第一梯度数据集合的计算之前,能够收到其他各个计算节点对第二梯度数据集合的部分计算结果,就能够立即进行S740。
因此,通过S710-S750,在采用同步的方式进行梯度数据传输的情况下,可以降低各个计算节点对不同训练数据及其标注信息进行处理所需时间的差异对训练时间造成的影响。
在一些实施例中,第一计算节点可以利用梯度修剪算法,对所述初始神经网络模型的参数进行调整。
第一计算节点可以利用梯度修剪算法,对第一梯度数据集合中的各个梯度进行梯度修剪,并获取经过梯度修剪后的第二梯度数据集合。或者,第一计算节点也可以利用梯度修剪算法,对第一梯度数据集合、第二梯度数据集合中的各个梯度进行梯度修剪。
之后,初始神经网络模型可以根据修剪后的第一梯度数据集合、第二梯度数据集合,确定初始神经网络模型中各个参数的聚合梯度,并根据聚合梯度,对初始神经网络模型中的参数进行调整。
第一计算节点还可以根据第一梯度数据集合、第二梯度数据集合中的各个参数的梯度,确定各个参数的聚合梯度,之后,可以利用梯度修剪算法对聚合梯度进行修剪,利用 调整后的聚合梯度对初始神经网络模型的参数进行调整。
通过梯度修剪,可以避免梯度消失和/或梯度爆炸情况的发生。
图8是本申请实施例提供的一种神经网络模型的训练方法的示意性流程图。
神经网络模型的训练方法由计算系统中的各个计算节点执行。每个计算节点包括计算单元和通信单元。计算单元用于进行运算和处理。通信单元用于与其他计算节点进行通信,以实现各个计算节点之间的信息传输。图8以计算系统中的一个计算节点利用的处理系统800为例,对神经网络模型的训练方法进行说明。
处理系统800包括初始神经网络模型、模块BP 821至BP 824、模块AR 831至AR 832、优化器841至优化器842。其中,初始神经网络模型用于实现初始神经网络模型610的功能,模块BP 821至BP 824用于实现BP 620的功能,模块AR 831至AR 832用于实现AR 630的功能,优化器841至优化器842用于实现优化器640的功能。
在时刻t0之前,计算节点可以获取训练数据集合,训练数据集合包括训练数据和每个训练数据对应的标注信息。
标注信息也可以称为标签。可以通过人工对各个训练数据进行标注,以得到每个训练数据对应的标签。
在时刻t0至t1,计算单元利用初始神经网络模型对训练数据进行处理,以得到该训练数据对应的训练信息。
初始神经网络模型对训练数据的处理,可以利用前向传播算法进行运算。
初始神经网络模型可以包括多个层集合,每个层集合包括一个或多个层。每个层集合可以理解为一个FP模块。图8以初始神经网络模型包括模块FP 811和FP 812为例进行说明。
在时刻t1至t2,计算单元利用反向传播算法,根据训练数据对应的训练信息和标注信息,计算初始神经网络模型中各个层的参数的梯度。
计算单元可以利用多个BP模块进行反型传播运算。其中,模块BP 822、模块BP 824用于计算参数的梯度。例如,模块BP 821可以用于计算FP 812中的各个层的产生的误差。模块BP 822可以用于根据模块BP 821的计算结果,计算FP 812中的各个层的参数的梯度。模块BP 823可以用于计算FP 811中的各个层的产生的误差。模块BP 824可以用于根据模块BP 823的计算结果,计算FP 811中的各个层的参数的梯度。
在模块BP 822运算结束,得到FP 812中的各个层的参数的梯度之后,通信单元可以向其他计算节点发送FP 812中的各个层的参数的梯度。一般情况下,各个计算节点的计算能力相近,各个计算节点对FP 812中的各个层的参数的梯度进行计算所需的时间基本相同。其他各个计算节点在完成对FP 812中的各个层的参数的梯度的计算之后,可以发送FP 812中的各个层的参数的梯度。因此,该计算节点中通信单元可以在模块BP 823和/或模块BP 824进行计算的过程中接收其他各个计算节点发送的FP 812中的各个层的参数的梯度。通信单元在模块BP 821、模块BP 822进行计算的过程中可以处于空闲状态。
通信单元可以利用AR模块,接收其他各个计算单元发送的参数梯度,并向其他各个计算单元发送参数梯度。也就是说,AR模块用于实现各个计算节点计算得到的参数梯度的聚合。通信单元可以利用模块AR 831进行FP 812中的参数梯度的聚合。
也就是说,在时刻t1至t2,通信单元用于实现FP 812中的各个层的参数的梯度在各 个计算节点之间的传输。在时刻t1至t2,各个计算节点之间实现了对个个计算节点计算得到的FP 812中的参数梯度的同步,每个计算节点获取了其他各个计算节点计算的FP 812中的参数梯度。
在时刻t2至t3,计算单元利用调整初始神经网络模型的参数。
计算单元可以利用优化器841,调整FP 812的参数。
优化器可以根据各个计算节点计算得到的初始神经网络中模型中某个参数的梯度,计算该参数的梯度平均值。并根据该梯度平均值,对初始神经网络中模型中的该参数的值进行调整。
在计算单元利用优化器841对FP 812的参数进行调整的同时,通信单元可以向其他各个计算节点发送模块BP 824计算得到的FP 811中的参数梯度,也可以接收其他各个计算节点计算得到的FP 811中的参数梯度。通信单元可以利用模块AR 832进行FP 812中的参数梯度的聚合。
从而,计算单元可以在利用优化器841调整FP 812的参数之后,利用优化器842,调整FP 811的参数。
应当理解,可以增加各个优化器对反向传播运算最后一个模块BP 824的依赖,也就是说,使得各个优化器的运算在模块BP 824的运算之后开始执行。
在时刻t0至t3,计算单元串行地利用模块FP、BP、优化器进行各种运算和处理。也就是说,各个模块的运算是串行进行的。计算节点在时刻t0至t3完成一次迭代,将调整后的初始神经网络模型作为初始神经网络模型,重复进行时刻t0至t3的处理,完成对神经网络模型的训练。
在计算系统的各个计算节点中,计算单元进行反向传播运算的过程中,按照与初始神经网络模型的层相反的顺序,输出初始神经网络模型中各个层的参数的梯度。在计算单元进行反向传播运算的过程中,通信单元将已经计算得到的参数梯度传输至其他计算节点,并接收其他计算节点发送的已经计算得到的参数梯度。在计算单元完成反向传播运算后,可以根据已经接收的各个计算单元计算完成的参数梯度对神经网络模型的参数进行调整,同时通信单元继续进行参数梯度的传输。从而,可以减小甚至消除每次迭代过程中计算单元的空闲时间,提高计算单元的利用率,降低神经网络模型训练所需时间,提升训练效率。
应当理解,每个模块进行处理所需的时间长度可以相同或不同,由实际处理所需的时长决定。
与计算节点600进行一次迭代所需的时间(初始神经网络模型610、BP 620、AR 630、优化器640所需的时间之和)相比,采用本申请实施例提供方法进行神经网络模型的训练,在计算单元进行运算的同时进行梯度数据的传输,可以在不增加运算量的同时,减小甚至消除每次迭代过程中计算单元的空闲时间。
在一些实施例中,优化器或BP模块可以进行梯度修剪(clipping gradient)。
如果参数的梯度无限接近0,即梯度消失,则初始神经网络模型无法有效更新。如果参数的梯度很大,即梯度爆炸,可能导致初始神经网络模型跳过最优解,无法收敛。
为了避免出现梯度消失和/或梯度爆炸情况的出现,可以进行梯度修剪。
梯度修剪也可以称为梯度裁剪。可以设定预设范围,当梯度超过预设范围时,以预设范围的边界值作为梯度,对神经网络模型的参数进行调整。或者,可以根据梯度的范数对 梯度进行修剪。可以设定多个参数的梯度的平均值预设范围或方差预设范围,在该多个参数的梯度等不满足该平均值预设范围或方差预设范围的情况下,对该多个参数的梯度进行修剪,以使得修剪后的梯度满足该平均值预设范围或方差预设范围。
应当理解,BP模块可以对计算得到的参数的梯度进行梯度修剪。优化器可以对各个计算节点计算得到的参数的梯度,或者,优化器可以对各个计算节点计算得到的参数的梯度取平均,对梯度平均值进行梯度修剪。
图9是本申请实施例提供的一种计算系统的示意性结构图。
计算系统包括多个计算节点,每个计算节点可以进行图7或图8所示的神经网络模型的训练方法,从而实现分布式并行训练。
该多个计算节点可以位于相同或不同的计算设备中。
每个计算节点可以仅与部分计算节点之间直接连接。计算节点之间的直接连接即计算节点之间的通信接口可以进行信息传输,无需通过其他计算节点对该信息的转发。未直接连接的各个计算节点之间的信息可以通过其他计算节点的转发。
例如,可以通过环聚合(ring all reduce,ring AR)的方式,实现各个计算节点之间的信息传输。环聚合也可以称为环,各个计算节点形成环形上,每个计算节点仅与相邻两个计算节点直接连接,从而通过计算节点对信息的转发,实现各个计算节点之间的信息传输。
或者,各个计算节点之间也可以全部实现直接连接。
通过两个计算节点的通信接口可以进行单向或双向的信息传输。
图10是本申请实施例提供的一种数据处理方法的示意性流程图。
数据处理方法1000包括S1010至S1020。
在S1010,获取待处理数据。
在S1020,利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层。
其中,所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度。
所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
可选地,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算 节点对所述第一层集合的参数进行调整的过程中进行的。
可选地,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
可选地,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
可选地,所述第一计算节点对所述初始神经网络模型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
也就是说,用于对待处理数据进行处理的神经网络模型可以是通过图7或图8所示的神经网络模型的训练方法训练得到的。
上文结合图1至图9描述了本申请实施例提供的数据处理系统、神经网络模型训练方法以及数据处理方法,下面结合图11至图15,描述本申请实施例的装置实施例。应理解,神经网络模型训练方法以及数据处理方法的描述与装置实施例的描述相互对应,因此,未详细描述的部分可以参见上文的描述。
图11是本申请实施例提供的一种神经网络模型训练装置的示意性结构图。神经网络模型训练装置3000可以位于图1所示的训练设备120或其他设备中。神经网络模型训练装置3000包括获取模块3010和处理模块3020。
获取模块3010用于,获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息。
处理模块3020用于,利用初始神经网络模型对所述训练数据进行处理,以得到所述训练数据对应的训练信息。
处理模块3020用于,利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层。
获取模块3010用于,获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度。
获取模块3010具体用于,在所述处理模块利用所述BP算法对所述差异进行处理的过程中,获取所述第三梯度数据。
处理模块3020用于,根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,以得到训练后的神经网络模型。
处理模块3020具体用于,在所述处理模块确定所述第一梯度数据集合之后,对所述第一层集合和所述第二层集合的参数进行调整。
可选地,每个第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度。
获取模块3010具体用于,在所述处理模块对所述第一层集合的参数进行调整的过程 中,获取所述第四梯度数据。
可选地,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。。
可选地,处理模块3020用于,利用梯度裁剪算法,对所述初始神经网络模型的参数进行调整。
可选地,处理模块3020用于,在所述处理模块确定所述第一梯度数据集合之后,对所述初始神经网络模型的参数的进行调整。
图12是本申请实施例提供的一种数据处理装置的示意性结构图。数据处理装置2000可以位于图1所示的执行设备110或其他设备中。数据处理装置2000包括获取模块2010和处理模块2020。
获取模块2010用于,获取待处理数据。
处理模块2020用于,利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层。
所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度。
所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
可选地,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算节点对所述第一层集合的参数进行调整的过程中进行的。
可选地,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
可选地,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
可选地,所述第一计算节点对所述初始神经网络模型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
图13是本申请实施例的数据处理装置的硬件结构示意图。图13所示的数据处理装置 4000包括存储器4001、处理器4002、通信接口4003以及总线4004。其中,存储器4001、处理器4002、通信接口4003通过总线4004实现彼此之间的通信连接。
存储器4001可以是ROM,静态存储设备和RAM。存储器4001可以存储程序,当存储器4001中存储的程序被处理器4002执行时,处理器4002和通信接口4003用于执行本申请实施例的数据处理方法的各个步骤。
处理器4002可以采用通用的,CPU,微处理器,ASIC,GPU或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的数据处理装置中的单元所需执行的功能,或者执行本申请方法实施例的数据处理方法。
处理器4002还可以是一种集成电路芯片,具有信号的处理能力,例如,可以是图4所示的芯片。在实现过程中,本申请实施例的数据处理方法的各个步骤可以通过处理器4002中的硬件的集成逻辑电路或者软件形式的指令完成。
上述处理器4002还可以是通用处理器、DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器4001,处理器4002读取存储器4001中的信息,结合其硬件完成本申请实施例的数据处理装置中包括的单元所需执行的功能,或者执行本申请方法实施例的数据处理方法。
通信接口4003使用例如但不限于收发器一类的收发装置,来实现装置4000与其他设备或通信网络之间的通信。例如,可以通过通信接口4003获取待处理图像。
总线4004可包括在装置4000各个部件(例如,存储器4001、处理器4002、通信接口4003)之间传送信息的通路。
图14是本申请实施例的神经网络模型训练装置的硬件结构示意图。与上述装置4000类似,图14所示的神经网络模型训练装置5000包括存储器5001、处理器5002、通信接口5003以及总线5004。其中,存储器5001、处理器5002、通信接口5003通过总线5004实现彼此之间的通信连接。
可以通过图14所示的神经网络模型训练装置5000对初始神经网络模型进行训练,训练得到的神经网络模型就可以用于执行本申请实施例的数据处理方法了。
具体地,图14所示的装置可以通过通信接口5003从外界获取训练所需的训练数据集以及初始神经网络模型,然后由处理器根据训练数据集和初始神经网络模型进行神经网络模型的训练。
应注意,尽管上述装置4000和装置5000仅仅示出了存储器、处理器、通信接口,但是在具体实现过程中,本领域的技术人员应当理解,装置4000和装置5000还可以包括实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当理解,装置4000和装置5000还可包括实现其他附加功能的硬件器件。此外,本领域的技术人员应当理解,装置4000和装置5000也可仅仅包括实现本申请实施例所必须的器件,而不必包括图13和图14中所示的全部器件。
应理解,本申请实施例中的处理器可以为中央处理单元(central processing unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
还应理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的随机存取存储器(random access memory,RAM)可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令或计算机程序。在计算机上加载或执行所述计算机指令或计算机程序时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质。半导体介质可以是固态硬盘。
应理解,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,其中A,B可以是单数或者复数。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系,但也可能表示的是一种“和/或”的关系,具体可参考前后文进行理解。
本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的 先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (23)

  1. 一种基于计算系统的神经网络模型训练方法,其特征在于,所述计算系统包括第一计算节点和第二计算节点,所述方法包括:
    所述第一计算节点获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息;
    所述第一计算节点利用初始神经网络模型对所述训练数据进行处理,以得到所述训练数据对应的训练信息;
    所述第一计算节点利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层;
    所述第一计算节点获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的;
    所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,以得到训练后的神经网络模型,其中,所述第一计算节点对所述第一层集合和所述第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
  2. 根据权利要求1所述的方法,其特征在于,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,
    所述第一计算节点获取所述第二计算节点计算的第二梯度数据集合,包括:在所述第一计算节点对所述第一层集合的参数进行调整的过程中,所述第一计算节点获取所述第四梯度数据。
  3. 根据权利要求1或2所述的方法,其特征在于,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
  4. 根据权利要求1-3中任一项所述的方法,其特征在于,所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,包括:
    所述第一计算节点利用梯度修剪算法,对所述初始神经网络模型的参数进行调整。
  5. 根据权利要求1-4中任一项所述的方法,其特征在于,所述第一计算节点根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,包括:
    在所述第一计算节点确定所述第一梯度数据集合之后,所述第一计算节点对所述初始神经网络模型的参数的进行调整。
  6. 一种数据处理方法,其特征在于,所述方法包括:
    获取待处理数据;
    利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层,
    所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度,
    所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
  7. 根据权利要求6所述的方法,其特征在于,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算节点对所述第一层集合的参数进行调整的过程中进行的。
  8. 根据权利要求6或7所述的方法,其特征在于,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
  9. 根据权利要求6-8中任一项所述的方法,其特征在于,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
  10. 根据权利要求6-9中任一项所述的方法,其特征在于,所述第一计算节点对所述初始神经网络模型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
  11. 一种神经网络模型训练装置,其特征在于,包括获取模块和处理模块;
    所述获取模块用于,获取训练数据集合,所述训练数据集合包括多个训练数据和每个训练数据对应的标注信息;
    所述处理模块用于,利用初始神经网络模型对所述训练数据进行处理,以得到所述训练数据对应的训练信息;
    所述处理模块还用于,利用反向传播BP算法对所述训练数据对应的训练信息与所述训练数据对应的标注信息的差异进行处理,以确定第一梯度数据集合,所述第一梯度数据 集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示第一层集合中的参数的梯度,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二梯度数据用于指示第二层集合中的参数的梯度,所述第二层集合包括所述初始神经网络模型的输入层;
    所述获取模块还用于,获取所述第二计算节点计算的第二梯度数据集合,所述第二梯度数据集合用于指示所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,
    所述获取模块具体用于,在所述处理模块利用所述BP算法对所述差异进行处理的过程中,获取所述第三梯度数据;
    所述处理模块还用于,根据所述第一梯度数据集合以及所述第二梯度数据集合,对所述初始神经网络模型的参数进行调整,以得到训练后的神经网络模型,
    所述处理模块具体用于,在所述处理模块确定所述第一梯度数据集合之后,对所述第一层集合和所述第二层集合的参数进行调整。
  12. 根据权利要求11所述的装置,其特征在于,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,
    所述获取模块具体用于,在所述处理模块对所述第一层集合的参数进行调整的过程中,获取所述第四梯度数据。
  13. 根据权利要求11或12所述的装置,其特征在于,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
  14. 根据权利要求11-13中任一项所述的装置,其特征在于,所述处理模块用于,利用梯度裁剪算法,对所述初始神经网络模型的参数进行调整。
  15. 根据权利要求11-14中任一项所述的装置,其特征在于,所述处理模块用于,在所述处理模块确定所述第一梯度数据集合之后,对所述初始神经网络模型的参数的进行调整。
  16. 一种数据处理装置,其特征在于,所述装置包括获取模块和处理模块;
    所述获取模块用于,获取待处理数据;
    所述处理模块用于,利用神经网络模型对所述待处理数据进行处理,所述神经网络模型是第一计算节点根据第一梯度数据集合,以及第二梯度数据集合,对初始神经网络模型的参数进行调整得到的,其中,第一层集合和第二层集合的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的,所述第一层集合包括所述初始神经网络模型中的一个或多个层,所述第二层集合包括所述神经网络模型的输入层,
    所述第一梯度数据集合是所述第一计算节点利用反向传播BP算法对训练数据对应的训练信息与所述训练数据对应的标注信息之间的差异进行处理得到的,所述训练数据对应的训练信息是所述第一计算节点利用所述初始神经网络模型对所述训练数据进行处理得到的,所述第一梯度数据集合包括第一梯度数据和第二梯度数据,所述第一梯度数据用于指示所述第一层集合中的参数的梯度,所述第二梯度数据用于指示所述第二层集合中的参数的梯度,
    所述第二梯度数据集合是第二计算节点计算得到的,所述第二梯度数据集合用于指示 所述初始神经网络模型的参数的梯度,所述第二梯度数据集合包括第三梯度数据,所述第三梯度数据用于指示所述第一层集合中的参数的梯度,所述第一计算节点对所述第三梯度数据的获取是在所述第一计算节点利用所述BP算法对所述差异进行处理的过程中进行的。
  17. 根据权利要求16所述的装置,其特征在于,所述第二数据集合包括第四梯度数据,所述第四梯度数据用于指示所述第二层集合中的参数的梯度,所述第一计算节点对所述第四梯度数据的获取是在所述第一计算节点对所述第一层集合的参数进行调整的过程中进行的。
  18. 根据权利要求16或17所述的装置,其特征在于,所述训练信息是经过j次调整后的初始神经网络模型处理得到的,所述第二梯度数据集合是所述第二计算节点利用经过j次调整后的初始神经网络模型处理得到的,j为正整数。
  19. 根据权利要求16-18中任一项所述的装置,其特征在于,所述第一计算节点对所述初始神经网络模型的参数的调整是利用梯度修剪算法进行的。
  20. 根据权利要求16-19中任一项所述的装置,其特征在于,所述第一计算节点对所述初始神经网络模型的参数的调整是在所述第一计算节点确定所述第一梯度数据集合之后进行的。
  21. 一种电子设备,其特征在于,所述装置包括存储器和处理器,所述存储器用于存储程序,当所述程序在所述处理器中执行时,所述处理器用于执行权利要求1-10中任一项所述的方法。
  22. 一种计算机可读存储介质,其特征在于,所述计算机可读介质存储用于设备执行的程序代码,该程序代码被所述设备执行时,所述设备执行如权利要求1至10中任一项所述的方法。
  23. 一种芯片,其特征在于,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,以执行如权利要求1至10中任一项所述的方法。
PCT/CN2021/102480 2021-06-25 2021-06-25 神经网络模型训练方法和装置、数据处理方法和装置 WO2022267036A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202180099427.XA CN117501245A (zh) 2021-06-25 2021-06-25 神经网络模型训练方法和装置、数据处理方法和装置
PCT/CN2021/102480 WO2022267036A1 (zh) 2021-06-25 2021-06-25 神经网络模型训练方法和装置、数据处理方法和装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/102480 WO2022267036A1 (zh) 2021-06-25 2021-06-25 神经网络模型训练方法和装置、数据处理方法和装置

Publications (1)

Publication Number Publication Date
WO2022267036A1 true WO2022267036A1 (zh) 2022-12-29

Family

ID=84545142

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/102480 WO2022267036A1 (zh) 2021-06-25 2021-06-25 神经网络模型训练方法和装置、数据处理方法和装置

Country Status (2)

Country Link
CN (1) CN117501245A (zh)
WO (1) WO2022267036A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116561787A (zh) * 2023-07-04 2023-08-08 北京数牍科技有限公司 视觉图像分类模型的训练方法、装置及电子设备
CN116955365A (zh) * 2023-09-21 2023-10-27 浪潮电子信息产业股份有限公司 梯度数据同步方法、模型训练方法、系统、设备及介质
CN117093871A (zh) * 2023-10-16 2023-11-21 之江实验室 一种面向深度学习分布式训练测评方法和系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150596A (zh) * 2013-02-22 2013-06-12 百度在线网络技术(北京)有限公司 一种反向传播神经网络dnn的训练系统
CN103996069A (zh) * 2013-02-20 2014-08-20 百度在线网络技术(北京)有限公司 一种基于多gpu的bpnn训练方法和装置
CN108292374A (zh) * 2015-11-09 2018-07-17 谷歌有限责任公司 训练表示为计算图的神经网络
CN109409505A (zh) * 2018-10-18 2019-03-01 中山大学 一种用于分布式深度学习的压缩梯度的方法
CN110263707A (zh) * 2019-06-19 2019-09-20 湖南大学 图像识别方法、装置、计算机设备以及存储介质
CN112631775A (zh) * 2020-12-24 2021-04-09 北京百度网讯科技有限公司 模型训练方法、装置、电子设备和计算机可读存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103996069A (zh) * 2013-02-20 2014-08-20 百度在线网络技术(北京)有限公司 一种基于多gpu的bpnn训练方法和装置
CN103150596A (zh) * 2013-02-22 2013-06-12 百度在线网络技术(北京)有限公司 一种反向传播神经网络dnn的训练系统
CN108292374A (zh) * 2015-11-09 2018-07-17 谷歌有限责任公司 训练表示为计算图的神经网络
CN109409505A (zh) * 2018-10-18 2019-03-01 中山大学 一种用于分布式深度学习的压缩梯度的方法
CN110263707A (zh) * 2019-06-19 2019-09-20 湖南大学 图像识别方法、装置、计算机设备以及存储介质
CN112631775A (zh) * 2020-12-24 2021-04-09 北京百度网讯科技有限公司 模型训练方法、装置、电子设备和计算机可读存储介质

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116561787A (zh) * 2023-07-04 2023-08-08 北京数牍科技有限公司 视觉图像分类模型的训练方法、装置及电子设备
CN116955365A (zh) * 2023-09-21 2023-10-27 浪潮电子信息产业股份有限公司 梯度数据同步方法、模型训练方法、系统、设备及介质
CN116955365B (zh) * 2023-09-21 2024-02-09 浪潮电子信息产业股份有限公司 梯度数据同步方法、模型训练方法、系统、设备及介质
CN117093871A (zh) * 2023-10-16 2023-11-21 之江实验室 一种面向深度学习分布式训练测评方法和系统
CN117093871B (zh) * 2023-10-16 2024-02-13 之江实验室 一种面向深度学习分布式训练测评方法和系统

Also Published As

Publication number Publication date
CN117501245A (zh) 2024-02-02

Similar Documents

Publication Publication Date Title
WO2020238293A1 (zh) 图像分类方法、神经网络的训练方法及装置
WO2021120719A1 (zh) 神经网络模型更新方法、图像处理方法及装置
EP4145308A1 (en) Search recommendation model training method, and search result sorting method and device
WO2022267036A1 (zh) 神经网络模型训练方法和装置、数据处理方法和装置
WO2022052601A1 (zh) 神经网络模型的训练方法、图像处理方法及装置
WO2022042713A1 (zh) 一种用于计算设备的深度学习训练方法和装置
WO2022001805A1 (zh) 一种神经网络蒸馏方法及装置
WO2021022521A1 (zh) 数据处理的方法、训练神经网络模型的方法及设备
US20220375213A1 (en) Processing Apparatus and Method and Storage Medium
CN110222718B (zh) 图像处理的方法及装置
WO2021018245A1 (zh) 图像分类方法及装置
WO2021051987A1 (zh) 神经网络模型训练的方法和装置
US20230281973A1 (en) Neural network model training method, image processing method, and apparatus
WO2023093724A1 (zh) 神经网络模型的处理方法及装置
WO2021018251A1 (zh) 图像分类方法及装置
WO2022012668A1 (zh) 一种训练集处理方法和装置
WO2022088063A1 (zh) 神经网络模型的量化方法和装置、数据处理的方法和装置
WO2022156475A1 (zh) 神经网络模型的训练方法、数据处理方法及装置
WO2024067884A1 (zh) 一种数据处理方法及相关装置
CN113536970A (zh) 一种视频分类模型的训练方法及相关装置
WO2022063076A1 (zh) 对抗样本的识别方法及装置
WO2021136058A1 (zh) 一种处理视频的方法及装置
WO2020062299A1 (zh) 一种神经网络处理器、数据处理方法及相关设备
WO2023071658A1 (zh) Ai模型的处理方法、运算方法及装置
CN114298289A (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: 21946528

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 202180099427.X

Country of ref document: CN

NENP Non-entry into the national phase

Ref country code: DE