A training method, device, equipment and computer-readable storage medium

By adjusting the difficult weight distribution of the sample set, the problem of difficult samples in the AI ​​model is solved, and the training accuracy of the model is improved, so that it can learn and process difficult samples more effectively.

CN113743426BActive Publication Date: 2025-03-25HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010462418.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-27
Publication Date
2025-03-25
Estimated Expiration
2040-05-27

AI Technical Summary

Technical Problem

In the prior art, difficult samples are difficult to label, resulting in bottlenecks in the training accuracy of AI models.

Method used

By obtaining the first sample set and determining the difficult weight distribution of its samples, adjust the sample set according to the task objectives of the model to be trained, obtain the second sample set, and use the sample set to be trained for training.

Benefits of technology

The problem of difficult samples being difficult to label is solved, and the training accuracy of AI models is improved, so that the model can learn and process difficult samples more effectively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113743426B_ABST
    Figure CN113743426B_ABST
Patent Text Reader

Abstract

The present application provides a training method, apparatus and related equipment. Before training the model to be trained, the method first determines the difficulty weight distribution of the samples in the first sample set, then adjusts the first sample set according to the task objective of the model to be trained and the above-mentioned difficulty weight distribution, obtains the second sample set, and finally uses the second sample set to train the model to be trained. Using the training method provided by the present application, a suitable number of difficult samples can be selected for training in combination with the complexity of the task objective of the model to be trained and the difficulty weight of each sample, which solves the problem that the training accuracy of the model to be trained is bottlenecked due to the difficulty of labeling difficult samples, thereby improving the training accuracy of the model to be trained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence (AI), and in particular to a training method, apparatus, device, and computer-readable storage medium. Background Art

[0002] With the continuous development of science and technology, AI models have been widely used in related fields such as video imaging, speech recognition, and natural language processing. AI models usually require a large number of samples to train them. When training AI models, the role of hard sample images is often greater than that of simple sample images. Among them, hard samples refer to samples that are difficult for the model to distinguish. Specifically, they can be blurred, overexposed, unclearly outlined samples, or samples that are very similar to other samples. In the learning process of the AI ​​model, even a large number of simple samples are difficult to significantly improve the prediction accuracy of the AI ​​model, while hard sample images often significantly improve the prediction accuracy of the AI ​​model.

[0003] However, in the process of training AI models, manually screening difficult samples is a waste of manpower and time. The accuracy of labeling difficult samples by computing equipment is very poor. The current situation that difficult samples are difficult to label has caused a bottleneck in the training accuracy of AI models. Summary of the invention

[0004] The present application provides a training method, a device, and a computer-readable storage medium for solving the problem that difficult samples are difficult to label, resulting in a bottleneck in the training accuracy of AI models.

[0005] In a first aspect, a training method is provided, the method comprising the following steps:

[0006] Obtain a first sample set, and after determining the difficulty weight distribution of the samples in the first sample set, adjust the first sample set to obtain a second sample set according to the task objectives of the model to be trained and the difficulty weight distribution of the samples in the first sample set, and finally use the second sample set to train the model to be trained.

[0007] In implementing the method described in the first aspect, before training the model to be trained, the difficulty weight distribution of the samples in the first sample set can be determined first, and then the first sample set can be adjusted according to the task objective of the model to be trained and the above-mentioned difficulty weight distribution to obtain the second sample set, and finally the second sample set can be used to train the model to be trained. In this way, in the process of training the model to be trained, the training device 200 can select a suitable number of difficult samples for training based on the complexity of the task objective of the model to be trained and the difficulty weight of each sample, thereby solving the problem that the training accuracy of the model to be trained is bottlenecked due to the difficulty in labeling difficult samples, thereby improving the training accuracy of the model to be trained.

[0008] In a possible implementation, the task objectives of the model to be trained include one or more of the application scenarios of the model to be trained after training, the event types to be achieved after training, and the training accuracy objectives of the model to be trained. The model to be trained is an AI model, such as a neural network model.

[0009] When implementing the above implementation method, the difficulty levels of the task objectives of different models to be trained are different. When training a model to be trained for achieving simple task objectives, such as face recognition in indoor gate scenes, the second sample set used in training can contain more samples with small difficulty weights. Using a large number of simple samples for training and a smaller number of difficult samples for auxiliary training can improve the training speed while achieving the task objectives. Conversely, if a model to be trained for achieving complex task objectives, such as face recognition in outdoor video surveillance scenes, the second sample set used in training can contain more samples with large difficulty weights. In this way, using a large number of difficult samples for training and a smaller number of simple samples for auxiliary training can enable the model to be trained to focus more on the learning of difficult samples, and specifically improve the training accuracy of the model to be trained, thereby achieving the purpose of reinforcement learning.

[0010] In one possible implementation, the first sample set is adjusted according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set. When obtaining the second sample set, the target difficulty weight distribution that the sample set used to train the model to be trained should achieve can be determined according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set. Then, the number of samples in the first sample set can be increased or decreased, or the difficulty weights of some samples in the first sample set can be changed to obtain the second sample set, wherein the difficulty weight distribution of the samples in the second sample set is equal to or approximate to the target difficulty weight distribution.

[0011] In a specific implementation, a training device used to train the model to be trained can maintain a correspondence library, which stores the correspondence between multiple task objectives and multiple target difficulty weight distributions. In this way, after the training device determines the difficulty weight distribution of the first sample set, it can determine the target difficulty weight distribution corresponding to the task objective based on the task objective of the model to be trained and the above-mentioned correspondence library, thereby adjusting the difficulty weight distribution of the first sample set based on the gap between the difficulty weight distribution of the first sample set and the target difficulty weight distribution, and obtaining the second sample set for training the model to be trained.

[0012] It should be noted that when the first sample set is adjusted according to the target difficulty weight distribution, the difficulty weight distribution of the samples in the second sample set obtained after the adjustment may be equal to the target difficulty weight distribution, or may be similar to the target difficulty weight distribution. Wherein, being similar to the target difficulty weight distribution means that the difference between the difficulty weight distribution of the second sample set and the target difficulty weight distribution is less than the third threshold value h3. For example, if the third threshold value h3=0.2, still taking the above example as an example, the target difficulty weight distribution is difficult sample: simple sample=3:2=1.5, and the difficulty weight distribution of the first sample set is difficult sample: simple sample=3:7. After adjusting the first sample set, the difficulty weight distribution of the second sample set obtained may also be 8:5=1.6, wherein the difference between the difficulty weight distribution of the second sample set and the target difficulty weight distribution 1.6-1.5=0.1 is less than the third threshold value h3=0.2. It should be understood that the above example is only for illustration and does not constitute a specific limitation.

[0013] When implementing the above implementation method, when adjusting the difficulty weight distribution of the first sample set, the target difficulty weight distribution is determined according to the task objective of the model to be trained, and then the difficulty weight distribution of the first sample set is adjusted according to the target difficulty weight distribution. The second sample set obtained in this way is more suitable for training the model to be trained, and the training accuracy of the model to be trained can be improved in a targeted manner to achieve the purpose of reinforcement learning.

[0014] In one possible implementation, when determining the difficulty weight distribution of samples in the first sample set, each sample in the first sample set can be first input into a feature extraction model to obtain feature information of each sample, and then, based on the feature information of each sample, reference feature information of multiple categories of samples in the first sample set can be determined. Then, based on the similarity between the feature information of each sample and the reference feature information of the corresponding category, the difficulty weight corresponding to each sample is determined, thereby obtaining the difficulty weight distribution of samples in the first sample set.

[0015] In the specific implementation, the feature extraction model is used to extract the feature information of the sample, which can be an AI model trained before obtaining the first sample set. The feature extraction model can adopt any of the AI ​​models already available in the industry for extracting sample features, such as the feature descriptor (Histogram of Oriented Gradient, HOG) for target detection, the local binary pattern (Local Binary Pattern, LBP), the convolution layer of the convolutional neural network, etc., which are not specifically limited in this application. In addition, the source of the above sample set may include mobile phones or surveillance cameras, local offline data, and Internet public data, etc., which are not specifically limited in this application.

[0016] The feature information of each sample extracted by the feature extraction model can be a feature vector or a feature matrix. Assuming that the number of samples in the first category is n, the feature information obtained after each sample in this category is input into the feature extraction model is the feature vector B1, B2, ..., B n , then the reference feature information of this type of sample can be the average vector A of these n feature vectors, or it can be a feature vector B that is closest to the above average vector A among the n feature vectors j , where j∈n, can also be the feature vector of each type of sample mapped to the 2D space, and the feature vector corresponding to the point in the most densely distributed area is determined as the reference feature information of this type of sample. This application does not limit the method for determining the reference feature information.

