# PELM: A Deep Learning Model for Early Detection of Pneumonia in Chest Radiography
## 3 Materials and Methods
### Model Architectures  
We explored several CNN architectures to determine the most effective model for diagnosing pneumonia from chest X-rays. The models included were as follows:  
* VGG16 is a 16-layer deep CNN known for its uniform and straightforward architecture. It consists of stacked 3 \(\times\) 3 convolutional layers followed by max-pooling layers, concluding with three fully connected layers. Despite having around 138 million parameters, VGG16 remains a popular backbone for transfer learning due to its strong performance on large-scale datasets like ImageNet. An overview of the adapted model used in our experiments is shown in Figure 6.
* ResNet50 is a 50-layer network that introduces residual connections to enable efficient training of deep networks. It uses identity and convolutional blocks with bottleneck layers for dimensionality reduction. With approximately 25.6 million parameters, ResNet50 is widely adopted for its generalization and ease of optimization. An overview of the adapted model used in this work is illustrated in Figure 7.
* InceptionV3 employs factorized and asymmetric convolutions to reduce computational cost while preserving expressiveness. It also integrates auxiliary classifiers to aid in training deeper networks. With \(\sim\)23.5 million parameters, it supports larger input sizes and excels in multi-scale feature extraction. An overview of the adapted version used in this work is illustrated in Figure 8.  
The Vision Transformer (ViT) applies transformer architecture to image patches, enabling global attention across the spatial domain. It divides the image into non-overlapping patches and processes them using multi-head self-attention mechanisms. ViT excels at capturing long-range dependencies and has demonstrated competitive performance on visual recognition tasks. In this study, ViT operates on 112 \(\times\) 112 images, partitioned into 49 patches of size 16 \(\times\) 16 \(\times\) 3. Each patch is embedded into a 768-dimensional vector, forming a 50 \(\times\) 768 sequence after adding the class token. The transformer encoder processes this sequence through 12 layers, leveraging attention heads to capture inter-patch dependencies. With these matrices computed, the self-attention mechanism within the MHA block is executed using the following equation:  
\[\textit{Attention}\ (Q,\textit{K},\textit{V})=\textit{softmax}\ ((Q*K^{T})/\textit{sqrt} \ (d_{K})), \tag{1}\]  
Compared to CNNs, which extract spatial features hierarchically through local filters, ViT offers a global attention mechanism that effectively models long-range relationships. This makes it particularly well-suited for medical imaging tasks where contextual awareness is crucial. An illustration of the ViT architecture is shown in Figure 9. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Training** & **Validation** & **Test** \\ \hline Pneumonia & 20,000 & 2500 & 2500 \\ Normal & 18,000 & 2250 & 2250 \\ Other Findings & 2000 & 250 & 250 \\ Total & 40,000 & 5000 & 5000 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Distribution of the augmented dataset. Figure 6: The structure of the adapted VGG16-based model. Figure 7: The structure of the adapted ResNet50-based model. Figure 8: The structure of the adapted InceptionV3-based model. The objective of the proposed PELM architecture is to effectively extract and combine rich feature representations from chest X-ray images for the binary classification of pneumonia and normal cases. As illustrated in Figure 10, the model leverages four high-performing pre-trained networks: InceptionV3, VGG16, ResNet50, and the Vision Transformer (ViT). Before feature extraction, all input chest X-ray images are standardized to a resolution of 224 \(\times\) 224 pixels to maintain compatibility with the pre-trained models. These backbone architectures were initially trained on the ImageNet dataset [27], enabling the transfer of generalized visual features to the medical imaging domain. Figure 9: Details of ViT architecture.