Face recognition model training method and device

By employing data parallelism in the backbone network and model parallelism in the classification matrix, the computational and memory constraints in face recognition involving tens of millions of faces were addressed, achieving a significant improvement in face recognition accuracy. The model parameters were optimized using large-scale face data.

CN115205919BActive Publication Date: 2025-12-09BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110395283.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-13
Publication Date
2025-12-09
Estimated Expiration
2041-04-13

AI Technical Summary

Technical Problem

Existing technologies have unacceptable computational and memory overhead for face recognition at the tens of millions level. Dynamic class selection methods are complex and lack versatility, making it difficult to improve the accuracy of face recognition models.

Method used

By employing a data parallelism approach for the backbone network and a model parallelism approach for the classification matrix, multiple face sample images are equally divided into multiple network node layers. The network node index and probability are calculated, and the model parameters are adjusted until convergence. Combined with the latest classification loss function, face recognition for tens of millions of categories can be achieved.

Benefits of technology

It significantly improves the accuracy of face recognition, solves the computational overhead and memory bottleneck of large-scale classification, and makes full use of large-scale face data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115205919B_ABST
    Figure CN115205919B_ABST
Patent Text Reader

Abstract

The present disclosure provides a face recognition model training method and device. The method comprises: inputting multiple face sample images into a face recognition model to be trained; the face recognition model to be trained comprises multiple network node layers; the multiple face sample images are equally divided into the multiple network node layers, and the multiple network node layers are called to process the multiple face sample images to obtain image features corresponding to the multiple network node layers; network node indexes corresponding to the multiple network node layers are calculated according to the image features and a preset classification matrix; node probabilities corresponding to the multiple network node layers are determined according to the network node indexes; a model gradient of the face recognition model to be trained is calculated according to the node probabilities; and model parameters of the face recognition model to be trained are adjusted based on the model gradient until the face recognition model to be trained converges. The present disclosure can save the calculation cost of face classification and significantly improve the face recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of model training, and in particular to a face recognition model training method and device. BACKGROUND

[0002] With the continuous development of science and technology, the application of electronic devices gradually penetrates people's work and life.

[0003] In daily work and life, users often use face recognition to punch in and out, pay, and the like, and a face recognition platform faces face recognition of tens of millions or even hundreds of millions of people, so the accuracy of the face recognition model used by the platform is required to be high. Training a face recognition network through large-scale classification of tens of millions of faces is a very effective method, and the face features trained in this way have good clustering characteristics and discrimination ability. However, it is unacceptable to directly implement complete classification of tens of millions of faces in terms of calculation and memory consumption.

[0004] In the prior art, a dynamic class selection method is usually designed to classify a part of the selected samples, which is actually an approximate method. Not only is the implementation process of class selection complex, but also an uncertain number of hyperparameters are introduced, which makes optimization difficult and has poor universality. SUMMARY

[0005] Embodiments of the present disclosure provide a face recognition model training method and device, which use data parallelism of a backbone network and model parallelism of a classification matrix to solve the calculation overhead and memory bottleneck of large-scale classification, and can fully utilize large-scale face data collected in a business scenario to significantly improve face recognition accuracy.

[0006] According to a first aspect of embodiments of the present disclosure, a face recognition model training method is provided, comprising:

[0007] inputting a plurality of face sample images into a face recognition model to be trained; the face recognition model to be trained comprises a plurality of network node layers;

[0008] equally dividing the plurality of face sample images into the plurality of network node layers, and calling the plurality of network node layers to process the plurality of face sample images to obtain image features corresponding to the plurality of network node layers;

[0009] calculating network node indices corresponding to the plurality of network node layers according to the image features and a preset classification matrix;

[0010] determining node probabilities corresponding to the plurality of network node layers according to the network node indices;

[0011] According to the node probability, a model gradient of the to-be-trained face recognition model is calculated;

[0012] Based on the model gradient, a model parameter of the to-be-trained face recognition model is adjusted until the to-be-trained face recognition model converges.

[0013] Optionally, the processing of the plurality of network node layers on the plurality of face sample images to obtain the image features corresponding to the plurality of network node layers comprises:

[0014] For the plurality of network node layers, the network node layer is called to obtain the face features of the sample face image divided to the network node layer;

[0015] The face features are subjected to a feature aggregation operation to obtain the image features corresponding to the network node layer.

[0016] Optionally, the calculation of the network node index corresponding to the plurality of network node layers according to the image features and a preset classification matrix comprises:

[0017] The preset classification matrix is distributed to the plurality of network node layers;

[0018] The network node index corresponding to the plurality of network node layers is determined according to the product of the image features corresponding to the plurality of network node layers and the preset classification matrix.

[0019] Optionally, the determination of the node probability corresponding to the plurality of network node layers according to the network node index comprises:

[0020] The network node index corresponding to the plurality of network node layers is subjected to a feature reduction operation to obtain node features corresponding to the plurality of network node layers;

[0021] The node probability of the plurality of network node layers is calculated according to the node features.