[0017] It should be noted that when the feature information is a feature vector, the difficulty weight of each sample can be determined based on the distance between the feature vector of each sample and the reference feature vector of the corresponding category. The greater the distance between the feature vector of each sample and the reference feature vector of the corresponding category, the smaller the similarity between the feature vector of the sample and the reference feature vector of the corresponding category, and the greater the difficulty weight of the sample. In other words, there is a direct proportional relationship between the distance and the difficulty weight, and an inverse proportional relationship between the similarity and the difficulty weight.

[0018] By implementing the above implementation method, the feature extraction model is used to extract the feature information of each sample in the sample set and the information of each category of samples, and then the difficulty weight of each sample is determined according to the similarity or distance between the feature information of each sample and the reference feature information of the corresponding category. The difficulty weight distribution of the first sample set obtained in this way is obtained based on the characteristics of the sample itself, and is independent of the structure of the training model and the training method used. It can well reflect the difficulty of the sample, and the accuracy of the labeling of difficult samples is very high, thereby solving the bottleneck problem of the training accuracy of the AI ​​model due to the difficulty of labeling difficult samples.

[0019] In a possible implementation, before using the second sample set to train the model to be trained, the method may further include the following steps: adjusting the weight parameters of the loss function of the model to be trained according to the difficulty weight distribution of the samples in the second sample set.

[0020] For example, if the commonly used loss function for the task objective of the model to be trained is Loss0, the weight parameter of the sample is α i , then the formula of the loss function Loss1 of the model to be trained can be as follows:

[0021] Loss1=α i Loss

[0022] By implementing the above implementation method, after the sample with a larger difficulty weight is input into the to-be-trained model, the larger the loss function value obtained, and using the loss function to perform back-propagation supervised training on the to-be-trained model, the to-be-trained model can be more inclined to use difficult samples for parameter update. The to-be-trained model can be more focused on learning the features of difficult samples and is more inclined to use difficult samples for parameter update, thereby achieving the purpose of strengthening the training of the to-be-trained model for difficult samples, thereby improving the model's ability to express the features of difficult samples.

[0023] In a second aspect, a training device is provided, which includes: an acquisition unit, used to acquire a first sample set, the first sample set including multiple samples; a determination unit, used to determine the difficulty weight distribution of the samples in the first sample set; an adjustment unit, used to adjust the first sample set according to the task objectives of the model to be trained and the difficulty weight distribution of the samples in the first sample set to obtain a second sample set; and a training unit, used to train the model to be trained using the second sample set.

[0024] In one possible implementation, the task objective of the model to be trained includes one or more of the application scenarios of the model to be trained after training, the event types to be achieved after training, and the training accuracy objectives of the model to be trained.

[0025] In one possible implementation, the adjustment unit is specifically used to determine a target difficulty weight distribution that should be achieved by the sample set used to train the model to be trained based on the task objectives of the model to be trained and the difficulty weight distribution of the samples in the first sample set; the adjustment unit is used to increase or decrease the number of samples in the first sample set, or change the difficulty weights of some samples in the first sample set to obtain a second sample set, wherein the difficulty weight distribution of the samples in the second sample set is equal to or approximate to the target difficulty weight distribution.

[0026] In a possible implementation, the determination unit is specifically used to input each sample of the first sample set into a feature extraction model to obtain feature information of each sample, wherein each sample corresponds to a category; the determination unit is used to determine reference feature information of multiple categories of samples in the first sample set based on the feature information of each sample, wherein each category of samples includes at least one sample of the same category; the determination unit is used to determine the difficulty weight corresponding to each sample based on the similarity between the feature information of each sample and the reference feature information of the corresponding category; the determination unit is used to obtain the difficulty weight distribution of the samples in the first sample set based on the difficulty weight of each sample in the first sample set.

[0027] In a possible implementation, before the model to be trained is trained using the second sample set, the adjustment unit is further configured to adjust a weight parameter of a loss function of the model to be trained according to a difficulty weight distribution of samples in the second sample set.

[0028] According to a third aspect, a computer program product is provided, comprising a computer program, which implements the method described in the first aspect when the computer program is read and executed by a computing device.

[0029] In a fourth aspect, a computer-readable storage medium is provided, comprising instructions, which, when executed on a computing device, enable the computing device to implement the method described in the first aspect.

[0030] In a fifth aspect, a computing device is provided, including a processor and a memory, wherein the processor executes a code in the memory to implement the method described in the first aspect.

[0031] In a sixth aspect, a chip is provided, comprising a memory and a processor; the memory is coupled to the processor, the processor comprises a modem processor, the memory is used to store computer program code, the computer program code comprises computer instructions, and the processor reads computer instructions from the memory so that the chip executes the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0033] Figure 1 It is a schematic diagram of the structure of a training and prediction system;

[0034] Figure 2 It is an example graph of difficult samples in an application scenario;

[0035] Figure 3 It is a structural schematic diagram of a training device provided by the present application;

[0036] Figure 4 It is a flowchart of a training method provided by the present application;

[0037] Figure 5 It is a schematic diagram of the structure of a convolutional neural network;

[0038] Figure 6 It is an example diagram of reference feature information of each type of sample in an application scenario;

[0039] Figure 7 is an example diagram of data distribution of a first sample set in an application scenario and data distribution of a second sample set;

[0040] Figure 8 It is a flowchart of the training method provided by this application in an application scenario;

[0041] Fig. 9 It is a schematic diagram of the structure of a chip provided by the present application;

[0042] Fig.10 It is a structural schematic diagram of a computing device provided by this application. DETAILED DESCRIPTION

[0043] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.

[0044] First, some terms involved in this application are explained.

[0045] Loss Function: The loss function is used to measure the degree of inconsistency between the model's predicted value f(x) and the true value y, and is usually a non-negative real-valued function. The smaller the value of the loss function, the better the robustness of the model. The loss function is generally used to adjust the direction of network learning. For example, in a 5-classification problem, the display classification result of an input picture is the 4th category, then the true value of the picture can be y = (0, 0, 0, 1, 0). If the model's prediction result is f(x) = (0.1, 0.15, 0.05, 0.6, 0.1), the value of the loss function is -log(0.6). If the threshold of the loss function value is -log(0.9), then the model still needs further training. By adjusting the network learning direction through the loss function, a model with good final performance can be obtained. Among them, the above loss function formula is only used for example, and this application does not limit the specific formula of the loss function.

[0046] Feature Extraction: A method of transforming a measurement value to highlight the representative features of the measurement value.

[0047] Back propagation: The neural network can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the error loss information (such as the value of the loss function) is back-propagated to update the parameters in the initial neural network model, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal neural network model parameters, such as the weight matrix.

[0048] Secondly, the application scenarios involved in this application are explained.

[0049] Artificial Intelligence (AI): It is the theory, method, technology and application system that uses digital computers or computing devices controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. The application scenarios of artificial intelligence are very wide, such as face recognition, vehicle recognition, pedestrian re-identification, data processing applications, etc.

[0050] AI model is a set of mathematical methods for implementing AI. A large number of samples can be used to train AI models so that the trained AI models can acquire prediction capabilities. For example, to train a model for classifying spam, a sample set with multiple spam labels and multiple non-spam labels can be used to train the neural network during the training phase. The neural network continuously captures the connection between these emails and labels to self-adjust and improve the parameters of the network structure. Then, during the prediction phase, the neural network can classify new emails without labels as spam. It should be understood that the above examples are for illustration purposes only and do not constitute specific limitations.

[0051] The following is an explanation of the structure of the AI ​​model training and prediction system. Figure 1 As shown, Figure 1 This is an architecture diagram of an AI model training and prediction system. The system 100 is a commonly used system architecture in the AI ​​field. The system 1000 includes: a training device 100, an execution device 200, a database 130, a client device 140, and a data acquisition device 150. The various components in the system 100 can be interconnected through a network, where the network can be a wired network or a wireless network, or a mixture of the two.

[0052] The training device 200 can be a physical server, such as an X86 server, ARM server, etc., or it can be a virtual machine (VM) based on a general physical server combined with network function virtualization (NFV) technology. A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment, such as a virtual machine in cloud data. This application does not make specific limitations.

[0053] The training device 200 is used to train the model to be trained using the sample set in the database 130, obtain the target model, and send it to the execution device 100. Specifically, when training the model to be trained, the training device 200 can compare the output data of the model to be trained with the label of the sample data, and continuously adjust the structural parameters of the model to be trained according to the comparison result, until the output data of the training device 200 and the label of the sample data are less than a certain threshold, thereby completing the training of the model to be trained and obtaining the target model. Among them, the model to be trained and the target model here can be any AI model, such as the neural network model used to classify spam in the above example, or it can be an image classification model, or it can be a semantic recognition model, etc., which is not specifically limited in this application. The sample sets maintained in the database 130 do not necessarily all come from the data acquisition device 150, and may also be received from other devices. The database 130 can be a local database, or it can be a database in the cloud or other third-party platforms, which is not specifically limited in this application.

[0054] The execution device 100 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality / virtual reality, a vehicle-mounted terminal, etc., or a server or a cloud device, etc., which is not specifically limited in this application.

