Model training method and apparatus, and computer storage medium

By mining hard samples using the teacher model and combining metric learning and reinforcement learning, the problem that lightweight student models cannot learn knowledge from the teacher model is solved, improving the model's recognition accuracy and reliability, and making it particularly suitable for training small models.

CN115294428BActive Publication Date: 2025-11-28江苏云从曦和人工智能有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210789561.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-06
Publication Date
2025-11-28
Estimated Expiration
2042-07-06

AI Technical Summary

Technical Problem

In existing technologies, lightweight student models cannot learn all the knowledge of teacher models, especially difficult samples, resulting in a high false recognition rate. Furthermore, they cannot guarantee that the distance within the same category is small enough, and the distance between different categories is large enough, which affects the model's recognition performance.

Method used

We utilize teacher models to mine difficult samples from the training samples, and train student models through metric learning and reinforcement learning to improve their performance on difficult samples. We also use offline methods to mine representative difficult samples for optimization training.

Benefits of technology

It improves the training effect and prediction accuracy of student models, especially suitable for small models with few parameters, and enhances the model's ability to identify difficult samples and the separability of features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115294428B_ABST
    Figure CN115294428B_ABST
Patent Text Reader

Abstract

The application provides a model training method and device and a computer storage medium, comprising: performing feature extraction on each training sample by using a teacher model to obtain teacher features of each training sample; determining a difficult sample of each training sample according to the teacher features of each training sample and a real label; performing feature extraction on each training sample by using a student model to obtain student features of each training sample; and training the student model according to the student features of each training sample and the difficult sample of each training sample. Accordingly, the application can provide better model training effect and improve model prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of artificial intelligence, and particularly relate to a model training method and device and computer storage medium. BACKGROUND

[0002] Model distillation is currently the mainstream training method in face recognition tasks, especially for small models with small parameter quantities, which has the advantages of fast convergence and high performance.

[0003] The current mainstream face recognition distillation method mainly includes pre-training a teacher model to fix the model parameters, and in the distillation stage, using the trained teacher model to extract features, and the student model extracts features for the same image sample, and then using the Euclidean distance measurement method to calculate the distance between the features extracted by the teacher model and the student model, thereby providing the student model with the knowledge of the teacher model to learn, thereby realizing the training of the student model.

[0004] However, due to the low parameter quantity of the lightweight student model, it is often impossible to learn all the knowledge of the teacher model. Especially for difficult samples that the teacher model is prone to make mistakes, the probability of student model misidentification will be greatly increased.

[0005] In addition, the student model obtained only by regression task distillation has no class concept, which easily causes the training requirement that the distance within the same class is not small enough and the distance between different classes is not large enough enough during the learning process, and cannot fully tap the performance of the recognition model.

[0006] Therefore, an improved model training scheme is needed to overcome the various problems in the prior art. SUMMARY

[0007] In view of the above problems, the present application provides a model training method, device and computer storage medium, which can improve the model training effect and improve the model prediction accuracy.

[0008] The first aspect of the present application provides a model training method, comprising: using a teacher model to perform feature extraction for each training sample to obtain a teacher feature of each training sample; determining a difficult sample of each training sample according to the teacher feature of each training sample and the real label; and training the student model using each training sample and the difficult sample of each training sample.

[0009] The second aspect of the present application provides a model training device, comprising: a difficult sample determination module, configured to perform feature extraction on each training sample by using a teacher model, to obtain a teacher feature of each training sample, and to determine a difficult sample of each training sample according to the teacher feature of each training sample and a real label; and a training module, configured to train the student model by using each training sample and the difficult sample of each training sample.

[0010] The third aspect of the present application provides a computer storage medium, wherein the computer storage medium stores instructions for performing each step in the method of the above aspects.

[0011] In summary, the model training scheme provided by the aspects of the present application uses a teacher model to mine difficult samples corresponding to each training sample, so that the student model performs model optimization training based on the difficult samples, which not only improves the model training effect, but also improves the accuracy and reliability of the model prediction result. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art based on these drawings.

[0013] Figure 1 The processing flowchart of the model training method of the exemplary embodiment of the present application.

[0014] Figure 2 The processing flowchart of the model training method of another exemplary embodiment of the present application.

[0015] Figure 3 The processing flowchart of the model training method of another exemplary embodiment of the present application.