[0022] Optionally, the calculation of the model gradient of the to-be-trained face recognition model according to the node probability comprises:

[0023] The classification matrix gradient corresponding to the plurality of network node layers is calculated according to the node probability and the image features on the plurality of network node layers;

[0024] The feature gradient corresponding to the plurality of network node layers is calculated according to the node probability;

[0025] The network gradient corresponding to the to-be-trained face recognition model is calculated according to the node probability and the chain rule.

[0026] Optionally, the adjusting, based on the model gradient, of the model parameter of the to-be-trained face recognition model comprises:

[0027] adjusting, according to the classification matrix gradient, a matrix parameter of the preset classification matrix;

[0028] adjusting, according to the feature gradient and the network gradient, a parameter of the to-be-trained face recognition model.

[0029] According to a second aspect of embodiments of the present disclosure, a face recognition model training apparatus is provided, comprising:

[0030] a sample image input module configured to input a plurality of face sample images to a to-be-trained face recognition model; the to-be-trained face recognition model comprises a plurality of network node layers;

[0031] an image feature acquisition module configured to divide the plurality of face sample images equally to the plurality of network node layers, and invoke the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers;

[0032] a node index acquisition module configured to calculate network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix;

[0033] a node probability determination module configured to determine node probabilities corresponding to the plurality of network node layers according to the network node indexes;

[0034] a model gradient calculation module configured to calculate a model gradient of the to-be-trained face recognition model according to the node probabilities;

[0035] a model parameter adjustment module configured to adjust a model parameter of the to-be-trained face recognition model based on the model gradient, until the to-be-trained face recognition model converges.

[0036] Optionally, the image feature acquisition module comprises:

[0037] a face feature acquisition unit configured to, for the plurality of network node layers, invoke the network node layers to acquire face features of sample face images divided to the network node layers;

[0038] an image feature acquisition unit configured to perform a feature aggregation operation on the face features, to obtain the image features corresponding to the network node layers.

[0039] Optionally, the node index acquisition module comprises:

[0040] a classification matrix distribution unit configured to distribute the preset classification matrix to the plurality of network node layers.

[0041] a node index determination unit, configured to determine network node indices corresponding to the plurality of network node layers according to a product of image features corresponding to the plurality of network node layers and the preset classification matrix.

[0042] Optionally, the node probability determination module comprises:

[0043] a node feature acquisition unit, configured to perform feature reduction operation on the network node indices corresponding to the plurality of network node layers to obtain node features corresponding to the plurality of network node layers;

[0044] a node probability calculation unit, configured to calculate node probabilities of the plurality of network node layers according to the node features.

[0045] Optionally, the model gradient calculation module comprises:

[0046] a classification matrix gradient calculation unit, configured to calculate classification matrix gradients corresponding to the plurality of network node layers according to the node probabilities and image features on the plurality of network node layers;

[0047] a feature gradient calculation unit, configured to calculate feature gradients corresponding to the plurality of network node layers according to the node probabilities;

[0048] a network gradient calculation unit, configured to calculate network gradients corresponding to the to-be-trained face recognition model according to the node probabilities and a chain rule.

[0049] Optionally, the model parameter adjustment module comprises:

[0050] a matrix parameter adjustment unit, configured to adjust matrix parameters of the preset classification matrix according to the classification matrix gradients;

[0051] a model parameter adjustment unit, configured to adjust parameters of the to-be-trained face recognition model according to the feature gradients and the network gradients.

[0052] According to a third aspect of embodiments of the present disclosure, an electronic device is provided, comprising:

[0053] a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the face recognition model training method according to any one of the preceding embodiments when executing the program.

[0054] According to a fourth aspect of embodiments of the present disclosure, a readable storage medium is provided, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the face recognition model training method according to any one of the preceding embodiments.

[0055] Embodiments of the present disclosure provide a face recognition model training method and device. The face recognition model training method comprises: inputting a plurality of face sample images into a to-be-trained face recognition model, the to-be-trained face recognition model comprising a plurality of network node layers; dividing the plurality of face sample images equally into the plurality of network node layers; calling the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers; calculating network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix; determining node probabilities corresponding to the plurality of network node layers according to the network node indexes; calculating a model gradient of the to-be-trained face recognition model according to the node probabilities; adjusting model parameters of the to-be-trained face recognition model based on the model gradient, until the to-be-trained face recognition model converges. Embodiments of the present disclosure decompose the optimization process of a neural network classification model, and innovatively use a distributed method to realize data parallelism of a backbone network and model parallelism of a classification matrix, to completely classify a face of a million classes, solve the calculation overhead and memory bottleneck of large-scale classification, and fully utilize large-scale face data collected in a business scenario, and in combination with a latest classification loss function, significantly improve face recognition accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments of the present disclosure will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.

[0057] Figure 1 A step flow chart of a face recognition model training method provided by an embodiment of the present disclosure;

[0058] Figure 2 A step flow chart of another face recognition model training method provided by an embodiment of the present disclosure;

[0059] Figure 3 A structural schematic diagram of a face recognition model training device provided by an embodiment of the present disclosure;

