Model training method, face recognition method and device

By performing first knowledge distillation on the initial assistant model and second knowledge distillation training combined with the teacher model, the overfitting problem caused by the parameter gap between the teacher model and the student model is solved, and the accuracy and data processing capabilities of the student model are improved. .

CN114611672BActive Publication Date: 2024-10-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210261833.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-16
Publication Date
2024-10-01
Estimated Expiration
2042-03-16

AI Technical Summary

Technical Problem

When there is a large parameter gap between the teacher model and the student model, direct knowledge distillation will lead to overfitting of the student model and reduce the effect of knowledge distillation.

Method used

By performing the first knowledge distillation training on the initial assistant model, an assistant model with a smaller number of parameters is obtained, and then jointly performs the second knowledge distillation training on the student model with the teacher model to gradually reduce the parameter gap, avoid overfitting, and use The learning ability of the teacher model supervises the training process.

Benefits of technology

It effectively avoids overfitting of the student model, improves the knowledge distillation effect, and enables the final student model to have higher accuracy and data processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114611672B_ABST
    Figure CN114611672B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a model training method, a face recognition method and a device. The model training method includes training an initial teacher model to obtain a trained teacher model; performing a first knowledge distillation training on an initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model; performing a second knowledge distillation training on an initial student model according to the teacher model and the assistant model to obtain a trained student model; wherein the parameter amount of the initial student model is smaller than the parameter amount of the initial assistant model. The present application can obtain a student model with higher accuracy by combining a teacher model and an assistant model.
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 technology, and in particular to a model training method, a face recognition method and a device. Background Art

[0002] Knowledge distillation is a method of constructing a teacher model and a student model, with the teacher model guiding the training of the student network model, so as to transfer the learning behavior of the teacher model with complex network structure, large number of parameters and strong learning ability to the student model with simple network structure, small number of parameters and weak learning ability.

[0003] However, when the difference in the number of parameters between the teacher model and the student model is large, if the features between the teacher model and the student model are forcibly fitted, the student model will be seriously overfitted, resulting in a decrease in the effect of knowledge distillation. Summary of the invention

[0004] In order to solve the above technical problems, the embodiments of the present application provide a model training method, a face recognition method and a device.

[0005] According to one aspect of an embodiment of the present application, a model training method is provided, including: training an initial teacher model to obtain a trained teacher model; performing a first knowledge distillation training on an initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model; performing a second knowledge distillation training on an initial student model according to the teacher model and the assistant model to obtain a trained student model; wherein the parameter amount of the initial student model is smaller than the parameter amount of the initial assistant model.

[0006] According to one aspect of an embodiment of the present application, a face recognition method is provided, including: collecting a face image to be recognized; inputting the face image to be recognized into a face recognition model; wherein the face recognition model is trained according to the model training method as described above, and the face recognition model corresponds to the student model in the model training method; and obtaining the face recognition result output by the face recognition model.

[0007] According to one aspect of an embodiment of the present application, a model training device is provided, including: a teacher model training module, configured to train an initial teacher model to obtain a trained teacher model; an assistant model training module, configured to perform a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model; a student model training module, configured to perform a second knowledge distillation training on the initial student model according to the teacher model and the assistant model to obtain a trained student model; wherein the parameter amount of the initial student model is smaller than the parameter amount of the initial assistant model.

[0008] According to one aspect of an embodiment of the present application, a face recognition device is provided, including: an image acquisition module, configured to acquire a face image to be recognized; a recognition module, configured to input the face image to be recognized into a face recognition model; wherein the face recognition model is trained according to the model training method as described above, and the face recognition model corresponds to the student model in the model training method; and a result acquisition module, configured to obtain the face recognition result output by the face recognition model.

[0009] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a memory storing computer-readable instructions; and a processor reading the computer-readable instructions stored in the memory to execute the model training method or face recognition method as described above.

[0010] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the model training method or face recognition method as described above.

[0011] According to one aspect of an embodiment of the present application, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the steps in the model training method or face recognition method as described above.

[0012] In the technical solution provided in the embodiments of the present application, the first knowledge distillation training is performed on the initial assistant model through the teacher model to obtain a trained assistant model, and then the second knowledge distillation training is performed on the initial student model by combining the teacher model and the assistant model to obtain a trained student model, so as to perform parameter transition through the assistant model whose parameter quantity is closer to that of the student model relative to the teacher model, thereby avoiding serious overfitting of the student model due to the large gap in parameter quantity between the teacher model and the student model, and the second knowledge distillation training process is supervised by the teacher model with stronger learning ability, so that the final student model has higher accuracy.

[0013] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0015] Figure 1 It is a schematic diagram of the implementation environment involved in this application;

[0016] Figure 2 is a flow chart of a model training method shown in an exemplary embodiment of the present application;

[0017] Figure 3 is a schematic diagram of a training teacher model shown in an exemplary embodiment of the present application;

[0018] Figure 4 is a flow chart of an initial student model training process shown in an exemplary embodiment of the present application;

[0019] Figure 5 yes Figure 4 Flowchart of step S420 in an exemplary embodiment;

[0020] Figure 6 is a schematic diagram of training an initial student model shown in an exemplary embodiment of the present application;

[0021] Figure 7 yes Figure 2 Flowchart of step S220 in an exemplary embodiment;

[0022] Figure 8 is a schematic diagram of a first knowledge distillation training shown in an exemplary embodiment of the present application;

[0023] Fig. 9 yes Figure 2 Flowchart of step S230 in an exemplary embodiment;

[0024] Fig.10 is a schematic diagram of a second knowledge distillation training shown in an exemplary embodiment of the present application;

[0025] Fig.11 yes Figure 3 Flowchart of step S920 in an exemplary embodiment;

[0026] Fig.12 is a flowchart of a face recognition method shown in an exemplary embodiment of the present application;

[0027] Fig.13 is a schematic diagram of obtaining a face recognition model shown in an exemplary embodiment of the present application;

[0028] Fig.14 This is a schematic diagram of a model deployment shown in an exemplary embodiment of the present application.

[0029] Fig.15 is a block diagram of a model training device shown in an exemplary embodiment of the present application;

[0030] Fig.16 is a block diagram of a face recognition device shown in an exemplary embodiment of the present application;

[0031] Fig.17 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0033] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0034] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0035] The term "multiple" as used in this application refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0036] The following is a brief introduction to the technologies that may be used in the embodiments of the present application.

[0037] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0038] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further processing graphics so that the computer processing becomes an image that is more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.

[0039] Machine Learning (ML) is a multi-disciplinary subject involving probability theory, statistics, approximation theory, convex analysis and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.

