## 3 Materials and Methods
### Model Architecture and Training  
To identify GI diseases from WCE images, we present the ILRC mechanism aimed at optimizing the training of DL models. The ILRC adjusts the LR adaptively based on the progress of training, which improves convergence speed and reduces the risk of overfitting. The mechanism was tested on several DL models, including EfficientNet-B0, ResNet101, ResNet101v2, InceptionV3, and InceptionResNetV2. Furthermore, we enhanced these models by using traditional transfer learning, fine-tuning techniques, residual learning, and modern regularization methods. The models were fine-tuned with the Kvasir-Capsule and KVASIR v2 datasets for multi-class classification. The architecture of the DL models is illustrated in Figure 3, and the algorithm for fine-tuning the four DL models is described in Algorithm 1, and the algorithm of the ILRC is depicted in Algorithm 2. The steps for implementing the ILRC on the four DL models are as follows: **Phase 1** (pre-processing the Kvasir-Capsule and Kvasir v2 datasets): In the first phase, the Kvasir-Capsule dataset and Kvasir v2 were downloaded and pre-processed. The pre-processing step is critical because it can chip away at the accuracy of the results. In the pre-processing phase, the images of the Kvasir-Capsule dataset were under-sampled, augmented, normalized, and re-scaled. **Phase 2** (splitting the Kvasir-Capsule and Kvasir v2 datasets): In the second phase, the Kvasir-Capsule dataset was divided into three sets: a training set, a test set, and a validation set. The training set consists of 70% of the total data (26,453 samples), the test set consists of 15% (5669 samples), and the validation set consists of 15% (5669 samples). **Phase 3** (pre-training for the four DL models): The third phase was the supervised pre-training step of the transfer learning process. In the supervised pre-training step, the first step of the transfer learning process, the EfficientNet-B0, ResNet101v2, InceptionV3, and \begin{table}
\begin{tabular}{c c c} \hline \hline
**Class\#Id** & **Class Name** & **Test Set** \\ \hline
0 & dyed lifted polyps & 154.0 \\
1 & dyed resection-margins & 134.0 \\
2 & esophagitis & 140.0 \\
3 & normal cecum & 141.0 \\
4 & normal pylorus & 166.0 \\
5 & normal z-line & 154.0 \\
6 & polyps & 150.0 \\
7 & ulcerative colitis & 161.0 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The distribution of classes in Kvasir v2 in the test set. Figure 2: KVASIR v2 dataset. InceptionRestNetV2 models were trained on the ImageNet dataset. During the transfer learning process, we applied a freezing layer. This means that certain layers of a pre-trained model are locked, and their weights remain unchanged during the training on a new task or dataset, such as ImageNet. This is important because it allows us to leverage the general features learned by the model from ImageNet while focusing the training effort on specific parts of the model that are more relevant to the Kvasir-Capsule and Kvasir v2 datasets. **Phase 4** (fine-tuning): In the fine-tuning step, the second step of the transfer learning process, the four DL models were fine-tuned on the training set of the Kvasir-Capsule and Kvasir v2 datasets. **Phase 5** (applying the ILRC): by using the ILRC process, the four DL models were evaluated on the training sets of the Kvasir-Capsule and Kvasir v2 datasets. In this process, we first assessed the training set error. If the training set error was high, we re-trained the model. Conversely, if the training set error was low, we proceeded to calculate the test set error. If the test set error was also high, we re-trained the model again. **Phase 6** (multi-classification using the ILRC): We experimented with multi-classification. Additionally, we evaluated the performance of the four DL models with the ILRC using various metrics including accuracy, specificity, precision, and sensitivity. Figure 3: The overall model architecture.