[0060] Figure 4 A structural schematic diagram of another face recognition model training device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0061] With reference to the accompanying drawings, the technical solutions in the embodiments of the present disclosure will be described clearly and completely. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present disclosure.

[0062] Embodiment one

[0063] With reference to Figure 1 , a step flowchart of a face recognition model training method provided by an embodiment of the present disclosure is shown, as shown in Figure 1 , the face recognition model training method can specifically include the following steps:

[0064] Step 101: inputting multiple face sample images into a face recognition model to be trained; the face recognition model to be trained includes multiple network node layers.

[0065] The embodiments of the present disclosure can be applied to the scene of training a face recognition model.

[0066] The face sample image refers to an image containing a face obtained for training the face recognition model to be trained.

[0067] In some examples, the face sample image can be an image selected from a database, for example, in the database of a certain platform, the face images uploaded by registered users are pre-stored, when the face recognition model needs to be trained, the face images meeting the conditions can be selected from the database of the platform as the face sample images, etc.

[0068] In some examples, the face sample image can be an image downloaded from a website, for example, when the face recognition model needs to be trained, the business personnel can download the face images from the Internet website as the face sample images.

[0069] It can be understood that the above examples are only examples for better understanding the technical solutions of the embodiments of the present disclosure, and are not the only limitation of the present embodiment.

[0070] The face recognition model to be trained refers to the face recognition model that needs to be trained. The face recognition model to be trained includes multiple network node layers, and the multiple network node layers can realize parallel processing of data.

[0071] When the face recognition model needs to be trained, multiple face sample images can be obtained, and the multiple face sample images are inputted into the face recognition model to be trained.

[0072] After inputting the face sample image into the face recognition model to be trained, step 102 is performed.

[0073] Step 102: The plurality of face sample images are equally divided into the plurality of network node layers, and the plurality of network node layers are called to process the plurality of face sample images to obtain image features corresponding to the plurality of network node layers.

[0074] After inputting the plurality of face sample images into the face recognition model to be trained, the plurality of face sample images can be equally divided into the plurality of network node layers. For example, the number of the plurality of face sample images is 1000, and the number of the plurality of network node layers is 5. At this time, the 1000 images can be equally divided into the 5 network node layers, that is, 200 images are divided into each network node layer.

[0075] It can be understood that the above examples are only examples for better understanding the technical solutions of the embodiments of the present disclosure, and are not the only limitation of the embodiments of the present disclosure.

[0076] The image feature refers to the total image feature corresponding to the network node layer after the network node layer aggregates the face features of the face sample images located on the network node layer.

[0077] After the plurality of face sample images are equally divided into the plurality of network node layers, the plurality of network node layers can be called to process the plurality of face sample images to obtain image features corresponding to the plurality of network node layers. Specifically, for each network node layer, the network node layer can be called to aggregate the face features of the face sample images located on the network node layer to obtain the image features corresponding to the network node layer.

[0078] After the plurality of network node layers are called to process the plurality of face sample images to obtain the image features corresponding to the plurality of network node layers, step 103 is performed.

[0079] Step 103: The network node indices corresponding to the plurality of network node layers are calculated according to the image features and a preset classification matrix.

[0080] The preset classification matrix refers to a classification matrix pre-set in the face recognition model to be trained. The specific form of the classification matrix can be determined according to business requirements, and the embodiments are not limited in this regard.

[0081] The network node index can be used to indicate the index of the image feature on the network node layer, that is, the logits of the network node layer.

[0082] After obtaining the image features corresponding to each network node layer in the plurality of network node layers, the network node index corresponding to each network node layer can be calculated according to the image features corresponding to each network node layer and the preset classification matrix.

[0083] After the network node indices corresponding to the plurality of network node layers are calculated according to the image features and the preset classification matrix, step 104 is performed.

[0084] Step 104: determining the node probability corresponding to the plurality of network node layers according to the network node indices.

[0085] The node probability refers to the probability corresponding to the image features on the network node layer, and the node probability can be used to indicate the probability of allocating feature classification on the network node layer.

[0086] After the network node indices corresponding to the plurality of network node layers are calculated, the node probability corresponding to the plurality of network node layers can be determined according to the network node indices. Specifically, the feature reduction operation (ALLReduce) can be performed according to the network node indices corresponding to the network node layers, and then the softmax is calculated to obtain the node probability of the network node layer.

[0087] After the node probability corresponding to the plurality of network node layers is determined according to the network node indices, step 105 is performed.

[0088] Step 105: calculating the model gradient of the to-be-trained face recognition model according to the node probability.

[0089] The model gradient refers to the gradient used to indicate whether the model parameters of the to-be-trained face recognition model meet the conditions. In this example, the model gradient can include a classification matrix gradient, a feature gradient, and a network gradient.

[0090] After the node probability corresponding to the plurality of network node layers is obtained, the model gradient of the to-be-trained face recognition model can be calculated according to the plurality of node probabilities.

[0091] After the model gradient of the to-be-trained face recognition model is calculated, step 106 is performed.

