## 3 Methodology  
### Dataset  
In this work, the kaggle chest X-ray pneumonia database was used, which is comprised of 5247 chest X-ray images with resolutions varying from 400p to 2000p [53]. Out of 5247 chest X-ray images, 3906 images are from different subjects affected by pneumonia (2561 images for bacterial pneumonia and 1345 images for viral pneumonia) and 1341 images are from normal subjects (Table 1). Mixed viral and bacterial infection occurs in some cases of pneumonia. However, the dataset used in this study does not include any case of viral and bacterial co-infection. This dataset was segmented into the training and test set.  
\begin{table}
\begin{tabular}{c c} \hline
**Type** & **Number of X-ray Images** \\ \hline Normal & 1341 \\ \hline Bacterial Pneumonia & 2561 \\ \hline Viral Pneumonia & 1345 \\ \hline Total & 5247 \\ \hline \end{tabular}
\end{table}
Table 1: Complete dataset details.  
Figure 5: DenseNet201 architecture.  
Figure 6: SqueezeNet architecture.  
Table 2 shows a number of train (using augmentation) and test images for different evaluation experiments. Four different algorithms were trained using the training dataset and then evaluated on test dataset. Figure 7 shows two samples for normal, bacterial, and viral pneumonia chest X-ray images.  
In this study, MATLAB (2019a) was utilized to train, evaluate, and test different algorithms. Figure 8 illustrates the overview of the methodology of this study. Image sets undergo some pre-processing steps, data augmentation, and then training using pre-trained algorithms: AlexNet, ResNet18, DenseNet201, and SqueezeNet, and all the tested algorithms on the test dataset. The training of the different models was carried out in a computer with Intel(c) i7-core @3.6 GHz processor and 16 GB RAM, 2 GB graphics card with graphics processing unit (GPU) on 64-bit Windows 10 operating system. Different parameters used for training the CNN models were shown in the Table 3. ResNet and DenseNet have different variants; however, ResNet18 and DenseNet201 were readily available for Matlab 2019a and therefore used in this study. Moreover, ResNet18 outperforms other ResNet models in terms of radiographic classification.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Software**} & \multicolumn{2}{c}{**Pre-Trained**} & \multicolumn{2}{c}{**Image**} \\  & **CNN Models** & **Size** & **Optimization** & **Momentum** & **Mini-Batch** & **Learning Rate** \\ \hline \multirow{4}{*}{**Matlab**} & AlexNet & 227 \(\times\) 227 & \multirow{4}{*}{Gradient Descent} & \multirow{4}{*}{0.9} & \multirow{4}{*}{16} & \multirow{4}{*}{0.0003} \\  & ResNet18 & 224 \(\times\) 224 & & & \\ \cline{1-1} \cline{2-5}  & DenseNet201 & 224 \(\times\) 224 & & & \\ \cline{1-1} \cline{2-5}  & SqueezeNet & 227 \(\times\) 227 & & & \\ \hline \hline \end{tabular}
\end{table}
Table 3: Training parameters of different pre-trained CNN models.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Types**} & \multicolumn{3}{c}{**Training Set**} \\  & & **(Using Augmentation)** & **Test Set** \\ \hline \multirow{2}{*}{**Normal and Pneumonia**} & Normal & 4500 & 205 \\ \cline{2-3}  & Pneumonia & 4500 & 214 \\ \hline \multirow{2}{*}{Normal, Bacterial, and Viral Pneumonia} & Normal & 4500 & 199 \\ \cline{2-3}  & Bacterial Pneumonia & 4500 & 197 \\ \cline{2-3}  & Viral Pneumonia & 4500 & 201 \\ \hline \multirow{2}{*}{Bacterial and Viral Pneumonia} & Bacterial Pneumonia & 4500 & 197 \\ \cline{2-3}  & Viral Pneumonia & 4500 & 201 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Details of the training and test set.  
Figure 7: Data samples from the dataset, (**A**) shows normal cases, (**B**) shows bacterial pneumonia cases, and (**C**) shows viral pneumonia cases.