An image detection model training method, apparatus, electronic device, and storage medium

By employing a hybrid gradient descent optimization algorithm in image detection model training, combining ADAM and SGDM algorithms, and switching the model and learning rate according to the number of iterations, the inefficiency of gradient descent optimization algorithm in image detection model training is solved, achieving faster convergence and higher accuracy.

CN117115551BActive Publication Date: 2025-12-02HANGZHOU EZVIZ SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311155994.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-07
Publication Date
2025-12-02
Estimated Expiration
2043-09-07

AI Technical Summary

Technical Problem

Existing gradient descent optimization algorithms in image detection model training suffer from problems such as the ADAM algorithm's fast convergence but difficulty in finding the global optimum, and the SGDM algorithm's slow gradient descent speed, resulting in low training efficiency.

Method used

The gradient descent optimization algorithm employs a hybrid strategy. In the early stages of training, the ADAM algorithm is used to achieve rapid convergence, while in the later stages, the algorithm is switched to SGDM to find the optimal solution. By switching different parameter optimization models and learning rate calculation functions according to the number of iterations, a gradual transition from ADAM to SGDM is achieved.

Benefits of technology

It improves the training efficiency of image detection models, enhances the convergence speed and accuracy of models, reduces the waste of computing resources, and avoids overfitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117115551B_ABST
    Figure CN117115551B_ABST
Patent Text Reader

Abstract

This application provides an image detection model training method, apparatus, electronic device, and storage medium. The method determines the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model, and calculates the current learning rate and current weight parameters accordingly. The calculated information is then used to adjust the image detection model. Subsequently, sample images with annotation information are acquired and input into the image detection model to obtain image detection results. Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined. When the loss converges, the trained image detection model is obtained. By determining a suitable current parameter optimization model and the current learning rate calculation function based on the current iteration number, the parameters of the image detection model can be further adjusted, thereby improving the training efficiency of the image detection model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an image detection model training method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the training process of machine learning algorithm models, optimization algorithms are used to optimize the loss function to obtain a well-trained model. Gradient descent optimization is the most commonly used optimization algorithm for solving machine learning algorithm model parameters. Commonly used gradient descent optimization algorithms include ADAM (Adaptive Moment Estimation) and SGDM (Stochastic Gradient Descent with Momentum). ADAM converges quickly but may not find the global optimum. SGDM can find the optimum, but its gradient descent speed is slower. Therefore, ADAM should be used in the early stages of training to take advantage of its fast convergence, while SGDM should be used in the later stages to find the optimum. That is, during training, ADAM and SGDM are switched to optimize the loss function. Therefore, choosing the right parameter optimization model is crucial for improving the training efficiency of image detection models. Summary of the Invention

[0003] The purpose of this application is to provide an image detection model training method, apparatus, electronic device, and storage medium to improve the training efficiency of image detection models. The specific technical solution is as follows:

[0004] In a first aspect, embodiments of this application provide an image detection model training method, the method comprising:

[0005] Based on the current iteration number of the image detection model, determine the current parameter optimization model and the current learning rate calculation function;

[0006] Based on the current parameter optimization model and the current learning rate calculation function, calculate the current learning rate and current weight parameters;

[0007] Adjust the parameters of the image detection model according to the current learning rate and current weight parameters;

[0008] A sample image is acquired and input into an image detection model to obtain an image detection result; wherein the sample image has corresponding annotation information.

[0009] Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined;

[0010] When the loss of the image detection model converges, the trained image detection model is obtained.

[0011] In one possible embodiment, determining the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model includes:

[0012] Obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein, the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval;

[0013] If the current iteration count is less than the number of iterations to enter the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the first learning rate calculation function.

[0014] If the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the second learning rate calculation function.

[0015] If the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is determined to be a stochastic gradient descent optimization model, and the current learning rate calculation function is determined to be the third learning rate calculation function.

[0016] Among them, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function.

[0017] The accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both smaller than the accuracy improvement of the image detection model under the second learning rate calculation function.

[0018] In one possible embodiment, if the current iteration number is less than the number of iterations to enter the transition interval, the current parameter optimization model is an adaptive moment estimation ADAM optimization model;

[0019] The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes:

[0020] Calculate the current learning rate based on the learning rate corresponding to the current iteration number and the previous iteration number;

[0021] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0022] Obtain the exponential decay rate estimated by the first moment and the exponential decay rate estimated by the second moment;

[0023] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0024] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0025] The current first moment deviation correction is calculated based on the current iteration number, the current first moment estimate, and the exponential decay rate of the first moment estimate;

[0026] The current second moment bias correction is calculated based on the current iteration number, the current second moment estimate, and the exponential decay rate of the second moment estimate;

[0027] Calculate the current weight parameters based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction.

[0028] In one possible embodiment, calculating the current learning rate based on the learning rates corresponding to the current iteration number and the previous iteration number includes:

[0029] The current learning rate is calculated using the following formula, based on the learning rates corresponding to the current iteration number and the previous iteration number:

[0030]

[0031] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations in the previous iteration, and t is the current iteration number.

[0032] Accordingly, calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes:

[0033] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0034]

[0035] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0036] Accordingly, the step of calculating the current first-order moment estimate based on the current gradient, the first-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-order moment estimate includes:

[0037] Based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0038] m t =β1m t-1 +(1-β1)g t

[0039] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0040] Accordingly, the step of calculating the current second-order moment estimate based on the current gradient, the second-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-order moment estimate includes:

[0041] Based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate, the current second moment estimate is calculated using the following formula:

[0042]

[0043] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0044] Accordingly, the step of calculating the current first-order moment deviation correction based on the current iteration number, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate includes:

[0045] Based on the current iteration number, the current first-moment estimate, and the exponential decay rate of the first-moment estimate, calculate the current first-moment bias correction using the following formula:

[0046]

[0047] in, For the current first-order moment deviation correction, m t For the current first moment estimate, t is the power of the exponential decay rate estimated by the first moment, where t is the current iteration number;

[0048] Accordingly, the step of calculating the current second-moment deviation correction based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate includes:

[0049] Based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate, the current second-moment bias correction is calculated using the following formula:

[0050]

[0051] in, For the current second-order moment deviation correction, v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0052] Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction includes:

[0053] Based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction, the current weight parameters are calculated using the following formula:

[0054]

[0055] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t The current learning rate, Let t be the exponential decay rate estimated by the second moment. It is the t-th power of the exponential decay rate estimated by the first moment. For the current first-order moment deviation correction, This is the correction for the current second-order moment deviation, where ∈ is a constant and t is the current iteration number.

[0056] In one possible embodiment, if the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is the ADAM optimization model.

[0057] The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes:

[0058] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0059] Obtain the confidence interval radius, the exponential decay rate estimated by the first moment, and the exponential decay rate estimated by the second moment;