[0092] Step 106: adjusting the model parameters of the to-be-trained face recognition model based on the model gradient until the to-be-trained face recognition model converges.

[0093] After the model gradient of the to-be-trained face recognition model is calculated, the model parameters of the to-be-trained face recognition model can be adjusted based on the model gradient until the to-be-trained face recognition model converges. Specifically, the model parameters can be adjusted for multiple rounds until the last model gradient meets the business requirements. At this time, the trained to-be-trained face recognition model can be used as the final face recognition model.

[0094] Embodiments of the present disclosure decompose the optimization process of the neural network classification model, innovatively use a distributed method to realize data parallelism of the backbone network and model parallelism of the classification matrix, fully classify faces of ten million categories, solve the calculation overhead and memory bottleneck of large-scale classification, can fully utilize large-scale face data collected in a business scenario, and combine the latest classification loss function to significantly improve the face recognition accuracy.

[0095] The face recognition model training method provided by the embodiments of the present disclosure includes the following steps: inputting multiple face sample images into a to-be-trained face recognition model; the to-be-trained face recognition model includes multiple network node layers; equally dividing the multiple face sample images into the multiple network node layers; calling the multiple network node layers to process the multiple face sample images; obtaining image features corresponding to the multiple network node layers; calculating network node indexes corresponding to the multiple network node layers according to the image features and a preset classification matrix; determining node probabilities corresponding to the multiple network node layers according to the network node indexes; calculating a model gradient of the to-be-trained face recognition model according to the node probabilities; adjusting model parameters of the to-be-trained face recognition model based on the model gradient until the to-be-trained face recognition model converges. Embodiments of the present disclosure decompose the optimization process of the neural network classification model, innovatively use a distributed method to realize data parallelism of the backbone network and model parallelism of the classification matrix, fully classify faces of ten million categories, solve the calculation overhead and memory bottleneck of large-scale classification, can fully utilize large-scale face data collected in a business scenario, and combine the latest classification loss function to significantly improve the face recognition accuracy.

[0096] Embodiment Two

[0097] Reference Figure 2 Another face recognition model training method provided by the embodiments of the present disclosure is shown in FIG. 2. As shown in FIG. 2, the face recognition model training method can specifically include the following steps: Figure 2

[0098] Step 201: input multiple face sample images into a to-be-trained face recognition model; the to-be-trained face recognition model includes multiple network node layers.

[0099] Embodiments of the present disclosure can be applied to a scenario of training a face recognition model. ​

[0100] The face sample image refers to an image containing a face obtained for training the to-be-trained face recognition model.

[0101] In some examples, the face sample image can be an image screened from a database, for example, face images uploaded by registered users are pre-stored in a database of a certain platform, when training of the face recognition model is needed, face images meeting the conditions can be screened from the database of the platform as face sample images, etc.

[0102] In some examples, the face sample image can be an image downloaded from a website, for example, when training of the face recognition model is needed, a business staff can download face images from an Internet website as face sample images.

[0103] It can be understood that the above examples are only examples listed for better understanding of the technical solutions of the embodiments of the present disclosure, and are not the only limitation of the present embodiment.

[0104] The to-be-trained face recognition model refers to a face recognition model that needs to be trained. The to-be-trained face recognition model contains a plurality of network node layers, and the plurality of network node layers can realize parallel processing of data.

[0105] When the face recognition model needs to be trained, a plurality of face sample images can be obtained, and the plurality of face sample images are input into the to-be-trained face recognition model.

[0106] After the face sample images are input into the to-be-trained face recognition model, step 202 is performed.

[0107] Step 202: The plurality of face sample images are equally divided into the plurality of network node layers, and for the plurality of network node layers, the network node layer is called to obtain the face features of the sample face images divided into the network node layer.

[0108] After the plurality of face sample images are input into the to-be-trained face recognition model, the plurality of face sample images can be equally divided into the plurality of network node layers, for example, the number of the plurality of face sample images is 1000, and the number of the plurality of network node layers is 5, at this time, the 1000 images can be equally divided into 5 network node layers, that is, 200 images are divided on each network node layer, etc.

[0109] After the plurality of face sample image is equally divided into a plurality of network node layers, the network node layer can be called to obtain the face feature of the sample face image divided into the network node layer. For example, the number of the plurality of face sample image is 1000, and the number of the network node layer is 5. At this time, 1000 images can be equally divided into 5 network node layers, that is, 200 images are divided on each network node layer. At this time, the first network node layer can be called to obtain the face feature in the 200 images divided on the network node layer. The second network node layer can be called to obtain the face feature in the 200 images divided on the network node layer, and so on, until the 5 network node layers obtain the face feature in the images respectively divided on the corresponding network node layer.

[0110] It can be understood that the above examples are only examples for better understanding the technical scheme of the embodiments of the present disclosure, and are not the only limitation of the embodiments of the present disclosure.