[0016] Figure 4 The processing flowchart of the model training method of another exemplary embodiment of the present application.

[0017] Figure 5 The structural block diagram of the model training device of the exemplary embodiment of the present application. DETAILED DESCRIPTION

[0018] In the specific embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described in connection with the drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by a person of ordinary skill in the art shall fall within the scope of protection of the present application.

[0019] The specific embodiments of the present application will be described in detail below in connection with the drawings.

[0020] Figure 1 The processing flow chart of the model training method of the exemplary embodiments of the present application is shown in the figure. As shown, the present embodiment mainly includes the following steps:

[0021] In step S102, the teacher model is used to perform feature extraction on each training sample to obtain the teacher feature of each training sample.

[0022] Optionally, the teacher model can include a detection model with image recognition capability, such as a face recognition model, an object recognition model, etc.

[0023] Optionally, the teacher model can be pre-trained to fix the model parameters (such as weight parameters, etc.) of the teacher model, and the trained teacher model is used to perform feature extraction on each training sample to obtain the teacher feature of each training sample.

[0024] In step S104, the difficult sample of each training sample is determined according to the teacher feature of each training sample and the real label.

[0025] Optionally, according to the real label of the current sample, each training sample with the same category as the current sample can be obtained, and similarity calculation can be performed to determine one or more samples with the lowest similarity value as the positive difficult sample of the current sample.

[0026] Optionally, according to the real label of the current sample, each training sample with a different category from the current sample can be obtained, and similarity calculation can be performed to determine one or more samples with the highest similarity value as the negative difficult sample of the current sample.

[0027] In step S106, the student model is trained using each training sample and the difficult sample of each training sample.

[0028] Optionally, the student model has the same image recognition capability as the teacher model.

[0029] Optionally, the metric learning and the reinforcement learning are respectively performed according to the student feature of each training sample, the positive difficult sample of each training sample, and the negative difficult sample of each training sample, so as to train the student model.

[0030] In summary, the model training method of the embodiment can improve the training effect of the student model, and improve the accuracy and reliability of the prediction result of the student model, and is especially suitable for training of a lightweight model.

[0031] Figure 2 The processing flowchart of the model training method of another exemplary embodiment of the present application is shown in the figure. The embodiment is a specific implementation of step S104, and mainly includes the following steps:

[0032] In step S202, one training sample in the training set is determined as a current sample.

[0033] Specifically, one training sample in the training set is sequentially obtained as the current sample.

[0034] In step S204, all training samples with the same real label as the current sample are obtained from the training set as positive candidate samples according to the real label of each training sample, and all training samples with different real labels from the current sample are obtained from the training set as negative candidate samples.

[0035] Specifically, all training samples with the real label of “Zhang San” are obtained from the training set as the positive candidate samples of the current sample according to the real label (for example, “Zhang San”) of the current sample, and all training samples with the real label other than “Zhang San” in the training set are obtained as the negative candidate samples of the current sample.

[0036] In step S206, similarity calculation is performed according to the teacher feature of the current sample and the teacher feature of each positive candidate sample to determine at least one positive difficult sample of the current sample from the positive candidate samples, and similarity calculation is performed according to the teacher feature of the current sample and the teacher feature of each negative candidate sample to determine at least one negative difficult sample of the current sample from the negative candidate samples.

[0037] Optionally, similarity calculation is performed according to the teacher feature of the current sample and the teacher feature of each positive candidate sample to obtain a similarity value of each positive candidate sample, and the positive candidate sample with a similarity value lower than a preset low threshold is determined as the positive difficult sample.

[0038] For example, according to the similarity value of each positive example candidate sample, N positive example candidate samples with the lowest similarity value with the current sample can be determined as the positive example difficult samples.

[0039] Optionally, similarity calculation can be performed according to the teacher feature of the current sample and the teacher feature of each negative example candidate sample to obtain the similarity value of each negative example candidate sample, and the negative example candidate sample with a similarity value higher than a preset high threshold can be determined as the negative example difficult sample.

[0040] For example, according to the similarity value of each negative example candidate sample, N negative example candidate samples with the highest similarity value with the current sample can be determined as the negative example difficult samples.

[0041] Step S208: It is judged whether all training samples are determined as the current sample. If yes, the process ends; if no, the process returns to step S202.