[0060] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0061] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0062] Calculate the current confidence interval based on the current first moment estimate, confidence interval radius, current second moment estimate, exponential decay rate of the second moment estimate, and current iteration number;

[0063] The current learning rate is calculated based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate.

[0064] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval.

[0065] In one possible embodiment, calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes:

[0066] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0067]

[0068] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0069] Accordingly, the step of calculating the current first-order moment estimate based on the current gradient, the first-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-order moment estimate includes:

[0070] Based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0071] m t =β1m t-1 +(1-β1)g t

[0072] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, gt This is the current gradient;

[0073] Accordingly, the step of calculating the current second-order moment estimate based on the current gradient, the second-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-order moment estimate includes:

[0074] Based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate, the current second moment estimate is calculated using the following formula:

[0075]

[0076] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0077] Accordingly, the step of calculating the current confidence interval based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number includes:

[0078] Based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number, the current confidence interval is calculated using the following formula:

[0079]

[0080] Among them, z t For the confidence interval corresponding to the current iteration number, sign(m) t ) is a symbolic function. For the minimum value function, m t This is the current first-order moment estimate, where δ is the radius of the confidence interval, and v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0081] Accordingly, the step of calculating the current learning rate based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate includes:

[0082] Based on the learning rate, confidence interval radius, and current first-order moment estimate corresponding to the previous iteration number, the current learning rate is calculated using the following formula:

[0083] α t =α t-1 δ / (δ+||m t ||+∈)

[0084] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations from the previous iteration, δ is the radius of the confidence interval, and m is the number of iterations from the previous iteration. t This is the estimate of the current first moment, where ∈ is a constant;

[0085] Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first-order moment estimate, the current second-order moment estimate, and the current confidence interval includes:

[0086] Based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first-order moment estimate, the current second-order moment estimate, and the current confidence interval, the current weight parameters are calculated using the following formula:

[0087]

[0088] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t m is the current learning rate. t For the current first-order moment estimate, z t v represents the current confidence interval. t This is the current second-order moment estimate, where ∈ is a constant.

[0089] In one possible embodiment, if the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is a momentum stochastic gradient descent (SGDM) optimization model.

[0090] The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes:

[0091] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0092] Get the current momentum parameters;

[0093] Calculate the current learning rate based on the current momentum parameter and the current gradient;

[0094] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration, the current learning rate, and the current momentum parameters.

[0095] In one possible embodiment, calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes:

[0096] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0097]

[0098] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0099] Accordingly, calculating the current learning rate based on the current momentum parameter and the current gradient includes:

[0100] The current learning rate is calculated using the following formula, based on the momentum parameter and the current gradient:

[0101] α t =g t / (1-β)

[0102] Where, α t β is the current learning rate, β is the current momentum parameter, and gt is the current gradient;

[0103] Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, and the current momentum parameters includes:

[0104] Based on the weight parameters corresponding to the previous iteration, the current learning rate, and the momentum parameter, calculate the current weight parameters using the following formula:

[0105] w t =w t-1 -(1-β)α t

[0106] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t β is the current learning rate, and β is the current momentum parameter.

[0107] Secondly, embodiments of this application provide an image detection model training apparatus, the apparatus comprising:

[0108] The first determining module is used to determine the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model.

[0109] The calculation module is used to optimize the model and the current learning rate calculation function based on the current parameters, and to calculate the current learning rate and current weight parameters.

[0110] The adjustment module is used to adjust the parameters of the image detection model according to the current learning rate and current weight parameters;

[0111] The acquisition module is used to acquire sample images, input the sample images into the image detection model, and obtain image detection results; wherein, the sample images correspond to annotation information;

[0112] The second determining module is used to determine the loss of the image detection model based on the annotation information of the sample image and the image detection result;

[0113] The training module is used to obtain the trained image detection model when the loss of the image detection model converges.

[0114] In one possible embodiment, the first determining module is configured to:

[0115] Obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein, the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval;

[0116] If the current iteration count is less than the number of iterations to enter the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the first learning rate calculation function.

[0117] If the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the second learning rate calculation function.

[0118] If the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is determined to be a stochastic gradient descent optimization model, and the current learning rate calculation function is determined to be the third learning rate calculation function.

[0119] Among them, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function.

[0120] The accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both smaller than the accuracy improvement of the image detection model under the second learning rate calculation function.

[0121] In one possible embodiment, when the current iteration number is less than the number of iterations to enter the transition interval, the current parameter optimization model is an adaptive moment estimation (ADAM) optimization model; the calculation module is used for:

[0122] Calculate the current learning rate based on the learning rate corresponding to the current iteration number and the previous iteration number;

[0123] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0124] Obtain the exponential decay rate estimated by the first moment and the exponential decay rate estimated by the second moment;

[0125] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0126] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0127] The current first moment deviation correction is calculated based on the current iteration number, the current first moment estimate, and the exponential decay rate of the first moment estimate;

[0128] The current second moment bias correction is calculated based on the current iteration number, the current second moment estimate, and the exponential decay rate of the second moment estimate;

[0129] Calculate the current weight parameters based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction.

[0130] In one possible embodiment, the computing module is configured to:

[0131] The current learning rate is calculated using the following formula, based on the learning rates corresponding to the current iteration number and the previous iteration number:

[0132]

[0133] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations in the previous iteration, and t is the current iteration number.

[0134] Accordingly, based on the objective function and the weight parameters corresponding to the previous iteration number, the current gradient is calculated using the following formula:

[0135]

[0136] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0137] Accordingly, based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0138] m t =β1m t-1 +(1-β1)g t

[0139] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0140] Accordingly, based on the current gradient, the second-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-moment estimate, the current second-moment estimate is calculated using the following formula:

[0141]

[0142] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0143] Accordingly, based on the current iteration number, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate, the current first-order moment deviation correction is calculated using the following formula:

[0144]

[0145] in, For the current first-order moment deviation correction, m t For the current first moment estimate, t is the power of the exponential decay rate estimated by the first moment, where t is the current iteration number;

[0146] Accordingly, based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate, the current second-moment bias correction is calculated using the following formula:

[0147]

[0148] in, For the current second-order moment deviation correction, v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0149] Accordingly, based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction, the current weight parameters are calculated using the following formula:

[0150]

[0151] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t The current learning rate, Let t be the exponential decay rate estimated by the second moment. It is the t-th power of the exponential decay rate estimated by the first moment. For the current first-order moment deviation correction, This is the correction for the current second-order moment deviation, where ∈ is a constant and t is the current iteration number.

[0152] In one possible embodiment, if the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is the ADAM optimization model.

[0153] The computing module is used for:

[0154] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0155] Obtain the confidence interval radius, the exponential decay rate estimated by the first moment, and the exponential decay rate estimated by the second moment;

[0156] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0157] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0158] Calculate the current confidence interval based on the current first moment estimate, confidence interval radius, current second moment estimate, exponential decay rate of the second moment estimate, and current iteration number;

[0159] The current learning rate is calculated based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate.

[0160] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval.

[0161] In one possible embodiment, the computing module is used for

[0162] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0163]

[0164] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0165] Accordingly, based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0166] m t =β1m t-1 +(1-β1)g t

[0167] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0168] Accordingly, based on the current gradient, the second-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-moment estimate, the current second-moment estimate is calculated using the following formula:

[0169]

[0170] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0171] Accordingly, based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number, the current confidence interval is calculated using the following formula:

[0172]

[0173] Among them, z t For the confidence interval corresponding to the current iteration number, sign(m) t ) is a symbolic function. For the minimum value function, m t This is the current first-order moment estimate, where δ is the radius of the confidence interval, and v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0174] Accordingly, based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate, the current learning rate is calculated using the following formula:

[0175] α t =α t-1 δ / (δ+||m t ||+∈)

[0176] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations from the previous iteration, δ is the radius of the confidence interval, and m is the number of iterations from the previous iteration. t This is the estimate of the current first moment, where ∈ is a constant;

[0177] Accordingly, based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval, the current weight parameters are calculated using the following formula:

[0178]

[0179] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t m is the current learning rate. t For the current first-order moment estimate, z t v represents the current confidence interval. t This is the current second-order moment estimate, where ∈ is a constant.

[0180] In one possible embodiment, if the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is a momentum stochastic gradient descent (SGDM) optimization model.

[0181] The computing module is used for:

[0182] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0183] Get the current momentum parameters;

[0184] Calculate the current learning rate based on the current momentum parameter and the current gradient;

[0185] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration, the current learning rate, and the current momentum parameters.

[0186] In one possible embodiment, the computing module is configured to:

[0187] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0188]

[0189] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0190] Accordingly, based on the momentum parameter and the current gradient, the current learning rate is calculated using the following formula:

[0191] α t =g t / (1-β)

[0192] Where, α t β is the current learning rate, β is the current momentum parameter, and g is the current learning rate. t This is the current gradient;

[0193] Accordingly, based on the weight parameters corresponding to the previous iteration, the current learning rate, and the momentum parameter, the current weight parameters are calculated using the following formula:

[0194] w t =w t-1 -(1-β)α t

[0195] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t β is the current learning rate, and β is the current momentum parameter.

[0196] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory;

[0197] The memory is used to store computer programs;

[0198] When the processor executes the program stored in the memory, it implements the image detection model training method described in this application.

[0199] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the image detection model training method described in this application.

[0200] Beneficial effects of the embodiments in this application:

[0201] The image detection model training method, apparatus, electronic device, and storage medium provided in this application determine the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model, and calculate the current learning rate and current weight parameters accordingly. The calculated information is then used to adjust the image detection model. Subsequently, sample images with annotation information are acquired and input into the image detection model to obtain image detection results. Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined. When the loss converges, the trained image detection model is obtained. A suitable current parameter optimization model and current learning rate calculation function are determined based on the current iteration number, thereby further adjusting the parameters of the image detection model. This improves the training efficiency of the image detection model. Of course, implementing any product or method of this application does not necessarily require achieving all the advantages described above simultaneously. Attached Figure Description

[0202] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0203] Figure 1 This is a first schematic diagram of an image detection model training method according to an embodiment of this application;

[0204] Figure 2 This is a second schematic diagram of the image detection model training method according to an embodiment of this application;

[0205] Figure 3 This is a schematic diagram comparing the training effects of using the ADAM model, using the SGDM model, and using both the ADAM model and the SGDM model to train the model, as described in this application embodiment.

[0206] Figure 4 This is a third schematic diagram of the image detection model training method according to an embodiment of this application;

[0207] Figure 5 This is a schematic diagram of an image detection model training device according to an embodiment of this application;

[0208] Figure 6 This is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0209] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0210] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0211] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0212] First, the technical terms used in this application will be explained.

[0213] Early stopping: A regularization method that avoids overfitting. It involves dividing the sample data into training and test sets. After each or more current training epochs, the test results are obtained on the test set, and the best test accuracy so far is recorded. As the number of epochs increases, if the test error on the test set rises, training is stopped, and the weight parameters with the highest accuracy on the test set are used as the final parameters of the model.

[0214] In related technologies, a conversion threshold parameter is set based on experience and used as a switching condition. Scaling rules are then used to determine the learning rate and gradient of the optimized algorithm after the switch. However, relying on experience to set the conversion threshold parameter cannot adapt to the dataset and deep network models, potentially leading to model convergence failure. Furthermore, improper settings may result in overfitting, affecting the model's generalization ability and leading to poor training performance. Additionally, using scaling rules to determine the learning rate and gradient of the optimized algorithm after the switch can result in insufficient model accuracy, increase the time and computational cost required for model training, and reduce the model's convergence speed.

[0215] To improve the training efficiency of image detection models, this application provides an image detection model training method, see [link to relevant documentation]. Figure 1 The method includes:

[0216] S101, determine the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model.

[0217] The essence of machine learning algorithms is to build and optimize models. These algorithms optimize the objective function to train the best model. The optimization algorithm directly affects the model's performance. Commonly used gradient descent optimization algorithms include adaptive learning rate adjustment (ADAM) and stochastic gradient descent (SGDM). ADAM converges quickly but may not find the global optimum. SGDM finds the optimum, but its gradient descent speed is slower. Therefore, ADAM can be used in the early stages of training to leverage its fast convergence, while SGDM can be used in the later stages to find the optimal solution. In other words, during image detection training, ADAM and SGDM can be switched to optimize the objective function (loss function).

[0218] This application provides a gradient descent optimization algorithm based on a hybrid strategy, which achieves a gradual and smooth transition from the ADAM optimization algorithm to the SGDM optimization algorithm. This allows the image detection model to have the same training speed as the ADAM optimization model in the initial stage and maintain the same stable learning rate as the SGDM optimization model in the later stage, thereby improving the speed of parameter calculation and the robustness of the image detection model.

[0219] In one possible embodiment, such as Figure 2 As shown, step S101 above may specifically include the following steps:

[0220] S1011, obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein, the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval;

[0221] S1012, if the current iteration number is less than the number of iterations to enter the transition interval, determine the current parameter optimization model as the adaptive learning rate adjustment optimization model, and the current learning rate calculation function as the first learning rate calculation function;

[0222] S1013, if the current iteration number is not less than the number of iterations to enter the transition interval and less than the number of iterations to end the transition interval, determine the current parameter optimization model as the adaptive learning rate adjustment optimization model and the current learning rate calculation function as the second learning rate calculation function;