[0040] In recent years, the development of machine learning has shown three major trends: the model structure is becoming more complex, the model level is deepening, and the massive data sets are growing. However, with the increasing demand for using neural network models for edge computing on mobile and embedded platforms, the neural network model is required to be as small as possible and have high computational efficiency due to the limited resources of the edge computing platform. To this end, in recent years, academia and industry have proposed various types of model compression methods, such as model pruning, low-rank decomposition, and low-precision quantization of model parameters. In the 2014 paper Distilling the Knowledge in a Neural Network, Hinton et al. proposed a knowledge distillation method, which can use a large neural network model trained on a large training data set as a teacher model (teacher network), and a small neural network model as a student model (student network). The student model is trained by combining the probability distribution vector output by the teacher model and the manual annotation of the training set to overcome the difficulty of training a small neural network model on a large data set. After training, the test results on the classification task can be close to or exceed those of the teacher model. This method can be regarded as a means of knowledge transfer, which transfers knowledge from the teacher model to the student model through training. After the transfer is completed, the student model designed to be small, fast and flexible replaces the large and bulky teacher model for task application, which greatly facilitates the deployment of neural network models on edge platforms.

[0041] However, when the difference in the number of parameters between the teacher model and the student model is large, if the teacher model is directly used to perform knowledge distillation on the student model, the student model will be severely overfitted due to forced fitting of the characteristics of the teacher model and the student model, resulting in the collapse of student model training.

[0042] Based on this, in order to ensure the training effect of the student model when the parameter quantity difference between the teacher model and the student model is large, the embodiments of the present application propose a model training method, a face recognition method, a device, a computer-readable storage medium and an electronic device.

[0043] The model training method provided in the embodiment of the present application is described below, wherein: Figure 1 Schematic diagram of an implementation environment involved in the model training method in this application. Figure 1 As shown, the implementation environment includes a terminal 110 and a server 120. The terminal 110 and the server 120 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present application.

[0044] Terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. Terminal 110 may generally refer to one of a plurality of terminals, and this embodiment is only illustrated by terminal 110. Those skilled in the art may know that the number of the above terminals may be more or less. For example, the above terminal may be only one, or the above terminal may be dozens or hundreds, or a greater number, in which case the implementation environment of the above model training method also includes other terminals. The embodiment of the present application does not limit the number of terminals and device types.

[0045] The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server 120 is used to provide background services for the applications running on the terminal 110.

[0046] Optionally, the above-mentioned wireless network or wired network uses standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a dedicated network or any combination of a virtual private network). In some embodiments, the data exchanged through the network is represented by technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec) can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.

[0047] Optionally, the server 120 undertakes the main model training work, and the terminal 110 undertakes the secondary model training work; or, the server 120 undertakes the secondary model training work, and the terminal 110 undertakes the main model training work; or, the server 120 or the terminal 110 can each independently undertake the model training work.

[0048] Exemplarily, the terminal 110 sends a model training instruction to the server 120, and the server 120 receives the model training instruction sent by the terminal 110 and obtains a trained teacher model; the server 120 performs a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; the server 120 performs a second knowledge distillation training on the initial student model according to the teacher model and the assistant model to obtain a trained student model.

[0049] Among them, the model training method provided in the embodiment of the present application can be widely used in training models based on neural networks.

[0050] See also Figure 2 , Figure 2 is a flowchart of a model training method shown in an exemplary embodiment of the present application. The model training method can be applied to Figure 1 The implementation environment shown is specifically executed by the server 120 in the implementation environment. It should be understood that the method can also be applied to other exemplary implementation environments and be specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment to which the method is applicable.

[0051] The model training method proposed in the embodiment of the present application is introduced in detail below using the server as the specific execution entity.

[0052] like Figure 2 As shown, in an exemplary embodiment, the model training method includes at least steps S210 to S230, which are described in detail as follows:

[0053] Step S210: train the initial teacher model to obtain a trained teacher model.

[0054] It should be noted that the initial teacher model refers to the teacher training model with initialized model parameters, and the teacher training model is the teacher model during training.

[0055] In one embodiment, see Figure 3 , Figure 3 is a schematic diagram of training the initial teacher model. Figure 3As shown, the training data is obtained, and the training data is input into the initial teacher model for data feature extraction to obtain the training data features, and then the training data features are classified and processed to obtain the teacher model prediction results, and then the loss information of the initial teacher model is calculated according to the teacher model prediction results, so as to judge whether the teacher model training completion conditions are met according to the loss information of the initial teacher model. If not, the model parameters of the initial teacher model are updated, and then the above steps are repeated for iterative training. If met, the current initial teacher model is used as the assistant model.

[0056] In an embodiment of the present application, according to the application scenario of the model, a corresponding training data set can be obtained, and the training data set includes multiple labeled training data. The training data in the training data set are input into the initial teacher model in batches according to the batch size, and a teacher model with a more complex structure can be trained.

[0057] It should be noted that the type of training data varies depending on the application scenario of the model. Optionally, the training data is image data with labeled categories, such as dog pictures labeled as dogs, car pictures labeled as cars, or advertising pictures labeled with text contained in the pictures, etc. Optionally, the training data is text data with labeled corresponding content, such as Chinese text with labeled corresponding English, English text with labeled corresponding German, or English text with labeled corresponding Chinese, etc. Optionally, the training data is labeled audio data, video data, etc., which is not limited in the embodiments of the present application.

[0058] By inputting the training data into the feature extraction network of the initial teacher model, the training data features output by the feature extraction network of the initial teacher model are obtained. Among them, the feature extraction network may include convolution calculation processing, pooling calculation processing and nonlinear activation function calculation processing, etc. Of course, there may also be other processing steps, which are not limited in the embodiments of the present application. For example, after the feature extraction network performs convolution calculation on the input training data, it uses an activation function to introduce nonlinear factors, extract nonlinear features, and obtain the training data features of the training data, wherein the activation function can be, for example, a ReLu function. The server inputs the training data in the training data set into the initial teacher model, and extracts the training data features corresponding to the training data through the feature extraction network in the initial teacher model, that is, obtains the feature vector of the training data corresponding to the training data, and then calculates the training data features through the classification module in the initial teacher model to obtain the training data prediction results corresponding to the training data.

[0059] Exemplarily, the initial teacher model will obtain a cluster center vector according to the characteristics of the training data during the training process. Different cluster center vectors correspond to different training data categories. For example, the teacher model includes N cluster center vectors, and the N cluster center vectors correspond one-to-one to the n categories included in the training data used to train the teacher model, that is, each category of the training data corresponds to a cluster center vector, and the cluster center vector corresponding to the category is used to characterize the overall characteristics of the training data whose classification result is that category. The cluster center vectors corresponding to the training data of different categories can be determined based on the feature vector of each training data. For example, when there is one training data, the server determines the feature vector of the training data as the cluster center vector corresponding to the category of the training data. When there are multiple training data, the server uses the mean of the feature vectors of each training data as the cluster center vector corresponding to the category of the training data. The cluster center vector corresponding to the obtained training data set can be expressed as a d×m vector matrix, where d is the feature dimension of a single training data and m is the number of categories of the training data.

[0060] Therefore, by performing matrix operations on the training data features corresponding to the current training data and the cluster center vectors existing in the initial teacher model, the training data category corresponding to the current training data is obtained, and the training data category is used as the prediction result of the initial teacher model.