[0042] Specifically, it is judged whether each training sample in the training set is determined as the current sample. If yes, the difficult samples representing all training samples have been screened, and the process can be exited; if no, the process returns to step S202 to perform difficult sample screening processing of the next training sample.

[0043] In summary, the teacher model trained in the embodiment is used to mine positive and negative difficult samples of each training sample in a global and offline manner, so that the student model can be trained directly based on these representative difficult samples to maximize the training effect.

[0044] Figure 3 The processing flowchart of the model training method of another exemplary embodiment of the present application is shown in the figure. The embodiment is a specific implementation of step S106. As shown in the figure, the embodiment mainly includes the following technical solutions:

[0045] Step S302: A triple of each training sample is constructed according to the positive difficult sample and the negative difficult sample of each training sample.

[0046] Optionally, a triple of each sample can be constructed according to each training sample, one positive difficult sample and one negative difficult sample of each sample.

[0047] Optionally, one training sample is determined as the current sample in sequence, one positive difficult sample with the lowest similarity value from all positive difficult samples of the current sample is obtained as the target positive difficult sample, one negative difficult sample with the highest similarity value from all negative difficult samples of the current sample is obtained as the target negative difficult sample, and a triple of the current sample is constructed according to the current sample, the target positive difficult sample and the target negative difficult sample of the current sample.

[0048] Step S306, determine the metric loss function according to the triplets of each training sample.

[0049] Optionally, the student model can be used to perform feature extraction on each training sample in each triplet, target positive difficult sample, and target negative difficult sample, to obtain the student features of each training sample, target positive difficult sample, and target negative difficult sample in each triplet, and to calculate the metric loss function according to the student features of each training sample, target positive difficult sample, and target negative difficult sample in each triplet using the preset metric loss function conversion formula.

[0050] In this embodiment, the preset metric loss function conversion formula is represented as:

[0051]

[0052] where i represents the i-th training sample, i is the total number of training samples, represents the student feature of the i-th training sample, represents the student feature of the target positive difficult sample of the i-th training sample; represents the student feature of the target negative difficult sample of the i-th training sample; a represents a preset minimum interval value; + represents that when the value in [] is greater than 0, the loss value is the value in [], and when the value in [] is less than 0, the loss value is zero.

[0053] Step S306, determine whether the metric loss function satisfies the preset convergence condition, if not, execute step S308, if yes, end the process.

[0054] Optionally, the determination result that the metric loss function satisfies the preset convergence condition can be obtained when the metric loss function satisfies the preset threshold.

[0055] Optionally, the determination result that the metric loss function satisfies the preset convergence condition can be obtained when the metric loss function tends to be stable.

[0056] Step S308, optimize the student model based on the metric loss function, and return to step S304.

[0057] Specifically, the model parameters of the student model can be optimized and updated based on the metric loss function, and step S304 can be re-executed based on the updated student model.

[0058] In summary, the difficult samples mined by the teacher model are used to perform metric learning on the student model, so that the feature extraction processing of the student model is more separable, the feature distance within the same category is closer, and the feature distance between different categories is farther, improving the model prediction performance.

[0059] Figure 4 The processing flowchart of the model training method of another exemplary embodiment of the present application. The present embodiment is another implementation of step S106. As shown in the figure, the present embodiment mainly includes the following processing steps:

[0060] Step S402, according to the student feature of each training sample, the teacher feature of the positive hard sample of each training sample, calculate the positive sample distance of each training sample, and according to the student feature of each training sample, the teacher feature of all negative hard samples of each training sample, calculate the negative sample distance of each training sample.

[0061] Optionally, one training sample can be determined as the current sample, all positive hard samples of the current sample are obtained, and the positive sample distance of the current sample compared with each positive hard sample is calculated according to the student feature of the current sample and the teacher feature of each positive hard sample.

[0062] Optionally, one training sample can be determined as the current sample, all negative hard samples of the current sample are obtained, and the negative sample distance of the current sample compared with each negative hard sample is calculated according to the student feature of the current sample and the teacher feature of each negative hard sample.

[0063] Step S404, comparing the positive sample distance and the negative sample distance of the same training sample, obtaining the distance comparison result of each training sample.