[0111] After the plurality of face sample image is equally divided into a plurality of network node layers, the network node layer can be called to obtain the face feature of the sample face image divided into the network node layer. For example, the number of the plurality of face sample image is 1000, and the number of the network node layer is 5. At this time, 1000 images can be equally divided into 5 network node layers, that is, 200 images are divided on each network node layer. At this time, the first network node layer can be called to obtain the face feature in the 200 images divided on the network node layer. The second network node layer can be called to obtain the face feature in the 200 images divided on the network node layer, and so on, until the 5 network node layers obtain the face feature in the images respectively divided on the corresponding network node layer.

[0112] Step 203: performing feature aggregation operation on the face feature to obtain the image feature corresponding to the network node layer.

[0113] The image feature refers to the total image feature corresponding to the network node layer obtained after the network node layer performs feature aggregation on the face feature of the face sample image located on the network node layer.

[0114] After the plurality of face sample image is equally divided into a plurality of network node layers, the network node layer can be called to obtain the face feature of the sample face image divided into the network node layer. For example, the number of the plurality of face sample image is 1000, and the number of the network node layer is 5. At this time, 1000 images can be equally divided into 5 network node layers, that is, 200 images are divided on each network node layer. At this time, the first network node layer can be called to obtain the face feature in the 200 images divided on the network node layer. The second network node layer can be called to obtain the face feature in the 200 images divided on the network node layer, and so on, until the 5 network node layers obtain the face feature in the images respectively divided on the corresponding network node layer.

[0115] After the face feature is subjected to the feature aggregation operation to obtain the image feature corresponding to the network node layer, step 204 is performed.

[0116] Step 204: distributing the preset classification matrix to the plurality of network node layers.

[0117] The preset classification matrix refers to the classification matrix pre-set in the face recognition model to be trained. The specific form of the classification matrix can be determined according to business requirements, which is not limited in the present embodiment.

[0118] After the feature aggregation operation is performed on the face features to obtain the image features corresponding to the network node layers, the preset classification matrix can be distributed to the network node layers.

[0119] After the preset classification matrix is distributed to the network node layers, step 205 is performed.

[0120] Step 205: determining network node indices corresponding to the network node layers according to the product of the image features corresponding to the network node layers and the preset classification matrix.

[0121] The network node indices can be used to indicate the indices of the image features on the network node layers, i.e., the logits of the network node layers.

[0122] After the preset classification matrix is distributed to the network node layers, the network node indices corresponding to the network node layers can be calculated according to the image features corresponding to the network node layers and the preset classification matrix. Specifically, the product of the image features on each network node layer and the preset classification matrix can be calculated, and the product is taken as the network node index corresponding to each network node layer.

[0123] After the network node indices corresponding to the network node layers are determined according to the product of the image features corresponding to the network node layers and the preset classification matrix, step 206 is performed.

[0124] Step 206: performing a feature reduction operation on the network node indices corresponding to the network node layers to obtain node features corresponding to the network node layers.

[0125] The node features refer to the features obtained after the feature reduction operation is performed on the network node indices corresponding to the network node layers.

[0126] After the network node indices corresponding to the network node layers are obtained, a feature reduction operation (ALLReduce) can be performed on the network node indices corresponding to the network node layers to obtain the node features corresponding to the network node layers.

[0127] After the node features corresponding to the network node layers are obtained, step 207 is performed.

[0128] Step 207: calculating node probabilities of the network node layers according to the node features.

[0129] The node probabilities refer to the probabilities corresponding to the image features on the network node layers. The node probabilities can be used to indicate the probabilities of allocating feature classifications on the network node layers.

[0130] After obtaining the node features of the plurality of network node layers, node probabilities of the plurality of network node layers can be calculated according to the node features. Specifically, the node probability of each network node layer can be calculated according to the node feature of the network node layer by using a softmax function.

[0131] After the node probabilities of the plurality of network node layers are calculated according to the node features, steps 208, 209 and 210 are performed.

[0132] Step 208: calculating classification matrix gradients corresponding to the plurality of network node layers according to the node probabilities and image features on the plurality of network node layers.

[0133] The classification matrix gradient refers to a gradient used to indicate the accuracy of the matrix parameters of the preset classification matrix.

[0134] After obtaining the node probabilities of the plurality of network node layers, the classification matrix gradients corresponding to the plurality of network node layers can be calculated according to the node probabilities and the image features on the plurality of network node layers. Specifically, the classification matrix gradient of each network node layer can be calculated according to the node feature of the network node layer and the node probability of the network node layer.

[0135] Step 209: calculating feature gradients corresponding to the plurality of network node layers according to the node probabilities.

[0136] The feature gradient refers to a gradient used to indicate the accuracy of the network layer parameters of the network node layer.

[0137] After obtaining the node probabilities of the plurality of network node layers, the feature gradients corresponding to the plurality of network node layers can be calculated according to the node probabilities of the plurality of network node layers.

[0138] Step 210: calculating a network gradient corresponding to the to-be-trained face recognition model according to the node probabilities and the chain rule.

[0139] The network gradient refers to a gradient used to indicate the accuracy of the parameters of the to-be-trained face recognition model.