[0061] Furthermore, the corresponding sample label is obtained by annotating each training data, and the sample label of the training data is used as the target output of the initial teacher model. The difference between the prediction result of the initial teacher model and the sample label of the training data is calculated to determine whether the training end condition is met based on the difference between the prediction result of the initial teacher model and the sample label of the training data. Among them, the training end condition can be that the number of training iterations meets the preset iteration number threshold, or the loss value corresponding to the teacher model training loss function is less than the preset loss value threshold. Exemplarily, the server constructs the teacher model training loss function based on the difference between the training data prediction result corresponding to the training data and the sample label of the training data, and uses the gradient descent algorithm based on the teacher model training loss function to reversely update the parameters of the initial teacher model. After obtaining the updated initial teacher model, it returns to the step of obtaining training data from the training data set to continue training until the training end condition is met. Among them, the teacher model training loss function can be a Softmax function, a Contrastive Loss function, a Triplet Loss function, a Center Loss function, a Margin function, etc., and the gradient descent algorithm can be an SGD (stochastic gradient descent stochastic gradient descent algorithm) algorithm, a stochastic gradient descent algorithm with momentum term, an adaptive gradient algorithm (adaptive gradient), an adaptive matrix estimation algorithm (adaptive moment estimation), etc.

[0062] Step S220: Perform a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; wherein the number of parameters of the initial assistant model is smaller than the number of parameters of the initial teacher model.

[0063] It should be noted that the initial assistant model refers to the assistant training model with model parameters initialized, and the assistant training model is the assistant model during training. The parameter amount of the model refers to the number of parameters contained in the model. The smaller the parameter amount of the model, the smaller the volume of the model. Conversely, the larger the parameter amount of the model, the larger the volume of the model. Among them, the parameter amount of the model can be obtained by obtaining the number of pending parameters of the model. Taking the convolutional neural network as an example, assuming that the convolution kernel size of the convolutional neural network is k×k, the input channel is i, the output channel is o, and the bias term is y, then each convolution operation requires the number of parameters: k×k×i×o+y.

[0064] The goal of the first knowledge distillation training is to use the output of the teacher model to guide the assistant model, so that the output distribution of the assistant model is the same or similar to the output distribution of the teacher model.

[0065] In the embodiment of the present application, the assistant model is trained using the teacher model so that the output of the assistant model obtained through training is the same or similar to the output of the teacher model, that is, the data processing capability of the assistant model is close to that of the teacher model through the first knowledge distillation training, but the structure of the assistant model is simpler than that of the teacher model. For example, after the above-mentioned first knowledge distillation training, the training data A is input into the teacher model and the assistant model respectively, and the output of the teacher model and the assistant model are both result A.

[0066] Step S230, performing a second knowledge distillation training on the initial student model according to the teacher model and the assistant model to obtain a trained student model; wherein the parameter amount of the initial student model is smaller than the parameter amount of the initial assistant model.

[0067] It should be noted that the initial student model refers to the student training model with initialized model parameters, and the student training model is the student model during training.

[0068] The goal of the second knowledge distillation training is to use the output of the teacher model and the assistant model to guide the student model, so that the output distribution of the student model is the same or similar to the output distribution of the teacher model and the assistant model.

[0069] In the embodiment of the present application, the student model is trained using the teacher model and the assistant model, so that the output of the trained student model is the same or similar to the output of the teacher model and the assistant model, that is, the data processing capability of the student model is close to the data processing capability of the teacher model and the assistant model through the second knowledge distillation training, but the structure of the student model is simpler than that of the teacher model and the assistant model. For example, after the above-mentioned second knowledge distillation training, the training data A is input into the teacher model, the assistant model and the student model respectively, and the outputs of the teacher model, the assistant model and the student model are all result A.

[0070] When the parameter difference between the teacher model and the student model is large, there is a problem that the student model is easily overfitted during the learning process due to the large number of parameters in the teacher model, thereby reducing the accuracy of the student model. Therefore, in order to improve the knowledge distillation effect of the student model, the model training method provided in the embodiment of the present application introduces an assistant model. Since the parameter amount of the assistant model is smaller than the parameter amount of the teacher model but larger than the parameter amount of the student model, the parameter amount can be transitioned through the assistant model that is closer to the parameter amount of the student model relative to the teacher model, thereby avoiding the situation where the student model is seriously overfitted due to the large parameter difference between the teacher model and the student model. At the same time, since the data processing capability of the teacher model is stronger than that of the assistant model, the initial student model can be trained by combining the teacher model and the assistant model, so that the obtained student model has better data processing capabilities.

[0071] In some embodiments, the student model of the present application is a classification model, which is used to identify the category of input data. For example, the student model is an image classification model, and the image to be classified is input into the image classification model, and the image classification model outputs the category to which the image to be classified belongs; for example, the student model is a text sentiment classification model, and the sentence to be classified is input into the text sentiment classification model, and the text sentiment classification model outputs the category to which the sentence to be classified belongs. Based on the above embodiments, the trained teacher model has a more accurate cluster center vector. Therefore, before the initial student model is subjected to the second knowledge distillation training, the present application trains the initial student model according to the more accurate cluster center vector in the teacher model, and the following solution is provided for details.

[0072] See also Figure 4 In the above exemplary embodiment, before the initial student model is subjected to the second knowledge distillation training according to the teacher model and the assistant model, steps S410 to S430 are also included, which are described in detail as follows:

[0073] Step S410: input the training data into the uninitialized student model to obtain the feature extraction result output by the uninitialized student model.

[0074] It should be noted that the training data carries sample labels, which are used to indicate the real category information to which the training data belongs. The uninitialized student model refers to the initial student training model whose model parameters are not initialized. The initial student training model is the initial student model during training. The feature extraction result refers to the result obtained by vectorizing the input training data. The uninitialized student model obtains the feature extraction result of the training data by vectorizing the training data.

[0075] Vectorization processing refers to representing the training data to be classified using feature vectors. The method of vectorization processing is determined according to the actual data type of the training data. When the training data is an image, the server obtains the feature vector of the training data through the feature extraction module of the uninitialized student model. When the training data is text, the server obtains the feature vector of the training data through at least one of the word vector (Word2Vectot) algorithm, word embedding (word embedding) algorithm, and one-hot algorithm.

[0076] Step S420: Obtain the prediction result of the uninitialized student model according to the feature extraction result and multiple cluster center vectors.

[0077] It should be noted that the prediction result of the uninitialized student model is used to represent the result obtained after the uninitialized student model classifies the input training data.

[0078] The server migrates multiple cluster center vectors in the classification module of the teacher model to the classification module of the uninitialized student model, and obtains the training data category corresponding to the feature extraction result based on the multiple cluster center vectors in the classification module of the uninitialized student model and the feature extraction result, that is, obtains the prediction result of the uninitialized student model.

[0079] Among them, the multiple cluster center vectors in the classification module of the teacher model are obtained during the training process of the teacher model, and the classification module of the teacher model is used to predict the category to which the training data belongs.

[0080] Step S430: adjust the model parameters of the uninitialized student model according to the difference between the prediction result of the uninitialized student model and the sample label of the training data to obtain the initial student model.

