Medical image classification method based on deep learning algorithm
By introducing the CG-Adam algorithm into machine learning algorithms, using control restart strategy and joint cutting technology of gradient and norm, the existing algorithms are solved, and the accuracy and efficiency of existing algorithms are insufficient in medical data processing, achieving higher diagnostic accuracy and efficiency.
Patent Information
- Application Number
- CN202411773462.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
AI Technical Summary
When existing machine learning algorithms process complex medical data, they lack accuracy and efficiency, making it difficult to fully capture key features, resulting in unstable classification performance, especially when facing different types of data, their adaptability and generalization capabilities are limited.
An improved optimization algorithm is proposed, called the CG-Adam algorithm. By controlling the restart strategy and the joint cropping of gradients and norms, it avoids gradient explosion and gradient disappearance problems, and improves the convergence stability and efficiency of the optimization process.
The CG-Adam algorithm significantly improves the diagnostic accuracy and efficiency of medical data sets, avoids the model from falling into local optimal solutions, enhances global search capabilities, and performs better than traditional Adam algorithms, especially when processing medical data.
Smart Images

Figure SMS_3 
Figure SMS_7 
Figure SMS_13
Abstract
Description
Technical Field
[0001] The present invention relates to the field of medical image processing technology, and in particular to a medical image resolution method based on a deep learning algorithm. Background Art
[0002] Gastroenterology involves a range of diseases that affect the stomach and intestines, such as gastritis, peptic ulcers, and irritable bowel syndrome (IBS), which often present with symptoms such as abdominal pain, bloating, and indigestion. The causes of gastrointestinal disease are complex and varied, including infection, long-term use of nonsteroidal anti-inflammatory drugs, stress, and poor eating habits. Diagnostic methods usually include endoscopy, laboratory tests, imaging tests, and biomarker analysis to determine the type and severity of the disease. Treatment options include drug therapy, such as proton pump inhibitors and antibiotics, dietary management, such as adjusting dietary structure and avoiding irritating foods, and lifestyle adjustments, including reducing stress, quitting smoking, and increasing exercise. Through comprehensive diagnosis and personalized treatment plans, gastrointestinal symptoms can be effectively managed and relieved, improving the quality of life of patients.
[0003] There are many types of gastrointestinal diseases with complex symptoms, such as abdominal pain, bloating, and indigestion. These non-specific symptoms increase the difficulty of diagnosis. Although traditional diagnostic methods (such as endoscopy and laboratory tests) are effective, the process is cumbersome and time-consuming, relies on the doctor's experience, and causes discomfort to patients. Existing machine learning algorithms often lack accuracy and efficiency when processing complex medical data, and it is difficult to fully capture key features, resulting in unstable classification performance. In addition, when faced with different types of data (such as images and text), the adaptability and generalization capabilities are limited, and the actual application performance is poor. Therefore, it is of great clinical significance and application value to develop more accurate and efficient machine learning models to improve the accuracy and efficiency of gastrointestinal disease diagnosis.
[0004] Therefore, proposing an effective algorithm to improve the accuracy of diagnosis of medical diseases is a problem that technical personnel in this field need to solve. Summary of the invention
[0005] The present invention proposes an improved optimization algorithm, called CG-Adam algorithm, which controls the restart strategy by periodically checking the number of steps. Once the number of steps reaches the preset restart period, the restart operation will be performed. This helps the algorithm avoid falling into the local optimum and maintain convergence stability. At the same time, the joint clipping of gradient and norm combines the two technologies of gradient clipping and norm clipping. By limiting the gradient and norm to a suitable range, the gradient explosion and gradient vanishing problems can be avoided, and it helps to accelerate the convergence of the optimization process.
[0006] To achieve the above objectives, this experiment adopts the following technical solutions: The specific steps of the algorithm are as follows: Initialization: Set the initial values of momentum m0 and v0 to 0. Initialize t' to 0, indicating the cycle count. Initialize restart_step to 0 to control the restart strategy. Set the initial step number of the optimizer to 0; Cycle Optimization: For each cycle t, perform the following steps: Calculate the gradient: Use the current parameters to calculate the gradient g of the loss function with respect to the parameters t . Update the first-order and second-order moments: Use the Adam algorithm to update the first-order moment m t and the second moment v t ; Check if restart is needed: if t' is equal to 0, reset restart_step to 0. Perform optimization: If restart is not required, the following substeps are performed: Calculate the estimates of the first-order and second-order moments: Using the current step number t', calculate the estimates of the first-order and second-order moments and Update parameters: For each parameter θ, do the following: Calculate the first-order m t′ and the second moment v t′ . Clip the gradient to ensure that the norm of the gradient does not exceed the threshold clip_value. Calculate the step size step_size and use the update formula to update the parameter θ; Update cycle counter: Update t' to the value of the next cycle and update restart_step; Return result: Return the final optimized parameter θ t . BRIEF DESCRIPTION OF THE DRAWINGS
[0007] In order to test the performance of the CG-Adam algorithm on medical datasets and highlight the comparison of comparative experiments, ShuffleNetV2 and MobileNetV2 lightweight neural networks were used on two datasets consisting of color RGB images CIFAR10 and gastrointestinal diseases. In this experiment, the convergence process of the five algorithms was demonstrated by taking the cross dataset as an example; Under the ShuffleNetV2 lightweight neural network, the performance of the five algorithms, CG-Adam, SGD, Adagrad, Adam, and Nadam, on the public dataset CIFAR10 and the medical dataset gastrointestinal diseases is as follows: Figure 1 , Figure 2 As shown; Figure 1 : Performance comparison of five algorithms with different learning rates on the CIFAR10 dataset. The left figure (a) is a comparison of accuracy. The right figure (b) is a comparison of loss values; Figure 2:Comparison of five algorithms on the gastrointestinal disease dataset. The left figure (a) is the comparison of accuracy, and the right figure (b) is the comparison of loss value; Under the MobileNetV2 lightweight neural network, the performance of the five algorithms, CG-Adam, SGD, Adagrad, Adam, and Nadam, on the public dataset CIFAR10 and two medical datasets for gastrointestinal diseases is shown below. Figure 3 , Figure 4 As shown; Figure 3 : Performance comparison of five algorithms with different learning rates on the CIFAR10 dataset. The left figure (a) is a comparison of accuracy. The right figure (b) is a comparison of loss values; Figure 4 :Comparison of five algorithms on the gastrointestinal disease dataset. The left figure (a) is the comparison of accuracy, and the right figure (b) is the comparison of loss value. DETAILED DESCRIPTION
[0008] The following examples are only used to illustrate the present invention, and the embodiments of the present invention are not limited to the following examples. Various other corresponding changes and modifications made according to the technical solutions and concepts described below are within the protection scope of the claims of the present invention.
[0009] Unless otherwise stated, the various data sets, parameter settings, model training and testing methods used in the following embodiments are all data sets, parameter settings, model training and testing methods conventionally used in the art.
[0010] Experimental steps: Algorithm: The experiment uses SGD, Adagrad, Adam, Nadam, and CG-Adam algorithms as experimental objects for comparison; Epochs: The epoch in the experiment is set to 100 to ensure that the algorithms are compared under the same number of training rounds; Batch size: Set the batch size to 128 to keep the experiment consistent; Learning rate: The initial learning rate of all algorithms in the experiment is set to 0.001; Network model: This experiment selected two lightweight networks, MobileNetV2 and ShuffleNetV2, to better verify the experimental results; Multiple experiments: Since the restart cycle and cropping value of the CG-Adam algorithm need to be adjusted, multiple experiments will be performed on each dataset and the best result will be selected as the experimental result.
[0011] Experimental results: 15 comparative experiments were conducted on the five algorithms on the CIFAR10 and gastrointestinal disease datasets, and the average of the 15 results was taken as the final result to reflect the accuracy of the CG-Adam algorithm in improving the medical dataset.
[0012] The present invention defines the following models and parameters: The Adam optimization algorithm is defined as: Among them, is the gradient at time step t, m t and v t They are the first-order moment estimation and the second-order moment estimation, respectively. When the initial time and decay rate are very small, the moment estimation value will be biased towards 0; the parameters β1, β2∈[0,1) represent the exponential decay rate of 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.
[0013] The formula of CG-Adam control restart strategy t is the current iteration number, mod represents the modulus operation, and when the restart cycle is executed, t'=t mod T represents the control of the step count within a cycle T. The step counter t' indicates the number of steps in the current cycle. At the beginning, t' is initialized to 0, and as the optimization process proceeds, the value of t' increases by 1 for each step. When t' reaches the cycle length T, t' is reset to 0 to restart the counting, thus completing a cycle. The introduction of this restart cycle effectively controls the step count of the optimization algorithm, so that the number of steps in each cycle can be well controlled and managed, thereby improving the stability and efficiency of the optimization algorithm.
[0014] t'=tmodT m t′ =β1m t′-1 +(1-β1)g t v t′ =β2v t′-1 +(1-β2)g t 2 The modified Adam optimization algorithm makes important changes to the Adam algorithm by introducing a control restart strategy and corresponding parameter update rules. The control restart strategy converts the timestamp t to t', and through t'=t mod T, the parameter update process has the characteristics of periodic adjustment, which can better adapt to the periodic changes of data distribution and model parameters. These adjustments not only take into account the bias correction and dynamic adjustment of the gradient estimation within each cycle, but also ensure the periodic impact of the bias correction, thereby improving the stability and generalization performance of the algorithm.
[0015] CG-Adam gradient and norm joint clipping formula: g t ′=g t / max(1,||g t ||2 / clip_value) denom represents the denominator in the step size adjustment. Denotes the bias-corrected second-order moment estimate, which is the moving average of the squared gradient. ∈ represents a small constant, usually used to prevent the denominator from being zero. By adding a small constant ∈ to the bias-corrected second-order moment estimate and then taking its square root, we ensure that the denominator term denom will not be too small. This helps avoid division errors caused by too small second-order moment estimates during parameter updates.
[0016] In the formula: The calculation of step size: step_size is based on the first-order moment estimate of the learning rate lr and the deviation correction In the formula The step_size is used to correct the deviation of the first-order moment estimate, ensuring a more accurate estimate when the deviation of the gradient estimate is large at the beginning of training. The step_size can be adjusted adaptively according to the actual situation. This adaptability can make the optimization algorithm better adapt to different data distributions, thereby improving the robustness and generalization performance of the algorithm.
[0017] In the formula: By comprehensively considering gradient normalization and step size control, the parameter update rule can effectively optimize the parameters and improve the performance and convergence speed of the optimization algorithm. At the same time, by adaptively adjusting the step size and normalized gradient, the algorithm's adaptability to different data is also enhanced.
[0018]
[0019] Table 1 The process of improving the algorithm
[0020] The above improved algorithms were experimented on CIFAR-10 and gastrointestinal datasets. First, Figure 2 and Figure 3 The performance of the improved algorithm on the gastrointestinal dataset was demonstrated and compared with other optimization algorithms, and the results showed good performance. Subsequently, the algorithm was applied to the CIFAR-10 dataset for verification experiments, and the results showed that it still achieved excellent performance compared with other optimization algorithms.
[0021] The Gastrointestinal dataset is a medical image dataset focusing on gastrointestinal diseases. It contains more than 110,000 high-quality images and a large amount of video data, which were collected and annotated by professional medical experts from the same Belum Hospital between 2008 and 2016. This dataset is of great value for automatic detection and classification of gastrointestinal diseases and medical education research. By applying machine learning and data analysis, the Gastrointestinal dataset helps to promote the development of medical technology and improve the accuracy of clinical diagnosis. This paper uses 1885 labeled images in this dataset for experiments.
[0022] The CIFAR-10 dataset is a very classic dataset in the field of machine learning. It consists of 60,000 images and contains 10 categories. Each sample is a 35×35 pixel color picture.
[0023] The programming languages used in the present invention are python and pytorch framework. Table 2 shows the accuracy and loss value of the optimization algorithm of the present invention and the existing deep learning optimization algorithm on the gastrointestinal disease and CIFAR-10 dataset test set.
[0024] Further analysis shows that this superiority mainly comes from the combination of gradient and norm joint clipping technology and controlled restart strategy in the CG-Adam algorithm. These improvements effectively avoid the gradient explosion and gradient vanishing problems, making the model more stable during training, and can adaptively adjust the learning rate, thereby accelerating the convergence speed. In addition, the CG-Adam algorithm avoids the model from falling into the local optimal solution by periodically restarting the optimization process, thereby improving the global search capability. These characteristics make CG-Adam perform better than the traditional Adam algorithm on various data sets, especially when processing medical data, it can provide higher diagnostic accuracy and reliability. In practical applications, these advantages of the CG-Adam algorithm can not only improve the performance of the model, but also reduce the consumption of training time and computing resources, and provide more efficient solutions. For the medical field, the improvement of accuracy and efficiency means that diseases can be discovered and diagnosed earlier, and timely treatment interventions can be provided, thereby improving the treatment effect and quality of life of patients. Therefore, the excellent performance of the CG-Adam algorithm on medical data sets further highlights its potential and value in promoting the advancement of medical technology.
Claims
1. An improved gastrointestinal disease image classification method based on deep learning algorithm, characterized in that: include: S1. Data loading and preprocessing: Load the gastrointestinal disease image dataset and perform denoising, normalization, and image resizing operations; S2. Data augmentation and partitioning: Perform data augmentation (rotation, flipping, scaling) and partition the dataset into training and validation sets. S3. Feature extraction: Use MobileNetV2 and ShuffleNetV2 lightweight neural networks for feature extraction; S4. Model initialization and training: Initialize model parameters and CG-Adam optimizer, and perform model training; S5. Parameter update: Calculate gradients, apply gradient and norm joint clipping method and control restart strategy, and update model parameters through CG-Adam optimizer; S6. Model evaluation and testing: Evaluate model performance on the validation set and test it on the test set; S7. Result Analysis and Visualization: Visualize the classification results, evaluate and analyze the model performance.
2. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: After data loading and preprocessing, it also includes: image denoising, normalization, and adjusting the image to a uniform size to ensure data consistency.
3. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: Step S3 uses MobileNetV2 and ShuffleNetV2 lightweight neural networks to extract image features, extracts key features in the image through the convolution layer, and uses them for subsequent model training.
4. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: In step S4, the model parameters are initialized, the initial learning rate, momentum factor and optimizer parameters are set, and the CG-Adam optimizer is used for training to improve the training stability and efficiency.
5. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: In step S5, by calculating the gradient, combining gradient clipping, norm clipping and control restart strategy, the CG-Adam algorithm is used to update the model parameters to improve the training effect and optimization efficiency.
6. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: Step S6 evaluates the model on the validation set, and performs a final test on the test set to calculate indicators such as accuracy, precision, recall, and F1 score to evaluate the model performance.
7. The improved gastrointestinal disease image classification method based on deep learning algorithm according to claim 1, characterized in that: In step S7, by analyzing the evaluation results, model optimization suggestions are put forward to improve the effect and reliability of the model in practical applications.