A neural network training method and device
By using multiple subsets to pre-train and noise process the model in neural network training, and updating the model using the distance between pseudo labels and initial labels, the problem of the impact of noisy labels is solved and the robustness and output accuracy of the model are improved.
Patent Information
- Application Number
- CN202110536755.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-17
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-05-17
AI Technical Summary
In a large number of learning tasks with complex input patterns, the training of neural networks is affected by noise labels, resulting in inaccurate model output, and deleting noise labels will cause changes in data distribution and affect the learning effect of the model.
By dividing the training set into multiple subsets, the initial model is pre-trained to obtain multiple pre-trained models. In the noise processing stage, the distance between the pseudo label and the initial label is used to calculate the loss value and update the model, thereby improving the robustness of the model. performance and output accuracy.
This method can improve the robustness and output accuracy of the model without deleting noise labels, avoid the reduction of information caused by noise labels, and enhance the generalization ability of the model.
Smart Images

Figure CN113705769B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a neural network training method and device. Background Art
[0002] Neural networks have demonstrated excellent performance in a wide range of learning tasks involving complex input patterns. This achievement is largely due to the large amount of accurately labeled data used for training. As the difficulty of the corresponding tasks increases, and in order to ensure the corresponding performance, large-scale datasets have become more and more common. However, obtaining a wide range of high-quality labels is not only time-consuming but also requires a lot of financial resources. This bottleneck seriously hinders the application of neural networks in more real-world scenarios. Usually, training samples can be labeled by manually adding labels or pre-trained neural networks. Usually, the labeled data often contains a variable proportion of noise labels, which affects the training of neural networks.
[0003] Generally, confidence learning can be used to reduce the impact of noise labels on neural networks. For example, noise labels can be identified and deleted, and samples without noise labels can be used to train the neural network. However, after deleting noise labels and corresponding samples, the data distribution in the training samples will be affected, resulting in data loss, so that the neural network cannot complete sufficient learning, and the output effect of the obtained neural network is poor. Summary of the invention
[0004] The present application provides a neural network training method and device for combining the initial label and pseudo label of a sample to measure the credibility of the initial label, and updating the model based on the initial label and pseudo label to obtain a model with better robustness.
[0005] In view of this, in a first aspect, the present application provides a neural network training method, comprising:
[0006] First, at least two pre-trained models divide the training set into at least two subsets, and use the at least two subsets to pre-train the initial model respectively, so as to obtain at least two pre-trained models;
[0007] Subsequently, the at least two pre-trained models are iteratively trained using the training set to obtain at least two trained first models, wherein any iterative training process of the first pre-trained model in the at least two pre-trained models includes the following steps:
[0008] A first subset is determined from a training set, and each sample in the first subset carries an initial label. At least two pre-trained models are determined from the training set, and each sample in the first subset carries an initial label; any sample in the first subset is used as an input of a second pre-trained model among at least two pre-trained models to obtain a first pseudo label of the sample; wherein no sample is used in the pre-training process of obtaining the second pre-trained model; each sample in the first subset is used as an input of the first pre-trained model to obtain a predicted label for each sample in the first subset; a first loss value is calculated based on the predicted label of each sample in the first subset, the initial label and the first pseudo label; the first pre-trained model is updated based on the first loss value to obtain the first pre-trained model after the current iterative training.
[0009] Therefore, a pre-training stage and a noise processing stage are set in the implementation mode of the present application. In the pre-training stage, the initial model is pre-trained using the training set to obtain at least two pre-training models, which is equivalent to obtaining at least two pre-training models that have learned the training set. In the noise processing stage, the output of the pre-training model is used as the pseudo-label of the sample. The distance between the pseudo-label and the initial label can reflect the credibility of the initial label to a certain extent, that is, the probability that the initial label is a noise label. Usually, the confidence and the probability are negatively correlated. And the first loss value is calculated by the distance between the pseudo-label and the initial label, and the pre-training model is updated based on the first loss value, so that the pre-training model can be updated based on the credibility of the initial label, the output accuracy of the model is improved, and the robustness of the model is optimized. It can be understood that the training method provided in the present application does not explicitly distinguish whether the sample has a noise label, but calculates the loss value according to the distance between the initial label and the pseudo-label, thereby completing the update of the model and improving the robustness of the model. Furthermore, compared with deleting noise labels, the present application calculates loss values by predicting labels, pseudo labels, and initial labels, so that the final model can learn more information and avoid reducing the learned information due to deletion.
[0010] In a possible implementation, the aforementioned updating of the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training may include: further determining a second subset from the training set, using the second subset of the training set as an input of the first pre-trained model, and calculating a second loss value according to an output of the first pre-trained model;
[0011] The first loss value and the second loss value are fused to obtain an updated first loss value; the first pre-trained model is updated according to the updated first loss value to obtain the first pre-trained model after the current iterative training.
[0012] Therefore, in the implementation manner of the present application, the pre-trained model can also be used to output pseudo labels for samples in the second subset, and the second loss value corresponding to the second subset can be calculated, so as to update the first loss value based on the second loss value, and use the updated first loss value to update the first pre-trained model, which is equivalent to combining semi-supervised learning to train the first pre-trained model, so that the first pre-trained model can learn the information of the samples included in the second subset, thereby learning more information, improving the output accuracy of the model, and improving the generalization ability of the model.
[0013] Optionally, in an embodiment of the present application, the specific method of determining the first subset or the second subset from the training set can be random division, so that all samples in the training set can be learned by the model. Of course, it can also be divided according to a preset size or a preset order.
[0014] In a possible implementation, the aforementioned taking the second subset as the input of the first pre-trained model and calculating the second loss value based on the output of the first pre-trained model may include: taking each sample in the second subset as the input of at least two pre-trained models to obtain a second pseudo-label for each sample in the second subset; taking each sample in the second subset as the input of the first pre-trained model to obtain a second predicted label for each sample in the second subset; and calculating the second loss value based on the second predicted label and the second pseudo-label.
[0015] Therefore, in an embodiment of the present application, the outputs of at least two pre-trained models obtained in the pre-training stage for the samples in the second subset can be used to obtain a pseudo-label for each sample in the second subset, i.e., a second pseudo-label, so as to calculate a second loss value based on the second pseudo-label and the predicted label output by the first pre-trained model, and update the first pre-trained model in combination with the first loss value and the second loss value, thereby combining semi-supervised learning to achieve an update of the first pre-trained model, so that the first pre-trained model can learn the information in the second subset and improve the output accuracy of the first pre-trained model.
[0016] In a possible implementation, the aforementioned calculation of the first loss value based on the predicted label, the initial label and the first pseudo label of each sample in the first subset may include: calculating the confidence corresponding to the initial label of each sample in the first subset based on the distance between the initial label of each sample in the first subset and the first pseudo label; calculating the fourth loss value between the predicted label and the initial label of each sample in the first subset, and the fifth loss value between the predicted label and the first pseudo label; fusing the fourth loss value and the fifth loss value of each sample in the first subset according to the confidence corresponding to the initial label of each sample in the first subset to obtain the first loss value.
[0017] In the implementation mode of the present application, the confidence of the initial label can be calculated based on the distance between the initial label and the pseudo label of each sample in the first subset, which can be understood as the credibility of the initial label, or the confidence can also indirectly represent the probability that the initial label is a noise label, such as the confidence and the probability are negatively correlated. Then, based on the confidence, the fourth loss value and the fifth loss value are fused, and the confidence is the weight corresponding to the fourth loss value, so as to obtain the loss value corresponding to each sample, and then obtain the loss value corresponding to the first subset. Therefore, the degree of influence of the initial label on the loss value can be set according to the confidence. The lower the confidence, the lower the weight of the fourth loss value, and the smaller the influence of the initial label when training the first pre-trained network. In this way, the influence of the noise label on the model training can be reduced, the output accuracy of the obtained model can be improved, and the robustness of the model can be improved.
[0018] Optionally, the aforementioned first loss value may include a loss value for the first subset as a whole. After the loss of each sample is calculated based on the fourth loss value and the fifth loss value of each sample, the loss value of each sample in the first subset may be fused to obtain the loss value of the first subset as a whole, that is, the first loss value. The specific fusion method may include summation or weighted summation, so that the first pre-trained model can be updated based on the overall loss of the first subset to obtain a model with more accurate output.
[0019] In a possible implementation, the distance between the initial label and the first pseudo-label of each sample in the first subset is negatively correlated with the confidence corresponding to the initial label of each sample in the first subset. Therefore, in the implementation of the present application, the distance between the initial label and the pseudo-label of the sample can be used to represent the difference between the initial label and the pseudo-label. The greater the difference, the greater the noise included in the initial label, and the lower the credibility of the initial label. Therefore, by setting a negative correlation between the distance and the confidence, the effect of noise on the model training can be reduced, a more accurate model output can be obtained, and the robustness of the model can be improved.
[0020] In a possible implementation, in each training process of multiple trainings, the training set is divided into at least two subsets, including: randomly dividing the training set into two subsets. Therefore, in the pre-training stage, the training set can be randomly divided into two subsets, so that each sample can participate in the training process of half the number of pre-training models, so that the pre-training model can output more accurate pseudo labels.
[0021] In a second aspect, the present application provides an inference method, including: taking an input sample as an input of a target model, and outputting a predicted label corresponding to the input sample, wherein the target model is obtained by training an initial model, and the training process includes the following steps:
[0022] The training set is divided into at least two subsets, and the initial model is trained respectively using the at least two subsets to obtain at least two pre-trained models; the at least two pre-trained models are iteratively trained using the training set to obtain at least two first models after training, and the at least two first models include a target model, wherein any iterative training process of the first pre-trained model among the at least two pre-trained models includes: determining a first subset from the training set, each sample in the first subset carries at least two pre-trained models with initial labels; using any sample in the first subset as input of the second pre-trained model among the at least two pre-trained models to obtain a first pseudo-label of the sample; using each sample in the first subset as input of the first pre-trained model to obtain a predicted label for each sample in the first subset; calculating a first loss value corresponding to the first subset according to the predicted label of each sample in the first subset, the initial label and the first pseudo-label; updating the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training.
[0023] Therefore, when training the model, a pre-training stage and a noise processing stage are set in the implementation mode of the present application. In the pre-training stage, the initial model is trained multiple times using the training set to obtain at least two pre-training models, which is equivalent to obtaining at least two pre-training models that have learned the training set. In the noise processing stage, the output of the pre-training model is used as the pseudo-label of the sample. The distance between the pseudo-label and the initial label can reflect the credibility of the initial label to a certain extent, that is, the probability that the initial label is a noise label, and usually the confidence and the probability are negatively correlated. And the loss value of the first subset is calculated by the distance between the pseudo-label and the initial label, so that the pre-training model can be updated based on the credibility of the initial label, the output accuracy of the model is improved, and the robustness of the model is optimized. It can be understood that the training method provided by the present application does not explicitly distinguish whether the sample has a noise label, but calculates the loss value according to the distance between the initial label and the pseudo-label, thereby completing the update of the model and improving the robustness of the model. Furthermore, compared with deleting noise labels, the present application calculates the loss value by the distance between the pseudo label and the initial label, so that the final model can learn more information and avoid reducing the learned information due to deletion.
[0024] In a third aspect, an embodiment of the present application provides a neural network training device, which has the function of implementing the neural network training method of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0025] In a fourth aspect, an embodiment of the present application provides a neural network training device, comprising: a processor and a memory, wherein the processor and the memory are interconnected via a line, and the processor calls a program code in the memory to execute the processing-related functions in the neural network training method shown in any one of the first aspects above. Optionally, the neural network training device can be a chip.
[0026] In the fifth aspect, an embodiment of the present application provides a digital processing chip or chip, the chip includes a processing unit and a communication interface, the processing unit obtains program instructions through the communication interface, the program instructions are executed by the processing unit, and the processing unit is used to perform functions related to processing in the above-mentioned first aspect or any optional embodiment of the first aspect.
[0027] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute the method in the above-mentioned first aspect or any optional implementation manner of the first aspect.
[0028] In the seventh aspect, an embodiment of the present application provides a computer program product comprising a computer program / instructions, which, when executed by a processor, enables the processor to execute the method in the above-mentioned first aspect or any optional implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of a system architecture provided for this application;
[0030] Figure 2 Another system architecture diagram provided for this application;
[0031] Figure 3 A schematic diagram of the structure of a convolutional neural network provided for this application;
[0032] Figure 4 Another system architecture diagram provided for this application;
[0033] Figure 5 A schematic diagram of a noise label of a sample provided for this application;
[0034] Figure 6 A flowchart of a neural network training method provided in this application;
[0035] Figure 7 A flowchart of another neural network training method provided in this application;
[0036] Figure 8 A schematic diagram of a training set provided for this application;
[0037] Fig. 9A schematic diagram of a training set division method provided for this application;
[0038] Fig.10 A noise processing flow diagram provided for this application;
[0039] Fig.11 A schematic diagram of the structure of a neural network training device provided in this application;
[0040] Fig.12 A schematic diagram of the structure of another neural network training device provided in this application;
[0041] Fig.13 A schematic diagram of the structure of a chip provided in this application. DETAILED DESCRIPTION
[0042] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1 The figure shows a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from the two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0044] (1) Infrastructure
[0045] Infrastructure provides computing power support for artificial intelligence systems, enables communication with the outside world, and supports it through the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, such as central processing units (CPU), neural-network processing units (NPU), graphics processing units (GPU), application specific integrated circuits (ASIC) or field programmable gate arrays (FPGA) and other hardware acceleration chips; the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0046] (2) Data
[0047] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0048] (3) Neural network training
[0049] Neural network training usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0050] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0051] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0052] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0053] (4) General ability
[0054] After the data has been trained by the neural network mentioned above, some general capabilities can be further formed based on the results of the neural network training, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0055] (5) Smart products and industry applications
[0056] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0057] The embodiments of the present application involve some neural network-related applications. In order to better understand the solutions of the embodiments of the present application, some neural network-related terms and concepts that may be involved in the embodiments of the present application are first introduced below.
[0058] The embodiments of the present application involve related applications of neural networks. In order to better understand the solutions of the embodiments of the present application, the relevant terms and concepts of the neural networks that may be involved in the embodiments of the present application are first introduced below.
[0059] (1) Neural Network
[0060] A neural network can be composed of neural units. A neural unit can be a s The output of the operation unit with the intercept 1 as input can be:
[0061]
[0062] Where, s = 1, 2, ... n, n is a natural number greater than 1, W s For x s The weight of the neural unit, b is the bias of the neural unit. f is the activation function of the neural unit, which is used to perform nonlinear transformation on the features obtained in the neural network and 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. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0063] (2) Deep Neural Networks
[0064] A deep neural network (DNN), also known as a multi-layer neural network, can be understood as a neural network with multiple hidden layers. According to the position of different layers, the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between 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.
[0065] Although DNN looks complicated, the work of each layer is not complicated. In simple terms, it can be expressed as the following linear relationship: 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, the output vector is obtained. Due to the large number of DNN layers, the coefficient W and the offset vector The number of these parameters is also relatively large. The definitions of these parameters in DNN are as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.
[0066] In summary, the coefficients from the kth neuron in the L-1th layer to the jth neuron in the Lth layer are defined as
[0067] It should be noted that the input layer does not have a W parameter. In a deep neural network, more hidden layers allow the network to better describe complex situations in the real world. Theoretically, the more parameters a model has, the higher its complexity and the greater its "capacity", which means it can complete more complex learning tasks. Training a 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 many layers of vector W).
[0068] (3) Convolutional Neural Network
[0069] Convolutional neural network (CNN) is a deep neural network with a convolutional structure. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter. Convolutional layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolutional layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layers. A convolutional layer usually contains several feature planes, each of which can be composed of some rectangularly arranged neural units. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract features is independent of position. Convolution kernels can be formalized as matrices of random size, and convolution kernels can obtain reasonable weights through learning during the training process of convolutional neural networks. In addition, the direct benefit of shared weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
[0070] (4) Loss Function
[0071] In the process of training deep neural networks, because we hope that the output of the deep neural network is as close as possible to the value we really want to predict, we can compare the predicted value of the current network with the target value we really want, and then update the weight vector of each layer of the neural network according to the difference between the two (of course, there is usually a process of optimization before the first update, that is, pre-configuring parameters for each layer in the deep neural network). For example, if the predicted value of the network is high, adjust the weight vector to make it predict lower, and continue to adjust until the deep neural network can predict the target value we really want or a value very close to the target value we really want. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the deep neural network becomes a process of minimizing this loss as much as possible. The loss function can usually include loss functions such as squared error, cross entropy, logarithm, exponential, etc. For example, the squared error can be used as a loss function, defined as The specific loss function can be selected according to the actual application scenario.
[0072] (5) Back propagation algorithm
[0073] Convolutional neural networks can use the back propagation (BP) algorithm to correct the size of the parameters in the initial network model during the training process, so that the reconstruction error loss of the model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial model are updated by back propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, aiming to obtain the optimal model parameters, such as the weight matrix.
[0074] In the implementation manner of the present application, in the pre-training stage or the noise processing stage, the BP algorithm can be used to train the model to obtain a trained model.
[0075] (6) Gradient: The derivative vector of the loss function with respect to the parameters.
[0076] (7) Stochastic gradient: The number of samples in machine learning is very large, so the loss function is calculated each time based on randomly sampled data, and the corresponding gradient is called stochastic gradient.
[0077] (8) Noise Label
[0078] The training set includes multiple samples, and labels can be added to each sample by manual labeling or neural network output. The labels added to the samples may not be completely correct. This application refers to incompletely correct labels as noise labels. Noise labels have a certain impact on training neural networks, which may cause inaccurate output of the trained neural network and poor robustness.
[0079] (9)Epoch
[0080] Defines the number of times the learning algorithm works on the entire training set. An epoch can be considered to represent the entire data set, that is, the number of times the neural network is trained using the entire training set.
[0081] (10) batch;
[0082] Closely related to the definition of epoch, an epoch involves training the neural network using the entire dataset, and a batch represents one of the batches of data in an epoch, specifically expressed as batch_size*batchs=epoch. It can be understood that each epoch is divided into one or more batches, and each batch can use part of the data in the training set to train the neural network.
[0083] The following introduces the system architecture provided by the embodiments of the present application.
[0084] See also Figure 2, the embodiment of the present application provides a system architecture 200. As shown in the system architecture 200, the data acquisition device 260 can be used to collect training data. After the data acquisition device 260 collects the training data, the training data is stored in the database 230, and the training device 220 trains the target model / rule 201 based on the training data maintained in the database 230.
[0085] The following describes how the training device 220 obtains the target model / rule 201 based on the training data. Exemplarily, the training device 220 processes multiple frames of sample images, outputs corresponding predicted labels, and calculates the loss between the predicted labels and the original labels of the samples, and updates the classification network based on the loss until the predicted labels are close to the original labels of the samples or the difference between the predicted labels and the original labels is less than a threshold, thereby completing the training of the target model / rule 201. For a detailed description, please refer to the training method in the following text.
[0086] The target model / rule 201 in the embodiment of the present application can specifically be a neural network. It should be noted that in actual applications, the training data maintained in the database 230 does not necessarily all come from the collection of the data acquisition device 260, and may also be received from other devices. It should also be noted that the training device 220 does not necessarily train the target model / rule 201 entirely based on the training data maintained by the database 230, and may also obtain training data from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.
[0087] The target model / rule 201 trained by the training device 220 can be applied to different systems or devices, such as Figure 2 The execution device 210 shown in the figure may be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR), a vehicle terminal, a television, etc., or a server or a cloud. Figure 2 In the embodiment, the execution device 210 is configured with a transceiver 212, which may include an input / output (I / O) interface or other wireless or wired communication interface, etc., for interacting with external devices. Taking the I / O interface as an example, a user may input data to the I / O interface through the client device 240.
[0088] When the execution device 210 preprocesses the input data, or when the computing module 111 of the execution device 210 performs calculations and other related processing, the execution device 210 can call the data, code, etc. in the data storage system 250 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 250.
[0089] Finally, the I / O interface returns the processing result to the client device 240 for providing to the user.
[0090] It is worth noting that the training device 220 can generate corresponding target models / rules 201 based on different training data for different goals or different tasks. The corresponding target models / rules 201 can be used to achieve the above goals or complete the above tasks, thereby providing users with the desired results.
[0091] In the attached Figure 2 In the case shown in the figure, the user can manually give the input data, and the manual giving can be operated through the interface provided by the transceiver 212. In another case, the client device 240 can automatically send the input data to the transceiver 212. If the client device 240 is required to automatically send the input data, it is necessary to obtain the user's authorization, and the user can set the corresponding authority in the client device 240. The user can view the results output by the execution device 210 on the client device 240, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 240 can also be used as a data acquisition terminal to collect the input data of the input transceiver and the output results of the output transceiver as shown in the figure as new sample data, and store them in the database 230. Of course, it is also possible not to collect through the client device 240, but the transceiver 212 directly stores the input data of the input transceiver and the output results of the output transceiver as shown in the figure into the database 230 as new sample data.
[0092] It is worth noting that Figure 2 This is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 2 In the embodiment, the data storage system 250 is an external memory relative to the execution device 210. In other cases, the data storage system 250 can also be placed in the execution device 210.
[0093] like Figure 2 As shown, the target model / rule 201 is obtained through training with the training device 220. In the embodiment of the present application, the target model / rule 201 may be the image enhancement model in the present application.
[0094] For example, CNN is a commonly used neural network. For example, in the following embodiments of the present application, CNN can be used to perform feature extraction or fusion steps. For ease of understanding, the structure of the convolutional neural network is introduced as an example below.
[0095] CNN is a deep neural network with a convolutional structure. CNN is a deep learning architecture, which refers to multiple levels of learning at different levels of abstraction through machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network in which each neuron responds to overlapping areas in the image input to it. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer. The feature extractor can be regarded as a filter, and the convolution process can be regarded as using a trainable filter to convolve an input image or convolution feature plane (feature map). Convolutional layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolutional layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layers. A convolutional layer usually contains several feature planes, each of which can be composed of some neural units arranged in a rectangular shape. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract image information is independent of position. The underlying principle is that the statistical information of a certain part of the image is the same as that of other parts. This means that the image information learned in one part can also be used in another part. Therefore, the same learned image information can be used for all positions on the image. In the same convolution layer, multiple convolution kernels can be used to extract different image information. Generally speaking, the more convolution kernels there are, the richer the image information reflected by the convolution operation.
[0096] 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. In addition, the direct benefit of shared weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
[0097] Convolutional neural networks can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial super-resolution model during the training process, so that the reconstruction error loss of the super-resolution model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the error loss information is back-propagated to update the parameters in the initial super-resolution model, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, aiming to obtain the optimal parameters of the super-resolution model, such as the weight matrix.
[0098] Combine the following Figure 3 The structure of CNN is introduced in detail as an example. As mentioned in the above basic concept introduction, convolutional neural network is a deep neural network with convolution structure, which is a deep learning architecture. Deep learning architecture refers to multiple levels of learning at different abstract levels through machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network, in which each neuron can respond to the image input into it.
[0099] like Figure 2 The convolution layer / pooling layer 120 shown may include layers 121-126 as shown in the examples. In one implementation, layer 121 is a convolution layer, layer 122 is a pooling layer, layer 123 is a convolution layer, layer 124 is a pooling layer, layer 125 is a convolution layer, and layer 126 is a pooling layer. In another implementation, layers 121 and 122 are convolution layers, layer 123 is a pooling layer, layers 124 and 125 are convolution layers, and layer 126 is a pooling layer. That is, the output of a convolution layer can be used as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
[0100] Taking the convolution layer 121 as an example, the convolution layer 121 may include a plurality of convolution operators, which are also called kernels. The convolution operator plays a role in image processing that is equivalent to a filter that extracts specific information from an input image matrix. The convolution operator can essentially be a weight matrix, which is usually predefined. In the process of performing a convolution operation on an image, the weight matrix is usually processed one pixel after another (or two pixels after two pixels... depending on the value of the stride) in the horizontal direction on the input image to complete the work of extracting specific features from the image. The size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is the same as the depth dimension of the input image. In the process of performing a convolution operation, the weight matrix extends to the entire depth of the input image. Therefore, convolution with a single weight matrix will produce a convolution output with a single depth dimension, but in most cases a single weight matrix is not used, but multiple weight matrices of the same dimension are applied. The output of each weight matrix is stacked to form the depth dimension of the convolution image. Different weight matrices can be used to extract different features in the image, for example, one weight matrix is used to extract image edge information, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to blur unnecessary noise points in the image, etc. The multiple weight matrices have the same dimensions, and the feature maps extracted by the multiple weight matrices with the same dimensions also have the same dimensions. The extracted feature maps with the same dimensions are then merged to form the output of the convolution operation.
[0101] Usually, the weight values in the weight matrix need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values obtained through training can extract information from the input image, thereby helping the convolutional neural network 100 to make correct predictions.
[0102] When the convolutional neural network 100 has multiple convolutional layers, the initial convolutional layer (for example, 121) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 100 increases, the features extracted by the later convolutional layers (for example, 126) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
[0103] Pooling layer:
[0104] Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer, such as Figure 2The layers 121-126 illustrated in 120 may be a convolution layer followed by a pooling layer, or may be multiple convolution layers followed by one or more pooling layers. In the image processing process, the only purpose of the pooling layer is to reduce the spatial size of the image. The pooling layer may include an average pooling operator and / or a maximum pooling operator for sampling the input image to obtain an image of smaller size. The average pooling operator may calculate the pixel values in the image within a specific range to generate an average value. The maximum pooling operator may take the pixel with the largest value within a specific range as the result of the maximum pooling. In addition, just as the size of the weight matrix used in the convolution layer should be related to the image size, the operator in the pooling layer should also be related to the image size. The size of the image output after processing by the pooling layer may be smaller than the size of the image input to the pooling layer, and each pixel in the image output by the pooling layer represents the average value or maximum value of the corresponding sub-region of the image input to the pooling layer.
[0105] Neural network layer 130:
[0106] After being processed by the convolution layer / pooling layer 120, the convolution neural network 100 is not sufficient to output the required output information. As mentioned above, the convolution layer / pooling layer 120 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other related information), the convolution neural network 100 needs to use the neural network layer 130 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 130 may include multiple hidden layers (such as Figure 2 131, 132 to 13n) and output layer 140. In the present application, the convolutional neural network is: the selected starting network is deformed at least once to obtain a serial network, and then obtained according to the trained serial network. The convolutional neural network can be used for image recognition, such as image recognition, image classification, image super-resolution reconstruction, etc.
[0107] After the multiple hidden layers in the neural network layer 130, that is, the last layer of the entire convolutional neural network 100 is the output layer 140, which has a loss function similar to the classification cross entropy, specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 100 (such as Figure 2 The propagation from 110 to 140 is forward propagation), and the reverse propagation (such as Figure 2 The propagation from 140 to 110 is called back propagation) and then the weight values and biases of the aforementioned layers will begin to be updated to reduce the loss of the convolutional neural network 100 and the error between the result output by the convolutional neural network 100 through the output layer and the ideal result.
[0108] It should be noted that if Figure 3The convolutional neural network 100 shown is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models. For example, multiple convolutional layers / pooling layers are operated in parallel, and the features extracted from each layer are input into the full neural network layer 130 for processing.
[0109] For example, the system architecture of the application of the neural network training method provided in the present application can be as follows: Figure 4 In the system architecture 400, the server cluster 410 is implemented by one or more servers, and optionally, cooperates with other computing devices, such as data storage, routers, load balancers, etc. The server cluster 410 can use the data in the data storage system 250, or call the program code in the data storage system 250 to implement the steps of the neural network training method provided in the present application.
[0110] Users can operate their respective user devices (e.g., local device 401 and local device 402) to interact with server cluster 410. Each local device can represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.
[0111] The local device of each user can interact with the server cluster 410 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, or any combination thereof. Specifically, the communication network may include a wireless network, a wired network, or a combination of a wireless network and a wired network. The wireless network includes, but is not limited to: a fifth generation mobile communication technology (5th-Generation, 5G) system, a long term evolution (long termevolution, LTE) system, a global system for mobile communication (global system for mobile communication, GSM) or a code division multiple access (code division multiple access, CDMA) network, a wideband code division multiple access (wideband code division multiple access, WCDMA) network, wireless fidelity (wireless fidelity, WiFi), Bluetooth (bluetooth), Zigbee protocol (Zigbee), radio frequency identification technology (radio frequency identification, RFID), long range (Lora) wireless communication, near field communication (near field communication, NFC) in any one or more combinations. The wired network may include a fiber optic communication network or a network composed of a coaxial cable, etc.
[0112] Neural networks have demonstrated excellent performance in a wide range of learning tasks involving complex input patterns. This achievement is largely due to the large amount of accurately labeled data used for training. As the difficulty of the corresponding tasks increases, and in order to ensure corresponding performance, large-scale datasets have become more and more common. However, obtaining a wide range of high-quality labels is not only time-consuming but also requires a lot of financial resources. This bottleneck seriously hinders DNNs from being applied to more real-world scenarios. In actual applications, the quality of labeled data is to some extent affected by human subjective factors, resulting in the fact that the labeled samples actually obtained often contain a variable proportion of noise labels, such as Figure 5 As shown in , the manually labeled labels may contain noise, such as Figure 5 The noise labels shown in the figure are: "fox", "seal", while the actual labels of the samples should be "cat" and "dolphin". If the noise labels are used to train the neural network, the output of the trained neural network may be inaccurate.
[0113] The methods for dealing with noisy labels all revolve around two issues: how to identify noisy labels and how to deal with noisy labels. The most accurate approach is to use multiple people with relevant knowledge to check the data set, re-label the controversial data, and vote on the labeling results to determine the final label and correct the label, but this solution often requires a lot of manpower and is not advisable in the current large-scale data set scenario. Unlike manual assistance, some solutions implicitly increase tolerance for noisy labels by designing a strong robustness loss function. In addition, there are some solutions that make assumptions about the distribution of noise, and based on this assumption, they explicitly filter out noisy labels and process them. This processing includes but is not limited to directly deleting noisy labels from the data set. However, this assumption based on noise distribution is limited to specific application scenarios. This non-universal solution is difficult to guarantee the final effect.
[0114] In some scenarios, neural networks can be trained by confidence learning. For example, by estimating the joint distribution of noise labels and true labels, samples with incorrect labels can be found and filtered out. After filtering out the incorrect samples, the remaining "clean samples" are used for retraining. In the retraining phase using "clean samples", the "clean samples" are repeatedly learned until the specified number of learning times is completed to obtain the optimal model. However, the noise labels identified by it have no meaning for learning, so they are eliminated. This elimination is reflected in two stages. In the first stage, the concept of "wrong samples" is proposed. This process determines that the error of this sample is irreparable through cross-validation, so it can be directly deleted from the data set permanently to generate a new "clean data set" identified by the framework; in the second stage, each model will "delete" (not permanently delete, but not use it in the current training times) the noise data, and only provide clean samples to another model for training. Deleting data has limitations. For example, in the case of imbalanced sample categories, the rough deletion of samples will lead to the loss of some categories, affecting the data distribution, so that some category knowledge cannot be learned at all.
[0115] In other scenarios, for the noise distribution in the data set, the Gaussian mixture model is used to divide the samples into noise data and non-noise data. For the noise data, its given label is removed and it is merged with the non-noise data to generate a new data set with some labels and some unlabeled data. Then, a semi-supervised learning strategy is used for semi-supervised learning to obtain the optimal performance model. Usually, for the noise labels recognized by the model based on the noise distribution, their label information will be directly removed, and the label knowledge of this part of the data will not be learned. First of all, the universality of identifying noise data based on noise distribution is not high, and the noise distribution of different data sets does not follow a unified principle. Secondly, for the operation of not learning the label information of noise data, on the one hand, this operation makes the model fail to learn the complete knowledge in the data set. On the other hand, as the training progresses, the model becomes more and more recognized of its own capabilities, which will lead to the occurrence of confirmation bias, thereby affecting the final performance.
[0116] Therefore, some commonly used solutions for adapting to noise labels have certain defects. This application uses a method of adaptive weighted noise labels using multi-model ensemble learning without manual assistance, without deleting samples, and without making assumptions about noise distribution. This method comprehensively learns the knowledge of the data set to alleviate the noise label problem and train a neural network with better robustness. The following is a detailed introduction to the neural network training method provided by this application.
[0117] First, see Figure 6 , a flowchart of a neural network training method provided in this application.
[0118] like Figure 6 As shown in , the neural network training method provided by the present application can be divided into two stages, which are called the pre-training stage and the noise processing stage for ease of understanding.
[0119] First, the training set may include multiple samples, and there may be samples with noise labels in the training set. The pre-training stage and the noise processing stage are introduced below.
[0120] 1. Pre-training stage
[0121] In the pre-training stage, the initial model is trained multiple times using the training set to obtain at least two pre-trained models.
[0122] In each training process, the training set can be divided into multiple subsets, or at least two subsets, and then each subset is used to pre-train the initial model, so that each subset has a corresponding pre-trained model.
[0123] For example, M trainings can be performed, and 2 pre-trained models can be obtained in each training, thereby obtaining 2M pre-trained models. In each training process, the training set can be randomly divided into two equal parts to obtain two subsets, and then the two subsets are used to pre-train the initial model respectively to obtain two pre-trained models. It can be understood that in each training process, each sample is only used in the training process of one of the models, and each sample is not used in the training process of the M pre-trained models.
[0124] 2. Noise Processing Stage
[0125] After obtaining at least two pre-trained models in the pre-training stage, the at least two pre-trained models can be iteratively trained using the training set to obtain multiple trained models. For ease of distinction, the trained model that is finally output is called the first model, that is, multiple first models are obtained.
[0126] In the noise processing stage, during any iterative training process, the first subset can be screened out from the training set, and each sample has an initial label (label). Any sample in the first subset is used as the input of the second pre-training model to obtain the pseudo label of the arbitrary sample. The second pre-training model has not learned the arbitrary sample in the pre-training stage. Then, the pre-training model to be trained (such as the first pre-training model) can be used to output the predicted label of each sample. Then, the first loss value corresponding to the first subset can be calculated based on the distance between the predicted label, the initial label and the pseudo label of each sample, and the pre-training model to be trained is updated based on the first loss value to obtain the trained pre-training model.
[0127] Specifically, when calculating the loss value corresponding to the first subset, the distance between the pseudo label and the initial label can be used to determine the weight of the loss value of the corresponding sample, thereby weighted fusion of the loss values of multiple samples to obtain a more accurate first loss value.
[0128] Therefore, in the implementation manner of the present application, it is not explicitly distinguished whether the sample has a noise label, but the loss value is calculated based on the distance between the initial label and the pseudo-label, thereby completing the update of the model and improving the robustness of the model. Moreover, relative to deleting the noise label, the present application calculates the loss value by the distance between the pseudo-label and the initial label, so that the final model can learn more information and avoid reducing the learned information due to deletion. In addition, relative to distinguishing noise labels in a fixed manner, the present application does not explicitly distinguish noise labels, but represents the credibility of the initial label by the distance between the pseudo-label and the initial label, thereby avoiding the problem of low accuracy of the final model output due to misidentification of noise labels.
[0129] The process of the neural network training method provided in this application is introduced in more detail below.
[0130] See also Figure 7 , a flow chart of another neural network training method provided in this application is as follows.
[0131] First, for ease of understanding, the neural network training method provided in this application is divided into two parts, namely, a pre-training stage and a noise processing stage, which are respectively introduced in detail below.
[0132] 71. Pre-training phase
[0133] In the pre-training stage, the initial model is trained multiple times to obtain multiple pre-trained models. This embodiment takes any one of the training processes as an example for illustrative introduction, such as the following steps 711-712. The multiple trainings can be performed in parallel or in series, that is, the following steps 711-712 can be performed in parallel once or multiple times, or can be performed in series multiple times, to obtain multiple pre-trained models.
[0134] 711. Divide the training set into at least two subsets.
[0135] The training set includes multiple samples, each of which is provided with an initial label, and the content of the initial label is related to the task performed by the neural network to be trained. For example, if a classification network needs to be trained, the label of each sample may include the category of the sample; if a segmentation network needs to be trained, the label of each sample may include the segmentation method of the foreground and background of the sample, etc.
[0136] The specific division method for the training set may be random division or division according to a pre-set method. For example, the training set may be randomly divided into at least two subsets, or may be equally divided into at least two subsets.
[0137] 712. Use at least two subsets to pre-train the initial model respectively to obtain at least two pre-trained models.
[0138] In each training process, after the training set is divided into multiple subsets, the multiple subsets can be used to train the initial models separately to obtain the pre-trained model corresponding to each subset.
[0139] For example, in the pre-training stage, the training set can be used to train the initial model M times, thereby obtaining 2M pre-trained models. In each training, the training set is randomly divided into two equal parts, that is, the training set is divided into two subsets, and then the initial model is pre-trained using the two subsets to obtain the pre-trained models corresponding to the two subsets, and the process is repeated M times to obtain 2M pre-trained models. Each sample is used in the process of training the M pre-trained models, and accordingly, each sample is not used in the process of training the M pre-trained models.
[0140] Therefore, in the implementation manner of the present application, a pre-trained model with basic output capabilities can be obtained by pre-training, which is equivalent to providing a better basic model for subsequent training.
[0141] 72. Noise processing stage
[0142] In the noise processing stage, the pre-training models obtained in the pre-training stage are iterated multiple times. The following is an exemplary introduction to the process of any iterative training of any pre-training model (referred to as the first pre-training model for easy distinction).
[0143] Generally, in the process of training a neural network, it can be divided into one or more epochs, that is, the number of times the entire training set is used for training, and each epoch can be divided into one or more batches, which is equivalent to dividing the training set into one or more subsets for iterative training. Exemplarily, the process of any batch can be as follows: Steps 721-725, and Steps 721-725 can be performed once or multiple times.
[0144] 721. Determine a first subset from the training set.
[0145] The training set may be divided according to the number of batches to obtain a sample set corresponding to each batch, and then a first subset is determined from the sample set, where the first subset includes a plurality of samples, and each sample has a corresponding initial label.
[0146] Specifically, the method of determining the first subset from the training set can be random division, or it can be divided according to a preset method, such as dividing the first subset from the training set according to a preset size or according to a preset arrangement order, etc., which can be adjusted according to the actual application scenario.
[0147] 722. Use the samples in the first subset as input to the second pre-trained model to obtain pseudo labels.
[0148] Among them, any sample in the first subset can be used as the input of the second pre-trained model to obtain the pseudo label of the arbitrary sample, and the second pre-trained model has not learned the arbitrary sample in the pre-training stage. It can be understood that each sample in the first subset has a corresponding second pre-trained model, that is, each sample has not been learned by the corresponding second pre-trained model in the pre-training stage. Therefore, at least one second pre-trained model corresponding to each sample in the first subset can be used to output the label of the sample and use it as the pseudo label of the sample, thereby obtaining the pseudo label of each sample in the first subset.
[0149] Taking any sample in the first subset (referred to as the first sample for ease of distinction) as an example, the first sample has one or more corresponding second pre-trained models, that is, the second pre-trained model has not learned the first sample during the pre-training stage. The first sample is used as the input of the corresponding one or more second pre-trained models, and the pseudo label of the first sample is obtained based on the output of the one or more second pre-trained models.
[0150] Generally, if the first sample has only one corresponding second pre-trained model, the output of the second pre-trained model is used as the pseudo label of the first sample (referred to as the first pseudo label in this embodiment for ease of distinction).
[0151] If the first sample corresponds to multiple second pre-trained models, the outputs of the multiple second pre-trained models can be fused, and the fusion result can be used as the pseudo label of the first sample. Specific fusion methods can include summation, weighted fusion, etc. For example, taking the classification task as an example, M pre-trained models have not learned the first sample, then the first sample can be used as the input of the M pre-trained models, and then the outputs of the M models are summed and converted into corresponding probability vectors through the softmax function, where each component corresponds to the probability that the first sample is the corresponding category.
[0152] 723. Use the samples in the first subset as input to the first pre-trained model to obtain a predicted label for each sample.
[0153] The first pre-trained model is the model that needs to be trained in the current iteration. After obtaining the first subset, the samples in the first subset can be used as the input of the first pre-trained model, so as to output the label of each sample and use the label as the predicted label of each sample. The first pre-trained model can be any pre-trained model obtained by training in the pre-training stage.
[0154] It should be noted that the present application does not limit the execution order of step 722 and step 723. Step 722 may be executed first, or step 723 may be executed first, or both may be executed simultaneously. The specific execution order may be adjusted according to the actual application scenario.
[0155] 724. Calculate a first loss value corresponding to the first subset according to the predicted label, the initial label, and the first pseudo label of each sample.
[0156] Among them, the first loss value can be calculated based on the predicted label, the first pseudo label and the initial label of each sample in the first subset, such as the difference between the predicted label and the first pseudo label, the difference between the predicted label and the initial label, or the difference between the first pseudo label and the initial label, etc., to obtain the first loss value.
[0157] Optionally, the distance between the first pseudo-label and the initial label can be used to determine the confidence of the initial label. It can be understood that the distance can be used to measure the probability that the initial label of the sample is a noise label. For example, the confidence and the probability can be negatively correlated, that is, the greater the confidence, the smaller the probability that the initial label of the sample is a noise label, and the smaller the confidence, the greater the probability that the initial label of the sample is a noise label.
[0158] In a possible implementation, a specific method for calculating the first loss value may include: calculating the confidence corresponding to the initial label of each sample in the first subset according to the distance between the initial label of each sample in the first subset and the first pseudo-label, and calculating the loss value between the predicted label and the initial label of each sample in the first subset (referred to as the fourth loss value for ease of distinction), and the loss value between the predicted label and the first pseudo-label (referred to as the fifth loss value for ease of distinction), and then, according to the confidence corresponding to the initial label of each sample in the first subset, fusing the fourth loss value and the fifth loss value of all samples in the first subset to obtain the first loss value corresponding to the first subset. The confidence can be understood as being related to the weight of the fourth loss value. The higher the confidence, the higher the credibility of the initial label, and the greater the weight of the fourth loss value. The lower the confidence, the lower the credibility of the initial label, and the smaller the weight of the fourth loss value. Therefore, the present application can adjust the weight of the initial label in calculating the loss of each sample by the confidence of the initial label. The greater the distance between the pseudo-label and the initial label, the greater the difference between the pseudo-label and the initial label, and the greater the noise included in the initial label. Therefore, the greater the distance, the lower the confidence, which means that the probability that the initial label is a noise label is greater. Correspondingly, the fourth loss value, that is, the loss value corresponding to the initial label, has a smaller weight, thereby reducing the impact of the noise label on the loss value, improving the accuracy of the final output model, and enhancing the robustness of the model.
[0159] More specifically, the distance between the initial label and the pseudo label may include: Euclidean distance, Minkowski distance (or Minkowski distance), Manhattan distance, Chebyshev distance, Minkowski distance or Mahalanobis distance, etc., which can be used to measure the similarity.
[0160] Generally, the distance between the initial label and the pseudo label is negatively correlated with the confidence, that is, the larger the distance, the smaller the confidence, and the smaller the distance, the greater the confidence.
[0161] Therefore, in the implementation mode of the present application, the output of the pre-trained model can be used as the pseudo-label of the sample, and the confidence of the initial sample of the sample can be determined by the distance between the pseudo-label and the initial label, so that the loss values of all samples in the first subset can be fused based on the confidence. Generally, the larger the distance, the smaller the similarity, and the correspondingly smaller the confidence. Therefore, when calculating the loss value of each sample, the weight of its initial label is also smaller, thereby reducing the influence of the noise label on the loss value of each sample, making the final first loss value more accurate.
[0162] In a possible implementation, a second subset may be determined from the training set, the second subset including a plurality of samples, the samples in the second subset may be used as inputs of the first pre-training model, and a second loss value corresponding to the second subset may be calculated according to the output of the first pre-training model. Then, the first loss value and the second loss value are fused to obtain an updated first loss value, or a third loss value.
[0163] Specifically, the samples in the second subset can be used as inputs of the multiple pre-trained models in the aforementioned step 71, and the pseudo labels of each sample in the second subset are obtained based on the outputs of the multiple pre-trained models. For ease of distinction, the pseudo labels of each sample in the second subset are referred to as second pseudo labels. Then, based on the output of each sample in the second subset and the second pseudo label of the first prediction model, the loss value corresponding to each sample can be calculated, thereby obtaining the second loss value corresponding to the second subset.
[0164] It can be understood that outputting the pseudo labels in the second subset through the pre-trained model and calculating the second loss value through the pseudo labels and predicted labels is equivalent to realizing semi-supervised learning, which can reduce the influence of the initial labels of the samples on the loss values, thereby reducing the influence of noise on the loss values and improving the robustness of the model obtained by subsequent training.
[0165] 725. Update the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training.
[0166] After obtaining the first loss value or the updated first loss value, the first pre-trained model can be reversely updated according to the first loss value or the updated first loss value to update the parameters of the first pre-trained model and obtain the first pre-trained model after the current iterative training.
[0167] If the first pre-trained model after training meets the preset convergence condition, the first pre-trained model after training can be used as the first model. If the first pre-trained model after training does not meet the preset convergence condition, the first pre-trained model after the current iteration training can be trained again until the convergence condition is met, that is, continue to execute steps 721-725 until the convergence condition is met. The convergence condition can be set according to the actual application scenario, such as the output accuracy of the pre-trained model after training exceeds the first threshold, or the average output accuracy of the pre-trained model after training exceeds the second threshold, or the number of updates of the pre-trained model reaches a preset number of times, etc., which will not be repeated here.
[0168] Therefore, a pre-training stage and a noise processing stage are set in the implementation mode of the present application. In the pre-training stage, the initial model is trained multiple times using the training set to obtain multiple pre-training models, which is equivalent to obtaining multiple pre-training models that have learned the training set. In the noise processing stage, the output of the pre-training model is used as the pseudo-label of the sample, and the confidence corresponding to each sample is determined by the distance between the pseudo-label and the initial label. The confidence can affect the weight of the loss value corresponding to the initial label when calculating the loss value of the sample. The greater the confidence, the greater the weight corresponding to the initial label. The smaller the confidence, the smaller the weight occupied by the initial label, so that the sample with a larger distance between the pseudo-label and the initial label has a smaller impact on the calculation of the loss value, thereby reducing the impact of the noise label on the model training and improving the robustness of the model. In addition, compared with directly discarding the noise label, the method provided in this embodiment can enable the model to learn more information and improve the output accuracy of the model. In addition, the unlabeled second subset is used as the input of the pre-trained model to output the pseudo-labels of the samples in the second subset, and the loss value is calculated based on the pseudo-label and the predicted label, which is equivalent to combining semi-supervised learning to improve the output accuracy of the model and obtain a model with better output effect. In addition, compared with determining the noise label from the training set through the Gaussian mixture model, the present application does not need to distinguish the noise label in a fixed way, avoids misidentifying the label as the noise label, and learns more information included in the sample, thereby improving the output accuracy of the model.
[0169] In a possible implementation, after obtaining a plurality of first models, a model that meets preset conditions or an optimal model can be screened out from the first models as a target model, and the target model can process the data input by the user or be deployed in a device provided by the user. The preset conditions may include that the output accuracy of the model exceeds the preset accuracy, the size of the model does not exceed the preset size, or the number of parameters of the model does not exceed the preset number of parameters, etc.
[0170] For example, as mentioned above Figure 2 In the framework shown, the user can send input data to the execution device through the client device, and the input data may include data to be processed, such as images to be recognized, images to be classified, etc. The execution device can select the best model from the obtained multiple first models as the target model to process the input data provided by the client device, and feedback the output results to the client device. Therefore, in the implementation mode of the present application, after obtaining multiple first models, the target model can be selected from them, and the data input by the user can be processed, so as to complete the feedback to the user and improve the user experience.
[0171] The above describes the process of the neural network training method provided by the present application. For ease of understanding, the following describes the neural network training method provided by the present application in more detail in combination with more specific application scenarios, such as classification tasks. The following describes the pre-training stage and the noise processing stage respectively.
[0172] 1. Pre-training stage
[0173] In the pre-training stage, the training set is divided into two subsets, each subset is used to pre-train the initial model, two pre-trained models are output, and the above steps are repeated M times to obtain 2M pre-trained models.
[0174] It can be understood that in each training process, the training set is divided into two subsets, and then the initial model is pre-trained using the subsets respectively, so that two pre-trained models are output each time. In each training process, one or more epochs may be included, and each epoch may include one or more batches. For each sample, it is learned by M models, and the other M models have not learned the sample.
[0175] For example, the training set can be Figure 8 As shown, the training set includes multiple samples, each sample has a corresponding initial label. For example, in a classification scenario, the label included in the training set can be the category corresponding to the image, such as "shark", "frog" or "fossil".
[0176] Then, if Fig. 9 As shown, the training set is divided at each training time, such as Fig. 9 As shown in , the training set D is divided into two subsets, D1 and D2, and then the initial model is trained using the data set D1 to obtain model 1, and the initial model is trained using the data set D2 to obtain model 2.
[0177] 2. Noise Processing Stage
[0178] After outputting 2M pre-trained models in the pre-training stage, the 2M pre-trained models can be trained for the noise in the training set to improve the robustness of the model.
[0179] When training a pre-trained model, you can pre-set the number of epochs and the number of batches in each epoch. Then, train each pre-trained model based on the set number of epochs and batches.
[0180] For example, a batch such as Fig.10 As shown. In each epoch, the training set is divided into q batches (i.e., q pieces of data), and each batch is randomly divided into two subsets n1 (i.e., the first subset) and n2 (i.e., the second subset), where the samples in n1 retain the initial labels, and the samples in n2 can remove the initial labels. The following describes the processing of n1 and n2 respectively.
[0181] 1. For n1
[0182] For n1, the samples in n1 are used as the input of the pre-trained model, such as Fig.10 The model shown in (1) (θ (1) ), f (2) (θ (2) ),…f (i) (θ (i) )…f (2M) (θ (2M) ), exemplarily, each model may include a feature extraction network and a fully connected network, the feature extraction network is used to extract features from the input image, and the fully connected network is used to output the label of the sample based on the features extracted by the feature extraction network, such as the aforementioned pseudo label or predicted label. Multiple M models that have not learned the input sample can be used to output the pseudo label of the sample, such as summing the outputs of the M models that have not learned the sample, and then a vector with a length equal to the number of label categories is obtained, which is converted into a corresponding probability vector through a softmax function, in which each component corresponds to the probability of each label category. With the training model f (i) (θ (i) ) as an example, the output of the model for the sample is expressed as f (i) (x,θ (i) ).
[0183] Calculate the distance between the pseudo label and the initial label, and use this distance to calculate the confidence level corresponding to the initial label. This calculation method can be expressed as:
[0184]
[0185] Among them, η is a hyperparameter, y represents the initial label, h(y) is the one-hot encoding of the initial label, is the pseudo label output by M models, ||ph(y)||2 represents the distance between the pseudo label and the initial label. From the above formula, we can see that the distance is negatively correlated with the confidence, that is, the larger the distance, the lower the confidence.
[0186] The loss value of the first subset is then calculated, as expressed as:
[0187]
[0188] in, represents the loss between the predicted label and the initial label, represents the loss between the predicted label and the pseudo label.
[0189] 2. For n2
[0190] Each sample in n2 can be used as the input of 2M models, and then the pseudo label of each sample is obtained based on the output of the 2M models, such as by summing up the output of the 2M models, weighted fusion, etc. to obtain the pseudo label of each sample.
[0191] Then calculate the loss value between the model's output and the pseudo label, as expressed as:
[0192]
[0193] Then the final loss value is calculated based on the loss values corresponding to n1 and n2, as expressed as:
[0194] L=L w +γL u
[0195] Among them, γ is a hyperparameter.
[0196] Then use L to adjust the model f (i) (θ (i) ) performs back-propagation update to obtain the updated model in the current batch process.
[0197] The above steps are then repeated until the model meets the convergence conditions and the model can be output, such as when the output accuracy of the model exceeds the first threshold, or when the average output accuracy of the model exceeds the second threshold, or when the number of model updates reaches a preset number.
[0198] Therefore, in the implementation mode of the present application, a pre-training stage is first performed, and the initial model is trained multiple times using the training set, and multiple pre-training models are output, so that each pre-training model has basic output capabilities. In the noise processing stage, a pre-training model with basic output capabilities can be used to output a pseudo-label, and the confidence is calculated based on the distance between the pseudo-label and the initial label, which can be understood as the probability that the label of the sample has noise, so that the loss value corresponding to each sample is determined based on the confidence. For example, the higher the confidence, the greater the weight of the initial label when calculating the loss value of each sample, making the loss value of each sample more accurate, and then making the first loss value corresponding to the first subset more accurate, and the noise is smaller, so that the model can learn information with less noise, improve the output accuracy of the model, and improve the robustness of the model. In addition, semi-supervised learning is also combined to train the model to further improve the output accuracy of the model. Compared with deleting noise labels, the method provided by the present application can learn more information included in the training set. Compared with distinguishing noise labels in a fixed way, the present application measures the credibility of the initial labels by means of confidence, and combines the semi-supervised learning method to learn the information included in each sample, so that the model can learn more information, improve the output accuracy of the model, and improve the generalization ability of the model.
[0199] In more detail, a more detailed scenario is used as an example to exemplify the method provided in this application.
[0200] For example, taking image recognition as an example, the training set can use several commonly used public data sets for the noise label problem in the image field, including Clothing-1M, WebVision, and Food-101N. The proportion of noise labels in the three data sets is 38.46%, 20%, and 20%, respectively. For the specific training process and parameter setting, take the Food-101N data set as an example. The initial model can use the residual network ResNet50, and the loss function can use cross-entropy.
[0201] Pre-training phase:
[0202] The noise dataset was used as the training set, and two groups of models were trained, each group containing two models, that is, a total of four models were trained. During the pre-training process of each group, the training set was randomly divided into two equal parts, and one model was trained with each half of the training set, and this was repeated twice. That is, for each sample, it was trained by two models, and the other two models had not learned the model in the pre-training stage. In this stage, a total of five epochs were trained.
[0203] Noise processing stage:
[0204] A total of 100 epochs are iterated and 8 models are trained in each epoch. Fig.10 As shown. Taking the training of a single model i in a certain epoch as an example, the parameters of other models except model i are fixed (that is, only model i is currently learned, and the parameters of other models are not updated). The specific operations are as follows:
[0205] In the current training epoch, the noise dataset D is randomly divided into 100 batches, batch_size is set to 160, and each batch is randomly divided into two subsets n1 = 144 and n2 = 16. The subset n1 retains its label information, and the subset n2 removes its label information.
[0206] For the labeled sample set n1, each sample is given a pseudo-label by ensemble learning of two models that have not learned the sample during the pre-training process (the prediction outputs of the currently selected four models are summed, and a vector with a length of the number of label categories is obtained at this time, which is converted into a corresponding probability vector through the softmax function, where each component corresponds to the probability of each label category). The distance between the pseudo-label and the given label is calculated. The distance formula is the L2 distance formula. The confidence weight w for the given label is obtained through the corresponding distance-weight conversion formula, as expressed as:
[0207]
[0208] where h(y) is the one-hot encoding of y (given label), The pseudo labels given by the two models, the label correction at this time is reflected in the weighted summation of different losses, and the loss function calculation method of subset n1 can be expressed as:
[0209]
[0210] in is the loss between the prediction of the current training model i and the given label, is the loss between the prediction and pseudo label of the current training model i.
[0211] For the unlabeled sample set n2, each sample is given a pseudo label by all four models, and the loss between the pseudo labels of the i-th model and all samples in n2 is calculated, that is, L u .
[0212] For each batch, the relevant loss function is calculated, that is, including subsets n1 and n2. The calculation can be expressed as: L = L w +γL u, where γ is a hyperparameter, such as 0.2, which is used to weight the loss of the n2 part. After the calculation is completed, the model i is updated.
[0213] Repeat the above steps until the model meets the convergence conditions, that is, after completing the overall training, 4 robust models can be output.
[0214] In an implementation manner of the present application, in the pre-training stage, the learning of samples is restricted so that each sample is learned by only half of the models, which corresponds to the processing of subset n1 in the adaptive weighted noise processing stage, that is, each sample in n1 is predicted by M models that have not learned the sample in the pre-training stage to obtain a pseudo label, which can enhance the robustness of the model; at the same time, the present embodiment does not discard samples. In the adaptive weighted noise processing stage, by randomly dividing the data set, each sample will experience the learning methods of subset n1 and subset n2 during the entire learning process. This comprehensive learning method from different angles further enhances the comprehensive learning of the data set, strengthens the effect of data mining, and greatly improves the overall performance of the model. In addition, in the adaptive weighted noise processing stage, labeled learning is performed for subset n1. This process does not require the introduction of other models to determine whether the sample is noisy. At this time, the data in subset n1 will be adaptively weighted with noise labels; for subset n2, the labels of this part of the data are completely unrecognized, but the relevant data will not be recognized as meaningless data and discarded by the model. Its labels are completely generated by model ensemble learning, which enhances the trust in the model and can alleviate the problem of small sample learning in real scenarios to a certain extent. The training method provided by this application can be widely used in the training of various types of noise data sets, has strong generalization ability, and can obtain a model with better output effect.
[0215] For ease of understanding, the output effects of the training method provided in this application are compared with those of some commonly used methods, such as standard cross-entropy loss (CE), determinant-based mutual information robust loss (DMI), learning data-driven curriculum for very deep neural networks on corrupted labels (MentorNet), unsupervised label noise modeling and loss correction (M-correction), transfer learning for Scalable Image Classifier Training with Label Noise (CleanNet), deep self-learning from noisy labels (SMP), beyond synthetic noise: deep learning on controlled noisy labels (MentorMix), learning with noisy labels as semi-supervised learning, and deep learning with noisy labels as semi-supervised learning. Semi-supervised Learning, referred to as DivideMix). Under the setting of M=2, the training method provided by this application surpasses some commonly used training methods on commonly used noise data sets. Under the setting of M=4, this application has a greater advantage, as shown in the following Table 1:
[0216] Training Method Clothing-1M WebVision Food-101N CE 69.0 74.0 82.5 DMI 72.46 - - MentorNet - 63.0 - M-correction 71.0 - - CleanNet 74.69 - 83.95 SMP 74.45 - 85.11 MentorMix 74.3 76.0 - DivideMix 74.76 77.32 - This application (M=2) 75.46 78.04 85.49 This application (M=4) 75.68 78.48 85.89
[0217] Table 1
[0218] Obviously, it can be seen from the above Table 1 that the output accuracy of the model trained by the training method provided in this application is better. Even in the presence of noise labels, it can still have higher output accuracy and the model is more robust.
[0219] In one possible scenario, after outputting multiple first models, the first model can be used for reasoning. It can be understood that the present application also provides a reasoning method, which can specifically include: taking the input sample as the input of the target model, outputting the predicted label corresponding to the input sample, the target model is obtained by training the initial model, and the training process includes the following steps: at least two pre-trained models divide the training set into at least two subsets, and use at least two subsets to train the initial model respectively, to obtain at least two pre-trained models; use the training set to iteratively train the at least two pre-trained models to obtain at least two first models after training, the at least two first models include the target model, wherein, in any of the first pre-trained models of the at least two pre-trained models An iterative training process includes: determining a first subset from a training set, each sample in the first subset carries at least two pre-trained models with an initial label; using any sample in the first subset as the input of a second pre-trained model among at least two pre-trained models to obtain a first pseudo-label of the sample; using each sample in the first subset as the input of the first pre-trained model to obtain a predicted label for each sample in the first subset; calculating a first loss value corresponding to the first subset according to the predicted label of each sample in the first subset, the initial label and the first pseudo-label; updating the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training.
[0220] The method of obtaining the first model can refer to the aforementioned Figure 6-Figure 10 The introduction of will not be repeated here.
[0221] The above has introduced in detail the steps of the method provided in the present application. The following is an introduction to the device for executing the above steps.
[0222] See also Fig.11 , a schematic diagram of the structure of a neural network training device provided in this application.
[0223] The neural network training device may include:
[0224] A pre-training module 1101 is used to divide the training set into at least two subsets, and use the at least two subsets to pre-train the initial model respectively, so as to obtain at least two pre-trained models;
[0225] The noise processing module 1102 is used to iteratively train at least two pre-trained models using a training set to obtain at least two first models after training, wherein any iterative training process of the first pre-trained model among the at least two pre-trained models includes the following steps: determining a first subset from the training set, each sample in the first subset carries an initial label of at least two pre-trained models; using any sample in the first subset as an input of a second pre-trained model among the at least two pre-trained models to obtain a first pseudo-label of the sample, wherein no sample is used in the pre-training process of obtaining the second pre-trained model; using each sample in the first subset as an input of the first pre-trained model to obtain a predicted label for each sample in the first subset; calculating a first loss value based on the predicted label of each sample in the first subset, the initial label and the first pseudo-label; updating the first pre-trained model based on the first loss value to obtain the first pre-trained model after the current iterative training.
[0226] In a possible implementation, the noise processing module 1102 is further used to: use the second subset of the training set as the input of the first pre-trained model, and calculate the second loss value set based on the output of the first pre-trained model; fuse the first loss value and the second loss value to obtain an updated first loss value; update the first pre-trained model based on the updated first loss value to obtain the first pre-trained model after the current iterative training.
[0227] In one possible implementation, the noise processing module 1102 is specifically used to: use each sample in the second subset as an input to at least two pre-trained models to obtain a second pseudo label for each sample in the second subset; use each sample in the second subset as an input to the first pre-trained model to obtain a second predicted label for each sample in the second subset; and calculate a second loss value based on the second predicted label and the second pseudo label.
[0228] In a possible implementation, the noise processing module 1102 is specifically used to: calculate the confidence corresponding to the initial label of each sample in the first subset based on the distance between the initial label of each sample in the first subset and the first pseudo label; calculate the fourth loss value between the predicted label and the initial label of each sample in the first subset, and the fifth loss value between the predicted label and the first pseudo label; and fuse the fourth loss value and the fifth loss value of each sample in the first subset based on the confidence corresponding to the initial label of each sample in the first subset to obtain the first loss value.
[0229] In a possible implementation, the distance between the initial label of each sample in the first subset and the first pseudo label is negatively correlated with the confidence corresponding to the initial label of each sample in the first subset.
[0230] In a possible implementation manner, the pre-training module 1101 is specifically configured to: during the pre-training process, randomly divide the training set into two equal subsets.
[0231] See also Fig.12 , a structural schematic diagram of another neural network training device provided in this application is described as follows.
[0232] The neural network training device may include a processor 1201 and a memory 1202. The processor 1201 and the memory 1202 are interconnected via a line. The memory 1202 stores program instructions and data.
[0233] The memory 1202 stores the aforementioned Figure 6-Figure 10 The program instructions and data corresponding to the steps in .
[0234] Processor 1201 is used to execute the above Figure 6-Figure 10 The method steps are performed by the neural network training device shown in any embodiment.
[0235] Optionally, the neural network training device may further include a transceiver 1203 for receiving or sending data.
[0236] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figure 6-Figure 10 The steps in the method described in any embodiment shown in any embodiment.
[0237] Optionally, the aforementioned Fig.12 The neural network training device shown in is a chip.
[0238] The embodiment of the present application also provides a neural network training device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface. The program instructions are executed by the processing unit. The processing unit is used to execute the aforementioned Figure 6-Figure 10 The method steps are performed by the neural network training device shown in any embodiment.
[0239] The embodiment of the present application also provides a digital processing chip. The digital processing chip integrates a circuit and one or more interfaces for implementing the above-mentioned processor 1201, or the functions of the processor 1201. When the digital processing chip integrates a memory, the digital processing chip can complete the method steps of any one or more of the above-mentioned embodiments. When the digital processing chip does not integrate a memory, it can be connected to an external memory through a communication interface. The digital processing chip implements the actions performed by the neural network training device in the above-mentioned embodiment according to the program code stored in the external memory.
[0240] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figure 6-Figure 10 The illustrated embodiment describes the steps performed by the neural network training device in the method.
[0241] The neural network training device provided in the embodiment of the present application may be a chip, and the chip may include: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit. The processing unit may execute the computer execution instructions stored in the storage unit, so that the chip in the server executes the above Figure 6-Figure 10 The neural network training method described in the illustrated embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0242] Specifically, the aforementioned processing unit or processor may be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC) or a 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 any conventional processor, etc.
[0243] For example, see Fig.13 , Fig.13 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 130, NPU 130 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 1303, which is controlled by the controller 1304 to extract matrix data from the memory and perform multiplication operations.
[0244] In some implementations, the operation circuit 1303 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 1303 is a two-dimensional systolic array. The operation circuit 1303 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 1303 is a general-purpose matrix processor.
[0245] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 1302 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 1301 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 1308.
[0246] The unified memory 1306 is used to store input data and output data. The weight data is directly transferred to the weight memory 1302 through the direct memory access controller (DMAC) 1305. The input data is also transferred to the unified memory 1306 through the DMAC.
[0247] The bus interface unit (BIU) 1310 is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (IFB) 1309 .
[0248] The bus interface unit 1310 (BIU) is used for the instruction fetch memory 1309 to obtain instructions from the external memory, and is also used for the storage unit access controller 1305 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0249] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1306 or to transfer weight data to the weight memory 1302 or to transfer input data to the input memory 1301.
[0250] The vector calculation unit 1307 includes multiple operation processing units, and further processes the output of the operation circuit when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, upsampling of feature planes, etc.
[0251] In some implementations, the vector calculation unit 1307 can store the processed output vector to the unified memory 1306. For example, the vector calculation unit 1307 can apply a linear function and / or a nonlinear function to the output of the operation circuit 1303, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1307 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1303, for example, for use in a subsequent layer in a neural network.
[0252] An instruction fetch buffer 1309 connected to the controller 1304 is used to store instructions used by the controller 1304;
[0253] Unified memory 1306, input memory 1301, weight memory 1302 and instruction fetch memory 1309 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0254] Among them, the operations of each layer in the recurrent neural network can be performed by the operation circuit 1303 or the vector calculation unit 1307.
[0255] The processor mentioned in any of the above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more processors for controlling the above Figure 6-Figure 10 The method is performed by a program of an integrated circuit.
[0256] It should also be noted that the device embodiments described above are merely schematic, wherein 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 they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0257] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0258] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0259] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is 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 a computer-readable storage medium, 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 site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
[0260] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0261] Finally, it should be noted that the above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A neural network training method, characterized in that: include: Dividing the training set into at least two subsets, and using the at least two subsets to pre-train the initial model respectively, to obtain at least two pre-trained models, wherein the training set includes at least one of image data, speech data, text data, business data, perception data, and computer vision processing data; Iteratively training the at least two pre-trained models using the training set to obtain at least two trained first models, wherein any iterative training process of the first pre-trained model among the at least two pre-trained models includes the following steps: Determine a first subset from the training set, each sample in the first subset carries an initial label; Using any one sample in the first subset as an input of a second pre-trained model among the at least two pre-trained models to obtain a first pseudo label of the sample; wherein the any one sample is not used in the pre-training process of obtaining the second pre-trained model; Using each sample in the first subset as input of the first pre-trained model to obtain a predicted label for each sample in the first subset; Calculate a first loss value according to the predicted label, the initial label and the first pseudo label of each sample in the first subset; Update the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training; The calculating the first loss value according to the predicted label, the initial label and the first pseudo label of each sample in the first subset includes: Calculate the confidence corresponding to the initial label of each sample in the first subset according to the distance between the initial label of each sample in the first subset and the first pseudo label; Calculate a fourth loss value between the predicted label and the initial label, and a fifth loss value between the predicted label and the first pseudo label for each sample in the first subset; fusing the fourth loss value and the fifth loss value of each sample in the first subset according to the confidence corresponding to the initial label of each sample in the first subset to obtain the first loss value; The updating the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training includes: Using a second subset of the training set as input to the first pre-trained model, and calculating a second loss value based on an output of the first pre-trained model; Fusion the first loss value and the second loss value to obtain an updated first loss value; The first pre-trained model is updated according to the updated first loss value to obtain the first pre-trained model after the current iterative training.
2. The method according to claim 1, characterized in that The step of using the second subset of the training set as the input of the first pre-trained model and calculating the second loss value according to the output of the first pre-trained model includes: Using each sample in the second subset as an input of the at least two pre-trained models to obtain a second pseudo label for each sample in the second subset; Using each sample in the second subset as an input of the first pre-trained model to obtain a second predicted label for each sample in the second subset; The second loss value is calculated according to the second predicted label and the second pseudo label.
3. The method according to claim 1, characterized in that The distance between the initial label of each sample in the first subset and the first pseudo label is negatively correlated with the confidence corresponding to the initial label of each sample in the first subset.
4. The method according to any one of claims 1 to 2, characterized in that The training set is divided into at least two subsets, including: The training set was randomly divided into two equal subsets.
5. A neural network training device, characterized in that: include: A pre-training module, used to divide a training set into at least two subsets, and use the at least two subsets to pre-train the initial model respectively, to obtain at least two pre-trained models, wherein the training set includes at least one of image data, speech data, text data, business data, perception data, and computer vision processing data; A noise processing module is used to iteratively train the at least two pre-trained models using the training set to obtain at least two trained first models, wherein any iterative training process of the first pre-trained model in the at least two pre-trained models includes the following steps: Determine a first subset from the training set, each sample in the first subset carries at least two pre-trained models with initial labels; Using any one sample in the first subset as an input of a second pre-trained model among the at least two pre-trained models to obtain a first pseudo label of the sample, wherein the any one sample is not used in a pre-training process for obtaining the second pre-trained model; Using each sample in the first subset as input of the first pre-trained model to obtain a predicted label for each sample in the first subset; Calculate a first loss value according to the predicted label, the initial label and the first pseudo label of each sample in the first subset; Update the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training; The noise processing module is specifically used for: Calculate the confidence corresponding to the initial label of each sample in the first subset according to the distance between the initial label of each sample in the first subset and the first pseudo label; Calculate a fourth loss value between the predicted label and the initial label, and a fifth loss value between the predicted label and the first pseudo label for each sample in the first subset; fusing the fourth loss value and the fifth loss value of each sample in the first subset according to the confidence corresponding to the initial label of each sample in the first subset to obtain the first loss value; Using a second subset of the training set as input to the first pre-trained model, and calculating a second set of loss values based on an output of the first pre-trained model; Fusion the first loss value and the second loss value to obtain an updated first loss value; The first pre-trained model is updated according to the updated first loss value to obtain the first pre-trained model after the current iterative training.
6. The device according to claim 5, characterized in that The noise processing module is specifically used for: Using each sample in the second subset as an input of the at least two pre-trained models to obtain a second pseudo label for each sample in the second subset; Using each sample in the second subset as an input of the first pre-trained model to obtain a second predicted label for each sample in the second subset; The second loss value is calculated according to the second predicted label and the second pseudo label.
7. The device according to claim 5, characterized in that The distance between the initial label of each sample in the first subset and the first pseudo label is negatively correlated with the confidence corresponding to the initial label of each sample in the first subset.
8. The device according to any one of claims 5 to 7, characterized in that: The pre-training module is specifically used to randomly divide the training set into two subsets.
9. A method of reasoning, characterized in that include: The input sample is used as the input of the target model, and the prediction label corresponding to the input sample is output. The target model is obtained by training the initial model. The training process of the target model includes the following steps: At least two pre-trained models divide the training set into at least two subsets, and use the at least two subsets to train the initial model respectively to obtain at least two pre-trained models, wherein the training set includes at least one of image data, voice data, text data, business data, perception data, and computer vision processing data; Iteratively training the at least two pre-trained models using the training set to obtain at least two trained first models, wherein the at least two first models include the target model, wherein any iterative training process of the first pre-trained model among the at least two pre-trained models includes the following steps: Determine a first subset from the training set, each sample in the first subset carries at least two pre-trained models with initial labels; Using any sample in the first subset as an input of a second pre-trained model of at least two pre-trained models to obtain a first pseudo label of the sample; Using each sample in the first subset as input of the first pre-trained model to obtain a predicted label for each sample in the first subset; Calculate a first loss value corresponding to the first subset according to the predicted label of each sample in the first subset and the distance between the initial label and the first pseudo label of each sample in the first subset; Update the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training; The calculating a first loss value corresponding to the first subset according to the predicted label of each sample in the first subset and the distance between the initial label of each sample in the first subset and the first pseudo label includes: Calculate the confidence corresponding to the initial label of each sample in the first subset according to the distance between the initial label of each sample in the first subset and the first pseudo label; Calculate a fourth loss value between the predicted label and the initial label, and a fifth loss value between the predicted label and the first pseudo label for each sample in the first subset; fusing the fourth loss value and the fifth loss value of each sample in the first subset according to the confidence corresponding to the initial label of each sample in the first subset to obtain the first loss value; The updating the first pre-trained model according to the first loss value to obtain the first pre-trained model after the current iterative training includes: Using a second subset of the training set as input to the first pre-trained model, and calculating a second loss value based on an output of the first pre-trained model; Fusion the first loss value and the second loss value to obtain an updated first loss value; The first pre-trained model is updated according to the updated first loss value to obtain the first pre-trained model after the current iterative training.
10. A neural network training device, characterized in that: The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores a program, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 1 to 4 is implemented.
11. A computer-readable storage medium comprising a program, which, when executed by a processing unit, performs the method according to any one of claims 1 to 4.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