[0140] After obtaining the node probabilities of the plurality of network node layers, the network gradient of the to-be-trained face recognition model can be calculated in combination with the node probabilities of the plurality of network node layers and the chain rule.

[0141] Step 211: adjusting the matrix parameters of the preset classification matrix according to the classification matrix gradients.

[0142] Step 212: adjusting the parameters of the to-be-trained face recognition model according to the feature gradients and the network gradient.

[0143] After obtaining the classification matrix gradient, the matrix parameters of the preset classification matrix can be adjusted according to the classification matrix gradient.

[0144] After obtaining the feature gradient and the network gradient, the parameters of the to-be-trained face recognition model can be adjusted according to the feature gradient and the network gradient.

[0145] The above process is repeated until the adjusted model parameters can meet the business requirements. At this time, the to-be-trained face recognition model obtained by training can be used as the final face recognition model, which can then be applied to subsequent batch face image recognition scenarios.

[0146] The face recognition model training method provided by the embodiments of the present disclosure includes inputting multiple face sample images into a to-be-trained face recognition model, the to-be-trained face recognition model including multiple network node layers, equally dividing the multiple face sample images into the multiple network node layers, and calling the multiple network node layers to process the multiple face sample images to obtain image features corresponding to the multiple network node layers. According to the image features and a preset classification matrix, network node indexes corresponding to the multiple network node layers are calculated. According to the network node indexes, node probabilities corresponding to the multiple network node layers are determined. According to the node probabilities, model gradients of the to-be-trained face recognition model are calculated. Model parameters of the to-be-trained face recognition model are adjusted based on the model gradients until the to-be-trained face recognition model converges. The embodiments of the present disclosure decompose the optimization process of the neural network classification model, innovatively use a distributed method to realize data parallelism of the backbone network and model parallelism of the classification matrix, completely classify millions of categories of faces, solve the calculation overhead and memory bottleneck of large-scale classification, can fully utilize large-scale face data collected in business scenarios, and combine the latest classification loss function to significantly improve face recognition accuracy.

[0147] Embodiment three

[0148] Referring to Figure 3 , a structure schematic diagram of a face recognition model training device provided by an embodiment of the present disclosure is shown. As shown in Figure 3 , the face recognition model training device 300 can specifically include the following modules:

[0149] A sample image input module 310 is configured to input multiple face sample images into a to-be-trained face recognition model. The to-be-trained face recognition model includes multiple network node layers.

[0150] An image feature acquisition module 320 is configured to equally divide the multiple face sample images into the multiple network node layers, and call the multiple network node layers to process the multiple face sample images to obtain image features corresponding to the multiple network node layers.

[0151] a node index obtaining module 330, configured to calculate network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix;

[0152] a node probability determining module 340, configured to determine node probabilities corresponding to the plurality of network node layers according to the network node indexes;

[0153] a model gradient calculating module 350, configured to calculate a model gradient of the to-be-trained face recognition model according to the node probabilities;

[0154] a model parameter adjusting module 360, configured to adjust model parameters of the to-be-trained face recognition model based on the model gradient until the to-be-trained face recognition model converges.

[0155] The face recognition model training apparatus provided by the embodiments of the present disclosure can input a plurality of face sample images into a to-be-trained face recognition model, the to-be-trained face recognition model including a plurality of network node layers, divide the plurality of face sample images equally into the plurality of network node layers, and call the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers, calculate network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix, determine node probabilities corresponding to the plurality of network node layers according to the network node indexes, calculate a model gradient of the to-be-trained face recognition model according to the node probabilities, adjust model parameters of the to-be-trained face recognition model based on the model gradient, and until the to-be-trained face recognition model converges. The embodiments of the present disclosure decompose the optimization process of a neural network classification model, innovatively use a distributed method to realize data parallelism of a backbone network and model parallelism of a classification matrix, completely classify a face of ten million categories, solve the calculation overhead and memory bottleneck of large-scale classification, can fully utilize large-scale face data collected in a business scenario, and combine a latest classification loss function to significantly improve face recognition precision.

[0156] Embodiment Four

[0157] Reference Figure 4 Fig. 4 shows a structure schematic diagram of another face recognition model training apparatus provided by the embodiments of the present disclosure, which can specifically include the following modules: Figure 4

[0158] a sample image input module 410, configured to input a plurality of face sample images into a to-be-trained face recognition model; the to-be-trained face recognition model including a plurality of network node layers;

[0159] ​The image feature acquisition module 420 is configured to divide the plurality of face sample images equally into the plurality of network node layers, and call the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers.

[0160] The node index acquisition module 430 is configured to calculate network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix.

[0161] The node probability determination module 440 is configured to determine node probabilities corresponding to the plurality of network node layers according to the network node indexes.

[0162] The model gradient calculation module 450 is configured to calculate a model gradient of the face recognition model to be trained according to the node probabilities.

[0163] The model parameter adjustment module 460 is configured to adjust model parameters of the face recognition model to be trained based on the model gradient, until the face recognition model to be trained converges.

