Neural network model training method for pedestrian attribute recognition and terminal device

By dynamically updating the gradient norm and weights, the convergence speed of the pedestrian attribute recognition model during training is balanced, solving the problem of inconsistent convergence in traditional methods and improving the model's recognition performance.

CN114612935BActive Publication Date: 2025-11-04WATRIX TECH CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210249718.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-14
Publication Date
2025-11-04
Estimated Expiration
2042-03-14

AI Technical Summary

Technical Problem

In the training of traditional pedestrian attribute recognition models, the different backpropagation gradients of different attributes lead to inconsistent convergence speeds for different tasks, and the differences in the number of samples in the training data affect the effectiveness of the weighting method.

Method used

By obtaining the weighted loss, gradient norm, and relative backpropagation speed of training tasks with different attributes, the gradient norm and weights are dynamically updated. The GradNorm method is used to balance the convergence speed of the training task, and the weights are weighted according to the proportion of the number of samples.

Benefits of technology

It improves the accuracy of loss weight updates, achieves a more balanced convergence speed for different attributes, and enhances the overall recognition performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114612935B_ABST
    Figure CN114612935B_ABST
Patent Text Reader

Abstract

The application discloses a neural network model training method and terminal equipment for pedestrian attribute recognition, belongs to the technical field of pedestrian recognition, and can solve the problem of poor effectiveness of a weighting method in existing multi-task model training. The method comprises the following steps: obtaining a forward propagation total loss of a neural network model according to a weighted loss of different attribute training tasks; weighting the gradient norm corresponding to the different attribute training tasks according to the sample number proportion of the different attribute training tasks to update the gradient norm; obtaining the relative back propagation speed of the different attribute training tasks, and obtaining a gradient norm difference total loss according to the updated gradient norm and the relative back propagation speed; updating the neural network model parameters by using the forward propagation total loss, and updating the weight of each training task by using the gradient norm difference total loss; performing normalization processing on the weight of the training task; and repeating the above steps until the training times reach a preset number of times. The application is used for training of a pedestrian attribute recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a neural network model training method and terminal equipment for pedestrian attribute recognition, and belongs to the technical field of pedestrian recognition. BACKGROUND

[0002] The training of a pedestrian attribute recognition model is a multi-task training process. Due to the different sizes of the loss back propagation gradient of different attributes in the training process, the traditional training method will lead to different convergence speeds of different tasks.

[0003] An effective method is to weight the loss of different attributes, but due to the difference in the number of attribute labels of different samples in the training data, the number of samples of different tasks in the same batch is different, thereby affecting the effectiveness of the existing weighting method. SUMMARY

[0004] The present application provides a neural network model training method and terminal equipment for pedestrian attribute recognition, which can solve the problem of poor effectiveness of the weighting method in the training of the existing multi-task model.

[0005] In one aspect, the present application provides a neural network model training method for pedestrian attribute recognition, which comprises:

[0006] S1. Obtaining the forward propagation total loss of the neural network model according to the weighted loss of different attribute training tasks in the same batch;

[0007] S2. Obtaining the gradient norm of the weighted loss of different attribute training tasks on the neural network model parameters, and weighting the gradient norm corresponding to the sample number proportion of different attribute training tasks to update the gradient norm;

[0008] S3. Obtaining the relative back propagation speed of different attribute training tasks, and obtaining the gradient norm difference total loss according to the updated gradient norm and the relative back propagation speed;

[0009] S4. Updating the neural network model parameters using the forward propagation total loss, and updating the weight of each training task using the gradient norm difference total loss;

[0010] S5. Normalizing the weight of the training task, and adding 1 to the training times;

[0011] S6. Repeating steps S1 to S5 until the training times reach a preset number.

[0012] Optionally, the S5 specifically comprises:

[0013] S51, weight the weight values of the training tasks corresponding to the training tasks of different attributes according to the proportion of the number of samples of the training tasks, to update the weight values of the training tasks;

[0014] S52, normalize the updated weight values of the training tasks.

[0015] Optionally, the S1 is specifically:

[0016] obtaining the forward propagation total loss of the neural network model according to a first formula;

[0017] The first formula is: Loss = å i ω i L i ;

[0018] Wherein, Loss is the forward propagation total loss of the neural network model; ω i is the weight value of the i-th training task, and the ω i of each training task is initialized to 1; L i is the loss value of the i-th training task.

[0019] Optionally, in the S2, the gradient norm of the weighted loss of the training task of different attributes to the neural network model parameter is obtained, specifically:

[0020] obtaining the gradient norm of the weighted loss of the training task of different attributes to the neural network model parameter according to a second formula;

[0021] The second formula is:

[0022] Wherein, is the gradient norm of the weighted loss of the i-th training task to the neural network model parameter; ω i (t)L i (t) is the weighted loss of the i-th training task; W is the neural network model parameter.

[0023] Optionally, in the S2, the gradient norm is weighted according to the proportion of the number of samples of the training task of different attributes corresponding to the gradient norm, to update the gradient norm, specifically:

[0024] obtaining the ratio of the number of samples of each training task to the total number of samples of the same batch of input images;

[0025] obtaining the product of the ratio and the gradient norm corresponding to the ratio, and taking the product as the updated gradient norm.

[0026] Optionally, in the S3, the relative back propagation speed of the training task of different attributes is obtained, specifically:

[0027] obtaining the relative back propagation speed of different attribute training tasks according to a third formula;

[0028] The third formula is:

[0029] wherein, L i L (0) is the loss value of the i-th training task in the initial training; L i L (t) is the loss value of the i-th training task in the t-th training; E task is the mean value symbol; r i L (t) is the relative back propagation speed of the i-th training task in the t-th training.

[0030] Optionally, in the S3, the gradient norm difference total loss is obtained according to the updated gradient norm and the relative back propagation speed, specifically:

[0031] obtaining the gradient norm difference total loss according to a fourth formula;

[0032] The fourth formula is:

[0033] wherein, L (t) is the gradient norm of the weighted loss of the i-th training task in the t-th training to the neural network model parameter; and α is a hyperparameter.

[0034] Optionally, the S51 specifically includes:

[0035] obtaining the ratio of the sample number of each training task to the total sample number of the same batch of input images;

[0036] obtaining the product of the ratio and the weight value of the corresponding training task, and taking the product as the updated weight value of the training task.

[0037] On the other hand, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of any of the above methods when executing the computer program.

[0038] The beneficial effects that can be produced by the present application include:

[0039] The application provides a neural network model training method for pedestrian attribute recognition. BRIEF DESCRIPTION OF DRAWINGS

[0040] Figure 1 The neural network model training method flowchart is provided for the embodiments of the application. DETAILED DESCRIPTION

[0041] The application will be described in detail below with reference to the embodiments, but the application is not limited to the embodiments.

[0042] The embodiments of the application provide a neural network model training method for pedestrian attribute recognition. Figure 1 As shown in the figure, the method comprises the following steps.

[0043] S1, obtaining a forward propagation total loss of a neural network model according to weighted losses of different attribute training tasks in a same batch.

[0044] Specifically, the forward propagation total loss of the neural network model is obtained according to a first formula.

[0045] The first formula is: Loss = ∑ i ω i L i ;

[0046] Wherein, Loss is the forward propagation total loss of the neural network model; ω i is a weight value of an i-th training task, and the ω i of each training task is initialized as 1; L i is a loss value of the i-th training task.

[0047] S2, obtaining a gradient norm of the weighted loss of the different attribute training tasks on the neural network model parameters, and weighting the gradient norm corresponding to the different attribute training tasks according to a sample number ratio of the different attribute training tasks to update the gradient norm.

[0048] Specifically, first, the gradient norm of the weighted loss of the different attribute training tasks on the neural network model parameters is obtained according to a second formula.

[0049] The second formula is:

[0050] Wherein, The gradient norm of the weighted loss of the i-th training task to the neural network model parameter; ω i (t) is the weighted loss of the i-th training task; W is the neural network model parameter. i (t) is the weighted loss of the i-th training task; W is the neural network model parameter.

[0051] Then, the ratio of the number of samples of each training task to the total number of samples of the same batch of input images is obtained; and the product of the ratio and its corresponding gradient norm is obtained as the updated gradient norm.

[0052] S3, obtain the relative back propagation speed of different attribute training tasks, and obtain the gradient norm difference total loss according to the updated gradient norm and the relative back propagation speed.

[0053] Specifically: first, the relative back propagation speed of different attribute training tasks is obtained according to the third formula;

[0054] The third formula is:

[0055] Wherein, L i (0) is the loss value of the i-th training task at the initial training; L i (t) is the loss value of the i-th training task at the t-th training; E task is the mean value symbol; r i (t) is the relative back propagation speed of the i-th training task at the t-th training.

[0056] Then, the gradient norm difference total loss is obtained according to the fourth formula;

[0057] The fourth formula is:

[0058] Wherein, The gradient norm of the weighted loss of the i-th training task to the neural network model parameter at the t-th training; α is a hyperparameter.