[0064] Specifically, one training sample can be determined as the current sample, and the positive sample distance of the current sample compared with each positive hard sample is compared with the negative sample distance of the current sample compared with each negative hard sample, to obtain the distance comparison result of the current sample.

[0065] Step S406, judging whether there is a positive sample distance of a training sample greater than the negative sample distance, if yes, proceeding to step S408, if no, ending the flow.

[0066] In the present embodiment, if the positive sample distance of any one training sample is greater than the negative sample distance, it represents that the training of the student model is not completed, and step S408 is performed.

[0067] Specifically, for any one current sample in each training sample, the positive sample distance of the current sample compared with each positive hard sample should be greater than the negative sample distance of the current sample compared with each negative hard sample, if any one positive sample distance of the current sample is less than any one negative sample distance, it represents that the training of the student model is not completed.

[0068] Step S408, the student model is optimized, and the student feature of each training sample is updated using the optimized student model, and the process returns to step S402.

[0069] Specifically, the model parameters of the student model can be updated, and the sample features of each training sample are extracted based on the updated student model to update the student features of each training sample, and the process returns to step S402 to re-perform the calculation steps of the positive sample distance and the negative sample distance.

[0070] In summary, the student model is trained using the student features of each training sample and the teacher features of the difficult samples of each training sample, and the student model is trained using the difficult samples mined by the teacher model. The student model can be optimized for the difficult samples mined by the teacher model, so that the student model maintains the same similarity as the teacher model on the difficult samples, thereby more effectively learning the more representative knowledge in the teacher model.

[0071] Figure 5 A structural block diagram of a model training device according to an example embodiment of the present application is shown in FIG. 5. As shown in the figure, the model training device 500 according to the embodiment includes a difficult sample determination module 502 and a training module 504.

[0072] The difficult sample determination module 502 is configured to perform feature extraction on each training sample using the teacher model to obtain the teacher features of each training sample, and determine the difficult samples of each training sample according to the teacher features of each training sample and the real labels.

[0073] The training module 504 is configured to train the student model using each training sample and the difficult samples of each training sample.

[0074] Optionally, the difficult sample determination module 502 is further configured to determine one training sample in the training set as a current sample, obtain all training samples having the same real label as the current sample from the training set as positive candidate samples according to the real labels of each training sample, and obtain all training samples having different real labels from the current sample from the training set as negative candidate samples, perform similarity calculation on the teacher features of the current sample and the teacher features of each positive candidate sample to determine at least one positive difficult sample of the current sample from each positive candidate sample, and perform similarity calculation on the teacher features of the current sample and the teacher features of each negative candidate sample to determine at least one negative difficult sample of the current sample from each negative candidate sample.

[0075] Optionally, the difficult sample determination module 502 is further configured to: perform similarity calculation on the teacher feature of the current sample and the teacher feature of each positive example candidate sample, obtain a similarity value of each positive example candidate sample, and determine a positive example difficult sample with a similarity value lower than a preset low threshold; perform similarity calculation on the teacher feature of the current sample and the teacher feature of each negative example candidate sample, obtain a similarity value of each negative example candidate sample, and determine a negative example difficult sample with a similarity value higher than a preset high threshold.

[0076] Optionally, the training module 504 is further configured to: perform metric learning and reinforcement learning on each training sample, the positive example difficult sample of each training sample, and the negative example difficult sample of each training sample, respectively, to train the student model.

[0077] Optionally, the training module 504 is further configured to: perform a triple construction step to construct a triple of each training sample according to the positive example difficult sample and the negative example difficult sample of the training sample; perform a loss calculation step to determine a metric loss function according to the triple of each training sample; optimize the student model based on the metric loss function, and return to perform the loss calculation step based on the optimized student model until the metric loss function meets a preset convergence condition.

[0078] Optionally, the training module 504 is further configured to: take one training sample as a current sample; obtain a positive example difficult sample with the lowest similarity value from all positive example difficult samples of the current sample as a target positive example difficult sample, and obtain a negative example difficult sample with the highest similarity value from all negative example difficult samples of the current sample as a target negative example difficult sample; construct a triple of the current sample according to the current sample, the target positive example difficult sample of the current sample, and the target negative example difficult sample of the current sample.