[0055] The execution device 100 is used to implement various functions according to the target model trained by the training device 200. Figure 1 In the example, the user can input data to the execution device 100 through the client device 140, and use the target model to predict the input data to obtain the output result. The execution device 100 can return the output result to the client device 140 so that the user can view the result output by the execution device 100. The specific presentation form can be display, sound, action and other specific methods; the execution device 100 can also use the output result as a new sample and store it in the database 130 so that the training device 200 can use the new sample to readjust the structural parameters of the target model and improve the performance of the target model.

[0056] For example, the client device 140 is a mobile phone terminal, the execution device 100 is a cloud device, and the trained target model is a semantic recognition model. The user can input text data to be recognized into the execution device through the client device 140, and the execution device 100 performs semantic recognition on the above text data to be recognized through the target model, and returns the result of the semantic recognition to the client device 140, so that the user can view the result of the semantic recognition through the user device (mobile phone terminal).

[0057] It is worth noting that Figure 1 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. Figure 1 In the embodiment, the database 130 is an external memory relative to the training device 200. In other cases, the database 130 may also be placed in the training device 200, which is not specifically limited in this application.

[0058] In summary, the realization of various applications in the field of AI depends on AI models, and different functions such as classification, recognition, detection, etc. are realized through AI models. AI models need to be pre-trained with sample sets before they can be put into execution devices for use. When using sample data from sample sets to train AI models, the role of difficult samples (HardSamples) is often greater than that of simple samples. Among them, difficult samples refer to samples that are difficult for AI models to distinguish. Specifically, they can be divided into two categories. One category is blurred, overexposed, and unclearly outlined samples. Such samples will cause AI models to make incorrect predictions regardless of the algorithm used in the AI ​​model or the initialization parameters. The other category is samples that are very similar to other samples, making it difficult for the AI ​​model to distinguish. Such samples are difficult samples only for the current AI model, but not for all AI models. For example, if Figure 1 As shown in the figure, when training an AI model for identifying the pet dog "Chihuahua", Figure 1 Samples 1, 3, and 5 with the "cookie" label are difficult to distinguish from the outline of a "Chihuahua" and are therefore difficult samples. When training an AI model for identifying "cats", Figure 1 Samples 1, 3, and 5 with the label "cookie" have good discrimination against "cat", so they are not difficult samples. Figure 1 It is for illustration only and does not constitute a specific limitation.

[0059] In the training process of AI models, even a large number of simple samples are unlikely to significantly improve the prediction accuracy of AI models, while difficult samples often significantly improve the prediction accuracy of AI models. Therefore, how to select difficult samples from a large number of training samples to strengthen the training of AI models has always been a problem that researchers have paid close attention to.

[0060] Generally speaking, difficult samples can be obtained through manual or machine labeling. Manual labeling of difficult samples is not only a waste of manpower and time, but also the labeling accuracy cannot be guaranteed due to personal cognitive bias, work fatigue and other reasons. In addition, computing devices obtain sample features by checking each pixel. Some samples that do not look similar to human eyes may also be difficult samples for AI models, resulting in poor accuracy of manual labeling of difficult samples.

[0061] Although machine labeling of difficult samples is simple and fast, the labeling accuracy is very poor. If only the samples with incorrect predictions are labeled as difficult samples, many difficult samples will be missed, because the samples with correct predictions may also be difficult samples. For example, the label of sample A is (0,1), which means that the sample belongs to the second category. If the prediction vector of sample A after inputting into the classification model M1 is (0.4,0.6), that is, the classification result of the classification model M1 shows that sample A belongs to the second category, the classification result is correct, but the prediction vector (0.4,0.6) is very different from the sample label (0,1), and the value of the loss function is also large. Although sample A is a correctly classified sample, it is also a sample that is difficult for the classification model M1 to distinguish and is a difficult sample. Therefore, the incorrectly classified samples are regarded as difficult samples, and the labeling accuracy is very poor. If samples with larger loss function values ​​are regarded as difficult samples, some simple samples may be incorrectly labeled as difficult samples. As mentioned above, the loss function is used to measure the inconsistency between the model's predicted value and the true value. There are many reasons for the inconsistency between the model's predicted value and the true value. It may be because the sample is indeed a difficult sample, or it may be because the selected model structure or training method is defective, and the sample itself is not a difficult sample that is difficult to identify. Therefore, if samples with larger loss function values ​​are regarded as difficult samples, the labeling accuracy is also poor.

[0062] In summary, in the process of training AI models, manually screening difficult samples is a waste of manpower and time. The accuracy of labeling difficult samples by computing equipment is very poor. The current situation that difficult samples are difficult to label has caused a bottleneck in the training accuracy of AI models.

[0063] In order to solve the problem that the difficult samples are difficult to label, which leads to a bottleneck in the training accuracy of the AI ​​model, the present application provides a training device 200, which can be applied to Figure 1In the AI ​​model training and prediction system shown in Figure 3 As shown, the training device 200 may include an acquisition unit 210 , a determination unit 220 , an adjustment unit 230 , a database 140 , a database 150 , and a training unit 240 .

[0064] The acquisition unit 210 is used to acquire a first sample set, where the first sample set includes a plurality of samples.

[0065] The determination unit 220 is used to determine the difficulty weight distribution of samples in the first sample set.

[0066] The higher the difficulty weight of a sample, the more difficult the sample is for the model to be trained, and the lower the difficulty weight of a sample, the simpler the sample is for the model to be trained. The difficulty weight distribution of a sample refers to the ratio of the number of samples corresponding to each difficulty weight. For example, in sample set A, the number of samples with a difficulty weight of 1 is 1,000, the number of samples with a difficulty weight of 2 is 2,000, and the number of samples with a difficulty weight of 3 is 3,000. Then the difficulty weight distribution of samples in sample set A is 1:2:3. It should be understood that the above examples are for illustration only and cannot be used as specific limitations.

[0067] In a specific implementation, the determination unit 220 may use the feature extraction model in the database 150 to determine the difficulty weight distribution of the samples in the first sample set. Specifically, the determination unit 220 may use the feature extraction model in the database 150 to perform feature extraction on each sample in the first sample set to obtain feature information of each sample, and then determine the reference feature information of each class of samples based on the feature information of each sample in each class of samples, and finally determine the difficulty weight corresponding to each sample based on the similarity between the feature information of each sample and the reference feature information of the corresponding class. For example, the determination unit 220 may input the first sample set into the feature extraction model in the database 150 to obtain the feature vector of each sample in the first sample set, and then use the average vector of the feature vectors of each class of samples as the reference feature information of the class of samples, and finally determine the difficulty weight corresponding to each sample based on the similarity or distance between the feature vector of each sample and the average vector of the corresponding class.

[0068] The adjustment unit 230 is used to adjust the difficulty weight distribution of the first sample set according to the difficulty weight of each sample and the task objective of the model to be trained, so as to obtain the second sample set.

[0069] In one embodiment, the adjustment unit 230 may first determine the target difficulty weight distribution that the sample set used to train the model to be trained should achieve based on the task objective of the model to be trained, and then increase or decrease the number of samples in the first sample set based on the difficulty weight distribution of the samples in the first sample set, or change some of the samples in the first sample set to obtain a second sample set, so that the difficulty weight distribution of the samples in the second sample set is equal to or approximate to the target difficulty weight distribution.

[0070] For example, if the first sample set has samples with three difficulty weights (α1, α2, and α3), and the difficulty weight distribution of the first sample set is α1:α2:α3=1:2:3, the adjustment unit 230 can first determine the target difficulty weight distribution for the model to be trained as α1:α2:α3=1:1:1 according to the difficulty of the task target of the model to be trained, and then adjust the first sample set to reduce the number of samples with difficulty weights α2 and α3, or increase the number of samples with difficulty weight α1, so that the difficulty weight distribution of the first sample set becomes 1:2:3, thereby obtaining the second sample set. It should be understood that the above examples are for illustration only, and the present application does not limit the number of difficulty weights.

[0071] It can be understood that when training a model to be trained to achieve simple task goals, such as face recognition in indoor gate scenes, the second sample set used in training can contain more samples with small difficulty weights. In this way, using a large number of simple samples for training and a smaller number of difficult samples for auxiliary training can improve the training speed while achieving the task goals. On the contrary, if a model to be trained to achieve complex task goals, such as face recognition in outdoor video surveillance scenes, the second sample set used in training can contain more samples with large difficulty weights. In this way, using a large number of difficult samples for training and a smaller number of simple samples for auxiliary training can enable the model to be trained to focus more on the learning of difficult samples, and specifically improve the training accuracy of the model to be trained, thereby achieving the purpose of reinforcement learning.

[0072] The training unit 240 is used to train the model to be trained using the second sample set to obtain a trained target model.