[0059] S4, update the neural network model parameter by using the forward propagation total loss, and update the weight of each training task by using the gradient norm difference total loss.

[0060] S5, normalize the weight of the training task, and add 1 to the training number.

[0061] Specifically, it includes:

[0062] S51, the weight of the training task corresponding to the sample number ratio of different attribute training tasks is weighted to update the weight of each training task.

[0063] Specifically, a ratio of the number of samples of each training task to the total number of samples of the same batch of input images can be obtained, and a product of the ratio and a weight value of the corresponding training task can be obtained, and the product can be taken as the updated weight value of the training task.

[0064] S52, normalizing the updated weight value of the training task.

[0065] S6, repeating steps S1 to S5 until the number of training reaches a preset number.

[0066] The preset number is a preset number of training, which can be set by those skilled in the art according to actual conditions, and the embodiments of the present application do not limit it. When training for the first time, the number of training t is initialized to 0, and the number of training is increased by 1 each time the training is performed; until the number of training reaches the preset number, the training is completed.

[0067] The present application adopts the GradNorm method to weight the loss of different training tasks, dynamically updates the weights of different training tasks through the gradients of the loss of different training tasks, balances the convergence speed of different training tasks, and adds a sample proportion factor when renormalizing the weight value, thereby improving the accuracy of the loss weight update and the effectiveness of the GradNorm weighting method.

[0068] Another embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of the above embodiments when executing the computer program.

[0069] The above is only a few embodiments of the present application, and does not limit the present application in any form. Although the above describes the preferred embodiments of the present application, it does not limit the present application. Any person skilled in the art can make some changes or modifications to the above disclosed technical contents without departing from the scope of the technical solution of the present application, and the equivalent embodiments are equivalent to the equivalent embodiments, which are all within the scope of the technical solution.

Claims

1. A method for training a neural network model for pedestrian attribute recognition, characterized in that, The method includes: S1. Obtain the total forward propagation loss of the neural network model based on the weighted loss of training tasks with different attributes in the same batch; S2. Obtain the gradient norm of the weighted loss of different attribute training tasks with respect to the parameters of the neural network model. At the same time, obtain the ratio of the number of samples of each training task to the total number of samples of the same batch of input images, and obtain the product of the ratio and its corresponding gradient norm, and use the product as the updated gradient norm. S3. Obtain the relative backpropagation speed of training tasks with different attributes, and obtain the total loss of gradient norm difference based on the updated gradient norm and the relative backpropagation speed. S4. Update the neural network model parameters using the forward propagation total loss, and update the weights of each training task using the gradient norm difference total loss; S5. Obtain the ratio of the number of samples for each training task to the total number of samples for the same batch of input images, obtain the product of the ratio and the weight of the corresponding training task, use the product as the updated weight of the training task, normalize the updated weight of the training task, and increment the training count by 1. S6. Repeat steps S1 to S5 until the number of training iterations reaches the preset number.

2. The method according to claim 1, characterized in that, Specifically, S1 is: The total forward propagation loss of the neural network model is obtained according to the first formula; The first formula is: ; in, This represents the total forward propagation loss of the neural network model. For the first The weights for each training task, and the weights for each training task. Initialize all values ​​to 1; For the first The loss value for each training task.

3. The method according to claim 1, characterized in that, In step S2, obtaining the gradient norm of the weighted loss for different attribute training tasks with respect to the neural network model parameters specifically involves: The gradient norm of the weighted loss with respect to the neural network model parameters for different attribute training tasks is obtained according to the second formula. The second formula is: ; in, For the first The gradient norm of the weighted loss for each training task with respect to the parameters of the neural network model; For the first Weighted loss for each training task; These are the parameters of the neural network model.

4. The method according to claim 3, characterized in that, In S3, obtaining the relative backpropagation speed of training tasks with different attributes specifically involves: The relative backpropagation speed for training tasks with different attributes is obtained based on the third formula; The third formula is: ; in, ; For the first training session The loss value for each training task; For the first During the training session The loss value for each training task; To determine the sign of the mean; For the first During the training session The relative backpropagation speed of each training task.

5. The method according to claim 4, characterized in that, In S3, obtaining the total loss of gradient norm difference based on the updated gradient norm and the relative backpropagation speed specifically involves: The total loss due to gradient norm difference is obtained using the fourth formula; The fourth formula is: ; in, ; For the first The updated version during the training session The gradient norm of the weighted loss for each training task with respect to the parameters of the neural network model; It's a hyperparameter.

6. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Multi-task model training method and device and electronic equipment

    CN112561077A