[0079] Optionally, the training module 504 is further configured to: perform feature extraction on the training sample, the target positive example difficult sample, and the target negative example difficult sample in each triple by using the student model to obtain student features of the training sample, the target positive example difficult sample, and the target negative example difficult sample in each triple, respectively; and calculate a metric loss function of the student model according to the student features of the training sample, the target positive example difficult sample, and the target negative example difficult sample in each triple by using a preset metric loss function conversion formula.

[0080] Optionally, the preset metric loss function conversion formula is represented as:

[0081]

[0082] wherein, the i represents an i-th training sample, the i is a total number of the training samples, the student feature of the i-th training sample, wherein the student feature of the i-th training sample is represented as student feature of the i-th training sample, wherein the student feature of the i-th training sample is represented as student feature of the i-th training sample, wherein the student feature of the i-th training sample is represented as

[0083] Optionally, the training module 504 is further configured to perform a distance calculation step, calculate a positive sample distance of each training sample according to the student feature of each training sample and the teacher feature of all positive difficult samples of each training sample, and calculate a negative sample distance of each training sample according to the student feature of each training sample and the teacher feature of all negative difficult samples of each training sample; compare the positive sample distance and the negative sample distance of the same training sample, and optimize the student model if the positive sample distance of any training sample is greater than the negative sample distance; update the student feature of each training sample by using the optimized student model, and return to perform the distance calculation step until the positive sample distance of all training samples is not greater than the negative sample distance.

[0084] Another embodiment of the present application further provides a computer storage medium, which stores instructions for performing each step of the method according to any of the above embodiments.

[0085] In summary, the model training scheme provided by the embodiments of the present application can significantly improve the recognition accuracy of the student model by using the teacher model to mine representative difficult samples, and is particularly suitable for training of small models with small amounts of parameters.

[0086] Furthermore, the model training scheme provided by the embodiments of the present application can make the features extracted by the student model more separable by adding metric learning training, that is, the features of the same category are more clustered, and the features of different categories are more distant, thereby further improving the recognition accuracy of the model.

[0087] Specifically, the present application retains the existing regression training task while adding a metric learning task, so that the features extracted by the student model are more distinguishable. In addition, the present scheme uses the trained teacher model to mine representative difficult samples in an offline mining manner, which can be used by the student model to perform optimization training directly based on the difficult samples, thereby maximizing the training benefit.

[0088] In addition, the model training scheme provided by the embodiments of the present application can make the student model maintain the same similarity as the teacher model on the difficult samples by introducing reinforcement learning, thereby more effectively learning the more representative knowledge in the teacher model.

[0089] It should be noted that the above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the same. Although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that the technical solutions recorded in the foregoing examples can be modified, or some technical features can be replaced by equivalent features. Such modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A model training method, characterized in that, include: The teacher model is used to perform feature extraction for each training sample to obtain the teacher features of each training sample, wherein the teacher model includes a detection model with image recognition capabilities; Based on the teacher characteristics and true labels of each training sample, the hard samples of each training sample are determined, wherein the hard samples include positive hard samples and negative hard samples. Based on each training sample and the hard samples of each training sample, metric learning and reinforcement learning are performed separately to train the student model; Among these, performing metric learning includes: The triplet construction step involves constructing a triplet for each training sample based on the positive hard samples and negative hard samples of each training sample. The loss calculation steps involve determining the loss function based on the student characteristics of each training sample's triples. Based on the aforementioned loss function, the student model is optimized, and the loss calculation step is returned based on the optimized student model until the loss function satisfies the preset convergence condition. Performing reinforcement learning includes: The distance calculation step involves calculating the positive sample distance of each training sample based on the student characteristics of each training sample and the teacher characteristics of all positive and difficult samples of each training sample, and calculating the negative sample distance of each training sample based on the student characteristics of each training sample and the teacher characteristics of all negative and difficult samples of each training sample. Compare the positive sample distance and negative sample distance of the same training sample. If the positive sample distance of any training sample is greater than the negative sample distance, optimize the student model. Update the student features of each training sample using the optimized student model, and return to execute the distance calculation step until the positive sample distance of all training samples is no greater than the negative sample distance.