[0073] In a specific implementation, before the training unit 240 uses the second sample set to train the training model, it can first adjust the weight parameters of the loss function of the model to be trained according to the difficulty weight of each sample in the second sample set, and then use the second sample set to train the model to be trained, and perform back propagation supervised training on the model to be trained according to the loss function to obtain the target model. Among them, in the loss function of the model to be trained, the difficulty weight of each sample in the second sample set is in direct proportion to the value of the loss function, so that the difficult samples with large difficulty weights have a greater impact on the loss function, and the AI ​​model can focus more on learning the characteristics of difficult samples, and is more inclined to use difficult samples for parameter updates, so as to achieve the purpose of strengthening the training of the model to be trained for difficult samples and improve the performance of the model to be trained.

[0074] Need to explain, Figure 3 The positional relationship between the devices and units shown in the figure does not constitute any limitation. Figure 3 In the embodiment, database 130 is an external memory relative to training device 200. In other cases, database 130 can also be placed in training device 200; database 140 and database 150 are internal memories relative to training device 200. In other cases, database 140 and / or database 150 can also be placed in external memories.

[0075] In summary, the training device 200 provided in the embodiment of the present application can first determine the difficulty weight distribution of the samples in the first sample set before training the model to be trained, and then adjust the first sample set according to the task objective of the model to be trained and the above-mentioned difficulty weight distribution to obtain the second sample set, and finally use the second sample set to train the model to be trained. In this way, in the process of training the model to be trained, the training device 200 can select a suitable number of difficult samples for training based on the complexity of the task objective of the model to be trained and the difficulty weight of each sample, thereby solving the bottleneck problem of AI model training accuracy caused by difficulty and security difficulty labeling, and improving the training accuracy of the AI ​​model.

[0076] The training method provided by the present application is described in detail below. The method is applied to Figure 3 The training device 200 in the embodiment. Figure 4 As shown, the method may include the following steps:

[0077] S210: The training device 200 obtains a first sample set, where the first sample set includes a plurality of samples.

[0078] Among them, the sample can be a sample in any form, such as an image sample, a text sample, a voice sample, a biometric data (such as a fingerprint, an iris) sample, etc. The first sample set may include samples of multiple categories, such as one category of samples are all "cookie" images, one category of samples are all images of the same face at various angles, and one category of samples are all images of the same model of vehicle at different angles and in different scenes. The first sample set can be specifically classified according to the task objective of the model to be trained. For example, if the task objective of the model to be trained is face recognition, then the face images of the same person can be divided into one category, such as category 1 is Xiao Ming's face photo, and category 2 is Xiao Gang's face photo. It should be understood that the above examples are for illustration only and do not constitute specific limitations.

[0079] S220: The training device 200 determines the difficulty weight distribution of samples in the first sample set.

[0080] In one embodiment, after extracting features from each sample through a feature extraction model, the difficulty weight of each sample can be determined based on the extracted feature information, and then the difficulty weight distribution of the samples in the first sample set can be obtained. Specifically, each sample in the first sample set can be input into the feature extraction model to obtain feature information of each sample, wherein each sample corresponds to a category, and then reference feature information of multiple categories of samples in the first sample set is determined based on the feature information of each sample, wherein each category of samples includes at least one sample of the same category, and the difficulty weight corresponding to each sample is determined based on the similarity between the feature information of each sample and the reference feature information of the corresponding category, and the difficulty weight corresponding to each sample is obtained based on the difficulty weight of each sample in the first sample set. The difficulty weight distribution of the samples in the first sample set is obtained. Step S220 will be described in steps S221-S224 below.

[0081] S230: The training device 200 adjusts the first sample set according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set to obtain a second sample set.

[0082] Among them, the task objectives of the model to be trained include one or more of the application scenarios of the model to be trained after training, the event types to be achieved after training, and the training accuracy targets of the model to be trained. For example, the face recognition model in the application scenario of video surveillance and the face recognition model in the application scenario of mobile phone unlocking have different target difficulty weight distributions of samples required for training; the target difficulty weight distributions of samples required for the event type of identity recognition and the event type of clothing recognition are different when training the model; the target difficulty weight distributions of samples required for the models to be trained with low training accuracy targets and high training accuracy targets are also different. It should be understood that the above examples are for illustration only and do not constitute specific limitations.

[0083] It can be understood that when training a model to achieve simple task goals, such as face recognition in indoor gate scenes, the second sample set used in training can contain more samples with small difficulty weights. In this way, using a large number of simple samples for training and a smaller number of difficult samples for auxiliary training can improve the training speed while achieving the task goals. Conversely, if a model is trained to achieve complex task goals, such as face recognition in outdoor video surveillance scenes, the second sample set used in training can contain more samples with large difficulty weights. In this way, using a large number of difficult samples for training and a smaller number of simple samples for auxiliary training can enable the model to be trained to focus more on the learning of difficult samples, and specifically improve the training accuracy of the model to be trained, thereby achieving the purpose of reinforcement learning.

[0084] In a specific implementation, the training device 200 can maintain a correspondence library, which stores the correspondence between multiple task objectives and multiple target difficulty weight distributions. In this way, after the training device 200 determines the difficulty weight distribution of the first sample set in the database 130, it can determine the target difficulty weight distribution corresponding to the task objective according to the task objective of the model to be trained and the above-mentioned correspondence library, thereby adjusting the difficulty weight distribution of the first sample set according to the difference between the difficulty weight distribution of the first sample set and the target difficulty weight distribution, and obtaining the second sample set for training the model to be trained. It should be noted that the above-mentioned correspondence library can be stored in the internal memory of the training device 200, or in the external memory of the training device 200, which can be specifically determined by the processing power and storage capacity of the training device, and is not specifically limited in this application.

[0085] In one embodiment, when adjusting the first sample set according to the target difficulty weight distribution, the number of samples in the first sample set may be increased or decreased, or the difficulty weights of some samples in the first sample set may be changed to obtain the second sample set. For example, if the task goal is face recognition in an outdoor video surveillance scene, the target difficulty weight distribution required for the task goal is determined according to the correspondence library as difficult samples: simple samples = 3:2, wherein the difficult samples are samples whose difficulty weight α is higher than the first threshold h1, and the simple samples are samples whose difficulty weight α is lower than the second threshold h2. At this time, the first sample set P1 contains 10,000 samples, the number of difficult samples is 3,000, and the number of simple samples is 7,000, that is, the difficulty weight distribution of the first sample set is difficult samples: simple samples = 3:7. When adjusting the difficulty weight distribution of the first sample set, the 3,000 difficult samples can be expanded to 6,000 difficult samples by data enhancement, and then 4,000 simple samples are randomly selected from the 7,000 simple samples. The 6,000 difficult samples and the 4,000 simple samples are combined into the second sample set P2, and the difficulty weight distribution of the second sample set P2 is difficult samples: simple samples = 3:2.

[0086] It should be noted that when the first sample set is adjusted according to the target difficulty weight distribution, the difficulty weight distribution of the samples in the second sample set obtained after the adjustment may be equal to the target difficulty weight distribution, or may be similar to the target difficulty weight distribution. Wherein, being similar to the target difficulty weight distribution means that the difference between the difficulty weight distribution of the second sample set and the target difficulty weight distribution is less than the third threshold value h3. For example, if the third threshold value h3=0.2, still taking the above example as an example, the target difficulty weight distribution is difficult sample: simple sample=3:2=1.5, and the difficulty weight distribution of the first sample set is difficult sample: simple sample=3:7. After adjusting the first sample set, the difficulty weight distribution of the second sample set obtained may also be 8:5=1.6, wherein the difference between the difficulty weight distribution of the second sample set and the target difficulty weight distribution 1.6-1.5=0.1 is less than the third threshold value h3=0.2. It should be understood that the above example is only for illustration and does not constitute a specific limitation.

[0087] For example, Figure 7 As shown in the bar graph on the left, after the training device 200 counts the difficulty weight distribution of the entire first sample set based on the difficulty weight of each sample, the number of samples with difficulty weight α1=1 is 3000, the number of samples with difficulty weight α2=2 is 2500, the number of samples with difficulty weight α3=3 is 2000, the number of samples with difficulty weight α4=4 is 1000, and the number of samples with difficulty weight α5=5 is 500, that is, the difficulty weight distribution of the first sample set is α1:α2:α3:α4:α5=6:5:4:2:1. Assume that the target difficulty weight distribution required by the current task goal is as follows Figure 7 As shown in the bar chart on the right, α1:α2:α3:α4:α5=25:25:20:18:16, that is, the number of samples with difficulty weight α of 1 is 2500, the number of samples with difficulty weight α of 2 is 2500, the number of samples with difficulty weight α of 3 is 2000, the number of samples with difficulty weight α of 4 is 1800, and the number of samples with difficulty weight α of 5 is 1600. At this time, the number of samples with difficulty weight α of 4 and difficulty weight α of 5 is insufficient, so the number of samples with difficulty weight α of 4 and difficulty weight α of 5 can be increased, and finally the difficulty weight distribution of the first sample set can be adjusted as follows Figure 7 As shown in the bar graph on the right, the second sample set is obtained. It should be understood that Figure 7 It is for illustration only and does not constitute a specific limitation.

