A modular neural network training platform based on multi-channel NPU

Through a modular neural network training platform based on multiple NPUs, parallel training and global optimal network parameter boot algorithms are adopted to solve the problem of long-term and poor training of image recognition neural network training in the prior art, achieving more efficient training effects and more accurate image recognition.

CN117725974BActive Publication Date: 2025-04-22CHENGDU MEISHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311831882.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-28
Publication Date
2025-04-22
Estimated Expiration
2043-12-28

AI Technical Summary

Technical Problem

In the prior art, the training process of image recognition neural networks takes a long time and has poor results, resulting in poor image recognition effect.

Method used

The modular neural network training platform based on multiple NPUs is adopted, and the training data and NPU data acquisition module, division module, core initialization module, update module, loop module and output module are combined to optimize the training process of the neural network.

Benefits of technology

It improves the training effect of neural network models, reduces training time, and improves the accuracy of image recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117725974B_ABST
    Figure CN117725974B_ABST
Patent Text Reader

Abstract

The present invention discloses a modular neural network training platform based on a multi-channel NPU, which relates to the technical field of neural network training. The platform is based on a multi-channel NPU and adopts a global optimal network parameter guidance algorithm, a parallel data optimization algorithm and a parallel weight optimization algorithm to train a neural network model to be trained, which not only improves the training effect of the neural network model, but also effectively reduces the training time of the neural network, thereby improving the training effect of the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition and neural network technology, and in particular to a modular neural network training platform based on a multi-channel NPU. Background Art

[0002] With the emergence of massive data, artificial intelligence technology has developed rapidly. Machine learning is an inevitable product of artificial intelligence development to a certain stage, which is committed to mining valuable potential information from large amounts of data through computing.

[0003] In the prior art, image recognition has been widely used, such as building image recognition neural networks for parts classification, defect recognition, and portrait recognition, etc. Before using these neural networks for image recognition, the neural networks often need to be trained. Neural network training refers to the training of artificial neural networks. Inputting enough samples into the neural network, adjusting the structure of the network (mainly adjusting the weights) through a certain algorithm, so that the output of the network matches the expected value, this process is neural network training. The training process of the existing image recognition neural network mainly obtains a trained neural network by performing gradient descent training on the neural network multiple times, but this process is time-consuming and the training effect is not good, which leads to poor image recognition effect. Summary of the invention

[0004] The purpose of the present invention is to provide a modular neural network training platform based on multi-channel NPU, which solves the problems existing in the prior art.

[0005] The present invention is achieved through the following technical solutions:

[0006] A modular neural network training platform based on multiple NPUs, comprising a training data and NPU data acquisition module, a partitioning module, a first core initialization module, a first update module, a second core initialization module, a second update module, a loop module and an output module;

[0007] The training data and NPU data acquisition module is used to obtain the neural network model to be trained and determine the idle cores in the multi-channel NPU to obtain multiple target cores;

[0008] The division module is used to divide the plurality of target cores into two parts to obtain a first core group and a second core group, wherein the first core group is used to perform a first parallel training, and the second core group is used to perform a second parallel training;

[0009] The first core initialization module is used to deploy multiple neural network models to be trained on each first core in the first core group, obtain the first neural network model to be trained, and generate initial network parameter values ​​for the multiple first neural network models to be trained respectively, obtain the first network parameter vector corresponding to the first neural network model to be trained, and complete the initialization of the first core;

[0010] The first updating module is used to run all the first cores simultaneously in a parallel operation mode, and for each first neural network model to be trained in the first core, use a global optimal network parameter guidance algorithm and a parallel data optimization algorithm to perform a first update on the first network parameter vector of each first neural network model to be trained until the number of first updates reaches an upper limit, and determine the local optimal network parameter vector in each first core according to the first network parameter vector;

[0011] The second core initialization module is used to deploy multiple neural network models to be trained on the second core in the second core group to obtain a second neural network model to be trained, determine a global optimal network parameter vector by a reduction method according to the local optimal network parameter vector in the first core, and use the global optimal network parameter vector as the initial network parameter of the second neural network model to be trained on the second core to obtain a second network parameter vector corresponding to the second neural network model to be trained, and complete the initialization of the second core;

[0012] The second updating module is used to run all the second cores simultaneously in a parallel operation mode, and for each second neural network model to be trained in the second core, use a parallel weight optimization algorithm to perform a second update on the second network parameter vector of each second neural network model to be trained, until the number of second updates reaches an upper limit or the iteration end requirement is met, and the second update ends;

[0013] The loop module is used to, when the number of second updates reaches an upper limit, use the second network parameter vector in the second core as the global optimal network parameter vector and return to the first update step;

[0014] The output module is used to, when the iteration end requirement is met, use the second network parameter vector in the second core as the final network parameter of the neural network to be trained, so as to complete the training of the neural network model to be trained.

[0015] In one possible implementation, initial network parameter values ​​are generated for multiple first neural network models to be trained, including: generating network parameter values ​​for the first neural network model to be trained by randomly generating network parameters between an upper limit of the network parameters and a lower limit of the network parameters, or generating network parameter values ​​for the first neural network model to be trained by a mixed sequence strategy.

[0016] In a possible implementation, a first network parameter vector of each first neural network model to be trained is first updated using a global optimal network parameter guidance algorithm and a parallel data optimization algorithm until the number of first updates reaches an upper limit, and a local optimal network parameter vector in each first core is determined according to the first network parameter vector, including:

[0017] A1. Parallel acquisition of a first fitness corresponding to a first network parameter vector of a first neural network model to be trained;

[0018] A2. Determine a first historical optimal value of each first network parameter vector according to the first fitness, and obtain the first historical optimal value and a first fitness corresponding to the first historical optimal value;