[0081] By annotating each training data, the corresponding sample label is obtained, and the sample label of the training data is used as the target output of the uninitialized student model. The difference between the prediction result of the uninitialized student model and the sample label of the training data is calculated to determine whether the end condition of the uninitialized student model training is met based on the difference between the prediction result of the uninitialized student model and the sample label of the training data. Among them, the end condition of the uninitialized student model training includes any of the following: the number of training times reaches the number threshold; the loss function converges; the loss function is less than the loss function threshold. The number threshold and the loss function threshold are set according to experience, or flexibly adjusted according to the application scenario, and the embodiments of the present application do not limit this.

[0082] Exemplarily, the loss function value is obtained by calculating the difference between the prediction result of the uninitialized student model and the sample label of the training data through the uninitialized student model loss function. Wherein, the uninitialized student model loss function can be a triplet loss loss function (triplet loss function), or it can also be other loss functions such as a cross entropy loss function. Then, according to the error between the prediction result of the uninitialized student model and the sample label of the training data, it is judged whether the preset conditions for terminating the model training are met. If it is met, the current uninitialized student model is used as the initial student model. If it is not met, the model parameters of the uninitialized student model are adjusted, and then the above steps are repeated, and so on, until the training termination condition is met, and the uninitialized student model obtained when the training termination condition is met is used as the initial student model.

[0083] In an embodiment of the present application, in addition to the multiple cluster center vectors in the classification module, the uninitialized student model also includes other modules whose parameters need to be updated (such as a feature extraction module), and the loss function is used to reversely update the parameters of the uninitialized student model.

[0084] Optionally, the embodiment of the present application may also adopt Figure 5 Steps 510 to 520 shown implement step S420, details of which are as follows:

[0085] Step 510: Calculate the similarity between the feature extraction result and each cluster center vector respectively.

[0086] The server obtains the similarity between the feature extraction result and each cluster center vector through the classification module of the uninitialized student model. The similarity between the feature extraction result and the cluster center vector is used to measure the similarity between the training data to be classified and the training data category corresponding to the cluster center vector. The greater the similarity between the feature extraction result and the cluster center vector, the greater the similarity between the training data and the training data category corresponding to the cluster center vector for the classification result; the smaller the similarity between the feature extraction result and the cluster center vector, the smaller the similarity between the training data and the training data category corresponding to the cluster center vector for the classification result.

[0087] The similarity between the feature extraction result and the cluster center vector can be represented by at least one of the following: the Euclidean distance between the feature extraction result and the cluster center vector, the cosine similarity between the feature extraction result and the cluster center vector, the Manhattan distance between the feature extraction result and the cluster center vector, the Chebyshev distance between the feature extraction result and the cluster center vector, etc. In the embodiment of the present application, only the similarity between the feature extraction result and the cluster center vector is represented by the cosine similarity between the two as an example for explanation.

[0088] Optionally, the cosine similarity cos(θ) between the feature extraction result and the cluster center vector is calculated by the following formula 1:

[0089] Formula 1.

[0090] X i Represents the feature of the i-th dimension of the feature extraction result, Y i Represents the feature of the i-th dimension of the cluster center vector, and n is the number of dimensions included in the feature extraction result or the cluster center vector.

[0091] The closer the cosine similarity between the feature extraction result and the cluster center vector is to 1, the greater the similarity between the feature extraction result and the cluster center vector; the closer the cosine similarity between the feature extraction result and the cluster center vector is to -1, the smaller the similarity between the feature extraction result and the cluster center vector.

[0092] Step 520: Determine the training data category to which the training data corresponding to the feature extraction result belongs based on the similarity, and use the training data category as the prediction result of the uninitialized student model.

[0093] The feature extraction result and each cluster center vector each correspond to a similarity. Optionally, each similarity can be sorted to obtain the cluster center vector with the highest similarity corresponding to the feature extraction result according to the sorting result, and then the training data category corresponding to the cluster center vector is used as the training data category to which the training data corresponding to the feature extraction result belongs, that is, the training data category is used as the prediction result of the uninitialized student model.

[0094] In one embodiment, see Figure 6 , Figure 6 is a schematic diagram of training an uninitialized student model. Figure 6 As shown, the training data is obtained, and the training data is input into the uninitialized student model for data feature extraction processing to obtain the training data features, and then the classification processing is performed according to the training data features to obtain the prediction results of the uninitialized student model, and then the loss information of the uninitialized student model is calculated according to the prediction results of the uninitialized student model, so as to judge whether the uninitialized student model training end condition is reached according to the loss information of the uninitialized student model, if not reached, the model parameters of the uninitialized student model are updated, and then the above steps are repeated for iterative training, and if reached, the current uninitialized student model is used as the initial student model. Among them, the cluster center vector used for classification processing of the uninitialized student model is migrated from the teacher model.

[0095] In the above training process, the multiple cluster center vectors in the classification module of the uninitialized student model only provide classification calculations, and do not participate in the update process of the model parameters. Only other parameters of the uninitialized student model are updated. After training the uninitialized student model according to multiple cluster center vectors, the initial student model obtained initially acquires the data processing capability of the teacher model, which can improve the training efficiency of the student model and facilitate the subsequent second knowledge distillation training of the student model.

[0096] Optionally, the embodiment of the present application may adopt Figure 7 Steps 710 to 730 shown implement step S220, and the details are as follows:

[0097] Step S710: input the training data into the initial assistant model and the teacher model respectively, and obtain the assistant model prediction results output by the initial assistant model and the teacher model prediction results output by the teacher model.

[0098] It should be noted that the teacher model is a high-precision, large-parameter deep network, and the initial assistant model has fewer parameters than the teacher model. The assistant model prediction result output by the initial assistant model refers to the output result obtained after the initial assistant model processes the training data, and the teacher model prediction result output by the teacher model refers to the output result obtained after the teacher model processes the training data. For example, when the initial assistant model and the teacher model need to perform data classification processing on the training data respectively, the assistant model prediction result and the teacher model prediction result are the data classification results of the initial assistant model and the teacher model on the training data respectively.

[0099] Step S720: Calculate the first knowledge distillation loss information according to the assistant model prediction results and the teacher model prediction results.

[0100] It should be noted that the first knowledge distillation loss information is used to characterize the difference between the prediction results of the assistant model and the prediction results of the teacher model, that is, it is used to characterize the difference between the output distribution of the initial assistant model and the output distribution of the teacher model and the assistant model.

[0101] The server can use a pre-set loss function to calculate the error between the assistant model prediction result and the teacher model prediction result to obtain the first knowledge distillation loss information. For example, the first knowledge distillation loss information can be calculated using Formula 2 shown below.

[0102] Formula 2.

[0103] Among them, L1 refers to the first knowledge distillation loss information, KL refers to the KL divergence loss function, and y a refers to the prediction result of the assistant model, y trefers to the prediction result of the teacher model, i refers to the amount of training data, represents the probability distribution of the teacher model’s prediction results, It refers to the probability distribution of the assistant model's prediction results. Among them, the KL divergence needs to satisfy: the distribution of the output obtained by the initial assistant model is similar to that of the student model.