[0088] In a specific implementation, increasing the number of samples in the first sample set, or changing the difficulty weights of some samples in the first sample set, this process can be achieved through data enhancement, which can refer to randomly perturbing some difficult samples or simple samples to obtain more difficult samples or simple samples, wherein the random perturbation includes adding noise points, changing illumination information, changing environmental information (such as weather, background, time), etc. Data enhancement can also refer to obtaining more difficult samples or simple samples after inputting some difficult samples or simple samples into a generative adversarial network (GAN), wherein GAN can include a discriminant network and a generative network, wherein the generative network is used to generate pictures according to input data, and the discriminant network is used to determine whether the input picture is a real picture. During the training process of GAN, the goal of the generative network is to generate real pictures as much as possible so that the output result of the discriminant network is real, and the goal of the discriminant network is to determine the accurate result as much as possible, that is, to determine that the data result of the picture generated by the generative network is false, and the two networks form a dynamic "game" process, and finally the trained GAN can generate "fake and real" pictures, thereby obtaining more difficult samples or simple samples.

[0089] S240: The training device 200 trains the model to be trained using the second sample set.

[0090] In one embodiment, before using the second sample set to train the model to be trained, the weight parameters of the loss function of the model to be trained are adjusted according to the difficulty weights of the samples in the second sample set, and then when using the second sample set to train the model to be trained, the model to be trained can be back-propagated and supervised according to the above loss function to obtain the trained model to be trained, wherein the difficulty weight of each sample in the loss function is directly proportional to the value of the loss function, therefore, after the sample with a larger difficulty weight is input into the model to be trained, the larger the loss function value obtained, and the back-propagation and supervised training of the model to be trained using the loss function can make the model to be trained more inclined to use difficult samples for parameter update.

[0091] Specifically, if the commonly used loss function of the task objective of the model to be trained is Loss0, then the formula of the loss function Loss1 of the model to be trained can be as follows:

[0092] loss1=α i Loss (1)

[0093] In this way, difficult samples with large difficulty weights have a greater impact on the loss function. When the above loss function is used to perform back-propagation supervised training on the to-be-trained model, the to-be-trained model can focus more on learning the features of difficult samples and is more inclined to use difficult samples for parameter update, thereby achieving the purpose of strengthening the training of the to-be-trained model for difficult samples, thereby improving the model's ability to express the features of difficult samples. It should be understood that formula 3 is only used for illustration, and the formula of the loss function Loss1 of the to-be-trained model can also be other formulas of Loss1 and α i The formula showing a directly proportional relationship is not specifically limited in this application.

[0094] For example, if the formula for Loss0 is:

[0095]

[0096] Among them, w and b are the parameters of the model to be trained, x is the input data, y is the output data, m is the number of input data, and n is the number of categories of the model to be trained. For example, if the model to be trained is a five-category model, then n = 5. During the training process of the model to be trained, the formula of Loss1 can be:

[0097]

[0098] It should be understood that the above formula is only used for illustration, and the specific formula of Loss0 can adopt any of the various Loss formulas available in the industry, such as mean square error loss function, cross entropy loss function, etc., and this application does not make specific limitations.

[0099] The specific process of the training device 200 determining the difficulty weight distribution of the samples in the first sample set at the above step S220 is described in detail below. This step can be divided into the following steps:

[0100] Step S221: input each sample of the first sample set into a feature extraction model to obtain feature information of each sample, wherein each sample corresponds to a category.

[0101] In the specific implementation, the feature information of each sample extracted by the feature extraction model can be a feature vector or a feature matrix. For example, to facilitate a better understanding of this application, the following unified example is given by taking the feature information as a feature vector. Among them, the feature vector is a numerical feature of the sample represented in the form of a vector, which can more effectively characterize the sample characteristics. Usually, the feature vector is a multi-dimensional vector, such as a 512-dimensional vector or a 1024-dimensional vector. This application does not limit the specific dimensions of the vector. It should be noted that the feature extraction model is used to extract a certain type of feature of the sample. Different feature extraction models extract different feature vectors for the same sample. The feature extraction model used to extract facial attributes can extract features such as eyes, nose and mouth of sample A. The feature extraction model used to extract vehicle attributes can extract features such as wheels and steel materials of sample A. Therefore, the feature extraction model can be determined according to the task objective of the model to be trained. If the model to be trained is a face recognition network, then the feature extraction model used in step S221 is a feature extraction model for extracting face attribute features. If the model to be trained is a vehicle recognition network, then the feature extraction model used in step S220 is a feature extraction model for extracting vehicle attribute features. It should be understood that the above examples are for illustration only and do not constitute specific limitations.

[0102] It is understandable that the feature vectors obtained after simple samples and difficult samples are input into the feature extraction model are different. The feature vectors extracted from simple samples are of good quality, while the feature vectors extracted from difficult samples are of poor quality. The quality of the feature vector depends on its ability to distinguish image samples of different categories. Good features should be rich in information, unaffected by noise and a series of transformations, and can quickly obtain the category to which the sample belongs after inputting the classifier. On the contrary, poor-quality features lack information, and it is difficult to determine the category to which the sample belongs after inputting the classifier. For example, the feature extraction model used to extract facial attributes can easily extract the features of eyes, nose, and mouth from simple samples when performing feature extraction on simple samples, while it is difficult to extract the features of eyes, nose, and mouth from difficult samples. Therefore, the feature vectors between simple samples should be similar, while the feature vectors of difficult samples are different from those of simple samples.

[0103] In a specific implementation, the feature extraction model in the database 150 is used to extract the feature information of the sample, which can be an AI model trained before step S210. The feature extraction model can adopt any of the AI ​​models already available in the industry for extracting sample features, such as feature descriptors (Histogram of Oriented Gradient, HOG) for target detection, local binary patterns (Local Binary Pattern, LBP), convolutional layers of convolutional neural networks, etc., which are not specifically limited in this application. In addition, the source of the above sample set may include mobile phones or surveillance cameras, local offline data, and Internet public data, etc., which are not specifically limited in this application.

[0104] The following uses convolutional neural network as an example to illustrate the feature extraction model.

[0105] Convolutional Neuron Network (CNN) is a deep neural network with a convolutional structure. It is a deep learning architecture. A deep learning architecture refers to an algorithm learned by a computing device that performs multiple levels of learning at different levels of abstraction. 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. Figure 5 As shown, the convolutional neural network (CNN) 300 may include an input layer 310, a convolutional layer / pooling layer 320, and a neural network layer 330, wherein the pooling layer is an optional network layer.

[0106] (1) Convolutional layer / pooling layer 320: Figure 5 The convolution layer / pooling layer 320 shown may include layers 321-326 as shown in the examples. In one implementation, layer 321 is a convolution layer, layer 322 is a pooling layer, layer 323 is a convolution layer, layer 324 is a pooling layer, layer 325 is a convolution layer, and layer 326 is a pooling layer. In another implementation, layers 321 and 322 are convolution layers, layer 323 is a pooling layer, layers 324 and 325 are convolution layers, and layer 326 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.

[0107] Taking the convolution layer 321 as an example, the convolution layer 321 may include a plurality of convolution operators, which are also called kernels. The convolution operator is equivalent to a filter that extracts specific information from the input image matrix in image processing. The convolution operator can essentially be a weight matrix, which is usually predefined. In the process of performing convolution operations on the image, the weight matrix is ​​usually processed one pixel after another (or two pixels after two pixels, depending on the value of the step length stride) along the horizontal direction on the input image, thereby completing 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 convolution operations, the weight matrix will extend 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 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 are also of the same dimensions. The extracted feature maps with the same dimensions are then merged to form the output of the convolution operation to obtain the final feature vector.

[0108] The weight values ​​in these weight matrices 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 specific information from the input image, generate feature vectors, and then input the feature vectors into the neural network layer for classification processing, thereby helping the convolutional neural network 300 to make correct predictions.

[0109] When the convolutional neural network 300 has multiple convolutional layers, the initial convolutional layer (for example, 321) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 300 increases, the features extracted by the later convolutional layers (for example, 326) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.

[0110] (2) Pooling layer: 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 5The layers 321-326 illustrated in 320 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 in the range as the result of the maximum pooling within a specific range. 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.

[0111] (3) Neural network layer 330:

[0112] After being processed by the convolution layer / pooling layer 320, the convolution neural network 300 is not sufficient to output the required output information. As mentioned above, the convolution layer / pooling layer 320 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 300 needs to use the neural network layer 330 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 330 may include multiple hidden layers (such as Figure 5 331, 332 to 33n) and the output layer 340 shown, the parameters contained in the multi-layer hidden layers can be pre-trained according to relevant training data of a specific task type.