[0019] A3. Determine the local optimal network parameter vector in the first core by using a reduction method according to the first fitness corresponding to the first historical optimal value corresponding to the first network parameter vector;

[0020] A4. Determine whether the first maximum update number threshold is reached. If so, output the local optimal network parameter vector in the first core. Otherwise, use the global optimal network parameter guidance algorithm to update the first network parameter vector and return to step A1.

[0021] In a possible implementation, according to a first fitness corresponding to a first historical optimal value corresponding to the first network parameter vector, a reduction method is used to determine a local optimal network parameter vector in the first core, including:

[0022] Obtain n first fitnesses according to a first fitness corresponding to a first historical optimal value corresponding to the first network parameter vector;

[0023] Compare the i-th first fitness with the ni-th first fitness, select the larger first fitness to enter the next round of comparison, until the number of selected first fitness is only one, and obtain the local optimal network parameter vector in the first core; among them, when n is an odd number, the middle number directly enters the next round of comparison.

[0024] In a possible implementation, updating the first network parameter vector using a global optimal network parameter guidance algorithm includes:

[0025] The first guided update is performed on the i-th first network parameter vector:

[0026]

[0027] Among them, f(t) represents a random number between [0,1] generated during the t-th local training, and all f(t) are uniformly distributed, X i(t) represents the i-th first network parameter vector in the t-th local training, i = 1, 2, ..., L, L represents the total number of first network parameter vectors, X i (t+1) represents the updated X i (t);X i,best (t) represents the state with the maximum fitness corresponding to the i-th first network parameter vector in the previous t local training processes, that is, the historical optimal value of the i-th first network parameter vector; represents the average value corresponding to the historical optimal value of all first network parameter vectors; X best represents the global optimal value. During the first cycle, each first core runs independently and does not know the global optimal value. Therefore, the local optimal network parameter vector in the first core is taken as the global optimal value; ω(t) represents the inertia weight during the tth local training;

[0028] All first network parameter vectors are divided into two parts, one part is K better network parameter vectors, and the other part is K worse network parameter vectors; the K better network parameter vectors are half of the first network parameter vectors with the largest fitness, and when the first network parameter vector is an odd number, the first network parameter vector with the largest fitness does not participate in the division;

[0029] According to K better network parameter vectors, the network parameter center vector is obtained as:

[0030]