[0164] Optionally, the image feature acquisition module 420 includes:

[0165] The face feature acquisition unit 421 is configured to call the network node layers to acquire face features of sample face images divided into the network node layers for the plurality of network node layers.

[0166] The image feature acquisition unit 422 is configured to perform feature aggregation on the face features, to obtain image features corresponding to the network node layers.

[0167] Optionally, the node index acquisition module 430 includes:

[0168] The classification matrix distribution unit 431 is configured to distribute the preset classification matrix to the plurality of network node layers.

[0169] The node index determination unit 432 is configured to determine network node indexes corresponding to the plurality of network node layers according to products of the image features corresponding to the plurality of network node layers and the preset classification matrix.

[0170] Optionally, the node probability determination module 440 includes:

[0171] The node feature acquisition unit 441 is configured to perform feature reduction on the network node indexes corresponding to the plurality of network node layers, to obtain node features corresponding to the plurality of network node layers.

[0172] The node probability calculation unit 442 is configured to calculate node probabilities of the plurality of network node layers according to the node features.

[0173] Optionally, the model gradient calculation module 450 comprises:

[0174] a classification matrix gradient calculation unit 451, configured to calculate a classification matrix gradient corresponding to the plurality of network node layers according to the node probability and the image features on the plurality of network node layers;

[0175] a feature gradient calculation unit 452, configured to calculate a feature gradient corresponding to the plurality of network node layers according to the node probability;

[0176] a network gradient calculation unit 453, configured to calculate a network gradient corresponding to the to-be-trained face recognition model according to the node probability and the chain rule.

[0177] Optionally, the model parameter adjustment module 460 comprises:

[0178] a matrix parameter adjustment unit 461, configured to adjust a matrix parameter of the preset classification matrix according to the classification matrix gradient;

[0179] a model parameter adjustment unit 462, configured to adjust a parameter of the to-be-trained face recognition model according to the feature gradient and the network gradient.

[0180] The face recognition model training device provided by the embodiments of the present disclosure comprises: inputting a plurality of face sample images into a to-be-trained face recognition model, the to-be-trained face recognition model comprising a plurality of network node layers; dividing the plurality of face sample images equally into the plurality of network node layers; calling the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers; calculating network node exponents corresponding to the plurality of network node layers according to the image features and a preset classification matrix; determining node probabilities corresponding to the plurality of network node layers according to the network node exponents; calculating a model gradient of the to-be-trained face recognition model according to the node probabilities; adjusting a model parameter of the to-be-trained face recognition model based on the model gradient, until the to-be-trained face recognition model converges. The embodiments of the present disclosure decompose the optimization process of the neural network classification model, innovatively use a distributed method to realize data parallelism of the backbone network and model parallelism of the classification matrix, completely classify the face of the ten-thousand-class category, solve the calculation overhead and memory bottleneck of large-scale classification, can fully utilize the large-scale face data collected by the business scene, and combine the latest classification loss function to significantly improve the face recognition accuracy.

[0181] Embodiments of the present disclosure also provide an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the face recognition model training method of the foregoing embodiments when executing the program.

[0182] Embodiments of the present disclosure also provide a readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the face recognition model training method of the foregoing embodiments.

[0183] For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts are referred to the part of the method embodiments.

[0184] The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems can be used with programs in accordance with the teachings herein, or it can prove convenient to construct more specialized apparatus to perform the required method steps. The required structure for a variety of these systems will be apparent from the description above. In addition, the present embodiments are not described with reference to any particular programming language. It will be appreciated that a variety of programming languages can be used to implement the present embodiments as described herein, and any references below to specific languages are provided for disclosure of enablement of the present embodiments.

[0185] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present disclosure can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order not to obscure the understanding of this description.

[0186] Similarly, it is to be understood that the technical features of the embodiments of the present disclosure are sometimes alternately grouped together in a single embodiment, drawing, or description of certain embodiments of the present disclosure for the purpose of brevity in the following detailed description. However, the disclosure should not be construed as reflecting an intention that the embodiments of the present disclosure require more features than are explicitly recited in each claim. Rather, the inventive aspects lie in less than all features of a single disclosed embodiment. Thus, the following claims by association to the following detailed description are expressly incorporated herein by reference and the present embodiments are thus not limited to specific embodiments described herein but only by the claims and their equivalents.

[0187] Those skilled in the art can understand that the modules in the device in the embodiments can be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and furthermore can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, all combinations of all features disclosed in the specification (including the accompanying claims, abstract and drawings), and all processes or units of any methods or apparatuses disclosed thus can be adopted. Unless explicitly stated otherwise, each feature disclosed in the specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0188] Various component embodiments of the embodiments of the present disclosure can be implemented in hardware, or implemented in software modules running on one or more processors, or implemented in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the dynamic picture generation device according to the embodiments of the present disclosure. The embodiments of the present disclosure can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the embodiments of the present disclosure can be stored on a computer readable medium, or can have the form of one or more signals. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0189] It should be noted that the above-described embodiments explain the embodiments of the present disclosure rather than limit the embodiments of the present disclosure, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not constitute a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The embodiments of the present disclosure can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unitary claim drawn to several devices, the terms "means" and "a means" can refer to distinct elements or to one element implemented in several ways. The use of the term "about" accompanying the word "comprising" does not exclude other elements being present not listed after the word "comprising".