[0113] After the multiple hidden layers in the neural network layer 330, that is, the last layer of the entire convolutional neural network 300 is the output layer 340, 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 300 (such as Figure 5 The propagation from 310 to 340 is forward propagation), and the reverse propagation (such as Figure 5 The propagation from 340 to 310 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 300 and the error between the result output by the convolutional neural network 300 through the output layer and the ideal result.

[0114] In summary, the input layer 310 and the convolution layer / pooling layer 320 are used to extract sample features and obtain sample feature vectors, and the neural network layer 330 is used to classify the input image according to the feature vectors extracted by the convolution layer / pooling layer 320. Therefore, the feature extraction model required by the present application can be simply understood as a convolutional neural network that only includes the convolution layer / pooling layer 320 and does not include the neural network layer 330. It should be understood that the above examples are only for illustration and do not constitute a specific limitation.

[0115] Step S222: Determine reference feature information of multiple categories of samples in the first sample set according to the feature information of each sample, wherein each category of samples includes at least one sample of the same category.

[0116] For example, assuming that the number of samples in the first category is n, the feature information of each sample in this category is the feature vector B1, B2, ..., B n , then the reference feature information of this type of sample can be the average vector A of these n vectors, or it can be a vector B among the n vectors that is closest to the above average vector A. j , where j∈n. Similarly, vectors of samples of other categories can be obtained. When the reference feature information is expressed in the form of a vector, the reference feature information is also called a reference feature vector. For example, if the feature information of each sample is a 512-dimensional feature vector, then the multi-dimensional feature vector obtained in step S221 is mapped to a 2D space and plotted in a plane rectangular coordinate system in the form of coordinate points. The reference feature information of each type of sample can be as follows: Figure 6 It should be understood that Figure 6 For example only, the reference feature information of each type of sample can also be obtained by mapping the feature vector of each type of sample to 2D space, and then determining the feature vector corresponding to the point in the most densely distributed area as the reference feature information of this type of sample. This application does not limit the method for determining the reference feature information.

[0117] Step S223: Determine the difficulty weight corresponding to each sample based on the similarity between the feature information of each sample and the reference feature information of the corresponding category.

[0118] Among them, the greater the similarity between the feature information of each sample and the reference feature information of the corresponding category, the smaller the difficulty weight of the sample, that is, the similarity and the difficulty weight are inversely proportional. It can be understood that when the feature information is a feature vector, the difficulty weight of each sample can be determined according to the distance between the feature vector of each sample and the reference feature vector of the corresponding category. The greater the distance between the feature vector of each sample and the reference feature vector of the corresponding category, the smaller the similarity between the feature vector of the sample and the reference feature vector of the corresponding category, and the greater the difficulty weight of the sample, that is, the distance and the difficulty weight are directly proportional.

[0119] For example, if the feature vectors obtained after each sample in the first category is input into the feature extraction model are B1, B2, …, B n , the reference feature vector is vector A, then the difficulty weight of feature vector B1 can be determined based on the distance between feature vector B1 and reference feature vector A, the difficulty weight of feature vector B2 can be determined based on the distance between feature vector B2 and reference feature vector A, and so on. n The distance between the feature vector and the reference feature vector A determines the feature vector B n Similarly, the difficulty weight of each sample can be determined according to the distance between each sample and the reference feature vector of the corresponding category.

[0120] In a specific implementation, the distance between a feature vector of a sample and a reference feature vector may be cosine distance, Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, etc., and the similarity between feature information of a sample and reference feature information may be cosine similarity, adjusted cosine similarity, Pearson Correlation Coefficient, Jaccard Coefficient, etc., which is not specifically limited in this application.

[0121] For example, the reference feature vector of a certain type of sample is A, and the feature vector is B i = {B1, B2, …, B n}, then the reference eigenvector A and eigenvector B i The distance formula D i (cosine distance) can be:

[0122]

[0123] Based on formula (4), the feature vector B of each sample can be determined i The distance D from the reference feature vector A i It should be understood that the above formula 4 is only used for illustration and does not constitute a specific limitation.

[0124] refer to Figure 5It can be seen from the embodiments that the feature extraction model used to extract sample features includes multiple weight matrices for extracting specific features. Each weight matrix can extract specific colors, specific edge information, etc. Therefore, for simple samples, the weight matrix can extract specific colors, specific edge information, etc. very well, and the feature vectors extracted from different simple samples are very similar; while for difficult samples, the weight matrix may not be able to extract specific colors, specific edge information, etc., so the feature vectors extracted from difficult samples are very different from the feature vectors extracted from simple samples. In this way, by determining the distance between the feature vector extracted from each sample and the reference feature vector, the difficulty of the sample can be well determined. The greater the distance between the feature vector of the sample and the reference feature vector, the smaller the similarity between the feature vector of the sample and the reference feature vector, indicating that the sample is more difficult to sample, and the greater the difficulty weight. On the contrary, the smaller the distance between the feature vector of the sample and the reference feature vector, the greater the similarity between the feature vector of the sample and the reference feature vector, indicating that the sample is more simple to sample, and the smaller the difficulty weight. Therefore, the difficulty weight α i The formula can be:

[0125] α i =T×D i i=1,2,…,n (5)

[0126] Among them, T is a constant greater than 1. It should be understood that the above formula 5 is only for illustration, and the formula of the difficulty weight α can be other formulas in which the difficulty weight α is in direct proportion to the distance D, and this application does not make any specific limitation.

[0127] Similarly, if the difficulty weight α of a sample is determined based on the similarity S between the feature information of the sample and Chen Kun's feature information, the formula for the difficulty weight can be:

[0128] α i =TS i i=1,2,…,n (6)

[0129] It should be understood that the above formula 6 is only for illustration, and the formula of the difficulty weight α may be other formulas in which the difficulty weight α is inversely proportional to the similarity S, and the present application does not make any specific limitation.

[0130] In one embodiment, in Formula 5 and Formula 6, the difficulty weight α iThe constant T in can be an adjustable constant. Specifically, in the early stage of training the model to be trained, T can be a larger constant, so that the difficulty weight of the difficult sample is higher, the value of the loss function is larger, and the learning focus of the model to be trained is more biased towards the difficult sample. At the end of the training of the model to be trained, T can be appropriately reduced, because at this time the AI ​​model has tended to converge and no longer needs to be biased towards the difficult samples that take more time, thereby increasing the training speed.

[0131] Step S224: Obtain the difficulty weight distribution of samples in the first sample set according to the difficulty weight of each sample in the first sample set.

[0132] It can be understood that the feature extraction model is used to extract the feature vector of each sample in the sample set and the vector of each category of samples, and then the difficulty weight of each sample is determined according to the similarity or distance between the feature vector of each sample and the vector of the corresponding category. The difficulty weight distribution of the first sample set obtained in this way is based on the characteristics of the sample itself, and has nothing to do with the structure of the training model and the training method used. It can well reflect the difficulty of the sample, and the accuracy of the labeling of difficult samples is very high, thereby solving the bottleneck problem of the training accuracy of the AI ​​model due to the difficulty of labeling difficult samples.

[0133] In one embodiment, after the training device obtains the difficulty weight distribution of the samples in the first sample set, the difficulty weight distribution of the first sample set can also be stored in the database 130. In this way, after the difficulty weight distribution of many sample sets is stored in the database 130, if the training device needs to train the AI ​​model, after determining the target difficulty weight distribution according to the task goal of the AI ​​model to be trained, the sample set close to the target difficulty weight distribution can be directly obtained from the database 130 to train the AI ​​model to be trained. For example, the database 130 stores three sample sets, namely sample sets X1, X2 and X3, and the database 130 also stores the difficulty weight distribution Y1=1:1 of the sample set X1, the difficulty weight distribution Y2=1:2 of the sample set X2, and the difficulty weight distribution Y3=1:5 of the sample set X3. The training device 200 can obtain the target difficulty weight distribution Y0=1:6 corresponding to the task goal according to the task goal of the model to be trained and the corresponding relationship library in the above content, and then obtain the sample set whose difficulty weight distribution is closest to the target difficulty weight distribution Y0 in the database 130, that is, the sample set X3. In this way, the training device 200 does not need to execute step S230 to adjust the difficulty weight distribution, but can directly select a sample set that is the same or similar to the target difficulty weight distribution as the second sample set to train the AI ​​model to be trained, thereby further improving the training speed of the AI ​​model.

[0134] In summary, the present application provides a model training method, which can determine the difficulty weight distribution of samples in the first sample set before training the model to be trained, and then adjust the first sample set according to the task goal of the model to be trained and the above-mentioned difficulty weight distribution to obtain the second sample set, and finally use the second sample set to train the model to be trained. In this way, in the process of training the model to be trained, the training device 200 can select a suitable number of difficult samples for training based on the complexity of the task goal of the model to be trained and the difficulty weight of each sample, thereby solving the problem of bottlenecks in the training accuracy of the AI ​​model caused by the difficulty of labeling difficult samples, thereby improving the training accuracy of the AI ​​model.

[0135] Combine the following Figure 8 , the training method provided in this application is illustrated by example. Figure 8 As shown in the figure, assuming that the task target of the current model to be trained is face recognition in outdoor video surveillance scenes, which is a relatively complex task scenario. The first sample set used to train the model to be trained includes two types of samples. The first type of samples is the face images of ID1 (such as the face images of the character Ann at various angles), including samples X11~X14, and the second type of samples is the face images of ID2 (such as the face images of the character Lisa at various angles), including samples X21~X24, a total of 8 samples. In this application scenario, Figure 8 As shown, the training method provided by the present application comprises the following steps:

[0136] Step 1: Input each sample of each class of samples in the first sample set into the feature extraction model to obtain the feature vector of each sample. The feature extraction model is used to extract facial features. Figure 8 As shown, inputting samples X11-X14 into the feature extraction model can obtain feature vectors A11-A14, and inputting samples X21-X24 into the feature extraction model can obtain feature vectors A21-A24. For details, please refer to step S221 in the above content, which will not be elaborated here.

[0137] Step 2: Determine the reference feature vector of each class of samples in the first sample set. The reference feature vector of each class of samples may be the average value of the feature vectors of each class of samples, or a feature vector that is closest to the average value, or the feature vector of each class of samples mapped to a 2D space, and the feature vector corresponding to the point in the most densely distributed area is determined as the reference feature information of the class of samples. This application does not limit the method for determining the reference feature information. Figure 8 This is illustrated by taking an eigenvector closest to the mean as an example, Figure 8 The reference feature vector A14 and the reference feature vector A21 shown in FIG. Specific details may be referred to step S222 in the aforementioned content, and will not be elaborated here.

[0138] Step 3: Determine the distance between each feature vector and the reference feature vector of the corresponding category. Figure 8 As shown, the distance D11 between the eigenvectors A14 and A11, the distance D12 between the eigenvectors A14 and A12, the distance D13 between the eigenvectors A13 and A14, and the distance between the eigenvectors A14 and A14 is 0. Similarly, the distance D21 between the eigenvectors A21 and A22 in the second class of samples, the distance D22 between the eigenvectors A21 and A23, and the distance D23 between the eigenvectors A21 and A24 can be calculated, and the distance between the eigenvectors A21 and A21 is 0. Wherein, the distance can be any one of the cosine distance, Euclidean distance, Manhattan distance, Chebyshev distance, and Manhattan distance in the foregoing content, and the present application does not make specific limitations. This step can refer to step S223 and its optional steps in the foregoing content, and will not be expanded here.

[0139] Step 4: Determine the difficulty weight α of each sample in the first sample set to obtain the difficulty weight distribution of the first sample set. The formula of the difficulty weight can refer to Formula 5, that is, α 11 =T×D11,α 12 =T×D12, and so on, the difficulty weight of each sample in the 8 samples can be obtained as follows Figure 8 As shown, samples with difficulty weights greater than the first threshold h1 are represented by dark colors, that is, the difficulty weights of samples X11 and X22 are higher than the threshold. This step can refer to step S224 and its optional steps in the above content, and will not be elaborated here.

[0140] Step 5: Determine the target difficulty weight of the model to be trained according to the task objective of the model to be trained, and adjust the difficulty weight distribution of the first sample set according to the target difficulty weight to obtain the second sample set. Figure 8 As shown, the difficulty weight distribution of the first sample set is difficult sample: non-difficult sample = 1:3, assuming that the target difficulty weight corresponding to the task target is difficult sample: non-difficult sample = 3:1, but since there are only two difficult samples in the first sample set, namely X11 and X22, it is necessary to expand the difficult samples through the data increment method so that the ratio between the expanded difficult samples (6) and the non-difficult samples (2) reaches 3:1, thereby obtaining a second sample set for training the model to be trained. This step can refer to step S230 and its optional steps in the aforementioned content, and will not be elaborated here.

[0141] Step 6, use the second sample set to train the model to be trained. Among them, the loss function of the model to be trained can be as shown in Formula 3. This loss function makes the difficult samples with large difficulty weights have a greater impact on the loss function during the training process of the model to be trained, so that the model to be trained can be more focused on learning the characteristics of difficult samples, and is more inclined to use difficult samples for parameter update, thereby achieving the purpose of reinforcement learning. In addition, the constant T in the difficulty weight can be set to a higher value at the beginning of training, so that the influence of difficult samples on the training of the model to be trained is the highest, and then the constant T in the difficulty weight can be set to a lower value at the end of training. At this time, the model to be trained has tended to converge, and it is no longer necessary to be biased towards difficult samples that consume more time, thereby increasing the training speed. This step can refer to step S240 and its optional steps in the aforementioned content, which will not be elaborated here.

[0142] The training method uses a feature extraction model to extract features from each sample in the first sample set, determines a reference feature vector of the same sample based on the feature vector extracted from each sample in the first sample set, and then determines the difficulty weight of each sample based on the distance between the feature vector of each sample in the same sample and the reference feature vector, and then adjusts the difficulty weight distribution of the first sample set based on the difficulty weight, and uses the second sample set after the difficulty weight distribution is adjusted to train the model to be trained. In this way, the training device 200 can select a suitable number of difficult samples for training in combination with the complexity of the task target of the model to be trained and the difficulty weight of each sample in the process of training the model to be trained, thereby solving the bottleneck problem of the training accuracy of the AI ​​model caused by the difficulty and security difficulty labeling, and improving the training accuracy of the AI ​​model. In addition, since the weight parameter of the loss function of the model to be trained is adjusted according to the difficulty weight distribution of the second sample set, the value of the loss function is in direct proportion to the difficulty weight. The larger the difficulty weight of the sample, the larger the loss function value obtained by using the sample to train the model to be trained, so that the model to be trained can focus more on learning the characteristics of the difficult samples, thereby achieving the enhanced training effect for the difficult samples, and further improving the prediction accuracy of the AI ​​model.

[0143] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, correspondingly, related equipment for cooperating in implementing the above scheme is also provided below.

[0144] Fig. 9 A chip hardware structure provided in an embodiment of the present application includes a neural network processor 50. The chip can be set in the training device 200 and the training device 200 in the aforementioned content to complete the training work of the training unit 240 and the feature extraction work of the extraction module 211. Figure 5The algorithms of each layer in the convolutional neural network shown in the figure can be used in Fig. 9 is implemented in the chip shown.

[0145] It should be noted that the neural network processor (NPU) 900 can be mounted on the host CPU as a coprocessor, and the host CPU 800 assigns tasks. The host CPU 800 is like a manager, responsible for determining which data needs to be executed by the NPU core, and then issuing instructions to trigger the NPU 900 to process the data. The NPU 900 can also be integrated into a CPU, such as the Kirin 970, or it can be used as a separate chip. The core part of the NPU 900 is the operation circuit 903, which is controlled by the controller 904 to extract the matrix data in the memory and perform multiplication operations, such as Figure 5 Convolution operation in an embodiment.

[0146] In some implementations, the operation circuit 903 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 903 is a two-dimensional systolic array. The operation circuit 903 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 903 is a general-purpose matrix processor.

[0147] 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 902 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 901 and performs matrix operation with matrix B. The partial result or final result of the matrix is ​​stored in the accumulator 908.

[0148] The unified memory 906 is used to store input data and output data. The weight data is directly transferred to the weight memory 902 through the direct memory access controller (DMAC) 905. The input data is also transferred to the unified memory 906 through the DMAC.

[0149] The bus interface unit (BIU) 910 is used to interact with the storage unit access controller 905 and the instruction fetch buffer (IFB) 909 through the bus protocol (Advanced Xtensible Interface, AXI).

[0150] The bus interface unit 910 is used for the instruction fetch memory 909 to obtain instructions from the external memory, and is also used for the storage unit access controller 905 to obtain the original data of the input matrix A or the weight matrix B from the external memory.

[0151] The storage unit access controller 905 is mainly used to transfer input data in the external memory to the unified memory 906 or to transfer weight data to the weight memory 902 or to transfer input data to the input memory 901 .

[0152] The vector calculation unit 907 includes multiple operation processing units, which further process 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 / FC layer network calculations in neural networks, such as pooling, batch normalization, local response normalization, etc.

[0153] In some implementations, the vector calculation unit 907 can store the processed output vector to the unified buffer 906. For example, the vector calculation unit 907 can apply a nonlinear function to the output of the operation circuit 903, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector calculation unit 907 generates a normalized value, a merged value, or both. In some implementations, the vector of processed outputs can be used as an activation input to the operation circuit 903, such as for use in a subsequent layer in a neural network.

[0154] The instruction fetch buffer 909 connected to the controller 904 is used to store instructions used by the controller 904; the controller 904 is used to call the instructions cached in the instruction fetch buffer 909 to realize the working process of controlling the computing accelerator.

[0155] Generally, unified memory 906, input memory 901, weight memory 902 and instruction fetch memory 909 are all on-chip memories. External memory is private to the NPU hardware architecture. The external memory can be a double data rate synchronous dynamic random access memory (DDR SDRAM), a high bandwidth memory (HBM) or other readable and writable memory.

[0156] Fig.10is a schematic diagram of the hardware structure of a computing device provided by the present application. The computing device 1000 may be Figure 2-Figure 10 The training device 200 in the embodiment. Fig.10 As shown, the computing device 1000 includes: a processor 1010, a communication interface 1020, a memory 1030 and a neural network processor 1050. Among them, the processor 1010, the communication interface 1020, the memory 1030 and the neural network processor 1050 can be interconnected through an internal bus 1040, and can also communicate through other means such as wireless transmission. The embodiment of the present application takes the connection through bus 1040 as an example. Bus 1040 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus 1040 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0157] The processor 1010 may be composed of at least one general-purpose processor, such as a central processing unit (CPU), or a combination of a CPU and a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 1010 executes various types of digital storage instructions, such as software or firmware programs stored in the memory 1030, which enables the computing device 1000 to provide a wide variety of services.