[0104] Exemplarily, the first knowledge distillation loss information can also be obtained by at least one or more of the distance constraint and the angle constraint between the prediction result of the assistant model and the prediction result of the teacher model. The distance and angle constraints need to meet the following requirements: for the same batch of training data, the distance and angle between the features extracted by the initial assistant model and the teacher model should be similar. For example, the distance can be Euclidean distance or cosine distance, or other distances (such as L1 distance, etc.).

[0105] Step S730: adjust the model parameters of the initial assistant model according to the first knowledge distillation loss information to obtain the assistant model.

[0106] The server determines whether the first knowledge distillation training completion condition is met based on the first knowledge distillation loss information. When the first knowledge distillation training completion condition is not met, the server uses the first knowledge distillation loss information to reversely update the model parameters in the initial assistant model, and iterates steps S710 to S720 until the first knowledge distillation training completion condition is met. The initial assistant model when the first knowledge distillation training completion condition is met is used as the assistant model.

[0107] In some embodiments, the embodiments of the present application can implement step S720 by the following steps: calculating the error between the assistant model prediction result and the teacher model prediction result to obtain result loss information; calculating the error between the assistant model prediction result and the sample label corresponding to the training data to obtain label loss information; and calculating the first knowledge distillation loss information based on the result loss information and the label loss information.

[0108] Among them, the result loss information is used to characterize the error between the assistant model prediction results and the teacher model prediction results, and the label loss information is used to characterize the error between the assistant model prediction results and the sample labels corresponding to the training data.

[0109] Exemplarily, the server can use the KL divergence loss function to calculate the error between the assistant model prediction result and the teacher model prediction result to obtain the result loss information, and then use different loss functions in different application scenarios to calculate the error between the assistant model prediction result and the sample label corresponding to the training data to obtain the label loss information. For example, in the application scenario of image classification and recognition, the classification loss function can be used to calculate the error between the assistant model prediction result and the sample label corresponding to the training data to obtain the label loss information. For example, in the application product of image segmentation, the cross entropy loss function can be used to calculate the error between the assistant model prediction result and the sample label corresponding to the training data to obtain the label loss information, and so on. Among them, the teacher model can also be used to predict the training data to obtain the probability value of each classification, and the probability value is used as the soft label of the training data to calculate the KL divergence loss function based on the soft label.

[0110] See also Figure 8 , Figure 8 It is a schematic diagram of the first knowledge distillation training. Figure 8 As shown, training data is obtained, and the training data is respectively input into the initial assistant model and the teacher model for data processing to obtain the processing results of the initial assistant model output and the processing results of the teacher model output, and then the first knowledge distillation loss information is calculated according to the outputs of the initial assistant model and the teacher model to determine whether the first knowledge distillation training completion conditions are met according to the first knowledge distillation loss information. If not, the model parameters of the initial assistant model are updated, and then the aforementioned steps are repeated for iterative training. If met, the current initial assistant model is used as the assistant model.

[0111] In some implementations, the present application may employ the following Fig. 9 Steps 910 to 930 shown implement step S230 to further match the output distribution of the initial student model with the output distribution of the teacher model and the assistant model.

[0112] Step S910, input the training data into the initial student model, the assistant model and the teacher model respectively, and obtain the initial student model prediction result output by the initial student model, the assistant model prediction result output by the assistant model and the teacher model prediction result output by the teacher model.

[0113] It should be noted that the teacher model is a high-precision, large-parameter deep network, the assistant model has fewer parameters than the teacher model, and the initial student model has fewer parameters than the assistant model. The initial student model prediction result output by the initial student model refers to the output result obtained after the initial student model processes the training data, the assistant model prediction result output by the assistant model refers to the output result obtained after the assistant model processes the training data, and the teacher model prediction result output by the teacher model refers to the output result obtained after the teacher model processes the training data. For example, when the initial student model, the assistant model, and the teacher model need to perform data classification processing on the training data respectively, the initial student model prediction result, the assistant model prediction result, and the teacher model prediction result are the data classification results of the initial student model, the assistant model, and the teacher model on the training data, respectively.

[0114] Step S920, calculate the second knowledge distillation loss information according to the initial student model prediction results, the assistant model prediction results and the teacher model prediction results.

[0115] It should be noted that the second knowledge distillation loss information is used to characterize the difference between the prediction results of the initial student model and the prediction results of the assistant model and the teacher model, that is, it is used to characterize the difference between the output distribution of the initial student model and the output distribution of the teacher model and the assistant model.

[0116] Exemplarily, in order to make the output distribution of the initial student model the same or similar to the output distribution of the assistant model and the teacher model, the second knowledge distillation loss information can be obtained through at least one or more of the KL divergence, distance constraint, and angle constraint between the prediction results of the initial student model and the prediction results of the assistant model and the teacher model. Among them, the KL divergence needs to satisfy: the distribution of the output obtained by the assistant model is similar to that of the initial student model; the distance and angle constraints need to satisfy: for the same batch of training data, the distance and angle between the features extracted by the assistant model and the initial student model should be similar, for example, the distance can be Euclidean distance or cosine distance, or other distances (such as L1 distance, etc.).

[0117] Step S930: adjust the model parameters of the initial student model according to the second knowledge distillation loss information to obtain a student model.

[0118] The goal of the second knowledge distillation is to use the output of the teacher model and the assistant model to guide the initial student model, so that the output distribution of the initial student model is the same or similar to the output distribution of the teacher model and the assistant model.

[0119] The server determines whether the second knowledge distillation training completion condition is met based on the second knowledge distillation loss information. When the second knowledge distillation training completion condition is not met, the server uses the second knowledge distillation loss information to reversely update the model parameters in the initial student model, and iterates steps S910 to S920 until the second knowledge distillation training completion condition is met. The initial student model when the second knowledge distillation training completion condition is met is used as the assistant model.

[0120] See also Fig.10 , Fig.10 It is a schematic diagram of the second knowledge distillation training. Fig.10 As shown, training data is obtained and input into the initial student model, assistant model and teacher model respectively. Then, the second knowledge distillation loss information is calculated according to the output of the initial student model, assistant model and teacher model to determine whether the second knowledge distillation training completion condition is met according to the second knowledge distillation loss information. If not, the model parameters of the initial student model are updated. Then, the aforementioned steps are repeated for iterative training. If met, the current initial student model is used as the assistant model.

[0121] Optionally, the embodiment of the present application may also adopt Fig.11 Steps 1110 to 1130 shown implement step S920, and the details are as follows:

[0122] Step S1110, calculate the error between the initial student model prediction result and the assistant model prediction result to obtain the assistant model loss information.

[0123] Among them, the assistant model loss information is used to characterize the difference between the prediction results of the initial student model and the prediction results of the assistant model, that is, it is used to characterize the difference between the output distribution of the initial student model and the output distribution of the assistant model.

[0124] Exemplarily, the server may use a preset loss function to calculate the error between the initial student model prediction result and the assistant model prediction result to obtain assistant model loss information. For example, the assistant model loss information may be calculated using Formula 2 shown below.

[0125] Formula 2.

[0126] Among them, L a refers to the assistant model loss information, KL refers to the KL divergence loss function, y a refers to the prediction result of the assistant model, y s refers to the initial student model prediction result, i refers to the amount of training data, represents the probability distribution of the assistant model prediction results, It refers to the probability distribution of the prediction results of the initial student model.