[0223] S1014, if the current iteration number is not less than the number of transition iterations to end, determine the current parameter optimization model as the stochastic gradient descent optimization model, and the current learning rate calculation function as the third learning rate calculation function;

[0224] Specifically, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function; the accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both less than the accuracy improvement of the image detection model under the second learning rate calculation function.

[0225] In one possible implementation, early stopping can be used to set the number of iterations before entering the transition interval. For example, the number of iterations before entering the transition interval can be set to the number of iterations when the value of the loss function no longer decreases. By setting the number of iterations before entering the transition interval to the number of iterations for early stopping, the image detection model can converge faster during training and avoid overfitting. Furthermore, using early stopping can reduce the waste of computational resources and improve training efficiency.

[0226] In one possible implementation, the transition interval length can be set based on experience. For example, if the transition interval length is set to 10, then the number of transition iterations to end is the number of iterations to enter the transition interval + 10.

[0227] For example, when the adaptive parameter optimization model is the ADAM optimization model and the stochastic gradient descent optimization model is the SGDM optimization model, the current parameter optimization model can be determined using formulas (1), (2), and (3):

[0228]

[0229] Where f(t) represents the current parameter optimization model weights, and t adam The number of iterations to enter the transition interval, where t is the current iteration number. switch This is to end the transition iteration count.

[0230] α t =f(t)α sgdm +(1-f(t))α adam (2)

[0231] Where, α t Let α be the current learning rate. sgdm α represents the current learning rate when using the SGDM optimization model to optimize the objective function. adam This represents the current learning rate when using the ADAM optimization model to optimize the objective function.

[0232] β t =f(t)β sgdm +(1-f(t))β adam (3)

[0233] Where, β t Let β be the current momentum parameter. sgdm β represents the current momentum parameter when using the SGDM optimization model to optimize the objective function. adam This refers to the current momentum parameter when using the ADAM optimization model to optimize the objective function.

[0234] Specifically, according to formulas (1), (2), and (3), when t < t adam and t adam ≤t<t switch When f(t) = 0, α t =α adam ,β t =β adam This means that in both of the above cases, the current parameter optimization model is determined to be the ADAM optimization model, and the current learning rate α is... t and current momentum parameter β t These represent the current learning rate and current momentum parameters when using the ADAM optimization model to optimize the objective function. (In cases where t ≥ t) switch When f(t) = 1, α t =α SGDM ,β t =β SGDM This means that, in this case, the current parameter optimization model is determined to be an SGDM optimization model, and the current learning rate α is... t and current momentum parameter β t These represent the current learning rate and current momentum parameters when using the SGDM optimization model to optimize the objective function.

[0235] In one possible embodiment, the first learning rate calculation function and the second learning rate calculation function can be functions for calculating the current learning rate under the ADAM optimization model, and the third learning rate calculation function can be functions for calculating the current learning rate under the SGDM optimization model.

[0236] In this embodiment, using cosine linear interpolation makes the transition from the ADAM optimization model to the SGDM optimization model smoother, avoiding oscillations during the transition. This ensures the stability of the model during the transition and improves the model's accuracy.

[0237] S102, Calculate the current learning rate and current weight parameters based on the current parameter optimization model and the current learning rate calculation function.

[0238] In one possible embodiment, the current learning rate and current weight parameters are calculated based on the current parameter optimization model and the current learning rate calculation function, including:

[0239] When the current iteration count is less than the number of iterations to enter the transition interval and the current parameter optimization model is the ADAM optimization model, calculate the current learning rate based on the learning rate corresponding to the current iteration count and the previous iteration count; calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration count; obtain the exponential decay rate of the first-order moment estimate and the exponential decay rate of the second-order moment estimate; calculate the current first-order moment estimate based on the current gradient, the first-order moment estimate corresponding to the previous iteration count, and the exponential decay rate of the first-order moment estimate; calculate the current second-order moment estimate based on the current gradient, the second-order moment estimate corresponding to the previous iteration count, and the exponential decay rate of the second-order moment estimate; calculate the current first-order moment deviation correction based on the current iteration count, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate; calculate the current second-order moment deviation correction based on the current iteration count, the current second-order moment estimate, and the exponential decay rate of the second-order moment estimate; calculate the current weight parameters based on the weight parameters corresponding to the previous iteration count, the current learning rate, the exponential decay rate of the first-order moment estimate, the exponential decay rate of the second-order moment estimate, the current first-order moment deviation correction, and the current second-order moment deviation correction.

[0240] When the current iteration number is not less than the number of iterations to enter the transition interval and less than the number of iterations to end the transition interval, and the current parameter optimization model is the ADAM optimization model, calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number; obtain the confidence interval radius, the exponential decay rate of the first moment estimate, and the exponential decay rate of the second moment estimate; calculate the current first moment estimate based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate; calculate the current second moment estimate based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate; calculate the current confidence interval based on the current first moment estimate, the confidence interval radius, the current second moment estimate, the exponential decay rate of the second moment estimate, and the current iteration number; calculate the current learning rate based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate; calculate the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval.

[0241] When the current iteration number is not less than the number of transition iterations and the current parameter optimization model is a momentum stochastic gradient descent (SGDM) optimization model, calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number; obtain the current momentum parameters; calculate the current learning rate based on the current momentum parameters and the current gradient; and calculate the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, and the current momentum parameters.

[0242] In one possible embodiment, before optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters using the current learning rate calculation function, some parameters need to be initialized so that the current learning rate and current weight parameters can be calculated based on these initialized parameters later.

[0243] Specifically, the initial learning rate is set very small to avoid skipping the optimal point of the loss function during parameter updates. Therefore, when the parameter optimization model is an ADAM optimization model, the current learning rate α can be set very low. t Initialize to between 0.001 and 0.1, for example, initialize to 10. -3 Current momentum parameter β t This includes the exponential decay rate β1 estimated by the first moment, the exponential decay rate β2 estimated by the second moment, and the constant ∈. The exponential decay rates β1 and β2 can be initialized to values ​​close to 1, for example, setting β1 to 0.9 and β2 to 0.999. Typically, the constant ∈ is initialized to a number close to 0 to prevent the denominator from being zero; for example, setting ∈ to 10. -9 When the parameter optimization model is the SGDM optimization model, β t Including β, which can be initialized to 0.9, the initial optimizer is usually the ADAM model, the initial iteration number t is initialized to 0, and the initial first-order moment estimate m is initialized. t The second-order moment estimate v is initialized to 0. t Set the value to 0 and initialize the cumulative variable λ. t The initial confidence interval radius is δ = 1.0, where t ← 0, m t ←0, v t ←0, λ t ←0, δ←1.0, at this point the current learning rate α t =α0=10 -3 .