[0158] The memory 1030 is used to store program codes and is controlled by the processor 1010 to execute the above Figure 2-Figure 8 The processing steps of the training device 200 in any embodiment of the present invention. The program code may include one or more software modules. The one or more software modules may be Figure 3The software modules provided in the illustrated embodiment, such as an acquisition unit, a determination unit, an adjustment unit, and a training unit, wherein the acquisition unit can be used to acquire a first sample set, the determination unit can be used to determine the difficulty weight distribution of the first sample set, the adjustment unit can be used to adjust the difficulty weight distribution of the first sample set according to the difficulty weight corresponding to each sample in the first sample set and the task objective of the model to be trained to obtain a second sample set, and the training unit can be used to perform training using the model to be trained of the second sample set, can be used to execute steps S210-S230 and optional steps thereof, steps 1-6 and optional steps thereof of the aforementioned method, and can also be used to execute Figure 2-Figure 8 The other steps performed by the training device described in the embodiment will not be described in detail here.

[0159] It should be noted that this embodiment can be implemented by a general physical server, for example, an ARM server or an X86 server, or it can be implemented by a virtual machine based on a general physical server combined with NFV technology. The virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. This application does not make any specific limitations.

[0160] The neural network processor 1050 can be used to obtain an inference model through the training program and sample data in the memory 1030 to execute at least a part of the method discussed herein. The hardware structure of the neural network processor 1050 can be specifically referred to in Fig. 9 .