[0127] Step S1120, calculate the error between the initial student model prediction result and the teacher model prediction result to obtain the teacher model loss information.

[0128] Among them, the teacher model loss information is used to characterize the difference between the initial student model prediction results and the teacher model prediction results, that is, it is used to characterize the difference between the output distribution of the initial student model and the output distribution of the teacher model.

[0129] Exemplarily, the server may use a preset loss function to calculate the error between the initial student model prediction result and the teacher model prediction result to obtain the teacher model loss information. For example, the teacher model loss information may be calculated using Formula 3 as shown below.

[0130] Formula 3.

[0131] Among them, L t refers to the teacher model loss information, KL refers to the KL divergence loss function, y t refers to the prediction result of the teacher model, y s refers to the initial student model prediction result, i refers to the amount of training data, represents the probability distribution of the teacher model’s prediction results, It refers to the probability distribution of the prediction results of the initial student model.

[0132] Step S1130: Obtain second knowledge distillation loss information based on the assistant model loss information and the teacher model loss information.

[0133] The server can use the preset weight coefficient to perform weighted calculation on the assistant model loss information and the teacher model loss information to obtain the second knowledge distillation loss information. For example, the second knowledge distillation loss information can be calculated using Formula 4 shown below.

[0134] Formula 4, L2=βL a +γL t

[0135] Among them, L2 refers to the second knowledge distillation loss information, L a refers to the assistant model loss information, L t refers to the loss information of the teacher model, β refers to the weight coefficient corresponding to the loss information of the assistant model, and γ refers to the weight coefficient corresponding to the loss information of the teacher model.

[0136] In an optional implementation, the model training method provided in the embodiment of the present application can be used in a face recognition scenario. The following is an introduction to the scenario of training a face recognition model. Fig.12As shown, the face recognition method includes steps S1210 to S1220.

[0137] Step S1210: Collect a face image to be identified.

[0138] It should be noted that the face image to be identified is an image to be subjected to face recognition. The face image to be identified may include one or at least two faces to be identified. The server may perform identity recognition on one or at least two faces to be identified in the face image to be identified based on the face image to be identified.

[0139] It should be noted that in the specific implementation of this application, related data such as facial images to be identified and user identity information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0140] Exemplarily, the terminal 110 is a client of an application software with a face recognition function deployed, and a trained face recognition model is deployed in the server 120 to realize face recognition on the terminal side. For example, in the field of financial payment, users can use smart phones to perform operations that require identity authentication, such as transferring, paying, or modifying account information, and identity authentication can be achieved by identifying the user's face image to be identified. In this process, the terminal 110 uploads the face image to be identified to the server 120, or the server 120 directly calls the face image to be identified in the database, and then uses the trained face recognition model to identify the face image to be identified to obtain a face recognition result. The server 120 can feedback the face recognition result to the terminal 110, or save the face recognition result locally for other business applications or processing.

[0141] Exemplarily, the terminal can collect facial images to be identified in real scenes through a built-in camera. The terminal can also collect facial images to be identified in real scenes through an external camera associated with the terminal. For example, the terminal can be connected to an image acquisition device through a connecting line or a network, and the image acquisition device collects facial images to be identified in real scenes through a camera, and transmits the collected facial images to be identified to the terminal. The camera can be a monocular camera, a binocular camera, a depth camera, a three-dimensional (3D) camera, etc. The terminal can collect facial images of living people to be identified in real scenes, and can also collect existing images containing faces in real scenes, such as scanned copies of identity documents.

[0142] Step S1220: input the face image to be recognized into the face recognition model; wherein the face recognition model is trained according to the above-mentioned model training method, and the face recognition model corresponds to the student model in the model training method.

[0143] The trained face recognition model is used to perform face recognition on the face image to be recognized, and the face recognition result corresponding to the face image to be recognized is obtained. Fig.13 As shown, the process of obtaining a face recognition model includes a model training phase and a model deployment phase. The model training phase includes performing a first knowledge distillation training on the initial assistant model through the trained teacher model to obtain a trained assistant model, and performing preliminary optimization training on the uninitialized student model through multiple cluster center vectors contained in the teacher model to obtain an initial student model, and then performing a second knowledge distillation training on the initial student model by combining the teacher model and the assistant model to obtain a trained student model, that is, a face recognition model. The model deployment phase is used to combine and deploy the related modules obtained in the module training phase to obtain a complete face recognition model, for example, Fig.14 As shown, the image acquisition input module, image feature extraction module and image classification module are integrated. The image acquisition input module acquires the face image to be identified, and then extracts the features of the face image to be identified according to the image feature extraction module to obtain the face image features, and then the image classification module performs face recognition according to the face image features. Among them, the face recognition model is derived from the knowledge transfer of the teacher model and the assistant model with stronger expression ability. The feature distribution extracted by it is highly similar to the feature distribution of the teacher model and the assistant model, so it has a higher recognition accuracy.

[0144] Step S1230: Obtain the face recognition result output by the face recognition model.

[0145] The server obtains facial image features corresponding to the facial image to be identified through the trained facial recognition model, and obtains facial recognition results corresponding to the facial image to be identified based on the facial image features.

[0146] In one embodiment, the face recognition result may be the identity corresponding to the face in the face image to be recognized. For example, in a one-to-many identity recognition scenario, the server obtains the face image features corresponding to the face image to be recognized through a trained face recognition model, matches the face image features with at least one reference image feature, and uses the identity corresponding to the reference image feature with the greatest matching degree as the identity of the face in the face image to be recognized. In other embodiments, the face recognition result may be the identity authentication result corresponding to the face in the face image to be recognized. For example, in a one-to-one identity authentication scenario, the server obtains the face image features corresponding to the face image to be recognized through a trained face recognition model, obtains the reference image features corresponding to the identity to be verified, and when the similarity between the image features to be verified and the reference image features exceeds a threshold, it is determined that the face image to be recognized has passed the identity authentication.

[0147] The training method of the face recognition model can be referred to the above embodiment and will not be described in detail here.

[0148] It can be seen that in the technical solution provided in the embodiments of the present application, the first knowledge distillation training is performed on the initial assistant model through the teacher model to obtain a trained assistant model, and then the second knowledge distillation training is performed on the initial student model by combining the teacher model and the assistant model to obtain a trained student model, so as to perform parameter transition through the assistant model whose parameter quantity is closer to that of the student model relative to the teacher model, thereby avoiding serious overfitting of the student model due to the large gap in parameter quantity between the teacher model and the student model, and the second knowledge distillation training process is supervised by the teacher model with stronger learning ability, so that the final student model has higher accuracy.

[0149] Fig.15 is a block diagram of a model training device shown in an exemplary embodiment of the present application. The model training device can be applied to Figure 1 The model training device can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applied.

[0150] like Fig.15 As shown, the exemplary model training device 1500 includes: a teacher model training module 1510, an assistant model training module 1520 and a student model training module 1530. Specifically:

[0151] The teacher model training module 1510 is configured to train the initial teacher model to obtain a trained teacher model.