[0244] For example, in t < t adam At that time, the current learning rate is calculated using formula (4) based on the learning rate corresponding to the current iteration number and the previous iteration number:

[0245]

[0246] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations in the previous iteration, and t is the current iteration number.

[0247] Based on the objective function and the weight parameters corresponding to the previous iteration number, the current gradient is calculated using formula (5):

[0248]

[0249] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0250] Based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate, the current first moment estimate is calculated using formula (6):

[0251] m t =β1m t-1 +(1-β1)g t (6)

[0252] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0253] Based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate, the current second moment estimate is calculated using formula (7):

[0254]

[0255] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0256] Based on the current iteration number, the current first moment estimate, and the exponential decay rate of the first moment estimate, the current first moment deviation correction is calculated using formula (8):

[0257]

[0258] in, For the current first-order moment deviation correction, m tFor the current first moment estimate, t is the power of the exponential decay rate estimated by the first moment, where t is the current iteration number;

[0259] Based on the current iteration number, the current second moment estimate, and the exponential decay rate of the second moment estimate, the current second moment deviation correction is calculated using formula (9):

[0260]

[0261] in, For the current second-order moment deviation correction, v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0262] Based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction, the current weight parameters are calculated using formula (10):

[0263]

[0264] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t The current learning rate, Let t be the exponential decay rate estimated by the second moment. It is the t-th power of the exponential decay rate estimated by the first moment. For the current first-order moment deviation correction, This is the correction for the current second-order moment deviation, where ∈ is a constant and t is the current iteration number.

[0265] For example, in t adam ≤t<t switch At that time, the current gradient is calculated using formula (5) based on the objective function and the weight parameters corresponding to the previous iteration number; the current first moment estimate is calculated using formula (6) based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate; the current second moment estimate is calculated using formula (7) based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0266] Based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number, the current confidence interval is calculated using formula (11):

[0267]

[0268] Among them, z t For the confidence interval corresponding to the current iteration number, sign(m) t ) is a symbolic function. For the minimum value function, m t This is the current first-order moment estimate, where δ is the radius of the confidence interval, and v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0269] Based on the learning rate, confidence interval radius, and current first moment estimate corresponding to the previous iteration number, the current learning rate is calculated using formula (12):

[0270] α t =α t-1 δ / (δ+||m t ||+∈) (12)

[0271] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations from the previous iteration, δ is the radius of the confidence interval, and m is the number of iterations from the previous iteration. t This is the estimate of the current first moment, where ∈ is a constant;

[0272] Based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval, the current weight parameters are calculated using formula (13):

[0273]

[0274] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t m is the current learning rate. t For the current first-order moment estimate, z t v represents the current confidence interval. t This is the current second-order moment estimate, where ∈ is a constant.

[0275] When t≥t switch At that time, the current gradient is calculated using formula (5) based on the objective function and the weight parameters corresponding to the previous iteration number;

[0276] Based on the current momentum parameter and the current gradient, calculate the current learning rate using formula (14):

[0277] α t =g t / (1-β) (14)

[0278] Where, α t β is the current learning rate, β is the current momentum parameter, and g is the current learning rate. t This is the current gradient;

[0279] Based on the weight parameters corresponding to the previous iteration, the current learning rate, and the current momentum parameter, the current weight parameters are calculated using formula (15):

[0280] w t =w t-1 -(1-β)α t (15)

[0281] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t β is the current learning rate, and β is the current momentum parameter.

[0282] S103, Adjust the parameters of the image detection model according to the current learning rate and current weight parameters.

[0283] The essence of image detection model training is to find suitable parameters (weight parameters) after the mathematical formula of the model is designed, so that the difference between the evaluation or classification results of the image detection model on a specified dataset and the real situation is minimized.

[0284] Based on the above steps, after obtaining the current weight parameters, this application can adjust the weight parameters of the image detection model to the current weight parameters, thus obtaining a parameter-adjusted image detection model. Subsequently, sample images can be input into the parameter-adjusted image detection model to train it, thereby obtaining a trained image detection model.

[0285] S104, acquire sample images, input the sample images into the image detection model, and obtain image detection results; wherein, the sample images have corresponding annotation information.

[0286] Sample images can be obtained from publicly available image algorithm datasets or from pre-defined image libraries. For example, as shown in Table 1, 6000 images with a size of 32*32 are obtained from the mainstream industrial image dataset CIFAR-10 as sample images. Of these, 5000 images are used to train the image detection model, and 1000 images are used to test the image detection model. The image detection model is a convolutional neural network model. For example, as shown in Table 2, the image detection model can be a ResNet-32 model with 470218 parameters and 100 iterations. Figure 3This diagram illustrates the comparison of training performance when using the ADAM model, the SGDM model, and both ADAM and SGDM models to train the ResNet-32 model. It shows the trend of the validation accuracy of the ResNet-32 model as the current iteration number t changes, across these three training scenarios. The horizontal axis represents the variable of the current iteration number t, with scales of 0, 20, 40, 60, 80, and 100. The vertical axis represents the accuracy variable, with scales of 0, 0.5, 0.6, 0.7, 0.8, and 0.9. The annotation information in the sample images represents the set of pixels in the labeled regions of the sample images. The annotation information for the sample images can be manually obtained or obtained from relevant open-source databases.

[0287] Table 1

[0288] Dataset Image size Training dataset Test dataset CIFAR-10 32*32 5000 1000

[0289] Table 2

[0290] Network Structure Parameters Number of iterations (t) Residual-Network-32 470,218 100

[0291] S105, Based on the annotation information of the sample images and the image detection results, determine the loss of the image detection model.

[0292] When training an image detection model, the loss function serves as the objective function, used to evaluate the difference between the image detection model's predictions (model predictions) and the labeled information of the sample images (target values), enabling the image detection model to predict closer to the true values. Specifically, the smaller the loss function value, the closer the model's predictions are to the target values, and the higher the model's accuracy; conversely, the larger the loss function value, the further the model's predictions deviate from the target values, and the lower the model's accuracy.

[0293] In one possible implementation, common loss functions include mean squared error (MSE), cross-entropy loss, KL divergence, etc.

[0294] S106, when the loss of the image detection model converges, the trained image detection model is obtained.

[0295] In one possible embodiment, the trained image detection model is obtained when the loss of the image detection model converges. If the loss of the image detection model does not converge, the above steps are continued to adjust the parameters of the image detection model and train the parameter-adjusted image detection model until the loss of the image detection model converges.