[0161] The memory 1030 may include a volatile memory, such as a random access memory (RAM); the memory 1030 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 1030 may also include a combination of the above types. The memory 1030 may store the first sample set and / or the second sample set, and the memory 1030 may store program codes, which may specifically include a program code for executing Figure 2-Figure 8 The program codes of other steps described in the embodiment will not be described in detail here.

[0162] The communication interface 1020 can be a wired interface (such as an Ethernet interface), an internal interface (such as a high-speed serial computer expansion bus (Peripheral Component Interconnect express, PCIe) bus interface), a wired interface (such as an Ethernet interface) or a wireless interface (such as a cellular network interface or a wireless local area network interface) for communicating with other devices or modules.

[0163] Need to explain, Fig.10 This is only a possible implementation of the embodiment of the present application. In practical applications, the computing device may also include more or fewer components, which is not limited here. Figure 2-Figure 8 The relevant explanations in the embodiments are not repeated here.

[0164] It should be understood that Fig.10 The computing device shown may also be a computer cluster consisting of at least one server, which is not specifically limited in this application.

[0165] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a processor, Figure 2-Figure 8 The method flow shown is realized.

[0166] The present application also provides a computer program product. When the computer program product is run on a processor, Figure 2-Figure 8 The method flow shown is realized.

[0167] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes at least one computer instruction. When the computer program instruction is loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instruction can 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 instruction can be transmitted from a website, computer, server or data to another website, computer, server or data by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data containing at least one available medium set. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a high-density digital video disc (DVD), or a semiconductor medium. The semiconductor medium may be an SSD.

[0168] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A training method, characterized in that: The method comprises: Acquire a first sample set, where the first sample set includes a plurality of samples, and the sample is one of an image sample, a text sample, a voice sample, and a biological data sample; Determine reference feature information of each class of samples in the first sample set according to the feature information of each sample, wherein the reference feature information of each class of samples includes an average value of feature vectors of each class of samples or a feature vector closest to the average value; Based on the similarity between the feature information of each sample and the reference feature information of the corresponding category, determine the difficulty weight corresponding to each sample, and obtain the difficulty weight distribution of the samples in the first sample set, wherein the smaller the similarity between the feature information of each sample and the reference feature vector of the corresponding category, the greater the difficulty weight; According to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set, the first sample set is adjusted to obtain a second sample set; The model to be trained is trained using the second sample set.

2. The method according to claim 1, characterized in that The task objectives of the model to be trained include one or more of the application scenarios of the model to be trained after training, the event types to be achieved after training the model to be trained, and the training accuracy objectives of the model to be trained.

3. The method according to claim 1 or 2, characterized in that: The step of adjusting the first sample set according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set to obtain the second sample set comprises: Determining a target difficulty weight distribution that should be achieved by the sample set used to train the model to be trained according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set; The number of samples in the first sample set is increased or decreased, or the difficulty weights of some samples in the first sample set are changed to obtain a second sample set, wherein the difficulty weight distribution of the samples in the second sample set is equal to or approximate to the target difficulty weight distribution.

4. The method according to any one of claims 1 to 3, characterized in that: The determining, according to the feature information of each sample, reference feature information of each type of samples in the first sample set comprises: Inputting each sample of the first sample set into a feature extraction model to obtain feature information of each sample, wherein each sample corresponds to a category; Reference feature information of multiple categories of samples in the first sample set is determined according to the feature information of each sample, wherein each category of samples includes at least one sample of the same category.

5. The method according to any one of claims 1 to 4, characterized in that: Before using the second sample set to train the model to be trained, the method further includes: According to the difficulty weight distribution of the samples in the second sample set, the weight parameters of the loss function of the model to be trained are adjusted.

6. A training device, characterized in that: The device comprises: An acquisition unit, configured to acquire a first sample set, wherein the first sample set includes a plurality of samples, and the sample is one of an image sample, a text sample, a voice sample, and a biological data sample; a determining unit, configured to determine reference feature information of each class of samples in the first sample set according to feature information of each sample, wherein the reference feature information of each class of samples includes an average value of feature vectors of each class of samples or a feature vector closest to the average value; The determining unit is used to determine the difficulty weight corresponding to each sample based on the similarity between the feature information of each sample and the reference feature information of the corresponding category, and obtain the difficulty weight distribution of the samples in the first sample set, wherein the smaller the similarity between the feature information of each sample and the reference feature vector of the corresponding category, the greater the difficulty weight; an adjusting unit, configured to adjust the first sample set according to a task objective of the model to be trained and a difficulty weight distribution of samples in the first sample set to obtain a second sample set; A training unit is used to train the model to be trained using the second sample set.

7. The device according to claim 6, characterized in that The task objectives of the model to be trained include one or more of the application scenarios of the model to be trained after training, the event types to be achieved after training the model to be trained, and the training accuracy objectives of the model to be trained.

8. The device according to claim 6 or 7, characterized in that The adjustment unit is specifically used for: Determining a target difficulty weight distribution that should be achieved by the sample set used to train the model to be trained according to the task objective of the model to be trained and the difficulty weight distribution of the samples in the first sample set; The number of samples in the first sample set is increased or decreased, or the difficulty weights of some samples in the first sample set are changed to obtain a second sample set, wherein the difficulty weight distribution of the samples in the second sample set is equal to or approximate to the target difficulty weight distribution.

9. The device according to any one of claims 6 to 8, characterized in that The determining unit is specifically used for: Inputting each sample of the first sample set into a feature extraction model to obtain feature information of each sample, wherein each sample corresponds to a category; Reference feature information of multiple categories of samples in the first sample set is determined according to the feature information of each sample, wherein each category of samples includes at least one sample of the same category.

10. The device according to any one of claims 6 to 9, characterized in that Before using the second sample set to train the model to be trained, the training unit is further used to: adjust the weight parameters of the loss function of the model to be trained according to the difficulty weight distribution of the samples in the second sample set.

11. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on a computing device, cause the computing device to execute the method according to any one of claims 1 to 5.

12. A computing device, characterized in that: The method comprises a processor and a memory, wherein the processor executes the code in the memory to perform the method according to any one of claims 1 to 5.

13. A computer program product, characterized in that The method comprises a computer program, and when the computer program is read and executed by a computing device, the computing device is caused to perform the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Sample weight allocation method, model training method, electronic equipment and storage medium

    CN108229555A

  • Neural network model training method and device, computer equipment and storage medium

    CN109840588A