[0152] The assistant model training module 1520 is configured to perform a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model.

[0153] The student model training module 1530 is configured to perform a second knowledge distillation training on the initial student model according to the teacher model and the assistant model to obtain a trained student model; wherein the parameter amount of the initial student model is smaller than the parameter amount of the initial assistant model.

[0154] In this exemplary model training device, in order to improve the knowledge distillation effect of the student model, an assistant model is introduced. Since the number of parameters of the assistant model is smaller than that of the teacher model but larger than that of the student model, the parameter quantity can be transitioned through the assistant model whose parameter quantity is closer to that of the student model relative to the teacher model, thereby avoiding the situation where the student model is seriously overfitted due to the large difference in the parameter quantity between the teacher model and the student model. At the same time, since the data processing capability of the teacher model is stronger than that of the assistant model, the initial student model can be trained by combining the teacher model and the assistant model, so that the obtained student model has better data processing capabilities.

[0155] Based on the above exemplary embodiment, the model training device 1500 further includes a first feature extraction module, a first prediction module, and a first model parameter adjustment module. Specifically:

[0156] The first feature extraction module is configured to input the training data into the uninitialized student model to obtain the feature extraction result output by the uninitialized student model.

[0157] The first prediction module is configured to obtain the prediction result of the uninitialized student model according to the feature extraction result and multiple cluster center vectors.

[0158] The first model parameter adjustment module is configured to adjust the model parameters of the uninitialized student model according to the difference between the prediction results of the uninitialized student model and the sample labels of the training data to obtain the initial student model.

[0159] In this exemplary model training device, the more accurate cluster center vector obtained during the teacher model training process is directly transferred to the uninitialized student model, and the uninitialized student model that obtains the cluster center vector is trained according to the training data, so as to preliminarily obtain an initial student model with a data processing capability that is not much different from that of the teacher model. This can speed up the efficiency of the subsequent second knowledge distillation training of the initial student model, reduce the difficulty of knowledge transfer in the second knowledge distillation training, and thus improve the accuracy of the student model.

[0160] Based on the above exemplary embodiment, the first prediction module further includes a similarity calculation module and a training data category acquisition module. Specifically:

[0161] The similarity calculation module is configured to respectively calculate the similarity between the feature extraction result and each cluster center vector.

[0162] The training data category acquisition module is configured to determine the training data category to which the training data corresponding to the feature extraction result belongs based on the similarity, and use the training data category as the prediction result of the uninitialized student model.

[0163] In this exemplary model training device, the similarity between the feature extraction results output by the uninitialized student model and each cluster center vector is calculated to confirm the training data category of the training data input to the uninitialized student model based on the similarity. Since the cluster center vector is a parameter migrated from the teacher model, the accuracy of the process of identifying the training data category of the feature extraction result is improved.

[0164] Based on the above exemplary embodiment, the assistant model training module 1520 further includes a second prediction module, a first knowledge distillation loss information calculation module and an assistant model parameter adjustment module. Specifically:

[0165] The second prediction module is configured to input the training data into the initial assistant model and the teacher model respectively, to obtain the assistant model prediction results output by the initial assistant model and the teacher model prediction results output by the teacher model.

[0166] The first knowledge distillation loss information calculation module is configured to calculate the first knowledge distillation loss information based on the assistant model prediction results and the teacher model prediction results.

[0167] The assistant model parameter adjustment module is configured to adjust the model parameters of the initial assistant model according to the first knowledge distillation loss information to obtain the assistant model.

[0168] In this exemplary model training device, the initial assistant model is trained for knowledge distillation using the teacher model prediction results output by the teacher model to transfer the data processing capabilities of the teacher model to the assistant model with a smaller number of parameters. This can then be used to avoid overfitting of the student model due to the large difference in parameter amounts between the teacher model and the student model based on the assistant model with a smaller number of parameters, thereby improving the accuracy of the student model.

[0169] Based on the above exemplary embodiment, the first knowledge distillation loss information calculation module also includes a result loss information acquisition module, a label loss information acquisition module and a comprehensive calculation module. Specifically:

[0170] The result loss information acquisition module is configured to calculate the error between the assistant model prediction result and the teacher model prediction result to obtain the result loss information.

[0171] The label loss information acquisition module is configured to calculate the error between the prediction result of the assistant model and the sample label corresponding to the training data to obtain the label loss information.

[0172] The first comprehensive calculation module is configured to calculate the first knowledge distillation loss information according to the result loss information and the label loss information.

[0173] In this exemplary model training device, label loss information is obtained based on the assistant model prediction results and the sample labels corresponding to the training data, result loss information is obtained based on the assistant model prediction results and the teacher model prediction results, and then the first knowledge distillation loss information is obtained based on the label loss information and the result loss information, so as to simultaneously consider the teacher model's prediction results for the training data and the actual results of the training data, thereby improving the accuracy of the assistant model.

[0174] Based on the above exemplary embodiment, the student model training module 1530 further includes a third prediction module, a second knowledge distillation loss information calculation module and a student model parameter adjustment module. Specifically:

[0175] The third prediction module is configured to input the training data into the initial student model, the assistant model and the teacher model respectively, to obtain the initial student model prediction results output by the initial student model, the assistant model prediction results output by the assistant model and the teacher model prediction results output by the teacher model.

[0176] The second knowledge distillation loss information calculation module is configured to calculate the second knowledge distillation loss information based on the initial student model prediction results, the assistant model prediction results and the teacher model prediction results.

[0177] The student model parameter adjustment module is configured to adjust the model parameters of the initial student model according to the second knowledge distillation loss information to obtain the student model.

[0178] In this exemplary model training device, knowledge distillation training is performed on the initial student model through the teacher model prediction results output by the teacher model and the assistant model prediction results output by the assistant model, so as to avoid overfitting of the student model due to the large difference in parameter amounts between the teacher model and the student model through the assistant model with a smaller parameter amount, and the second knowledge distillation training process is supervised by the teacher model with stronger learning ability, so that the final student model has higher accuracy.

[0179] Based on the above exemplary embodiment, the second knowledge distillation loss information calculation module also includes an assistant model loss information acquisition module, a teacher model loss information acquisition module and a second comprehensive calculation module. Specifically:

[0180] The assistant model loss information acquisition module is configured to calculate the error between the initial student model prediction result and the assistant model prediction result to obtain the assistant model loss information.

[0181] The teacher model loss information acquisition module is configured to calculate the error between the initial student model prediction result and the teacher model prediction result to obtain the teacher model loss information.

[0182] The second comprehensive calculation module is configured to obtain second knowledge distillation loss information based on the assistant model loss information and the teacher model loss information.

[0183] In this exemplary model training device, by combining the assistant model loss information and the teacher model loss information to calculate the second knowledge distillation loss information of the initial student model, the output distribution of the assistant model and the teacher model can be combined to make the obtained second knowledge distillation loss information more accurate.

[0184] It should be noted that the model training device provided in the above embodiment and the model training method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In practical applications, the model training device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0185] Fig.16 is a block diagram of a face recognition device shown in an exemplary embodiment of the present application. The face recognition device can be applied to Figure 1 The face recognition device can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applied.