[0296] In this embodiment, the current parameter optimization model and the current learning rate calculation function are determined based on the current iteration number of the image detection model. The current learning rate and current weight parameters are then calculated based on this, and the calculated information is used to adjust the image detection model. Subsequently, sample images with annotation information are acquired and input into the image detection model to obtain image detection results. Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined. When the loss converges, the trained image detection model is obtained. The current learning rate and current weight parameters are determined based on the current iteration parameters, the parameter optimization model, and the current learning rate calculation function. This allows for a smooth switching of the parameter optimization model, ensuring the stability of the image detection model during the switching process and thus improving the accuracy of the trained image detection model.

[0297] This application also provides an image detection model training method, see [link to relevant documentation]. Figure 4 Specifically, it includes the following steps:

[0298] Step 1: Begin;

[0299] Step 2: Initialize model parameters;

[0300] Step 3: Train the model using the ADAM algorithm and record the loss function value for the current iteration.

[0301] Step 4: Determine if the switching function is satisfied. If not, return to Step 3; if yes, proceed to Step 5.

[0302] Step 5: Enter the transition interval, and calculate the current learning rate and current momentum parameter in each iteration;

[0303] Step 6: Is the transition interval termination condition met? If not, return to Step 5; if yes, proceed to Step 7.

[0304] Step 7: End the transition and train the model using SGDM;

[0305] Step 8: Stop training when the loss function value on the validation set no longer decreases.

[0306] In this embodiment, the switching process from the ADAM-optimized model to the SGDM-optimized model is integrated into the adaptive learning rate and momentum optimization algorithm. This improves the model's robustness and generalization ability, while also accelerating the training process and saving computational resources. Furthermore, determining whether to perform the transition based on the loss function's performance on the validation set ensures that the model maintains good generalization ability during the transition period. This further enhances the model's accuracy, robustness, and generalization ability on top of the original accuracy. Finally, experimental results are presented.

[0307] This application also provides an image detection model training device, see [link to relevant documentation]. Figure 5 The device includes:

[0308] The first determining module 501 is used to determine the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model.

[0309] Calculation module 502 is used to optimize the model and the current learning rate calculation function based on the current parameters, and to calculate the current learning rate and current weight parameters;

[0310] The adjustment module 503 is used to adjust the parameters of the image detection model according to the current learning rate and the current weight parameters;

[0311] The acquisition module 504 is used to acquire sample images, input the sample images into the image detection model, and obtain image detection results; wherein, the sample images have corresponding annotation information;

[0312] The second determining module 505 is used to determine the loss of the image detection model based on the annotation information of the sample image and the image detection results;

[0313] Training module 506 is used to obtain the trained image detection model when the loss of the image detection model converges.

[0314] In one possible embodiment, the first determining module is configured to:

[0315] Obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein, the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval.

[0316] If the current number of iterations is less than the number of iterations to enter the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the first learning rate calculation function.

[0317] If the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, then the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the second learning rate calculation function.

[0318] If the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is determined to be the stochastic gradient descent optimization model, and the current learning rate calculation function is determined to be the third learning rate calculation function.

[0319] Among them, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function.

[0320] The accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both smaller than the accuracy improvement of the image detection model under the second learning rate calculation function.

[0321] In one possible embodiment, when the current iteration number is less than the number of iterations to enter the transition interval, the current parameter optimization model is an adaptive moment estimation ADAM optimization model; the calculation module is used for:

[0322] Calculate the current learning rate based on the learning rate corresponding to the current iteration number and the previous iteration number;

[0323] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0324] Obtain the exponential decay rate estimated by the first moment and the exponential decay rate estimated by the second moment;

[0325] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0326] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0327] The current first moment deviation correction is calculated based on the current iteration number, the current first moment estimate, and the exponential decay rate of the first moment estimate;

[0328] The current second moment bias correction is calculated based on the current iteration number, the current second moment estimate, and the exponential decay rate of the second moment estimate;

[0329] Calculate the current weight parameters based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction.

[0330] In one possible embodiment, the computing module is used for:

[0331] The current learning rate is calculated using the following formula, based on the learning rates corresponding to the current iteration number and the previous iteration number:

[0332]

[0333] Where, αt Let α be the current learning rate. t-1 The learning rate is the number of iterations in the previous iteration, and t is the current iteration number.

[0334] Accordingly, based on the objective function and the weight parameters corresponding to the previous iteration number, the current gradient is calculated using the following formula:

[0335]

[0336] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0337] Accordingly, based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0338] m t =β1m t-1 +(1-β1)g t

[0339] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0340] Accordingly, based on the current gradient, the second-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-moment estimate, the current second-moment estimate is calculated using the following formula:

[0341]

[0342] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0343] Accordingly, based on the current iteration number, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate, the current first-order moment deviation correction is calculated using the following formula:

[0344]

[0345] in, For the current first-order moment deviation correction, m t For the current first moment estimate, t is the power of the exponential decay rate estimated by the first moment, where t is the current iteration number;

[0346] Accordingly, based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate, the current second-moment bias correction is calculated using the following formula:

[0347]

[0348] in, For the current second-order moment deviation correction, v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0349] Accordingly, based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction, the current weight parameters are calculated using the following formula:

[0350]

[0351] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t The current learning rate, Let t be the exponential decay rate estimated by the second moment. It is the t-th power of the exponential decay rate estimated by the first moment. For the current first-order moment deviation correction, This is the correction for the current second-order moment deviation, where ∈ is a constant and t is the current iteration number.

[0352] In one possible embodiment, if the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is the ADAM optimization model.

[0353] The calculation module is used for:

[0354] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0355] Obtain the confidence interval radius, the exponential decay rate estimated by the first moment, and the exponential decay rate estimated by the second moment;

[0356] The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate.

[0357] The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate.

[0358] Calculate the current confidence interval based on the current first moment estimate, confidence interval radius, current second moment estimate, exponential decay rate of the second moment estimate, and current iteration number;

[0359] The current learning rate is calculated based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate.

[0360] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval.

[0361] In one possible embodiment, the computing module is used for

[0362] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0363]

[0364] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0365] Accordingly, based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula:

[0366] m t =β1m t-1 +(1-β1)g t

[0367] Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient;

[0368] Accordingly, based on the current gradient, the second-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-moment estimate, the current second-moment estimate is calculated using the following formula:

[0369]

[0370] Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient;

[0371] Accordingly, based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number, the current confidence interval is calculated using the following formula:

[0372]

[0373] Among them, z t For the confidence interval corresponding to the current iteration number, sign(m) t ) is a symbolic function. For the minimum value function, m t This is the current first-order moment estimate, where δ is the radius of the confidence interval, and v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number;

[0374] Accordingly, based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate, the current learning rate is calculated using the following formula:

[0375] α t =α t-1 δ / (δ+||m t ||+∈)

[0376] Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations from the previous iteration, δ is the radius of the confidence interval, and m is the number of iterations from the previous iteration. t This is the estimate of the current first moment, where ∈ is a constant;