2. The method according to claim 1, wherein, The process of determining the hard samples for each training sample based on the teacher characteristics and real labels of each training sample includes: Select a training sample from the training set as the current sample; Based on the true label of each training sample, all training samples with the same true label as the current sample are obtained from the training set as positive candidate samples, and all training samples with different true labels as the current sample are obtained from the training set as negative candidate samples. A similarity calculation is performed between the teacher features of the current sample and the teacher features of each positive candidate sample to determine at least one positive difficult sample of the current sample from each positive candidate sample. A similarity calculation is also performed between the teacher features of the current sample and the teacher features of each negative candidate sample to determine at least one negative difficult sample of the current sample from each negative candidate sample.

3. The method according to claim 2, characterized in that, The step of performing a similarity calculation based on the teacher characteristics of the current sample and the teacher characteristics of each positive candidate sample to determine at least one positive difficult sample from each positive candidate sample includes: Based on the teacher characteristics of the current sample and the teacher characteristics of each positive candidate sample, a similarity calculation is performed to obtain the similarity value of each positive candidate sample, and positive candidate samples with similarity values ​​lower than a preset low threshold are identified as difficult positive samples. The step of performing similarity calculations based on the teacher characteristics of the current sample and the teacher characteristics of each negative candidate sample to determine at least one difficult negative sample from each negative candidate sample includes: Based on the teacher characteristics of the current sample and the teacher characteristics of each negative candidate sample, a similarity calculation is performed to obtain the similarity value of each negative candidate sample, and negative candidate samples with similarity values ​​higher than a preset high threshold are identified as difficult negative samples.

4. The method according to claim 1, characterized in that, The triplet construction steps include: Use a training sample as the current sample: From all the positive hard samples of the current sample, obtain the positive hard sample with the lowest similarity value as the target positive hard sample, and from all the negative hard samples of the current sample, obtain the negative hard sample with the highest similarity value as the target negative hard sample; Based on the current sample, the target positive hard samples of the current sample, and the target negative hard samples, construct the triplet of the current sample.

5. The method according to claim 4, characterized in that, The loss calculation steps include: The student model is used to perform feature extraction on the training samples, target positive hard samples, and target negative hard samples in each triplet to obtain the student features of the training samples, target positive hard samples, and target negative hard samples in each triplet. Using a preset conversion formula for the metric loss function, the metric loss function of the student model is calculated based on the student characteristics of the training samples, target positive hard samples, and target negative hard samples in each triplet. The conversion formula for the preset metric loss function is expressed as follows: Among them, the Indicates the first The training samples, The total number of training samples, the Indicates the first Student characteristics of each training sample, the Indicates the first The student characteristics of the target positive examples and difficult examples in the training samples; Indicates the first The student characteristics of the target negative examples and difficult examples of the training samples; This indicates the preset minimum interval value; the This means that when the value inside the brackets is greater than 0, the loss value is the value inside the brackets; when the value inside the brackets is less than 0, the loss value is zero.

6. A model training device, characterized in that, include: The difficult sample determination module is used to perform feature extraction for each training sample using the teacher model to obtain the teacher features of each training sample, and to determine the difficult samples of each training sample based on the teacher features and the true label of each training sample. The difficult samples include positive difficult samples and negative difficult samples. The teacher model includes a detection model with image recognition capabilities. The training module is used to perform metric learning and reinforcement learning on each training sample and each hard sample to train the student model. Among these, performing metric learning includes: The triplet construction step involves constructing a triplet for each training sample based on the positive hard samples and negative hard samples of each training sample. The loss calculation steps involve determining the loss function based on the student characteristics of each training sample's triples. Based on the aforementioned loss function, the student model is optimized, and the loss calculation step is returned based on the optimized student model until the loss function satisfies the preset convergence condition. Performing reinforcement learning includes: The distance calculation step involves calculating the positive sample distance of each training sample based on the student characteristics of each training sample and the teacher characteristics of all positive and difficult samples of each training sample, and calculating the negative sample distance of each training sample based on the student characteristics of each training sample and the teacher characteristics of all negative and difficult samples of each training sample. Compare the positive sample distance and negative sample distance of the same training sample. If the positive sample distance of any training sample is greater than the negative sample distance, optimize the student model. Update the student features of each training sample using the optimized student model, and return to execute the distance calculation step until the positive sample distance of all training samples is no greater than the negative sample distance.

7. A computer storage medium, characterized in that, The computer storage medium stores instructions for performing each step of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Knowledge distillation-based unsupervised industrial image anomaly detection method and system

    CN114240892A

  • Training method and training device of neural network for object recognition

    CN114444558A