# PneumoNet: Artificial Intelligence Assistance for Pneumonia Detection on X-Rays
## 3 Pneumonet Framework
### Pneumonia Classification Module  
As discussed in previous (sub)sections, AlexNet is an excellent base for the foundation of the pneumonia classification module, as it offers a good answer for this kind of assignment. The original AlexNet backbone is kept, but the original (head of the network) fully connected (FC) layers, the two 4096-unit and the 1000-unit layers, are eliminated because they are not suitable for binary classification. In their place, a custom stack emerges with three 3 \(\times\) 3 convolutional layers (CNN), each with 16 filters and same-padding to preserve dimensions, with the corresponding three batch normalisation (BN) to stabilise training and reduce covariate shift--a refinement  
Figure 1: Block diagram of the PneumoNet framework. Top left-centre is the PCM, right is the XAI module, and at the bottom is the MRM. over AlexNet's normalisation approach. A single ReLU layer introduces nonlinearity, followed by an FC layer sized 2 for the two classes, tuned with elevated learning rates (20\(\times\) for weights and biases) with a SoftMax for the classification layers (the source code can be found at: [[https://github.com/kucaantunes/PneumoNet-Automatic-Pneumonia-Detection-on-X-rays](https://github.com/kucaantunes/PneumoNet-Automatic-Pneumonia-Detection-on-X-rays)]([https://github.com/kucaantunes/PneumoNet-Automatic-Pneumonia-Detection-on-X-rays](https://github.com/kucaantunes/PneumoNet-Automatic-Pneumonia-Detection-on-X-rays)) (accessed on 13 January 2025)) probabilistic output. In summary, the head of the network has the following architecture: Conv_0 (3 \(\times\) 3, 16 filters) + BatchNorm + Conv_1 (3 \(\times\) 3, 16 filters) + BatchNorm + Conv_2 (3 \(\times\) 3, 16 filters) + BatchNorm \(\rightarrow\) ReLU + Fully Connected layer (2 neurones) + SoftMax + Classification Layer (Binary Cross-Entropy Loss). The architecture employs the Adam optimiser (learning rate 10\({}^{-4}\), minibatch size 128, 10 epochs), with validation checks every 50 iterations and early stopping after four stagnant cycles, optimising the network for pneumonia detection. This pneumonia classification module is expected to achieve higher accuracy than the current state-of-the-art models because it incorporates several advanced techniques and design choices tailored to medical image classification. The preprocessing step ensures uniformity across input images by handling variations in lighting, colour constancy, and dimensions. Additionally, the greyscale images are converted to three-channel RGB, making them compatible with AlexNet. Finally, the transfer learning approach with AlexNet allows the model to benefit from features learnt from large-scale datasets (in this case, ImageNet). The fine-tuning process, which involved adding custom convolutional layers and batch normalisation, enhanced feature extraction specific to the datasets. The use of the Adam optimiser, a carefully selected learning rate, and dynamic data shuffling ensures robust training and stable convergence. Early stopping based on validation patience prevents overfitting, further improving the model's generalisation to unseen data. For more details, see later on Algorithm 1. Tests, Validations, and Results Discussion  
The classification module, PCM, was trained on chest X-ray datasets, namely [8; 9; 10] individually and as an ensemble, organised into pneumonia and normal categories, split into 80% training, 20% testing, and 10% training for validation via stratification. Incorporating diverse and representative datasets, along with reporting of experimental details, further enhances the reliability and clinical applicability of PCM. These efforts would not only improve model validation but also foster collaboration and innovation in developing robust AI-driven diagnostic tools. Images are pre-processed to 227 \(\times\) 227 pixels, converted to RGB, normalised with colour constancy, and augmented with rotations (\(\pm\)5 deg), reflections, and shears (\(\pm\)0.05 radians) to enhance robustness.