[0377] Accordingly, based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval, the current weight parameters are calculated using the following formula:

[0378]

[0379] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t m is the current learning rate. t For the current first-order moment estimate, z t v represents the current confidence interval. t This is the current second-order moment estimate, where ∈ is a constant.

[0380] In one possible embodiment, if the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is a momentum stochastic gradient descent (SGDM) optimization model.

[0381] The calculation module is used for:

[0382] Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number;

[0383] Get the current momentum parameters;

[0384] Calculate the current learning rate based on the current momentum parameter and the current gradient;

[0385] The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration, the current learning rate, and the current momentum parameters.

[0386] In one possible embodiment, the computing module is used for:

[0387] The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number:

[0388]

[0389] Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration;

[0390] Accordingly, based on the momentum parameter and the current gradient, the current learning rate is calculated using the following formula:

[0391] α t =g t / (1-β)

[0392] Where, α t β is the current learning rate, β is the current momentum parameter, and g is the current learning rate. t This is the current gradient;

[0393] Accordingly, based on the weight parameters corresponding to the previous iteration, the current learning rate, and the momentum parameter, the current weight parameters are calculated using the following formula:

[0394] w t =w t-1 -(1-β)α t

[0395] Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t β is the current learning rate, and β is the current momentum parameter.

[0396] This application also provides an electronic device, such as... Figure 6 As shown, it includes:

[0397] Memory 601 is used to store computer programs;

[0398] When processor 602 executes a program stored in memory 601, it performs the following steps:

[0399] Based on the current iteration number of the image detection model, determine the current parameter optimization model and the current learning rate calculation function;

[0400] Calculate the current learning rate and current weight parameters based on the current parameter optimization model and the current learning rate calculation function;

[0401] Adjust the parameters of the image detection model according to the current learning rate and current weight parameters;

[0402] Acquire sample images, input them into the image detection model, and obtain image detection results; the sample images contain corresponding annotation information.

[0403] Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined;

[0404] When the loss of the image detection model converges, the trained image detection model is obtained.

[0405] Furthermore, the aforementioned electronic device may also include a communication bus and / or a communication interface, with the processor 602, communication interface, and memory 601 communicating with each other via the communication bus.

[0406] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0407] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0408] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. In one possible embodiment, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0409] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0410] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the above-described image detection model training methods.

[0411] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the image detection model training methods described above.

[0412] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state disk (SSD), etc.

[0413] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0414] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, and storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0415] The above are merely preferred embodiments of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method for training an image detection model, characterized in that, The method includes: Based on the current iteration number of the image detection model, determine the current parameter optimization model and the current learning rate calculation function; Calculate the current learning rate and current weight parameters based on the current parameter optimization model and the current learning rate calculation function; Adjust the parameters of the image detection model according to the current learning rate and current weight parameters; A sample image is acquired and input into an image detection model to obtain an image detection result; wherein the sample image has corresponding annotation information. Based on the annotation information of the sample images and the image detection results, the loss of the image detection model is determined; When the loss of the image detection model converges, the trained image detection model is obtained; The step of determining the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model includes: Obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein, the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval; If the current iteration count is less than the number of iterations to enter the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the first learning rate calculation function. If the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is determined to be the adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be the second learning rate calculation function. If the current iteration number is not less than the number of transition iterations to end, the current parameter optimization model is determined to be a stochastic gradient descent optimization model, and the current learning rate calculation function is determined to be the third learning rate calculation function. Among them, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function. The accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both smaller than the accuracy improvement of the image detection model under the second learning rate calculation function.

2. The method according to claim 1, characterized in that, If the current iteration number is less than the number of iterations required to enter the transition interval, the current parameter optimization model is the adaptive moment estimation ADAM optimization model. The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes: Calculate the current learning rate based on the learning rate corresponding to the current iteration number and the previous iteration number; Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number; Obtain the exponential decay rate estimated by the first moment and the exponential decay rate estimated by the second moment; The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate. The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate. The current first moment deviation correction is calculated based on the current iteration number, the current first moment estimate, and the exponential decay rate of the first moment estimate; The current second moment bias correction is calculated based on the current iteration number, the current second moment estimate, and the exponential decay rate of the second moment estimate; Calculate the current weight parameters based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction.

3. The method according to claim 2, characterized in that, The step of calculating the current learning rate based on the learning rates corresponding to the current iteration number and the previous iteration number includes: The current learning rate is calculated using the following formula, based on the learning rates corresponding to the current iteration number and the previous iteration number: Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations in the previous iteration, and t is the current iteration number. Accordingly, calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes: The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number: Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration; Accordingly, the step of calculating the current first-order moment estimate based on the current gradient, the first-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-order moment estimate includes: Based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula: m t =β1m t-1 +(1-β1)g t Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient; Accordingly, the step of calculating the current second-order moment estimate based on the current gradient, the second-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-order moment estimate includes: Based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate, the current second moment estimate is calculated using the following formula: Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient; Accordingly, the step of calculating the current first-order moment deviation correction based on the current iteration number, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate includes: Based on the current iteration number, the current first-order moment estimate, and the exponential decay rate of the first-order moment estimate, calculate the current first-order moment bias correction using the following formula: in, For the current first-order moment deviation correction, m t For the current first moment estimate, t is the power of the exponential decay rate estimated by the first moment, where t is the current iteration number; Accordingly, the step of calculating the current second-moment deviation correction based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate includes: Based on the current iteration number, the current second-moment estimate, and the exponential decay rate of the second-moment estimate, the current second-moment bias correction is calculated using the following formula: in, For the current second-order moment deviation correction, v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number; Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction includes: Based on the weight parameters corresponding to the previous iteration, the current learning rate, the exponential decay rate of the first moment estimate, the exponential decay rate of the second moment estimate, the current first moment bias correction, and the current second moment bias correction, the current weight parameters are calculated using the following formula: Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t The current learning rate, Let t be the exponential decay rate estimated by the second moment. It is the t-th power of the exponential decay rate estimated by the first moment. For the current first-order moment deviation correction, This is the correction for the current second-order moment deviation, where ∈ is a constant and t is the current iteration number.

4. The method according to claim 1, characterized in that, If the current iteration number is not less than the number of iterations to enter the transition interval and is less than the number of iterations to end the transition interval, the current parameter optimization model is the ADAM optimization model. The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes: Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number; Obtain the confidence interval radius, the exponential decay rate estimated by the first moment, and the exponential decay rate estimated by the second moment; The current first moment estimate is calculated based on the current gradient, the first moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first moment estimate. The current second moment estimate is calculated based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate. Calculate the current confidence interval based on the current first moment estimate, confidence interval radius, current second moment estimate, exponential decay rate of the second moment estimate, and current iteration number; The current learning rate is calculated based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate. The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first moment estimate, the current second moment estimate, and the current confidence interval.

