Gastrointestinal tract image classification method based on improved Adam optimization algorithm
By adding weight attenuation and adaptive gradient cropping technology to the Adam optimization algorithm, the AdamW_AGC algorithm is designed to solve the problems of sensitivity to non-equilibrium data and local extreme values in the gastrointestinal image classification task, achieving higher classification accuracy and training stability.
Patent Information
- Application Number
- CN202411757624.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art has the problem of being sensitive to non-equilibrium data and being easily trapped in local extreme values in the gastrointestinal image classification task, and the traditional Adam optimization algorithm still has room for improvement in medical image processing.
A gastrointestinal image classification method based on improved Adam optimization algorithm is proposed. By combining weight attenuation and adaptive gradient cropping technology, a new deep learning optimization algorithm AdamW_AGC is designed to improve the accuracy and stability of gastrointestinal image classification.
It significantly improves the accuracy and stability of gastrointestinal image classification, enhances the generalization ability of the model, prevents gradient explosion and gradient disappearance, and improves the efficiency and effect of training.
Smart Images

Figure CN119649125A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical image processing, and in particular to a gastrointestinal tract image classification method based on an improved Adam optimization algorithm. Background Art
[0002] With the rapid development of deep learning technology, the application of image classification technology in the medical field is becoming more and more extensive. From simple two-dimensional images to high-dimensional three-dimensional images, from simple single-site images to multi-site or even whole-body images, medical imaging data has gradually become more and more complex. These complex features make it a very difficult task to automatically identify and classify different pathological features from medical images. In addition, due to the high dimensionality, large noise interference, and diverse classification of medical imaging data, traditional image processing and machine learning algorithms also face great challenges. Therefore, the study of more effective and accurate medical image classification methods is of great significance to promoting the progress of medical diagnosis technology, medical research, etc.
[0003] Gastrointestinal diseases seriously endanger people's health, and accurate and rapid diagnosis is the key to clinical treatment. In recent years, with the continuous development of artificial intelligence, especially deep learning has made breakthrough progress in image recognition, making it possible to automatically classify gastrointestinal disease images based on deep learning.
[0004] Based on this complex large-scale image classification method, the Adam optimization algorithm is generally used as the default neural network training optimization algorithm. The Adam (Adaptive Moment Estimation) algorithm is an effective stochastic gradient descent method that can reduce the fluctuations in training to a great extent by adaptively adjusting the learning rate. This method has the advantages of high efficiency and fast learning speed. Although the Adam algorithm has been successful in many fields, there are few studies on the improved Adam algorithm in the gastrointestinal image classification task, and there are certain shortcomings. However, although the improved Adam algorithm has achieved good results in many aspects, it is still sensitive to unbalanced data and prone to falling into local extreme values. There is still room for improvement in its use in medical images. Summary of the invention
[0005] In order to overcome the above-mentioned deficiencies of the prior art, the present invention proposes a gastrointestinal image classification method based on an improved Adam optimization algorithm, which significantly improves the accuracy and stability of gastrointestinal image classification by combining weight decay and adaptive gradient clipping technology.
[0006] The core of the present invention is to design a deep learning optimization algorithm and use it for gastrointestinal image classification tasks, including: firstly, improving the traditional Adam algorithm, adding weight decay on its basis, this method can avoid overfitting during training; then, by combining the adaptive gradient clipping method, designing a new deep learning optimization algorithm AdamW_AGC. By training with the deep learning optimization algorithm provided by the present invention, a gastrointestinal image classification method based on AdamW_AGC can be realized.
[0007] The technical solution provided by the present invention is:
[0008] A gastrointestinal image classification method based on an improved Adam optimization algorithm is proposed. A new deep learning optimization algorithm AdamW_AGC is constructed. A deep neural network model is trained using image training data and the constructed deep learning optimization algorithm AdamW_AGC to obtain a trained image classification deep neural network model, thereby realizing large-scale image classification, including the following steps: S1. A data preprocessing module is used to obtain gastrointestinal image data for preprocessing, construct a data set, and randomly divide the preprocessed gastrointestinal images into a training set and a test set; S2. Feature extraction module, used to extract key features from the preprocessed image; S3. Image classification module, using the improved Adam algorithm (AdamW_AGC algorithm) to classify the image after feature extraction; S4. Result output module, used to display image classification results; S5. Evaluation module, evaluates the classification results.
[0009] The feature extraction module in step S2 uses a convolutional neural network in a deep learning network to extract key features from the image.
[0010] The improved Adam algorithm (AdamW_AGC algorithm) described in step S3 combines weight decay and adaptive gradient clipping strategy (Adaptive Gradient Clipping, AGC for short), and improves the generalization ability and training stability of the model by integrating weight decay and adaptive gradient clipping technology into the Adam optimization algorithm.
[0011] Weight decay is a common regularization technique used to prevent machine learning models from overfitting, thereby improving the model's generalization ability on data.
[0012] The adaptive gradient clipping technology (AGC) includes performing norm ratio calculation on the gradient of each model parameter and dynamically adjusting the clipping range of the gradient according to a set threshold.
[0013] The image classification module in step S3 uses the deep learning framework Pytorch and the improved AdamW_AGC algorithm to perform effective image classification.
[0014] The result output module in step S4 displays the classification results through a graphical user interface and provides necessary information.
[0015] The evaluation results in step S5 include classification accuracy and loss value to assist clinicians in making accurate diagnoses.
[0016] Compared with the prior art, the technical solution of the present invention has the following beneficial effects: The present invention proposes an improved optimization algorithm based on Adam, the AdamW_AGC algorithm, which aims to enhance the efficiency and effect of deep learning model training by integrating weight decay and adaptive gradient clipping mechanism. The addition of weight decay prevents overfitting of machine learning models and enhances the generalization ability of the model on data; adaptive gradient clipping can adaptively adjust the size of gradient clipping to prevent gradient explosion and gradient disappearance problems. Thereby improving training stability, enhancing the generalization ability of the model and improving the final performance. At the same time, the system has shown good stability and generalization ability in practical applications, providing strong support for the diagnosis of gastrointestinal diseases. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of a gastrointestinal image classification method based on an improved Adam optimization algorithm provided by the present invention; Figure 2 It is the accuracy of a gastrointestinal image classification method based on an improved Adam optimization algorithm provided by the present invention on gastrointestinal images; Figure 3 It is the loss value of a gastrointestinal image classification method based on an improved Adam optimization algorithm provided by the present invention on gastrointestinal images. DETAILED DESCRIPTION
[0018] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0019] The present invention proposes a gastrointestinal image classification method based on an improved Adam optimization algorithm. A new optimization algorithm AdamW_AGC is obtained by combining the weight decay method and the adaptive gradient method, and the input image is classified using the existing deep network model.
[0020] In one embodiment, Figure 1As shown, a gastrointestinal image classification method based on an improved Adam optimization algorithm comprises the following steps: S1. Data preprocessing module, which obtains gastrointestinal image data for preprocessing, constructs a data set, and randomly divides the preprocessed gastrointestinal images into a training set, a validation set, and a test set; Specifically, the gastrointestinal tract images are gastrointestinal tract images in the HyperKvasir dataset. The experimental images are preprocessed to obtain the preprocessed images through operations such as cropping and normalization.
[0021] S2. Feature extraction module, used to extract key features from the preprocessed image; Specifically, the feature extraction module uses the Mobilenetv2 lightweight network in the deep learning network to extract key features from the preprocessed image.
[0022] S3. Image classification module, using the improved Adam algorithm (AdamW_AGC algorithm) to classify the image after feature extraction; Specifically, the improved Adam algorithm (AdamW_AGC algorithm) combines weight decay and adaptive gradient clipping strategy (Adaptive Gradient Clipping, referred to as AGC).
[0023] S4. Result output module, used to display image classification results; Specifically, the result output module displays the classification results through a graphical user interface and provides necessary information.
[0024] S5. Evaluation module, evaluating the classification results; Specifically, the evaluation results include classification accuracy and loss value, which are compared with the results of other algorithms and follow the advantages of the improved algorithm to assist clinicians in making accurate diagnoses.
[0025] The present invention defines the following models and parameters: The traditional Adam algorithm combines the idea of moment estimation and dynamically adjusts the learning rate by calculating and correcting the first-order and second-order moments of each round of gradients. It is a variant of the gradient descent algorithm used to update the weights of the neural network. It combines the stochastic gradient descent algorithm (SGD) and the adaptive learning rate algorithm to converge quickly and reduce training time. The Adam algorithm calculates an independent adaptive learning rate for each parameter and does not require manual adjustment of the learning rate, so it is widely used in practice. The algorithm has the advantages of fast convergence speed and low memory requirements. Its optimization algorithm is defined as: Among them, is the gradient at time step t, m t and v t They are first-order moment estimation and second-order moment estimation. When the initial time and decay rate are very small, the moment estimation value will be biased towards 0; parameter β 1 , β 2 ∈[0,1) represents the exponential decay rate of controlling the first-order moment and the second-order moment; and is the bias-corrected exponential moving mean and squared gradient; η is the learning rate, and ε is a sufficiently small value greater than 0.
[0026] For the AdamW_AGC algorithm, this algorithm combines weight decay and adaptive gradient clipping technology. When weight decay is applied, the model parameters are regularized by adding a weight decay term to the loss function to reduce the complexity of the model and enhance the generalization ability of the model. The weight decay regularization term formula of the AdamW_AGC algorithm is: θ=θ·(1-η·λ)(6) Where λ is the value of weight decay. Adaptive gradient clipping (AGC) is performed before parameter update, and the clipping threshold is dynamically adjusted according to the gradient norm to control the gradient within an appropriate range. When the gradient norm exceeds the clipping threshold, the gradient is scaled to within the threshold, and when the gradient norm is within the threshold range, the gradient remains unchanged. The formula for adaptive gradient clipping is: Where τ is the AGC clipping threshold. By fine-tuning the gradient value, the stability and efficiency of the training process are ensured, and the gradient explosion or vanishing problem is prevented. This is a key stability control mechanism in the algorithm. The specific algorithm process is shown in Table 1.
[0027] Table 1 The process of improving the algorithm
[0028] The above improved algorithm was experimented on MNIST and HyperKvasir datasets. First, Figure 2 and Figure 3 This indicates that the improved algorithm shows better performance compared with other optimization algorithms on the HyperKvasir dataset. Afterwards, the algorithm was verified on the classic MNIST dataset. Compared with other optimization algorithms, the AdamW_AGC algorithm still achieved good performance.
[0029] The HyperKvasir dataset is a medical image dataset focusing on gastrointestinal diseases. The dataset was collected from the same Belum Hospital from 2008 to 2016 and contains more than 110,000 high-quality images and a large amount of video data. More than 110,000 high-quality images and a large amount of video data, annotated by professional medical experts. This dataset is valuable for automatic detection of gastrointestinal diseases, classification research, and medical education. It is of great value in education. By applying machine learning and data analysis, HyperKvasir can promote technological development in the medical field and improve the accuracy of clinical diagnosis. This paper uses 1885 labeled images from the HyperKvasir public dataset for experiments.
[0030] The MNIST dataset is a very classic dataset in the field of machine learning. It consists of 70,000 images and contains 10 categories. Each sample is a 28×28 pixel grayscale handwritten digit image from 0 to 9.
[0031] The programming languages used in the present invention are python and pytorch framework. Table 2 shows the accuracy and loss values of the optimization algorithm of the present invention and the existing deep learning optimization algorithm on the HyperKvasir and MNIST data set test sets.
[0032] Table 2 Accuracy and loss values of HyperKvasir and MNIST datasets on the test set
[0033] According to the accuracy and loss values of the HyperKvasir dataset on the test set in Table 2, it can be concluded that the accuracy of the AdamW_AGC algorithm is 75.8% and the loss value is 0.7556. In this set of data, AdamW_AGC performs best. It not only has the highest accuracy, but also the lowest loss value, which shows that it is the best choice in terms of accuracy and ability to fit data. In the MNIST dataset, the algorithm also shows good performance. These results also emphasize the importance of choosing a suitable optimizer for the performance of deep learning models.
[0034] The results show that the method and system of the present invention can effectively improve the accuracy of gastrointestinal image classification and have important practical application value for the automated analysis and diagnosis of medical images.
[0035] The above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A gastrointestinal image classification method based on an improved Adam optimization algorithm, characterized in that: The method comprises the following steps: S1. Data preprocessing module, which obtains gastrointestinal image data for preprocessing, constructs a data set, and randomly divides the preprocessed gastrointestinal images into a training set and a test set; S2. Feature extraction module, used to extract key features from the preprocessed image; S3. Image classification module, using the improved Adam algorithm (AdamW_AGC algorithm) to classify the image after feature extraction; S4. Result output module, used to display image classification results; S5. Evaluation module, evaluates the classification results.
2. A gastrointestinal image classification method based on an improved Adam optimization algorithm according to claim 1, characterized in that: The feature extraction module in step S2 uses a convolutional neural network in a deep learning network to extract key features from the image.
3. The gastrointestinal image classification method based on the improved Adam optimization algorithm according to claim 1, characterized in that: The improved Adam algorithm (AdamW_AGC algorithm) described in step S3 combines weight decay and adaptive gradient clipping strategy (Adaptive Gradient Clipping, AGC for short), and improves the generalization ability and training stability of the model by integrating weight decay and adaptive gradient clipping technology into the Adam optimization algorithm.
4. The gastrointestinal tract image classification method based on the improved Adam optimization algorithm according to claim 3, characterized in that: The weight decay is a common regularization technique used to prevent overfitting of machine learning models, thereby improving the generalization ability of the model on data.
5. The gastrointestinal tract image classification method based on the improved Adam optimization algorithm according to claim 3, characterized in that: The adaptive gradient clipping technology (AGC) includes calculating the norm ratio of the gradient of each model parameter and dynamically adjusting the gradient clipping range according to a set threshold.
6. The gastrointestinal tract image classification method based on the improved Adam optimization algorithm according to claim 1, characterized in that: The image classification module in step S3 uses the deep learning framework Pytorch and the improved AdamW_AGC algorithm to perform effective image classification.
7. The gastrointestinal image classification method based on the improved Adam optimization algorithm according to claim 1, characterized in that: The result output module in step S4 displays the classification results through a graphical user interface and provides necessary information.
8. The gastrointestinal tract image classification method based on the improved Adam optimization algorithm according to claim 1, characterized in that: The evaluation results in step S5 include classification accuracy and loss value to assist clinicians in making accurate diagnoses.