[0031] Among them, C(t) represents the center vector of network parameters, X k (t) represents the kth optimal network parameter, F(X k (t) represents the fitness of the kth optimal network parameter;

[0032] According to the network parameter center vector C(t), the second guided update is performed on the inferior network parameter vector as follows:

[0033] X k' (t+1)=X k' (t)+rand*(C(t)-X k' (t))

[0034] Among them, X k' (t) represents the k'th inferior network parameter vector, X k' (t+1) represents the updated X k' (t), rand represents a random number between (0,1);

[0035] Determine whether the fitness of the inferior network parameter vector after the second guide update is greater than the fitness before the second guide update. If so, accept the inferior network parameter vector Xk' (t) The second guided update completes the update of the first network parameter vector, otherwise the inferior network parameter vector X is rejected k' (t) The second guided update completes the update of the first network parameter vector.

[0036] In a possible implementation manner, the inertia weight is:

[0037]

[0038] Among them, ω max represents the maximum inertia weight, ω min represents the minimum inertia weight, iter represents the maximum number of times the first network parameter vector is updated, and t represents the current number of times the first network parameter vector is updated.

[0039] In a possible implementation, a parallel weight optimization algorithm is used to perform a second update on the second network parameter vector of each second neural network model to be trained until the number of second updates reaches an upper limit or the iteration end requirement is met, including:

[0040] B1. construct a task node for each second neural network model to be trained on the second core, construct a main task node, and allocate a private memory and a public memory for each task node;

[0041] B2, initialize the iteration counter t'=1, initialize the scale matrix B t' =I;

[0042] B3. For all the second neural network models to be trained, obtain the error function value E(w t' ), and the error function value E(w t' ) is put into the public memory for each task node to call; among them, the error function value E(w t' ) is obtained through the second neural network model to be trained on any task node, w t' A second network parameter vector representing the application of the second neural network to be trained during the t'th training;

[0043] B4. Obtain the gradient matrix of the second neural network model to be trained And the scale matrix B t' And the gradient matrix g t' Put it into the public memory for each task node to call; among them, the gradient matrix g t' Each column in is the gradient of a network parameter in the second neural network model to be trained;

[0044] Where I represents the unit scale matrix, represents the gradient operator, E(w t' ) represents the error function, w t' represents the weight vector corresponding to the second neural network model to be trained, B t' is an M-order square matrix, where M represents the weight dimension of the second neural network model to be trained;

[0045] B5. Each task node runs in parallel, and the scale matrix B is called from the public memory for each task node. t' And the gradient matrix g t' , determine the search direction d of the second neural network to be trained on the mth task node m is the scale matrix B t' The mth row of data and the gradient matrix g t' The multiplication and accumulation data of the mth column data in ; where m = 1, 2, ..., M, and the search direction is d m Stored in the private memory corresponding to the mth task node;

[0046] B6. Each task node runs in parallel, and each task node retrieves the search direction d from its private memory. m , according to the search direction d m The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m , and update the step size λ m Stored in the private memory corresponding to the mth task node;

[0047] B7. Each task node runs in parallel, and each task node retrieves the update step size λ from its private memory. m , and according to the update step size λ m Update the mth network parameter in the second neural network model to be trained on the task node; obtain the mth gradient component according to the mth updated network parameter of the second neural network model to be trained on the mth task node;

[0048] B9. Each task node runs in parallel, and according to the mth gradient component, the gradient matrix g corresponding to the mth task node is re-determined. m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' Make updates;

[0049] B10, output scale matrix B through each task node t' The mth column element in and the mth network parameter corresponding to the second neural network model to be trained are sent to the main task node;

[0050] B11, the m network parameters are used to form an updated second network parameter vector through the main task node, and it is determined whether the fitness corresponding to the updated second network parameter vector is greater than the set threshold. If so, the iteration end requirement is met and the second update process ends, otherwise, it goes to step B12;

[0051] B12, determine whether the count value of the iteration counter t' is greater than the upper limit. If so, determine that the number of second updates has reached the upper limit and end the second update process. Otherwise, increase the count value of the iteration counter t' by one and output the scale matrix B of each task node. m The elements in the mth column form the scale matrix B t' , use the updated second network parameter vector as the network parameter of the second neural network model to be trained on all task nodes, and return to step B3.

[0052] In a possible implementation, the error function value E(w t' )for:

[0053]

[0054] Wherein, s = 1, 2, ..., S, S represents the total number of training samples, n = 1, 2, ..., N, N represents the total number of output neurons corresponding to the second neural network model to be trained; y n (x s ,w t' ) indicates that when the second neural network model to be trained is trained with the sample x s As input, w t' When d is the network parameter, the actual output of the nth output neuron of the second neural network model to be trained; sn Represents y n (x s ,w t' ) corresponding to the expected output; d max,n represents the maximum value of the nth expected output corresponding to all training samples, and each training sample corresponds to an expected output vector; d min,n Represents the minimum value of the nth expected output corresponding to all training samples.

[0055] In a possible implementation, according to the search direction d m The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m ,include:

[0056] Use search direction d m Construct a search matrix D with only one row, where the mth element is the search direction d m, the other elements are 0, and the total number of elements in the search matrix is ​​the same as the total number of network parameters of the second neural network model to be trained;

[0057] Construct a step size matrix λ' with only one column. The mth element in the step size matrix is ​​the update step size λ to be determined. m , the other elements are 0, and the total number of elements in the step matrix is ​​the same as the total number of network parameters of the second neural network model to be trained

[0058] Construct solution conditions based on search matrix D and search matrix D And solve the solution condition to determine the update step size λ m ;

[0059] According to the update step size λ m Update the mth network parameter in the second neural network model to be trained on the task node as follows:

[0060] w m '=w m +λ m d m

[0061] Among them, w m represents the mth network parameter in the second neural network model to be trained, w m ' indicates the updated w m .

[0062] In a possible implementation, the gradient matrix g corresponding to the mth task node is re-determined according to the mth gradient component. m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' Updates include:

[0063] With the gradient matrix g t' Based on, the gradient matrix g is updated using the mth gradient component t' The mth element in gets the gradient matrix g corresponding to the mth task node. m ;

[0064] According to the gradient matrix g corresponding to the mth task node m , for the scale matrix B corresponding to the mth task node t' Update to:

[0065]

[0066] Among them, B t' 'Indicates the updated B t' , W represents the weight difference matrix, W = w t' '-wt' , w t' ' indicates that according to the update step size λ m The updated weight vector of the second neural network model to be trained, w t' represents the weight vector of the second neural network model to be trained before updating, T represents transposition, Z = g m -g t' , Z represents the gradient difference matrix.

[0067] The present invention provides a modular neural network training platform based on multi-channel NPU, which is based on multi-channel NPU and adopts global optimal network parameter guidance algorithm, parallel data optimization algorithm and parallel weight optimization algorithm to train the neural network model to be trained, which not only improves the training effect of the neural network model, but also effectively reduces the training time of the neural network, improves the training effect of the neural network, and thus improves the accuracy of image recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0069] Figure 1 A schematic diagram of the structure of a modular neural network training platform based on a multi-channel NPU provided in an embodiment of the present invention.

[0070] Marks and corresponding parts names in the attached drawings:

[0071] 1- training data and NPU data acquisition module, 2- division module, 3- first core initialization module, 4- first update module, 5- second core initialization module, 6- second update module, 7- loop module, 8- output module. DETAILED DESCRIPTION

[0072] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.

[0073] like Figure 1As shown, a modular neural network training platform based on a multi-channel NPU (Neural Processor Unit) includes a training data and NPU data acquisition module 1, a division module 2, a first core initialization module 3, a first update module 4, a second core initialization module 5, a second update module 6, a loop module 7 and an output module 8.

[0074] The training data and NPU data acquisition module 1 is used to obtain the neural network model to be trained, and determine the idle cores in the multi-channel NPU to obtain multiple target cores.

[0075] Optionally, the training data and NPU data acquisition module 1 is also used to acquire training data, which is used to train the neural network model to be trained.

[0076] The division module 2 is used to divide the multiple target cores into two parts to obtain a first core group and a second core group. The first core group is used to perform the first parallel training, and the second core group is used to perform the second parallel training.

[0077] Since the data computing amount of the second core group is less than that of the first core group, the cores can be divided according to actual conditions. For example, the ratio of the number of first cores in the first core group to the number of second cores in the second core group can be 7:3 or 8:2.

[0078] Optionally, when dividing the core groups, it is possible to avoid multiple cores on one NPU being in different core groups.

[0079] The first core initialization module 3 is used to deploy multiple neural network models to be trained on each first core in the first core group, obtain the first neural network model to be trained, and generate initial network parameter values ​​for the multiple first neural network models to be trained respectively, obtain the first network parameter vector corresponding to the first neural network model to be trained, and complete the initialization of the first core.

[0080] Optionally, an upper limit of the network parameter threshold and a lower limit of the network parameter threshold can be set, and between the upper limit of the network parameter threshold and the lower limit of the network parameter threshold, a first network parameter vector corresponding to the first neural network model to be trained is generated in a random manner, where the vector here can be understood as a single-row matrix including all network parameters of the first neural network model to be trained. The first network parameter vector corresponding to the first neural network model to be trained can also be initialized using an initialization method similar to a chaotic sequence.

[0081] The first update module 4 is used to run all the first cores simultaneously in parallel, and for each first neural network model to be trained in the first core, a global optimal network parameter guidance algorithm and a parallel data optimization algorithm are used to perform a first update on the first network parameter vector of each first neural network model to be trained, until the number of first updates reaches an upper limit, and the local optimal network parameter vector in each first core is determined according to the first network parameter vector.

[0082] In the prior art, when training an image recognition neural network (such as training a convolutional neural network for product classification or portrait recognition), the traditional optimization algorithm not only needs to process data serially, but also has the problem of being easily trapped in the local optimum, resulting in poor training effect of the neural network and poor final image recognition effect. Therefore, this embodiment uses a global optimal network parameter guidance algorithm and a parallel data optimization algorithm to perform a first update on the first network parameter vector of each first neural network model to be trained, which not only optimizes the training effect of the neural network, but also effectively improves the training efficiency.

[0083] The second core initialization module 5 is used to deploy multiple neural network models to be trained on the second core in the second core group to obtain a second neural network model to be trained, determine the global optimal network parameter vector by reduction method according to the local optimal network parameter vector in the first core, and use the global optimal network parameter vector as the initial network parameter of the second neural network model to be trained on the second core to obtain the second network parameter vector corresponding to the second neural network model to be trained, thereby completing the initialization of the second core.

[0084] The local optimal network parameter vector in the first core is a network parameter vector obtained by running multiple first cores in parallel. It can be regarded as having been trained many times, but has not reached the optimal position. Therefore, the optimal value in the local optimal network parameter vector can be used as the second network parameter vector, and a parallel weight optimization algorithm is used to perform a second update on the second network parameter vector of each second neural network model to be trained, so that the network parameters are further optimized to achieve the expected training effect, while also maintaining a high training efficiency.

[0085] The second update module 6 is used to run all the second cores simultaneously in parallel, and for each second neural network model to be trained in the second core, a parallel weight optimization algorithm is used to perform a second update on the second network parameter vector of each second neural network model to be trained, until the number of second updates reaches an upper limit or the iteration end requirement is met, thereby terminating the second update.

[0086] In the process of training image recognition networks, traditional algorithms often construct kernel functions to calculate data, and repeatedly schedule a kernel function to perform operations through serial operations to achieve data updates. This method is simple and easy to implement, but the efficiency is low. Therefore, this embodiment uses a parallel weight optimization algorithm to perform a second update on the second network parameter vector of each second neural network model to be trained.

[0087] The loop module 7 is used to, when the number of second updates reaches an upper limit, use the second network parameter vector in the second core as the global optimal network parameter vector and return to the first update step.

[0088] The output module 8 is used to, when the iteration end requirement is met, use the second network parameter vector in the second core as the final network parameter of the neural network to be trained, so as to complete the training of the neural network model to be trained.

[0089] In one possible implementation, initial network parameter values ​​are generated for multiple first neural network models to be trained, including: generating network parameter values ​​for the first neural network model to be trained by randomly generating network parameters between an upper limit of the network parameters and a lower limit of the network parameters, or generating network parameter values ​​for the first neural network model to be trained by a mixed sequence strategy.

[0090] First, the global optimal network parameter guidance algorithm is used for search, and then a local optimal network parameter vector is determined from each first core. Then, based on all the local optimal network parameter vectors, the global optimal network parameter vector in this overall cycle is determined, and then the parallel weight optimization algorithm is used to perform a fine search on the global optimal network parameter vector to obtain the network parameters with the target accuracy. If the target accuracy is not achieved after a certain number of fine searches, the next overall cycle is entered.

[0091] In a possible implementation, a first network parameter vector of each first neural network model to be trained is first updated using a global optimal network parameter guidance algorithm and a parallel data optimization algorithm until the number of first updates reaches an upper limit, and a local optimal network parameter vector in each first core is determined according to the first network parameter vector, including:

[0092] A1. Acquire in parallel a first fitness corresponding to a first network parameter vector of a first neural network model to be trained.

[0093] Optionally, the fitness function of the first neural network model to be trained may be the negative value of its error function. For example, when the first neural network model to be trained is not a BP neural network, its error function may be: E represents the error, p = 1, 2, ..., P, P represents the total number of input data, q = 1, 2, ..., Q, Q represents the total number of outputs of the BP neural network; It represents the actual output of the qth output neuron of the BP neural network when the pth data is input, y' pq represents the expected output of the qth output neuron of the BP neural network when the pth data is input; then the fitness function can be

[0094] A2. Determine a first historical optimal value of each first network parameter vector according to the first fitness, and obtain the first historical optimal value and a first fitness corresponding to the first historical optimal value.

[0095] The first historical optimal value also participates in subsequent updates. When the first network parameter vector is updated for the first time, its historical optimal value is itself.

[0096] A3. According to the first fitness corresponding to the first historical optimal value corresponding to the first network parameter vector, a reduction method is used to determine the local optimal network parameter vector in the first core.

[0097] A4. Determine whether the first maximum update number threshold is reached. If so, output the local optimal network parameter vector in the first core. Otherwise, use the global optimal network parameter guidance algorithm to update the first network parameter vector and return to step A1.

[0098] In a possible implementation, according to a first fitness corresponding to a first historical optimal value corresponding to the first network parameter vector, a reduction method is used to determine a local optimal network parameter vector in the first core, including:

[0099] According to the first fitness corresponding to the first historical optimal value corresponding to the first network parameter vector, n first fitnesses are obtained.

[0100] Compare the i-th first fitness with the ni-th first fitness, select the larger first fitness to enter the next round of comparison, until the number of selected first fitness is only one, and obtain the local optimal network parameter vector in the first core. Among them, when n is an odd number, the middle number directly enters the next round of comparison.

[0101] By determining the local optimal network parameter vector in the first core through the reduction method, the amount of data comparison can be effectively reduced and computing resources can be saved.

[0102] In a possible implementation, updating the first network parameter vector using a global optimal network parameter guidance algorithm includes:

[0103] The first guided update is performed on the i-th first network parameter vector:

[0104]

[0105] Among them, f(t) represents a random number between [0,1] generated during the t-th local training, and all f(t) are uniformly distributed, X i (t) represents the i-th first network parameter vector in the t-th local training, i = 1, 2, ..., L, L represents the total number of first network parameter vectors, X i (t+1) represents the updated X i (t).X i,best (t) represents the state with the maximum fitness corresponding to the i-th first network parameter vector in the previous t local training processes, that is, the historical optimal value of the i-th first network parameter vector. Represents the average value corresponding to the historical optimal value of all first network parameter vectors. best Represents the global optimal value. During the first cycle, each first core runs independently and does not know the global optimal value. Therefore, the local optimal network parameter vector in the first core is taken as the global optimal value. ω(t) represents the inertia weight during the tth local training.

[0106] The first guided update provided in this embodiment improves the local development capability in the later stage of iteration, and avoids the algorithm from converging too early and falling into the local optimum.

[0107] All first network parameter vectors are divided into two parts, one part is K better network parameter vectors, and the other part is K worse network parameter vectors. The K better network parameter vectors are half of the first network parameter vectors with the largest fitness. When the first network parameter vector is an odd number, the first network parameter vector with the largest fitness does not participate in the division.

[0108] According to K better network parameter vectors, the network parameter center vector is obtained as:

[0109]

[0110] Among them, C(t) represents the center vector of network parameters, X k (t) represents the kth optimal network parameter, F(X k (t) represents the fitness of the kth optimal network parameter.

[0111] According to the network parameter center vector C(t), the second guided update is performed on the inferior network parameter vector as follows:

[0112] X k' (t+1)=X k' (t)+rand*(C(t)-X k' (t))

[0113] Among them, X k' (t) represents the k'th inferior network parameter vector, X k' (t+1) represents the updated X k' (t), rand represents a random number between (0,1).

[0114] Determine whether the fitness of the inferior network parameter vector after the second guide update is greater than the fitness before the second guide update. If so, accept the inferior network parameter vector X k' (t) The second guided update completes the update of the first network parameter vector, otherwise the inferior network parameter vector X is rejected k' (t) The second guided update completes the update of the first network parameter vector.

[0115] High fitness can prove that the position of the network parameter vector is better, and it has a certain reference value for other network parameter vectors with low fitness. Therefore, K better network parameter vectors can be used as a reference to update K inferior network parameter vectors to speed up the update of the entire network parameter population, and the inferior network parameter vectors can be updated by adopting the mechanism of survival of the fittest to avoid inferior development.

[0116] Optionally, after each boot update, the network parameters may be processed for out-of-bounds conditions to avoid the presence of abnormal data.

[0117] In one possible implementation, the inertia weight is:

[0118]

[0119] Among them, ω max represents the maximum inertia weight, ω min represents the minimum inertia weight, iter represents the maximum number of times the first network parameter vector is updated, and t represents the current number of times the first network parameter vector is updated.

[0120] By setting the inertia weight related to the number of updates, the local search capability and the global search capability are balanced, and the overall efficiency of the algorithm is improved. Although the first update performs local search and global search, its accuracy may not be enough, so a second update can be performed to further improve the search accuracy and ensure the overall training effect.

[0121] In a possible implementation, a parallel weight optimization algorithm is used to perform a second update on the second network parameter vector of each second neural network model to be trained until the number of second updates reaches an upper limit or the iteration end requirement is met, including:

[0122] B1. Build a task node for each second neural network model to be trained on the second core, build a main task node, and allocate private memory and a public memory for each task node.

[0123] B2, initialize the iteration counter t'=1, initialize the scale matrix B t' =I.

[0124] B3. For all the second neural network models to be trained, obtain the error function value E(w t' ), and the error function value E(w t' ) is put into the public memory for each task node to call. Among them, the error function value E(w t' ) is obtained through the second neural network model to be trained on any task node, w t' Represents the second network parameter vector applied by the second neural network to be trained during the t'th training.

[0125] B4. Obtain the gradient matrix of the second neural network model to be trained And the scale matrix B t' And the gradient matrix g t' Put it into the public memory for each task node to call. Among them, the gradient matrix g t' Each column in is the gradient of a network parameter in the second neural network model to be trained.

[0126] Where I represents the unit scale matrix, represents the gradient operator, E(w t' ) represents the error function, w t' represents the weight vector corresponding to the second neural network model to be trained, B t' It is an M-order square matrix, where M represents the weight dimension of the second neural network model to be trained.

[0127] B5. Each task node runs in parallel, and the scale matrix B is called from the public memory for each task node. t' And the gradient matrix g t' , determine the search direction d of the second neural network to be trained on the mth task node m is the scale matrix B t' The mth row of data and the gradient matrix g t' The multiplication and accumulation data of the mth column data in . Where m=1,2,…,M, the search direction is d m Stored in the private memory corresponding to the mth task node.

[0128] B6. Each task node runs in parallel, and each task node retrieves the search direction d from its private memory. m , according to the search direction dm The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m , and update the step size λ m Stored in the private memory corresponding to the mth task node.

[0129] B7. Each task node runs in parallel, and each task node retrieves the update step size λ from its private memory. m , and according to the update step size λ m The mth network parameter in the second neural network model to be trained on the task node is updated. The mth gradient component is obtained according to the mth updated network parameter of the second neural network model to be trained on the mth task node.

[0130] B9. Each task node runs in parallel, and according to the mth gradient component, the gradient matrix g corresponding to the mth task node is re-determined. m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' to update.

[0131] B10, output scale matrix B through each task node t' The mth column element in and the mth network parameter corresponding to the second neural network model to be trained are sent to the main task node.

[0132] B11. The m network parameters are used to form an updated second network parameter vector through the main task node, and it is determined whether the fitness corresponding to the updated second network parameter vector is greater than the set threshold. If so, the iteration end requirement is met and the second update process ends, otherwise, step B12 is entered.

[0133] B12, determine whether the count value of the iteration counter t' is greater than the upper limit. If so, determine that the number of second updates has reached the upper limit and end the second update process. Otherwise, increase the count value of the iteration counter t' by one and output the scale matrix B of each task node. m The elements in the mth column form the scale matrix B t' , use the updated second network parameter vector as the network parameter of the second neural network model to be trained on all task nodes, and return to step B3.

[0134] In a possible implementation, the error function value E(w t' )for:

[0135]

[0136] Wherein, s = 1, 2, ..., S, S represents the total number of training samples, n = 1, 2, ..., N, N represents the total number of output neurons corresponding to the second neural network model to be trained. n (x s ,w t' ) indicates that when the second neural network model to be trained is trained with the sample x s As input, w t' When is the network parameter, the actual output of the nth output neuron of the second neural network model to be trained. sn Represents y n (x s ,w t' ) corresponds to the expected output. max,n Represents the maximum value of the nth expected output corresponding to all training samples, and each training sample corresponds to an expected output vector. min,n Represents the minimum value of the nth expected output corresponding to all training samples.

[0137] In a possible implementation, according to the search direction d m The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m ,include:

[0138] Use search direction d m Construct a search matrix D with only one row, where the mth element is the search direction d m , the other elements are 0, and the total number of elements in the search matrix is ​​the same as the total number of network parameters of the second neural network model to be trained.

[0139] Construct a step size matrix λ' with only one column. The mth element in the step size matrix is ​​the update step size λ to be determined. m , the other elements are 0, and the total number of elements in the step matrix is ​​the same as the total number of network parameters of the second neural network model to be trained

[0140] Construct solution conditions based on search matrix D and search matrix D And solve the solution condition to determine the update step size λ m .

[0141] According to the update step size λ m Update the mth network parameter in the second neural network model to be trained on the task node as follows:

[0142] w m '=w m +λ m d m

[0143] Among them, wm represents the mth network parameter in the second neural network model to be trained, w m ' indicates the updated w m .

[0144] In a possible implementation, the gradient matrix g corresponding to the mth task node is re-determined according to the mth gradient component. m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' Updates include:

[0145] With the gradient matrix g t' Based on, the gradient matrix g is updated using the mth gradient component t' The mth element in gets the gradient matrix g corresponding to the mth task node. m .

[0146] If the traditional method is used to calculate the gradient, a large amount of computing resources will be consumed, and high accuracy cannot be guaranteed. For example, if V groups of training data are used to train a neural network, V work items are required to calculate the objective function. The weight of the neural network structure has C elements. If the traditional gradient definition is used to calculate the gradient of the weight, then the objective function needs to be called C times to calculate the partial derivative of each element of the weight, which greatly reduces the computing efficiency. Therefore, this embodiment adopts another method for updating the gradient matrix, including: dividing the parallelism according to the training data, each task node calculates the partial derivative of the weight based on a set of training data, and finally obtains the partial derivative of the objective function. Assuming that there are V training data, the weight of the second neural network structure has C elements. When the mth network parameter in the second neural network model to be trained is updated, the updated network parameter is synchronized to all nodes, and then each second neural network to be trained only uses one training data to obtain the partial derivative of the weight, and then the partial derivatives of the weight are reduced and summed to obtain the gradient matrix g m .

[0147] The reduction and summation method is: for the M partial derivatives corresponding to the same network parameter, add the mth partial derivative and the Mmth partial derivative, and put the addition result into the next round of addition data. Only one data is left in the next round of addition data, and the final partial derivative corresponding to a network parameter is obtained. Among them, when n is an odd number, the middle partial derivative directly enters the next round of addition.

[0148] When data integration and data communication are required, the main task node sends and receives data to other task nodes. Although this application adds a process of data transmission and reception, it reduces the serial calls of functions and effectively improves the training efficiency.

[0149] According to the gradient matrix g corresponding to the mth task nodem , for the scale matrix B corresponding to the mth task node t' Update to:

[0150]

[0151] Among them, B t' 'Indicates the updated B t' , W represents the weight difference matrix, W = w t' '-w t' , w t' ' indicates that according to the update step size λ m The updated weight vector of the second neural network model to be trained, w t' represents the weight vector of the second neural network model to be trained before updating, T represents transposition, Z = g m -g t' , Z represents the gradient difference matrix.

[0152] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A modular neural network training platform based on multi-channel NPU, characterized in that: It includes a training data and NPU data acquisition module, a partitioning module, a first core initialization module, a first update module, a second core initialization module, a second update module, a loop module and an output module; The training data and NPU data acquisition module is used to obtain the neural network model to be trained and determine the idle cores in the multi-channel NPU to obtain multiple target cores; The division module is used to divide the plurality of target cores into two parts to obtain a first core group and a second core group, wherein the first core group is used to perform a first parallel training, and the second core group is used to perform a second parallel training; The first core initialization module is used to deploy multiple neural network models to be trained on each first core in the first core group, obtain the first neural network model to be trained, and generate initial network parameter values ​​for the multiple first neural network models to be trained respectively, obtain the first network parameter vector corresponding to the first neural network model to be trained, and complete the initialization of the first core; The first updating module is used to run all the first cores simultaneously in a parallel operation mode, and for each first neural network model to be trained in the first core, use a global optimal network parameter guidance algorithm and a parallel data optimization algorithm to perform a first update on the first network parameter vector of each first neural network model to be trained until the number of first updates reaches an upper limit, and determine the local optimal network parameter vector in each first core according to the first network parameter vector; The second core initialization module is used to deploy multiple neural network models to be trained on the second core in the second core group to obtain a second neural network model to be trained, determine a global optimal network parameter vector by a reduction method according to the local optimal network parameter vector in the first core, and use the global optimal network parameter vector as the initial network parameter of the second neural network model to be trained on the second core to obtain a second network parameter vector corresponding to the second neural network model to be trained, and complete the initialization of the second core; The second updating module is used to run all the second cores simultaneously in a parallel operation mode, and for each second neural network model to be trained in the second core, use a parallel weight optimization algorithm to perform a second update on the second network parameter vector of each second neural network model to be trained, until the number of second updates reaches an upper limit or the iteration end requirement is met, and the second update ends; The loop module is used to, when the number of second updates reaches an upper limit, use the second network parameter vector in the second core as the global optimal network parameter vector and return to the first update step; The output module is used to, when the iteration end requirement is met, use the second network parameter vector in the second core as the final network parameter of the neural network to be trained, so as to complete the training of the neural network model to be trained.

2. The modular neural network training platform based on multi-channel NPU according to claim 1, characterized in that: Generating initial network parameter values ​​for multiple first neural network models to be trained includes: generating network parameter values ​​for the first neural network models to be trained by randomly generating network parameters between an upper limit of the network parameters and a lower limit of the network parameters, or generating network parameter values ​​for the first neural network models to be trained by using a chaotic sequence strategy.

3. The modular neural network training platform based on multi-channel NPU according to claim 1, characterized in that: The first network parameter vector of each first neural network model to be trained is first updated using a global optimal network parameter guidance algorithm and a parallel data optimization algorithm until the number of first updates reaches an upper limit, and the local optimal network parameter vector in each first core is determined according to the first network parameter vector, including: A1. Parallel acquisition of a first fitness corresponding to a first network parameter vector of a first neural network model to be trained; A2. Determine a first historical optimal value of each first network parameter vector according to the first fitness, and obtain the first historical optimal value and a first fitness corresponding to the first historical optimal value; A3. Determine the local optimal network parameter vector in the first core by using a reduction method according to the first fitness corresponding to the first historical optimal value corresponding to the first network parameter vector; A4. Determine whether the first maximum update number threshold is reached. If so, output the local optimal network parameter vector in the first core. Otherwise, use the global optimal network parameter guidance algorithm to update the first network parameter vector and return to step A1.

4. The modular neural network training platform based on multi-channel NPU according to claim 3, characterized in that: According to the first fitness corresponding to the first historical optimal value corresponding to the first network parameter vector, a local optimal network parameter vector in the first core is determined by a reduction method, including: Obtain n first fitnesses according to a first fitness corresponding to a first historical optimal value corresponding to the first network parameter vector; Compare the i-th first fitness with the ni-th first fitness, select the larger first fitness to enter the next round of comparison, until the number of selected first fitness is only one, and obtain the local optimal network parameter vector in the first core; among them, when n is an odd number, the middle number directly enters the next round of comparison.

5. The modular neural network training platform based on multi-channel NPU according to claim 3, characterized in that: Using the global optimal network parameter guidance algorithm to update the first network parameter vector includes: The first guided update is performed on the i-th first network parameter vector: Among them, f(t) represents a random number between [0,1] generated during the t-th local training, and all f(t) are uniformly distributed, X i (t) represents the i-th first network parameter vector in the t-th local training, i = 1, 2, ..., L, L represents the total number of first network parameter vectors, X i (t+1) represents the updated X i (t);X i,best (t) represents the state with the maximum fitness corresponding to the i-th first network parameter vector in the previous t local training processes, that is, the historical optimal value of the i-th first network parameter vector; represents the average value corresponding to the historical optimal value of all first network parameter vectors; X best represents the global optimal value. During the first cycle, each first core runs independently and does not know the global optimal value. Therefore, the local optimal network parameter vector in the first core is taken as the global optimal value; ω(t) represents the inertia weight during the tth local training; All first network parameter vectors are divided into two parts, one part is K better network parameter vectors, and the other part is K worse network parameter vectors; the K better network parameter vectors are half of the first network parameter vectors with the largest fitness, and when the first network parameter vector is an odd number, the first network parameter vector with the largest fitness does not participate in the division; According to K better network parameter vectors, the network parameter center vector is obtained as: Among them, C(t) represents the center vector of network parameters, X k (t) represents the kth optimal network parameter, F(X k (t) represents the fitness of the kth optimal network parameter; According to the network parameter center vector C(t), the second guided update is performed on the inferior network parameter vector as follows: X k' (t+1)=X k' (t)+rand*(C(t)-X k' (t)) Among them, X k' (t) represents the k'th inferior network parameter vector, X k' (t+1) represents the updated X k' (t), rand represents a random number between (0,1); Determine whether the fitness of the inferior network parameter vector after the second guide update is greater than the fitness before the second guide update. If so, accept the inferior network parameter vector X k' (t) The second guided update completes the update of the first network parameter vector, otherwise the inferior network parameter vector X is rejected k' (t) The second guided update completes the update of the first network parameter vector.

6. The modular neural network training platform based on multi-channel NPU according to claim 5, characterized in that: The inertia weight is: Among them, ω max represents the maximum inertia weight, ω min represents the minimum inertia weight, iter represents the maximum number of times the first network parameter vector is updated, and t represents the current number of times the first network parameter vector is updated.

7. The modular neural network training platform based on multi-channel NPU according to claim 5, characterized in that: The second network parameter vector of each second neural network model to be trained is updated for the second time using a parallel weight optimization algorithm until the number of second updates reaches an upper limit or the iteration end requirement is met, including: B1. Build a task node for each second neural network model to be trained on the second core, build a main task node, and allocate a private memory and a public memory for each task node; B2, initialize the iteration counter t'=1, initialize the scale matrix B t' =I; B3. For all the second neural network models to be trained, obtain the error function value E(w t' ), and the error function value E(w t' ) is put into the public memory for each task node to call; among them, the error function value E(w t' ) is obtained through the second neural network model to be trained on any task node, w t' A second network parameter vector representing the application of the second neural network to be trained during the t'th training; B4. Obtain the gradient matrix of the second neural network model to be trained And the scale matrix B t' And the gradient matrix g t' Put it into the public memory for each task node to call; among them, the gradient matrix g t' Each column in is the gradient of a network parameter in the second neural network model to be trained; Where I represents the unit scale matrix, represents the gradient operator, E(w t' ) represents the error function, w t' represents the weight vector corresponding to the second neural network model to be trained, B t' is an M-order square matrix, where M represents the weight dimension of the second neural network model to be trained; B5. Each task node runs in parallel, and the scale matrix B is called from the public memory for each task node. t' And the gradient matrix g t' , determine the search direction d of the second neural network to be trained on the mth task node m is the scale matrix B t' The mth row of data and the gradient matrix g t' The multiplication and accumulation data of the mth column data in ; where m = 1, 2, ..., M, and the search direction is d m Stored in the private memory corresponding to the mth task node; B6. Each task node runs in parallel, and each task node retrieves the search direction d from its private memory. m , according to the search direction d m The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m , and update the step size λ m Stored in the private memory corresponding to the mth task node; B7. Each task node runs in parallel, and each task node retrieves the update step size λ from its private memory. m , and according to the update step size λ m Update the mth network parameter in the second neural network model to be trained on the task node; obtain the mth gradient component according to the mth updated network parameter of the second neural network model to be trained on the mth task node; B9. Each task node runs in parallel, and the gradient matrix g corresponding to the mth task node is re-determined according to the mth gradient component. m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' Make updates; B10, output scale matrix B through each task node t' The mth column element in and the mth network parameter corresponding to the second neural network model to be trained are sent to the main task node; B11, the m network parameters are used to form an updated second network parameter vector through the main task node, and it is determined whether the fitness corresponding to the updated second network parameter vector is greater than the set threshold. If so, the iteration end requirement is met and the second update process ends, otherwise, it goes to step B12; B12, determine whether the count value of the iteration counter t' is greater than the upper limit. If so, determine that the number of second updates has reached the upper limit and end the second update process. Otherwise, increase the count value of the iteration counter t' by one and output the scale matrix B of each task node. m The elements in the mth column form the scale matrix B t' , use the updated second network parameter vector as the network parameter of the second neural network model to be trained on all task nodes, and return to step B3.

8. The modular neural network training platform based on multi-channel NPU according to claim 7, characterized in that: Get the error function value E(w t' )for: Wherein, s = 1, 2, ..., S, S represents the total number of training samples, n = 1, 2, ..., N, N represents the total number of output neurons corresponding to the second neural network model to be trained; y n (x s ,w t' ) indicates that when the second neural network model to be trained is trained with the sample x s As input, w t' When d is the network parameter, the actual output of the nth output neuron of the second neural network model to be trained; sn Represents y n (x s ,w t' ) corresponding to the expected output; d max,n represents the maximum value of the nth expected output corresponding to all training samples, and each training sample corresponds to an expected output vector; d min,n Represents the minimum value of the nth expected output corresponding to all training samples.

9. The modular neural network training platform based on multi-channel NPU according to claim 7, characterized in that: According to the search direction d m The golden section method is used to determine the update step length λ corresponding to the mth network parameter in the second neural network model to be trained on the task node. m ,include: Use search direction d m Construct a search matrix D with only one row, where the mth element is the search direction d m , the other elements are 0, and the total number of elements in the search matrix is ​​the same as the total number of network parameters of the second neural network model to be trained; Construct a step size matrix λ' with only one column. The mth element in the step size matrix is ​​the update step size λ to be determined. m , the other elements are 0, and the total number of elements in the step matrix is ​​the same as the total number of network parameters of the second neural network model to be trained; Construct solution conditions based on search matrix D and step matrix λ' And solve the solution condition to determine the update step size λ m ; According to the update step size λ m Update the mth network parameter in the second neural network model to be trained on the task node as follows: w m '=w m +λ m d m Among them, w m represents the mth network parameter in the second neural network model to be trained, w m ' indicates the updated w m .

10. The modular neural network training platform based on multi-channel NPU according to claim 7, characterized in that: According to the mth gradient component, re-determine the gradient matrix g corresponding to the mth task node m , and according to the gradient matrix g m The scale matrix B corresponding to the mth task node t' Updates include: With the gradient matrix g t' Based on, the gradient matrix g is updated using the mth gradient component t' The mth element in gets the gradient matrix g corresponding to the mth task node. m ; According to the gradient matrix g corresponding to the mth task node m , for the scale matrix B corresponding to the mth task node t' Update to: Among them, B t′ ′ represents the updated B t' , W represents the weight difference matrix, W = w t′ ′-w t' , w t′ ′ represents the update step size λ m The updated weight vector of the second neural network model to be trained, w t' represents the weight vector of the second neural network model to be trained before updating, T represents transposition, Z = g m -g t' , Z represents the gradient difference matrix.

Citation Information

Patent Citations

  • Training method and device of tracking model, medium and computing equipment

    CN113537095A

  • NPU power consumption optimization method and system based on neural network structure

    CN116502685A