5. The method according to claim 4, characterized in that, The step of calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes: The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number: Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration; Accordingly, the step of calculating the current first-order moment estimate based on the current gradient, the first-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-order moment estimate includes: Based on the current gradient, the first-moment estimate corresponding to the previous iteration number, and the exponential decay rate of the first-moment estimate, the current first-moment estimate is calculated using the following formula: m t =β1m t-1 +(1-β1)g t Where, m t Here, β1 is the exponential decay rate of the first moment estimate, and m is the current first moment estimate. t-1 For the first moment estimate corresponding to the previous iteration number, g t This is the current gradient; Accordingly, the step of calculating the current second-order moment estimate based on the current gradient, the second-order moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second-order moment estimate includes: Based on the current gradient, the second moment estimate corresponding to the previous iteration number, and the exponential decay rate of the second moment estimate, the current second moment estimate is calculated using the following formula: Among them, v t This is the current estimate of the second moment, where β2 is the exponential decay rate of the second moment estimate, and v t-1 This is the second moment estimate corresponding to the previous iteration number. The square of the current gradient; Accordingly, the step of calculating the current confidence interval based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number includes: Based on the current first-order moment estimate, the confidence interval radius, the current second-order moment estimate, the exponential decay rate of the second-order moment estimate, and the current iteration number, the current confidence interval is calculated using the following formula: Among them, z t For the confidence interval corresponding to the current iteration number, sign(m) t ) is a symbolic function. For the minimum value function, m t This is the current first-order moment estimate, where δ is the radius of the confidence interval, and v t For the current second-order moment estimate, Let t be the exponential decay rate estimated by the second moment, where t is the current iteration number; Accordingly, the step of calculating the current learning rate based on the learning rate corresponding to the previous iteration number, the confidence interval radius, and the current first moment estimate includes: Based on the learning rate, confidence interval radius, and current first-order moment estimate corresponding to the previous iteration number, the current learning rate is calculated using the following formula: a t =a t-1 d / (d+‖m t ‖+∈) Where, α t Let α be the current learning rate. t-1 The learning rate is the number of iterations from the previous iteration, δ is the radius of the confidence interval, and m is the number of iterations from the previous iteration. t This is the estimate of the current first moment, where ∈ is a constant; Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first-order moment estimate, the current second-order moment estimate, and the current confidence interval includes: Based on the weight parameters corresponding to the previous iteration number, the current learning rate, the current first-order moment estimate, the current second-order moment estimate, and the current confidence interval, the current weight parameters are calculated using the following formula: Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t Let m be the current learning rate. t For the current first-order moment estimate, z t For the current confidence interval, v t This is the current second-order moment estimate, where ∈ is a constant.

6. The method according to claim 1, characterized in that, If the current iteration number is not less than the number of iterations to end the transition, the current parameter optimization model is the momentum stochastic gradient descent SGDM optimization model; The step of optimizing the model based on the current parameters and calculating the current learning rate and current weight parameters according to the current learning rate calculation function includes: Calculate the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number; Get the current momentum parameters; Calculate the current learning rate based on the current momentum parameter and the current gradient; The current weight parameters are calculated based on the weight parameters corresponding to the previous iteration, the current learning rate, and the current momentum parameters.

7. The method according to claim 6, characterized in that, The step of calculating the current gradient based on the objective function and the weight parameters corresponding to the previous iteration number includes: The current gradient is calculated using the following formula, based on the objective function and the weight parameters corresponding to the previous iteration number: Among them, g t Let f(w) be the current gradient. t-1 Let w be the objective function. t-1 The weight parameter corresponds to the number of the previous iteration; Accordingly, calculating the current learning rate based on the current momentum parameter and the current gradient includes: The current learning rate is calculated using the following formula, based on the momentum parameter and the current gradient: α t =g t / (1—β) Where, α t β is the current learning rate, β is the current momentum parameter, and g is the current learning rate. t This is the current gradient; Accordingly, the step of calculating the current weight parameters based on the weight parameters corresponding to the previous iteration number, the current learning rate, and the current momentum parameters includes: Based on the weight parameters corresponding to the previous iteration, the current learning rate, and the momentum parameter, calculate the current weight parameters using the following formula: w t =w t-1 -(1-β)α t Among them, w t w is the current weight parameter. t-1 Let α be the weight parameter corresponding to the previous iteration number. t β is the current learning rate, and β is the current momentum parameter.

8. An image detection model training device, characterized in that, The device includes: The first determining module is used to determine the current parameter optimization model and the current learning rate calculation function based on the current iteration number of the image detection model. The calculation module is used to optimize the model and the current learning rate calculation function based on the current parameters, and to calculate the current learning rate and current weight parameters. The adjustment module is used to adjust the parameters of the image detection model according to the current learning rate and current weight parameters; The acquisition module is used to acquire sample images, input the sample images into the image detection model, and obtain image detection results; wherein, the sample images correspond to annotation information; The second determining module is used to determine the loss of the image detection model based on the annotation information of the sample image and the image detection result; The training module is used to obtain the trained image detection model when the loss of the image detection model converges; Specifically, the first determining module is used to obtain the number of iterations entering the transition interval and the number of iterations ending the transition interval; wherein the number of iterations ending the transition interval is greater than the number of iterations entering the transition interval; when the current iteration number is less than the number of iterations entering the transition interval, the current parameter optimization model is determined to be an adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be a first learning rate calculation function; when the current iteration number is not less than the number of iterations entering the transition interval and less than the number of iterations ending the transition interval, the current parameter optimization model is determined to be an adaptive learning rate adjustment optimization model, and the current learning rate calculation function is determined to be a second learning rate calculation function; in the current iteration... If the number of iterations is not less than the number of iterations required to terminate the transition, the current parameter optimization model is determined to be a stochastic gradient descent optimization model, and the current learning rate calculation function is determined to be a third learning rate calculation function. Specifically, the convergence speed of the image detection model under the first learning rate calculation function is greater than that under the second learning rate calculation function, and the convergence speed of the image detection model under the second learning rate calculation function is greater than that under the third learning rate calculation function. The accuracy improvement of the image detection model under the first learning rate calculation function and the accuracy improvement of the image detection model under the third learning rate calculation function are both less than the accuracy improvement of the image detection model under the second learning rate calculation function.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The method includes a processor and a machine-readable storage medium storing machine-executable instructions that can be executed by the processor, the processor being prompted by the machine-executable instructions to perform the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Gradient descent optimization method based on hybrid strategy

    CN112183763A

  • Adaptive optimization training method of convolutional neural network for image classification

    CN115205577A