[0190] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the system, device and unit described above can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.

[0191] The above merely describes preferred embodiments of the present disclosure, and is not intended to limit the embodiments of the present disclosure. Any modification, equivalent replacement, and improvement made within the spirit and principle of the embodiments of the present disclosure shall be included in the protection scope of the embodiments of the present disclosure.

[0192] The above merely describes specific embodiments of the present disclosure, but the protection scope of the embodiments of the present disclosure is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the embodiments of the present disclosure, which shall be included in the protection scope of the embodiments of the present disclosure. Therefore, the protection scope of the embodiments of the present disclosure shall be subject to the protection scope of the claims.

Claims

1. A method for training a face recognition model, characterized in that, The method comprises the following steps: inputting a plurality of face sample images into a to-be-trained face recognition model; the to-be-trained face recognition model comprises a plurality of network node layers; dividing the plurality of face sample images into the plurality of network node layers in equal amounts, and calling the plurality of network node layers to process the plurality of face sample images, to obtain image features corresponding to the plurality of network node layers; calculating network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix; determining node probabilities corresponding to the plurality of network node layers according to the network node indexes; calculating a model gradient of the to-be-trained face recognition model according to the node probabilities; adjusting model parameters of the to-be-trained face recognition model based on the model gradient until the to-be-trained face recognition model converges.

2. The method of claim 1, wherein, The calling the plurality of network node layers to process the plurality of face sample images, to obtain the image features corresponding to the plurality of network node layers, comprises the following steps: for the plurality of network node layers, calling the network node layer to obtain face features of sample face images divided into the network node layer; performing feature aggregation operation on the face features, to obtain the image features corresponding to the network node layer.

3. The method of claim 1, wherein, The calculating the network node indexes corresponding to the plurality of network node layers according to the image features and the preset classification matrix comprises the following steps: distributing the preset classification matrix to the plurality of network node layers; determining the network node indexes corresponding to the plurality of network node layers according to a product of the image features corresponding to the plurality of network node layers and the preset classification matrix.

4. The method of claim 1, wherein, The determining the node probabilities corresponding to the plurality of network node layers according to the network node indexes comprises the following steps: performing feature reduction operation on the network node indexes corresponding to the plurality of network node layers, to obtain node features corresponding to the plurality of network node layers; calculating the node probabilities of the plurality of network node layers according to the node features.

5. The method of claim 1, wherein, The calculating the model gradient of the to-be-trained face recognition model according to the node probabilities comprises the following steps: calculating classification matrix gradients corresponding to the plurality of network node layers according to the node probabilities and the image features on the plurality of network node layers; calculating feature gradients corresponding to the plurality of network node layers according to the node probabilities; calculating a network gradient corresponding to the to-be-trained face recognition model according to the node probabilities and the chain rule.

6. The method of claim 5, wherein, The adjusting the model parameters of the to-be-trained face recognition model based on the model gradient comprises the following steps: adjusting matrix parameters of the preset classification matrix according to the classification matrix gradients; adjusting the parameters of the to-be-trained face recognition model according to the feature gradients and the network gradient. 7.A face recognition model training apparatus, characterized in that, The method comprises the following steps: a sample image input module is configured to input a plurality of face sample images into a to-be-trained face recognition model; the to-be-trained face recognition model comprises a plurality of network node layers; The image feature acquisition module is configured to divide the plurality of face sample images equally into the plurality of network node layers, and call the plurality of network node layers to process the plurality of face sample images to obtain image features corresponding to the plurality of network node layers. The node index acquisition module is configured to calculate network node indexes corresponding to the plurality of network node layers according to the image features and a preset classification matrix. The node probability determination module is configured to determine node probabilities corresponding to the plurality of network node layers according to the network node indexes. The model gradient calculation module is configured to calculate model gradients of the face recognition model to be trained according to the node probabilities. The model parameter adjustment module is configured to adjust model parameters of the face recognition model to be trained based on the model gradients until the face recognition model to be trained converges.

8. The apparatus of claim 7, wherein, The image feature acquisition module includes: The face feature acquisition unit is configured to call the network node layer to acquire face features of a sample face image divided into the network node layer for the plurality of network node layers. The image feature acquisition unit is configured to perform a feature aggregation operation on the face features to obtain image features corresponding to the network node layer.

9. An electronic device, comprising: The processor, the memory, and the computer program stored on the memory and executable on the processor, wherein the processor implements the face recognition model training method in any one of claims 1 to 6 when executing the program. When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the face recognition model training method in any one of claims 1 to 6.

10. A readable storage medium, characterized by, ​

Citation Information

Patent Citations

  • Face parallel identification method based on deep learning and Spark

    CN108229258A

  • Expression recognition method and device and electronic device

    CN109934173A