## 2 Proposed Method
### Normal vs. Pneumonia Infected Lungs  
The first scenario conducted is to test the proposed algorithm in a normal vs. infected lungs fashion including a mix of bacterial and viral infection CXR images. First, the confusion matrix of the proposed feature extraction method compared to deep-layer features is shown in Figure 7. The sensitivity, F1 score and accuracy are (99.4%, 99.2%, and 99.6% respectively compared to features extracted from deep bottleneck layers, i.e., when \(l\) is larger than 5. It is evident that in our case, going deeper in some applications and in particular using medical images for diagnosis could have a negative impact on system performance. Additionally, to illustrate the advantage of using the modified residual building blocks as an efficient feature extractor, we conducted the same experiment on most off-the-shelve deep networks as shown in Table 3. We extracted low-layer features  
Figure 6: Performance of proposed model using bacterial vs. viral pneumonia scenario. (**a**) is the feature space of bacterial vs. viral infected lung CXR images, and (**b**) is the SVM with Bayesian optimization of the proposed scenario.  
from these networks and our proposed method has the upper hand in terms of accuracy achieving 99.6%.  
Next, we compared our work with recent state-of-the-art methods for pneumonia diagnosis using CXR images as shown in Table 4. It is evident that the proposed method has outperformed recent transfer learning methods in terms of accuracy, training time, and complexity as only a few modified residual blocks are needed and trained to achieve higher accuracy on a simple PC providing a feasible solution. It is worth pointing out that our proposed method is slightly better than the work in [23] by only 0.02% and lower than the work in [33] by only 0.04%, our proposed method however utilizes only five residual building blocks densely connected to extract features. Whereas the method in [23] involves transfer learning and re-train three different deep networks extracting an abundance amount of features; the classification method in [33] uses mix of various algorithms such as PCA, CNN, CLAHE, and EML. As a consequence, more complex feature reduction and more processing time are required which subsequently increase system complexity. Besides, our proposed method uses an adaptive weight setting method to assign the decision power effectively to the best feature descriptor.  
Figure 7: The confusion matrices showing a comparison between (**a**) deep-layer features and (**b**) features extracted using proposed method.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Deep Network**} & \multirow{2}{*}{**Number of Layers**} & \multicolumn{2}{c}{**Accuracy (\%)**} \\ \cline{3-4}  & & **Deep Layer Features** & **Early Layer Features** \\ \hline AlexNet [5] & 8 & 96.0 & 97.3 \\ \hline VGG [17] & 19 & 96.8 & 98.4 \\ \hline SqueezeNet [13] & 14 & 96.7 & 96.0 \\ \hline GoogleNet [29] & 27 & 96.2 & 97.7 \\ \hline ShuffleNet [45] & 20 & 96.5 & 96.8 \\ \hline NASNetMobile [46] & 913 & 95.8 & 96.9 \\ \hline DenseNet [18] & 201 & 98.0 & 98.4 \\ \hline Xception [19] & 36 & 96.4 & 98.4 \\ \hline ResNet [6] & 50 & 97.6 & 97.1 \\ \hline Proposed method & 35 & na & 99.6 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of early-layer and deep-layer accuracy for pneumonia diagnosis using most off-the-shelf deep networks vs. proposed densely-connected residual blocks.  
Figure 8: The confusion matrix of the proposed model in a normal vs. bacterial vs. viral CXR images classification fashion using (**a**) deep features and (**b**) proposed features.