An Image Classification Method Based on a Deep Learning PID Optimizer
Through the image classification method based on the deep learning PID optimizer, KP, KI and KD coefficients of each layer of subnet are adaptively generated, and the parameters are updated by the PID optimizer and Adam optimizer, the problem of low efficiency and low accuracy of the deep learning image classification method when the task distribution is inconsistent, and high-precision recognition is achieved quickly adapted to new tasks.
Patent Information
- Application Number
- CN202410135709.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2044-01-31
AI Technical Summary
The existing deep learning image classification methods have low learning efficiency when the distribution of training tasks and testing tasks are inconsistent, the recognition accuracy is reduced, theoretical knowledge research is lacking, and the adaptability is weak.
The image classification method based on the deep learning PID optimizer is adopted, and the KP, KI and KD coefficients of each layer of subnet are adaptively generated by the generation algorithm, and the inner loop learnable parameters are updated in combination with the PID optimizer, and the outer loop learnable parameters are updated using the Adam optimizer to build a 4-layer convolutional neural network or ResNet12 structure to perform image preprocessing and loss value calculation.
It improves the accuracy and adaptability of image classification, can quickly adapt to new tasks, and improves the generalization performance and robustness of the model.
Smart Images

Figure CN117975135B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision and pattern recognition, and relates to an image classification method based on a deep learning PID optimizer. Background Art
[0002] The image processing technology based on deep learning has made great technological breakthroughs in the field of machine vision (such as image classification), and solved the problems of low accuracy and slow efficiency of traditional feature engineering technology. Large-scale data sets, complex neural network structures, huge computational amounts, and training times are the key reasons for the powerful performance of deep learning. In order to reduce the training duration of the model and accelerate the learning efficiency of the model, using a fast and robust optimizer is the core technology of the deep learning model. On the one hand, the optimizer can quickly update the weights of the model and learn effective empirical knowledge; on the other hand, it can make the model converge to an approximate global optimum.
[0003] In the existing optimizer algorithms in deep learning, when the training task and the test task distributions are inconsistent, their learning efficiency is low, and it takes dozens of rounds of iterative learning to converge, and the recognition accuracy is also greatly reduced; secondly, there is a lack of theoretical knowledge research, and the adaptability is weak, and it only improves in the fields involved in specific tasks.
[0004] The PID control theory has a very mature application in the control discipline and can quickly adjust the deviation to reduce it. Deep neural networks are widely used as feature extractors, mapping image data into an embedding space to form specific feature vectors, and finally used in downstream tasks. For the deviation value existing in the algorithm prediction, using the parameter update criterion based on the PID optimizer can quickly reduce the deviation. Regarding the proportional term P as the error between the prediction score of the model for a certain category and the actual label, it is used to adjust the importance of each category for the model; using the integral term I to handle the long-term error accumulation to help the model better learn the features of rare categories; the differential term D can balance P and I to prevent the model from overfitting or over-adjusting for certain samples. By predicting the future and accumulating the history to adjust the weights of the model, the algorithm has the ability to quickly adapt to new tasks and has strong recognition performance for brand-new tasks, greatly improving the accuracy of image classification.
[0005] Therefore, an image classification method based on a deep learning PID optimizer is needed to solve the above problems. Summary of the Invention
[0006] In order to solve the above problems of lacking specific, perfect, and mature actual experimental devices, the present invention provides an image classification method based on a deep learning PID optimizer.
[0007] An image classification method based on a deep learning PID optimizer of the present invention includes the following steps:
[0008] Step S1: Divide the data set into a training data set, a validation data set, and a test data set;
[0009] Step S2: Construct an image classification model based on deep learning. The image classification model includes N_layer sub-networks, and initialize the weights and the maximum number of iterations of the N_layer sub-networks;
[0010] Step S3: Use the training data set to train the image classification model and calculate the loss value between the model prediction value and the true label;
[0011] Step S4: Generate K P , K I and K D coefficients for each layer of the sub-network based on a generation algorithm;
[0012] Step S5: Based on the K P , K I and K D coefficients generated in Step S4, use a PID optimizer to update the inner-loop learnable parameters of the image classification model, and use an Adam optimizer to update the outer-loop learnable parameters of the image classification model;
[0013] Step S6: Test the generalization performance of the image classification model on the validation data set, and use a PID optimizer to adjust the weight parameters of the N_layer sub-network as the initial weight values of the image classification model;
[0014] Step S7: Repeat Steps S3 - S6 until the number of iterations reaches the maximum number of iterations set in Step S2 to obtain an optimized image classification model.
[0015] Furthermore, image preprocessing is also included in Step 1: Normalize the mean and variance of each image in the data set, and then convert the image data into a tensor format.
[0016] Furthermore, the image classification model in Step S2 is composed of a 4-layer convolutional neural network CNN or is a ResNet12 structure.
[0017] Furthermore, the number of convolutional kernels of the convolutional neural network CNN is 64, and the size of the convolutional kernel is 3.
[0018] Furthermore, in Step S3, use the training data set to train the image classification model: Read a fixed number of batch data in each round of training. Each batch of data includes N_way×(K support +K query ) sample data, where N_way is the number of categories, and K supportis the number of support sets for each category, K query is the number of query sets for each category.
[0019] Furthermore, in step S3, the loss value is calculated by the cross-entropy loss function.
[0020] Furthermore, in step S4, the generation algorithm consists of two Linear layers, with an input dimension of N_layer×3 and an output dimension of N_layer×3, where N_layer is the number of layers of the image classification model.
[0021] Furthermore, in step S4, the following formula is used to generate K P , K I and K D coefficients:
[0022]
[0023] where f is the generation algorithm, N_layer is the number of layers of the image classification model, and are the mean, variance, and gradient values of the parameters of each layer of the image classification model, respectively.
[0024] Furthermore, in step S5, the following formula is used to update the learnable parameters of the inner loop of the image classification model using the PID optimizer:
[0025]
[0026] In the formula, K P , K I , K D are the adaptive coefficients generated by the generation algorithm in step S5, is the gradient value of the parameter weight of the i-th layer sub-network of the image classification model at the t-th iteration, α is the weight decay factor, L t and L t-1 are the loss values of the image classification model at the t-th and t-1-th iterations, respectively, and are the parameter values of the i-th layer sub-network of the image classification model at the t-th and t-1-th iterations, respectively, α t-m and α t-m+1 are the weight decay factors at the t-m and t-m+1 moments, respectively.
[0027] Beneficial effects: The image classification method based on the deep learning PID optimizer of the present invention uses the image classification method based on the PID optimizer to solve the problems of slow efficiency and low accuracy in existing image classification tasks, and uses the generation algorithm to adaptively generate K of each layer sub-network of the modelP , K I and K D Coefficients, which solve the problem of manually adjusting parameters in the PID control algorithm, have stronger generalization and robustness, and can achieve the effect of quickly adapting to new tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a schematic flow chart of the image classification method based on the deep learning PID optimizer of the present invention;
[0029] Figure 2 is a schematic diagram of the inner loop PID optimizer parameter update criterion. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are all simplified schematic diagrams, only illustrating the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.
[0031] As Figure 1-2 shown, the image classification method based on the deep learning PID optimizer of the present invention includes the following steps:
[0032] Step S1: Divide the entire data set into a training data set, a validation data set, and a test data set according to a certain ratio, and there are no overlapping categories among the three. Taking the mini-ImageNet data set as an example, this data set contains 100 categories, each category contains 600 images, 70 categories are selected as the training data set, 20 categories are selected as the validation data set, and 10 categories are selected as the test data set; perform normalization preprocessing on the mean and variance of each image, and then convert the image data into a tensor format. When training each round, read a fixed number of batch data, and each batch data contains N_way×(K support + K query ) sample data, where N_way is the number of categories, usually set to 5 or 20, K support is the number of support sets for each category, usually set to 5 or 1, K query is the number of query sets for each category, usually set to 15;
[0033] Step S2: Build a few-shot image classification learning model and initialize the weights: The built model consists of 4 layers of CNN or is a ResNet12 structure, where the number of convolutional kernels of each layer of the CNN model is set to 64, and the size of the convolutional kernels is set to 3; In particular, for each sub-network of the built model, the feature vector of the image can be calculated forward using its own weights, or the feature vector of the image can be calculated using the specified weights; For the convolutional layer of the model, initialize the weights using the Gaussian or Xavier initialization method, and for the bias layer of the model, initialize the weights using the zero initialization method;
[0034] Step S3: Pack the images in the training dataset into batch data as described in S1, set the number of iteration rounds, input the packed batch data into the model constructed in S2 for forward calculation, and map the image features to feature vectors of a fixed length;
[0035] Step S4: Train the model based on the training dataset, and calculate the loss value between the labels predicted by the model and the true label values corresponding to the images. The loss function can be calculated using cross-entropy loss;
[0036] Step S5: Adaptive generate respective K P ,K I ,K D coefficients for each sub-network layer of the model, where the generation algorithm consists of two learnable Linear layers, with an input dimension of N_layer×3 and an output dimension of N_layer×3. Here, N_layer is the number of layers of the model constructed in Step 2. Specifically, the input data is the mean and variance of the weights of each layer of the model and the gradient values corresponding to the weights of each layer of the model, that is:
[0037]
[0038] In the formula, f is the generation algorithm, N_layer is the number of layers of the model constructed in Step 2, and the output is the K P ,K I ,K D coefficients of each sub-network layer of the model.
[0039] Step S6: According to the loss value calculated in S4, obtain the gradient values of each sub-network layer through gradient backpropagation operation. Use the PID optimizer to update the inner-loop learnable parameters of the model, and use the Adam optimizer to update the outer-loop learnable parameters of the model. Among them, the formula for updating the PID optimizer parameters is:
[0040]
[0041] In the formula, K P ,K I ,K D are the adaptive coefficients generated by the generation algorithm in Step S5, is the gradient value of the parameter weights of the i-th sub-network layer of the model constructed in Step S2 at the t-th iteration, and α is the weight decay factor;
[0042] Step S7: In the above S6, after each round of training dataset is iterated, the generalization performance of the model is tested on the validation dataset, and the PID optimizer is used to fine-tune the model weight parameters as the initial weight value of the model;
[0043] Step S8: Use the model weights learned in the above S7 as the initial weight value of the test task, and after a small number of iterative calculations, test the recognition accuracy of the model on the test dataset.
[0044] The present invention uses a PID optimizer to update the learnable parameters of the inner loop of the model, which solves the problem of low learning efficiency when the training and test task distributions are different in the image classification learning algorithm; uses a generation algorithm to adaptively generate the K P ,K I ,K D coefficients of each sub-network layer of the model, which solves the problem of manual parameter adjustment of the traditional PID controller and enables the model to have stronger adaptability; introduces the PID control theory algorithm to avoid the disadvantage of weak interpretability of the traditional image classification learning method. It has stronger adaptability and higher recognition accuracy than previous methods and can quickly adapt to new tasks.
[0045] Inspired by the ideal embodiments of the present invention described above, through the above description, relevant staff can make various changes and modifications without departing from the technical idea of the present invention. The technical scope of the present invention is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. An image classification method based on a deep learning PID optimizer, characterized in that, Including the following steps: Step S1: Divide the data set into a training data set, a validation data set, and a test data set; Step S2: Construct an image classification model based on deep learning, where the image classification model includes layers of sub-networks, and initialize the weights and the maximum number of iterations of the layers of sub-networks; Step S3: Use the training data set to train the image classification model and calculate the loss value between the model prediction value and the true label; Step S4: Generate the coefficients of each layer of sub-networks based on the generation algorithm; Step S5: Based on the coefficients, use a PID optimizer to update the inner-loop learnable parameters of the image classification model, and use an Adam optimizer to update the outer-loop learnable parameters of the image classification model; Step S6: Test the generalization performance of the image classification model on the validation dataset, and use the PID optimizer to adjust the weight parameters of the layer sub-network as the initial weight values of the image classification model; Step S7: Repeat steps S3 - S6 until the number of iterations reaches the maximum number of iterations set in step S2 to obtain an optimized image classification model.
2. The image classification method based on the deep learning PID optimizer according to claim 1, wherein Image preprocessing is also included in step S1: Normalize the mean and variance of each image in the data set, and then convert the image data into a tensor format.
3. The image classification method based on the deep learning PID optimizer according to claim 1, wherein The image classification model in step S2 consists of a 4 - layer Convolutional Neural Network (CNN) or is a ResNet12 structure.
4. The image classification method based on a deep learning PID optimizer according to claim 3, characterized in that The number of convolution kernels of the Convolutional Neural Network (CNN) is 64, and the size of the convolution kernel is 3.
5. The image classification method based on the deep learning PID optimizer according to claim 1, characterized in that, In step S3, the image classification model is trained using the training data set: in each round of training, a fixed number of batch data are read, and each batch of data includes sample data, where is the number of classes, is the number of support sets for each class, is the number of query sets for each class.
6. The image classification method based on the deep learning PID optimizer according to claim 1, wherein, In step S3, the loss value is calculated through a cross - entropy loss function.
7. The image classification method based on the deep learning PID optimizer according to claim 1, characterized in that, In step S4, the generation algorithm consists of two Linear layers, and its input dimension is , and the output dimension is , where is the number of layers of the image classification model.
8. The image classification method based on a deep learning PID optimizer according to claim 1, characterized in that, In step S4, the coefficients of each layer of sub-network are generated using the following formula: Coefficient: where, is the generation algorithm, , , , is the number of layers of the image classification model, are the mean, variance and gradient value of the parameters of each layer of the image classification model, respectively.
9. The image classification method based on a deep learning PID optimizer according to claim 1, wherein In step S5, the following formula is used to update the inner - loop learnable parameters of the image classification model using a PID optimizer: ; wherein, is the adaptive coefficient generated by the generation algorithm in step S4, is the parameter weight of the -th sub-network of the image classification model at the -th iteration, is the weight decay factor, are respectively the loss values of the image classification model at the -1-th iteration, are respectively the parameter values of the -th sub-network of the image classification model at the -1-th iteration, and are respectively the weight decay factors at the -m-th and -m + 1-th moments.
Citation Information
Patent Citations
Large-scale image classification method based on deep learning optimizer
CN115170879A
Federated Learning with Adaptive Optimization
US20210073639A1