# Enhancing an Imbalanced Lung Disease X-ray Image Classification with the CNN-LSTM Model
## 4 Results and Discussion  
### Determining the Optimal Number of Deep-Learning Layers  
In this section, there are two processes, determining the number of convolutional blocks and the number of LSTM layers. Two training scenarios were employed to determine the optimal number of convolutional blocks: one with four convolutional blocks and another with five convolutional blocks. Each convolutional block in this study consisted of two convolutional layers with a kernel size of 3 \(\times\) 3. Following the convolution-al layers, there was one layer of batch normalization and, subsequently, a layer of max pooling with a pool size of 2 \(\times\) 2. Additionally, a dropout layer with a parameter of 0.5 was added to the output layer in both scenarios. Figure 7 illustrates the architecture consisting of four convolutional blocks, with each block employing a distinct number of convolutional filters. Specifically, the convolutional filters used were 64, 128, 256, and 512 for the corresponding blocks. Figure 8 illustrates the architecture with five convolutional blocks. This architecture is similar to the one with four convolutional blocks, with the addition of an extra block that has a convolutional filter size of 512. Figure 6: Research scheme. \begin{table}
\begin{tabular}{c c} \hline \hline  & **Hyperparameters** \\ \hline Batch Size & 32 \\ \hline Optimizer & Adam \\ \hline Learning rate & \(5\times 10^{-6}\) \\ \hline Epochs & 65 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Hyperparameters Setup. From Table 4, it can be concluded that the second scenario, which utilizes a convolutional neural network with five convolutional blocks, achieves better performance than scenario 1, with an F1 score of 0.97. This indicates that increasing the number of convolutional blocks in the model allows for deeper and more comprehensive learning of the input data, resulting in improved performance. As the best scenario involves using five convolutional blocks, for the next step, which is determining the number of LSTM layers, we will proceed with the five convolutional layers in the model. The next step involves determining the optimal number of LSTM layers. Two scenarios are conducted, one with one LSTM layer and another with two LSTM layers. Since the LSTM layer accepts two-dimensional input while the output of the convolutional layer is three-dimensional, we need to reshape the convolutional output value to match the input shape required by the LSTM layer. The output value of the initial convolution, which is (2, 2, 512), is reshaped (4, 512) to serve as the input for the LSTM layer. Figure 9 presents the architecture of the CNN-LSTM model with one layer of LSTM. This architecture utilizes five convolutional blocks and incorporates an additional layer of LSTM with a unit size of 100. Consequently, the output shape of this model will be (100). Figure 10 presents the architecture with two layers of LSTM. This architecture is similar to the one with one layer of LSTM but includes an additional LSTM layer with a unit size of 50. As a result, the output shape will be (50). \begin{table}
\begin{tabular}{c c} \hline \hline
**Scenario** & **F1 Score** \\ \hline
4 convolutional blocks & 0.96 \\ \hline
5 convolutional blocks & 0.97 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Results for the Number of Convolution Blocks. Figure 8: Convolutional neural network with 5 convolution blocks. Figure 7: Convolutional neural network with 4 convolution blocks. Based on the findings presented in Table 5, it can be concluded that using two layers of LSTM leads to improved performance compared to using only one layer. The model with two LSTM layers achieves an F1 score of 0.99, indicating its effectiveness. This suggests that the deeper architecture with two layers of LSTM enables the model to capture more complex patterns and dependencies in the data, resulting in higher accuracy in classifying lung diseases.