[0186] like Fig.16 As shown, the exemplary face recognition device 1600 includes: an image acquisition module 1610, a recognition module 1620 and a result acquisition module 1630. Specifically:

[0187] An image acquisition module 1610 is configured to acquire a face image;

[0188] The recognition module 1620 is configured to input the face image into the face recognition model; wherein the face recognition model is trained according to the above-mentioned model training method, and the face recognition model corresponds to the student model in the model training method;

[0189] The result acquisition module 1630 is configured to obtain the face recognition result output by the face recognition model.

[0190] In this exemplary model training device, a face recognition model is trained based on the above-mentioned model training method. The face recognition model has similar or the same data processing capabilities as the teacher model, and the face recognition model has a smaller number of parameters, which is easy to deploy.

[0191] It should be noted that the face recognition device provided in the above embodiment and the face recognition method provided in the above embodiment belong to the same concept, and the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, which will not be repeated here. In practical applications, the model training device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0192] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the model training method provided in the above-mentioned embodiments.

[0193] Fig.17 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Fig.17 The computer system 1700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0194] like Fig.17As shown, the computer system 1700 includes a central processing unit (CPU) 1701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1702 or the program loaded from the storage part 1708 to the random access memory (RAM) 1703, such as executing the method described in the above embodiment. In RAM 1703, various programs and data required for system operation are also stored. CPU 1701, ROM 1702 and RAM 1703 are connected to each other through bus 1704. Input / output (I / O) interface 1705 is also connected to bus 1704.

[0195] The following components are connected to the I / O interface 1705: an input section 1706 including a keyboard, a mouse, etc.; an output section 1707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1708 including a hard disk, etc.; and a communication section 1709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1709 performs communication processing via a network such as the Internet. A drive 1710 is also connected to the I / O interface 1705 as needed. A removable medium 1711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1710 as needed so that a computer program read therefrom is installed into the storage section 1708 as needed.

[0196] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1709, and / or installed from a removable medium 1711. When the computer program is executed by a central processing unit (CPU) 1701, various functions defined in the system of the present application are executed.

[0197] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0198] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0199] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0200] Another aspect of the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the model training method as described above when the computer program is executed by a processor. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0201] Another aspect of the present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the model training method provided in each of the above embodiments.

[0202] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A model training method, characterized in that: The method comprises: Train the initial teacher model to obtain a trained teacher model; Performing a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model; the teacher model includes a plurality of cluster center vectors, and different cluster center vectors correspond to different training data categories; Inputting the training data into an uninitialized student model to obtain a feature extraction result output by the uninitialized student model; Migrating the multiple cluster center vectors included in the teacher model to the classification module of the uninitialized student model, and obtaining the uninitialized student model prediction result according to the multiple cluster center vectors in the classification module of the uninitialized student model and the feature extraction result; Adjusting the model parameters of the uninitialized student model according to the difference between the prediction result of the uninitialized student model and the sample label of the training data to obtain an initial student model; wherein the parameter amount of the initial student model is less than the parameter amount of the initial assistant model; Inputting the training data into the initial student model, the assistant model and the teacher model respectively, obtaining the initial student model prediction result output by the initial student model, the assistant model prediction result output by the assistant model and the teacher model prediction result output by the teacher model; Calculating the error between the prediction result of the initial student model and the prediction result of the assistant model to obtain assistant model loss information; Calculating the error between the initial student model prediction result and the teacher model prediction result to obtain teacher model loss information; Obtaining second knowledge distillation loss information according to the assistant model loss information and the teacher model loss information; Adjusting the model parameters of the initial student model according to the second knowledge distillation loss information to obtain a student model; Collecting facial images to be identified; The face image to be recognized is input into the student model, and the face recognition result output by the student model is obtained.

2. The method according to claim 1, characterized in that: The method of obtaining the prediction result of the uninitialized student model according to the feature extraction result and the multiple cluster center vectors includes: Calculating the similarity between the feature extraction result and each of the cluster center vectors respectively; The training data category to which the training data corresponding to the feature extraction result belongs is determined according to the similarity, and the training data category is used as the prediction result of the uninitialized student model.

3. The method according to claim 1, characterized in that The first knowledge distillation training is performed on the initial assistant model according to the teacher model to obtain a trained assistant model, including: Inputting the training data into the initial assistant model and the teacher model respectively, obtaining the assistant model prediction result output by the initial assistant model and the teacher model prediction result output by the teacher model; Calculate first knowledge distillation loss information according to the assistant model prediction result and the teacher model prediction result; The model parameters of the initial assistant model are adjusted according to the first knowledge distillation loss information to obtain the assistant model.

4. The method according to claim 3, characterized in that The calculating the first knowledge distillation loss information according to the prediction result of the assistant model and the prediction result of the teacher model includes: Calculate the error between the prediction result of the assistant model and the prediction result of the teacher model to obtain result loss information; Calculate the error between the prediction result of the assistant model and the sample label corresponding to the training data to obtain label loss information; The first knowledge distillation loss information is calculated based on the result loss information and the label loss information.

5. A model training device, characterized in that: The device comprises: A teacher model training module is configured to train the initial teacher model to obtain a trained teacher model; An assistant model training module is configured to perform a first knowledge distillation training on the initial assistant model according to the teacher model to obtain a trained assistant model; wherein the parameter amount of the initial assistant model is smaller than the parameter amount of the initial teacher model; the teacher model contains multiple cluster center vectors, and different cluster center vectors correspond to different training data categories; A student model training module is configured to input training data into an uninitialized student model to obtain a feature extraction result output by the uninitialized student model; Migrating the multiple cluster center vectors included in the teacher model to the classification module of the uninitialized student model, and obtaining the uninitialized student model prediction result according to the multiple cluster center vectors in the classification module of the uninitialized student model and the feature extraction result; Adjusting the model parameters of the uninitialized student model according to the difference between the prediction result of the uninitialized student model and the sample label of the training data to obtain an initial student model; wherein the parameter amount of the initial student model is less than the parameter amount of the initial assistant model; Inputting the training data into the initial student model, the assistant model and the teacher model respectively, obtaining the initial student model prediction result output by the initial student model, the assistant model prediction result output by the assistant model and the teacher model prediction result output by the teacher model; Calculating the error between the prediction result of the initial student model and the prediction result of the assistant model to obtain assistant model loss information; Calculating the error between the initial student model prediction result and the teacher model prediction result to obtain teacher model loss information; Obtaining second knowledge distillation loss information according to the assistant model loss information and the teacher model loss information; Adjusting the model parameters of the initial student model according to the second knowledge distillation loss information to obtain a student model; Collecting facial images to be identified; The face image to be recognized is input into the student model, and the face recognition result output by the student model is obtained.

6. A computer device, characterized in that: include: a memory, wherein a computer program is stored in the memory; A processor, used to load the computer program to implement the model training method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the model training method as described in any one of claims 1 to 4.

8. A computer program product, characterized in that The computer program product comprises a computer program, which is suitable for being loaded by a processor and executing the model training method as described in any one of claims 1 to 4.