# PELM: A Deep Learning Model for Early Detection of Pneumonia in Chest Radiography
## 3 Materials and Methods
### Model Architectures
Figure 10: Details of the proposed ensemble learning model PELM. Each base model in the PELM ensemble independently processes the input chest X-ray image of size 224 \(\times\) 224 \(\times\) 3 and extracts deep visual features through its respective convolutional and transformer layers. Rather than producing direct class probabilities, the models are modified to output intermediate feature representations optimized for pneumonia-related information. Let:  
* F1: Feature vector from InceptionV3, reduced to 80 dimensions;
* F2: Feature vector from VGG16, reduced to 2048 dimensions;
* F3: Feature vector from ResNet50, reduced to 512 dimensions;
* F4: Feature vector from Vision Transformer (ViT), reduced to 768 dimensions. Each of these outputs passes through a Last Identity Compensation Layer, aligning their feature shapes and scaling for concatenation. The resulting unified representation is as follows:  
\[F=[F_{1}\|F_{2}\|F_{3}\|F_{4}]\in R^{1\times 3408} \tag{2}\]  
This fused vector aggregates both local and global features, combining convolutional and transformer-based descriptors into a comprehensive feature profile. As illustrated in Figure 10, the concatenated feature vector \(F\) is passed to a fully connected classification head, composed of the following:  
* Batch Normalization layer: stabilizes feature distributions;
* Dense Layer 1;
* Dropout (rate = 0.4);
* Dense Layer 2;
* Dropout (rate = 0.3);
* Dense Layer 3;
* Output Layer: A single neuron with sigmoid activation. The output of the final layer is a scalar probability y predicted \(\in\)[0, 1] indicating the predicted likelihood of pneumonia. Binary classification is performed using a threshold of 0.5:  
\[ \begin{split}\text{y}^{-}=\sigma(WF+b)\Rightarrow\text{Prediction = 1 if y predicted \geq 0.5 (Pneumonia),}\\ \text{otherwise (Normal/Other Findings)}\end{split}  \tag{3}\]  
Each architecture processes the input image in parallel, extracting hierarchical and semantic features relevant to pneumonia diagnosis. To ensure compatibility and reduce dimensional complexity, a Last Identity Compensation Layer is applied to each model's output, followed by dimensional adjustments--80 neurons for InceptionV3, 2048 for VGG16, 512 for ResNet50, and 768 for ViT. These representations are then concatenated into a unified feature vector of size 3408, combining both local and global feature descriptors from each 568 model. To expedite training and mitigate overfitting, the weights of the four backbone models were frozen during the fine-tuning phase. Only the classification head--composed of batch normalization, multiple dense layers, and dropout layers (with dropout rates of 0.4 and 0.3)--was retrained using pneumonia-specific data. The training was conducted using both a large dataset containing five different thoracic diseases and a curated pneumonia subset, allowing the model to adapt effectively to domain-specific patterns. The final output layer produces binary predictions indicating the presence or absence of pneumonia. By integrating both convolutional and transformer-based feature representations and applying a structured dimensional alignment and fusion strategy, PELM offers a powerful, scalable, and clinically applicable framework for pneumonia diagnosis from chest X-ray images.