Multiscale Attention Guided Network for COVID-19 Diagnosis Using Chest X-Ray Images

Coronavirus disease 2019 (COVID-19) is one of the most destructive pandemic after millennium, forcing the world to tackle a health crisis. Automated lung infections classification using chest X-ray (CXR) images could strengthen diagnostic capability when handling COVID-19. However, classifying COVID-19 from pneumonia cases using CXR image is a difficult task because of shared spatial characteristics, high feature variation and contrast diversity between cases. Moreover, massive data collection is impractical for a newly emerged disease, which limited the performance of data thirsty deep learning models. To address these challenges, Multiscale Attention Guided deep network with Soft Distance regularization (MAG-SD) is proposed to automatically classify COVID-19 from pneumonia CXR images. In MAG-SD, MA-Net is used to produce prediction vector and attention from multiscale feature maps. To improve the robustness of trained model and relieve the shortage of training data, attention guided augmentations along with a soft distance regularization are posed, which aims at generating meaningful augmentations and reduce noise. Our multiscale attention model achieves better classification performance on our pneumonia CXR image dataset. Plentiful experiments are proposed for MAG-SD which demonstrates its unique advantage in pneumonia classification over cutting-edge models. The code is available at https://github.com/JasonLeeGHub/MAG-SD.


I. INTRODUCTION
T HE coronavirus disease 2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) is one of the most devastating infectious diseases after millennium [1]. This new type of coronavirus is announced in late December, 2019, then spread globally in 2020. It has been declared as a pandemic by World Health Organization (WHO) according to its high contagiosity and unprecedented pressure bought to public healthcare system [2]. The current gold-standard for screening COVID-19 is polymerase chain reaction (PCR) laboratory test, however, the test capacity is extremely limited and requires professional equipment [3]. [4] also reports that PCR tests suffers from high false negative rate.
Radiological images collected by X-ray and computed tomography (CT) are important complements to PCR tests. The virus leads to pneumonia, which is an inflammatory condition of the lung's air sacs [5]. Radiological signs show ground-glass opacity, airspace opacities and later consolidation with bilateral, peripheral, and lower zone predominant distributions [6]. Comparing with CT imaging, CXR diagnosis provides a low-cost and time-saving diagnosis method [7]. Besides, underdeveloped regions can hardly have sufficient CT scanners, making CT based COVID-19 screening impossible. X-rays are the most common diagnostic imaging equipment available even in rural regions, which means X-ray diagnosis can cover larger susceptible population [8].
Diagnosis accuracy of COVID-19 and radiography based infection localization are critical for treatment planning and follow-up evaluations [9]. However, pressure of pandemic forces physicians to evaluate in limited time, which raises misdiagnosis rate implicitly [10]. As a result, accurate and robust classification methods are required. This is challenging as COVID-19 is a new type of disease which has low amount of data comparing with available datasets, such as image data published by [11] or [12]. In addition, the COVID-19 shares characteristic with other types of pneumonia, which requires the method focus on both global and local features [13]. Moreover, varied parameter settings causes imparities when collecting X-ray image from different devices.
Massive radiological data and rapid developing computational power give artificial intelligence (AI) a chance to assist clinical diagnosis. Recently, classification of COVID-19 from radiological images have been explored. Wang and Wong [14] present a COVID-Net operated on CXR images to classify COVID-19 from pneumonia and normal cases. COVID-19 cases are extracted from online COVID-19 datasets published by [15] and [16]. Non-COVID-19 image includes 1591 pneumonia images and 1203 normal images released by National Institutes of Health Clinical Center [17]. The experimental results showed that classification method with residual projection-expansionprojection-extension (PEPX) design pattern achieves 93.3% accuracy, which is better than general deep models such as VGG-19 (83.0% Accuracy) and ResNet-50 (90.6% Accuracy). The authors illustrate the locations focused by their model to visualize its decision making process. Ghoshal and Tucker [18] present a Bayesian CNN to make diagnosis through model uncertainty. It is trained on 68 COVID-19 cases from [15] and Non-COVID-19 cases from Kaggle's Chest X-ray Images (Pneumonia) [19], which improve the classification accuracy of a standard ResNet50V2 model from 86.0% to 89.8%. The authors further discuss the effectiveness of uncertainty-aware classification by decision visualization.
Zhang et al. [20] design a screening method based on ResNet to detect COVID-19 and find abnormalities from CXR images. Images are evaluated by an abnormity detecting module producing reference score to optimize classification loss. The model is trained on 70 COVID-19 images and 1008 non-COVID-19 images, which reaches 96.0%, 70.7%, 95.2% in Sensitivity, Specificity and AUC respectively.
Generally, current studies operated on CXR images mostly depends on online datasets with limited COVID-19 cases. Insufficient data can hardly evaluate the robustness of the models and restricted their generalizability. Models trained on extremely imbalanced dataset also lead to long-tail distribution problems. Although plenty of works have discussed diagnosing COVID-19 by AI, few works address the problem of imbalanced data and limited size of dataset because of several issues: 1) Models trained by imbalanced data tend to classify all the targets to the dominant class which has overwhelmingly more labels than other classes. 2) Unique labels on X-ray image, such as L/R position labels, easily attract model's attention then mislead the predictions. 3) COVID-19 cases share features with non-COVID cases, which requires a sensitive and robust model to do classification.
These challenges inspired us to treat pneumonia classification as a Fine-Grained Visual Classification (FGVC) problem, which aims at classifying sub-level categories under a basic-level category. FGVC cases are similar apart from some minor differences and also has the problem of lacking training data. Classic Convolutional Neural Networks (CNNs), including VGG [21], ResNet [22] and Inception [23], has difficulties handling this problem. We propose a novel Multiscale Attention Guided deep network with Soft Distance regularization (MAG-SD) for COVID-19 CXR image classification. To balance the quantity of different data, a weakly-supervised method is presented, which requires a few labeled data to do effective augmentations. Multiscale strategy is applied to attention generator, producing detailed scalar matrix for prediction. Our classification model is motivated from the fact that clinical diagnosis of COVID-19 follows a procedure which firstly evaluates the regional appearance, then makes diagnosis exclusively. Thus, we propose a multiscale attention module which estimates both shallow and deep layers. Comparing with using feature maps from only highest level features, the utilization of lower features could increase its ability of finding fine-grained features. Moreover, a soft distance regularization method is integrated to refine classification result by adaptively adjusting classification loss. In a nutshell, contribution of this paper is threefold: 1) We design a novel deep network, MA-Net, to treat COVID-19 diagnosis as a FGVC problem. Multiscale attention is introduced to assess attention maps on multi level features. Composed attention maps are used as guidance for training steps. Attention pooling is proposed to utilize attention maps for classification.
2) We address data shortage by proposing attention guided data augmentation and multi-shot training phase. It includes attention mix-up, attention patching and attention dimming that could enhance and search local feature then generating data. Models are trained on imbalanced COVID-19 datasets and achieve the state-of-the-art.
3) Without introducing other modules or parameters, we formulate a new regularization term utilizing soft distance between predictions, which works as a constraint to limit classifiers from producing contradicted output for one target.
This paper is organized as follows. In Section II, we introduce insightful works which have high relevance with our contribution. Section III presents the proposed method. In Section IV, database and experimental setup are reported in detail, then results are presented and discussed individually. The last section concludes this study and highlights the future work.

II. RELATED WORKS
Related works are introduced in this section, including X-ray appearance for typical pneumonia, fine-grained visual classification, attention mechanism for CNNs and multiscale feature fusion utilized in computer vision.

A. Pneumonia X-Ray Imagery
Chest X-ray is a widely used imaging modality providing high-resolution pictures to visualize the pathological changes of thoracic diseases. Diagnosis could be made according to the visual patterns demonstrated on CXR images [19]. Clinical research from Katz and Leung [24] demonstrated that typical image pattern for bacterial pneumonia includes opacity of single lobe and pleural effusion. Viral pneumonia also has radiological appearance such as pulmonary edema, small area of effusions, consolidation or lobe mass. Reports from [25], [26], demonstrated that the most common pattern on CXR in COVID-19 was consolidation or ground-glass opacity. It is notable that COVID-19 shares some visual feature with viral pneumonia while viral and bacterial pneumonia can hardly be differentiated because of similar spatial appearance.

B. Fine-Grained Visual Classification
Mass application of CNNs revealed its advantage in solving large scale image classification problem [27] and illuminated a promising way to settle FGVC tasks by using CNN models to explore inconspicuous local features. Some models relied on local annotations to train part-based detectors, localizing certain parts before prediction [28], [29]. However, local feature annotation requires expensive human labor, limiting its reproducibility in reality. Recently, approaches only require global labels also emerged whose motivation was to first localize the corresponding parts and then compare their local features [30]. Fu et al. [31] introduced WS-DAN, which was a weakly supervised deep network handling FGVC by posing attention to enhance local feature and guide augmentation. FGVC was also a common problem in medical image because of spatial similarity between infections. Qin et al. [32] proposed a fine-grained classification CNN for different types of lung cancer in PET and CT Images.

C. Attention for CNNs
For visual task, attention usually indicates a scalar matrix representing the relative importance and inner relevance of local feature [33]. This nonuniform representation was produced by special designed modules [34]. Works reported that applying attention on classification oriented CNN could provide an intuitional way to localize target object, helping to identify visual properties through local representation. An attention guided method demonstrated by Gondal et al. [35] reported that attention mechanism is helpful in Diabetic Retinopathy (DR) localization and recognition. Zhang et al. [36] regulated the attention of deep model by training self-attention blocks for skin lesion classification and surpassed the baselines. Generally, attention mechanism guide the models to analyze global and local features simultaneously then generate believable classification results.

D. Multiscale Feature Fusion
Extracting hybrid feature maps from multi-resolution input image is a common strategy in computer vision since the the era of hand-engineered features. CNNs have an inherent multiscale feature in pyramidal shape, which is advantageous in producing semantically strong representations if effective feature fusion is operated. Models such as U-Net [37] and V-Net [38] exploited skip connections to associate feature maps across resolutions. FPN [39] leveraged the prediction of multiscale hierarchy by generating multiple prediction. For CXR image, Huang et al. [40] presented weight concatenation method to cooperate global and local feature. Thriving of spatial attention gave inspiration to extract attention from multi-resolution feature map. Sedai et al. [41] proposed A-CNN for chest pathologies localization, which utilized multiscale attention by calculating convex combination from weighted average of the feature maps.

III. METHOD
In this episode, we propose our approach that explore multiscale fine-grain feature adaptively. We first produce an overview for our MAG-SD. Then MA-Net is presented in terms of network architecture with attention modules. A weakly supervised data augmentation module, Attention Guided Augmentation, is introduced to address the shortage of COVID-19 cases. At last, Soft Distance Regularization is proposed to erase noise imported by augmentations.

A. Overview
COVID-19 CXR images are less distinctive comparing with other pneumonia cases, which requires a model to extract features for fine-grained feature of input image. WS-DAN [31], which is competitive in fine-grained image classification has been adopted for this topic. The architecture includes a feature extractor (i.e. ResNet50), an attention generator operated on feature map and an augmentation generator producing localenhanced and noise-blended image. An overview of our MAG-SD is shown in Fig. 1. In primary training route, preprocessed CXR image I 0 is fed into MA-Net for prediction vector P and attention map A. Attention Guided Augmentation is operated on I 0 , using A to produce augmented data I 1 , I 2 , I 3 . In Auxiliary training routes, I 1 , I 2 , I 3 are pushed into MA-Net for prediction vectors p 1 , p 2 , p 3 . All the vectors (i.e. P, p 1 , p 2 , p 3 ) are utilized by Soft Distance Regularization for a proper loss.

B. Multiscale Attention Guided Network (MA-Net)
1) Network Architecture: Fig. 2 presents a demonstration of our proposed MA-Net. As observed, a CNN based encoder is operated on augmented images. Encoder utilizes ResNet50 as backbone, extracting size-different feature maps f 1 , f 2 , f 3 from image I. Multiscale attention generator is used to extract attention map a1, a2, a3 and estimate scale-wised interests. Attention maps are resized for a single output A from features. Then, the output of encoder f 3 and attention map A are assessed by Attention Pooling to generate prediction vector P .
2) Multiscale Attention Generator: Attention mechanism has been used in natural image topics to guide feedforward process [42], [43]. Recently, tentative efforts have been made on deep models such as image classification [44], person perception [45] and sequential decision tasks [46]. Most of the attention models aim at gathering top level information to decide where to attend for the next learning steps. The proposed attention generating model is operated on multiscale feature maps, aiming at extracting attention from different scale. Layers before downsampling are selected as feature map in order to squeeze information out of single resolution feature. For ResNet50 we used, feature maps with 512 * 28 * 28, 1024 * 14 * 14, 2048 * 7 * 7 sizes are chosen. The number of attention map is 32.
The architecture of multiscale attention generator is shown in Fig. 3. f 1 , f 2 and f 3 are feature maps selected from feature extractor. Each of them are processed by 1 * 1 convolution to generate corresponding attention. All the attention maps are downsampled to 7 * 7 and connected residually. The effect of using different number of feature maps is discussed in experiments.
3) Attention Pooling: Attention pooling module mimics the structure proposed by [31], which associates attention output and feature map. Fig. 4 shows the pipeline of the pooling method. Feature map f 3 (2048 * 7 * 7) is extracted from the output of CNN encoder. Multiscale attention map A presented by attention generator is 32 * 7 * 7. Each attention map focuses on diverse location that may contain valuable fine-grained feature. Attention biased features (i.e. part feature map (P F )) are presented by multiplying all the attention maps A, each by each, with  feature map. There are 32 P F s which size equals 2048 * 7 * 7. Global average pooling (GAP) is operated to shrink each P F to 2048 * 1 * 1 in order to describe the activation intensity of attention on feature map. Feature matrix M is produced by concatenating GAP results, producing a vector of 65 536 * 1 * 1. Eq. (1) describes the calculation of P F .
where stands for multiplication of elements between two tensors. f 3 is feature map extracted by CNN. N represents the number of attention maps, which is 32 in our work.
P F j has to go through a downsampling method such as GAP to get description with compressed size, which is 2048 * 1 * 1. Feature matrix M is represented by concatenating all condensed P F j presented in Fig. 4.

C. Attention Guided Augmentation
As mentioned above, attention mechanism emphasizes local feature which affects the classification result. Following the idea, the performance of classification network could be enhanced if attention guided training cases are considered. Weakly supervised methods demonstrated in Fig. 5 present effective augmentations for original image. One normalized attention map (A * ) is randomly chosen for each instance to do individual augmentation.

1) Attention Mixup:
Mixup is an augmentation strategy which generates data by mixing overall image and regional feature  together. As we have a attention map A * j , a detailed region D j could be extracted by doing threshold.
For elements in A * j (l, m), Eq. (2) sets D j (l, m) to 1 if it is greater than threshold θ m ∈ [0, 1]. If not, it will be set to 0. A bounding box surrounding the extracted region is proposed from the raw region. Region coved by the box is enlarged to the same size as input image then merged together with original input I 0 to get augmented input I 1 , which is defined in Eq. (3).
where γ is a parameter range in [0,1] and B stands for the enlarged bounding box. Model could see target precisely by learning local and global feature together.
2) Attention Patching: Encoder could be sensitive to limited part of reception field as valuable spatial features usually distribute in similar position. To encourage the encoder to explore feature from varied part, attention patching is proposed. D mentioned in 1) is patched onto the original image I 0 to propose patched data I 2 , which is demonstrated in Fig. 5. Attention patching enlarges the model's interest region by duplicating the interested area, promoting model to global evaluate its input.
3) Attention Dimming: When training attention generating module for feature map, multiple attention maps may be sensitive to similar region. A responsible fine-grain classification model have to focus on different local features of one target. Attention dimming is proposed to stimulate the attention model searching the whole reception field for valuable information. We obtain a Dimming Mask (DM ) from A * , applying threshold θ d ∈ [0, 1], as represented in Eq. (4).
Augmented image I 3 is generated by applying the mask onto the input, which is illustrated in Fig. 5(c).

D. Soft Distance Regularization
Disturbances are introduced into the original image by using augmentation. (e.g. infection area reduced by attention dimming). To address this problem, we formulate the uncertainty of predictions via the distance between prediction vectors. Intuitively, the distance d could be modeled as Eq. (5).
where x denotes the augmented image, P (I), p(x) represent primary and auxiliary prediction vector respectively. However, the distance between P (I) and p(x) is unstable before the the model well-fitted. Ground truth labels are referenced to stabilize gradients. In Algorithm 1, P (I) is replaced by soft label P (I), filtering out low confidence inferences. Soft distance d (x) can be represented in Eq. (6). The value of θ in Algorithm. 1 is 0.7.
At last, overall loss is modeled by a combination of cross entropy loss and average soft distance, which is demonstrated in Eq. (7).
where L prim ce operates between labels and primary prediction. If two vectors have different prediction for one target, L reg will generate a large value, which reflects the uncertainty of the model on one target. It is also notable that L reg punishes soft distanced , leading the model to generate similar predictions.

IV. EXPERIMENTS
In this section, extensive experiments were conducted to comprehensively assess MAG-SD. Models were trained on datasets with different types of pneumonia and the performance of each proposed method was evaluated. Then the models were compared between other baseline methods using several metrics.

A. Dataset and Experimental Settings
The proposed model was trained and tested on several datasets to evaluate its classification performance and ability of finegrained pneumonia localization. Details of each dataset was shown in Table I. Dataset A was a mutated dataset with 90 COVID-19 from [15] and 168 other pneumonia cases from [17], which directly assessed model's fine-grained classification ability. Dataset B was selected from [47] and [17], aiming at evaluating the model's performance on larger scale. Dataset C was the largest dataset we operated on, which included COVID-19 detection and fine-grained pneumonia classification. Quality of pneumonia localization was evaluated by Localization dataset, which had 13 COVID-19 cases with pixel-wise masks from [48] and 118 non-COVID pneumonia cases with bounding boxes annotations from [17]. In experiments, classic ResNet50 has been adopted as feature extractor. Its layer4 output was chosen as feature map. Attention was extracted from the output of layer2, layer3 and layer4 to ensure multiscale attention. Size of the attention maps were 28 * 28, 14 * 14 and 7 * 7. Both training and testing sets were divided roughly in the same class proportions. 5-fold cross validation was applied to get reliable results.
Models were implemented using Pytorch and trained on two NVIDIA RTX 2080TI GPUs. The optimizer was Stochastic Gradient Descent (SGD) with the momentum of 0.9. For each training, 100 training epochs were deployed, with 10 −6 weight decay, 32 cases per minibatch and 10 −3 learning rate at beginning. Images were resized to 224 * 224 when training and testing.

B. Pre-Processing and Data Augmentation
X-ray images have different appearance according to varied imaging equipment configurations, resolving that the same tissue can be radiologically different. To ensure the intensity distribution of one tissue is similar over the dataset, Z-score normalization was employed when training and testing. Large contrast distribution also introduced extra noise to the dataset, impacting the performance of trained model. Contrast limited adaptive histogram equalization (CLAHE) was proposed to enhance contrast between tissues and restrain noise signal [49].
In image classification, data augmentation has been proved as an effective method to improve robustness and evaluate performance [50]. Augmented data provides more varieties for classification target and remitting the impact of overfitting. Random number of transformations were chosen from a sequence of linear transformation for each training sequence. The list is shown in Table II.

C. Evaluation Metrics
Experiments were evaluated by several metrics. For Classification, Accuracy (ACC), Sensitivity (SEN), Specificity (SPC) and F1 score were employed. For multi-class datasets, mean value between classes were calculated to represent the final performance score of each model. Plots of receiver operating characteristic (ROC) curve and area under the curve (AUC) value were used to compare model functionality. Localization quality was quantified by intersection over union (IOU) which has been widely used in target detect and semantic segmentation task [41]. Accuracy describes the proportion of correctly classified targets,  which is expressed in Eq. (8).
where TP, TN, FP and FN stand for the number of true positive, true negative, false positive and false negative predictions. Sensitivity, also known as true positive rate (TPR), is useful to measure the proportion of true positive predictions over all positive targets, which is defined in Eq. (9).
Specificity, or true negative rate (TNR), is a ratio between the amount of true negative (TN) and false positive (FP) predictions, defined in Eq. (10).
F1 Score considers the performance from both precision and recall, defined in Eq. (11).
IoU represents a value calculated by dividing the overlap of prediction and ground truth by their union. It could be defined straightforward in Eq. (12), where A o and A u denote area of overlap and area of union respectively.

D. Components Validation and Discussion
The methods composed could be concluded into attention modules, attention guided data augmentation and soft distance regularization. Each component was studied by evaluating its improvement in classification performance, which has been quantified by metrics mentioned above. Performance gain was obtained by the following method: the proposed model was first trained on specific dataset with metrics, then, single component was changed or removed and reevaluate on the same dataset.
For all the tested models, Mean value and standard deviation of ACC, SEN, SPC, F1 were recorded. Components validations were reported in Tables IV, V, VI, VII and VIII. Inter-model comparisons could be found in Table III and Fig. 6. Regions interested the attention module were presented in Fig. 7. Parameters in all the experiments were maintained unchanged as possible for condition control. The model were trained on the same size of training set then evaluated on the same size of testing set. 1) Architecture Comparing: Advantages of architecture design has been deeply explored. It has been performed by evaluating classic coarse-grained deep neural networks (i.e. VGG16, ResNet18, ResNet50 and InceptionV3), COVID-19 oriented architectures (i.e. [51] (ResNet), [51] (InceptionV3), COVID-Net-Large), high performance fine-grained image classification structure (i.e. BCNN, BCNN(Attention)) and multiscale feature fusion models (i.e. FPN, U-Net). Statistics analysis between these deep structures helped to explain our advantages in finegrained feature extraction. It can be observed in Table III and Fig. 6 that proposed model had noticeably better performance over others. For our model, accuracy on dataset A, B and C reached 96.94% ± 1.10%, 95.85% ± 1.27%, 87.12% ± 1.55% respectively and performance assessed by AUC are 99.94%, 98.72%, and 95.11%.
Comparing with classic models, our model was specialized for COVID-19 image classification and attention guided training phase had advantage in fine-grained visual classification task. Most of the other COVID-19 oriented models presented better performance than classic models, however, none of them applied attention mechanism or considered fine-grained features, which impacted their accuracy on large scale, multi-class dataset such as Dataset B and C. Comparison between FPN, U-Net and classic models demonstrated that FPN presented results over InceptionV3 in Dataset A and B. In Dataset C, U-Net had higher accuracy than FPN, which exceeded ResNet50. Results indicated that multiscale feature fusion models reached competitive results using relatively simple structures comparing with classic deep models, which left us a hint that multiscale attention might be a possible route to improve.   generated by our model has advantage in AUC value, which is over 0.5% in dataset A, B and C. Architecture differences of our proposed method also influence the performance over datasets. Generally, MAG-SD(proposed) is the most stable model which stays in top-3 in all the datasets, which is a method given consideration to both generalizability and robustness. BCNN was a FGVC model with stable performance on multiple datasets. In order to evaluate the generalization ability of our attention module, multiscale attention and attention pooling were transported to BCNN to train BCNN(Attention). Statistically, BCNN reached 96.00% ± 1.52%, 94.41% ± 1.37%, 84.36% ± 1.84% in Accuracy, which was competitive in all the evaluated models. Attention modules remarkably boosted the performance of BCNN, exceeded our proposed method in Dataset A (SPC) and Dataset B (SEN), which were 96.16% ± 1.74%, 96.61% ± 2.00% respectively.
2) CLAHE Preprocessing: Images collected by different devices were probably distinct in contrast due to configuration variety. CLAHE was employed to relieve the noise brought by contrast distribution. Table IV showed the result that CLAHE obviously improved the performance of proposed model and raised over 1.5% Accuracy on average. Model trained without CLAHE had notable higher standard deviation value. Larger datasets such as Dataset B and C were reported to have more performance gain.

3) Multiscale Attention Generator and Attention Pooling:
Normally, state-of-the-art coarse-grained CNN models suffer from similar global features when dealing FGVC. Under this circumstance, models have to depend on local features, which could be effectively localized by our multiscale attention module. Models trained with attention module (i.e. MAG-SD(0AUG)) and baseline model (i.e. ResNet50) were compared in Table III, and Fig. 6. Results revealed that proposed model surpasses the baseline on dataset A, B and C using most of the benchmarks. In dataset B (SPC), ResNet50 has slight advantage. Comparing with AUC, MAG-SD(0AUG) was 2% over ResNet50. Furthermore, two parts of attention module, attention generating and attention pooling has been investigated separately. Firstly, models were compiled to assess multiscale attention, with 1,2 or 3 size of attention maps considered. Results presented in Table V and Fig. 6 showed the model considering two feature maps achieved the best performance in all three datasets. Possible explanation was that the proposed attention module was too simple to locate valuable fine grained feature on low-level feature maps. Instead of importing meaningful location information, noise was brought into the proposed model. Secondly, we evaluated attention pooling module with models trained with other commonly used pooling methods such as global average pooling (GAP) or global max pooling (GMP). Results on pooling methods were presented in Table VI and Fig. 6, demonstrating that attention pooling surpassed GAP and GMP in all three datasets.

4) Attention Guided Augmentation:
The generated attention maps emphasized local feature that interested the model, which could be used to effectively guide data augmentation in Fig. 5. Models trained with 0, 1, 2 or 3 augmentation were discussed in experiment. In the case of 1 augmentation, attention mixup was selected. 2 augmentations model included attention mixup and attention patching. The results were presented in Table VII and Fig. 6. The table reflects that model with all three augmentations had better performance, however, AUC value showed that in dataset A and B, two augmentations was advantageous. The proposed augmentations emphasized data according to attention map, minimizing negative effect caused by random augmentations. 5) Soft Distance Regularization: Soft distance regularization was presented to relieve augmentation variance. Experiments have been composed to compare it with L2 distance regularization. Table VIII and Fig. 6 illustrated that it surpassed L2 in mean value, but, inferior in standard deviation. Constraint between auxiliary vector and primary vector screen the false prediction introduced by attention guided augmentations. Regularization was calculated between ground truth and auxiliary vector when primary vector cannot provide reliable prediction, keeping the final result away from local minima. L2 compared all predictions directly with ground truth, which has higher stability and sidestepped the disturbances introduced by primary prediction. 6) Attention Based Infection Localization: Technically, attention improved the models by roughly localize the part with high activation intensity. This characteristic of attention inspired us to try MAG-SD on localization topics. The models were trained on the Dataset B we proposed, then test on Localization dataset demonstrated in Fig. 7. It included COVID-19 cases with pixel-wise segmentation and non-COVID-19 cases with bounding box for pneumonia infection. Attention maps A were upsampled from 7 * 7 to 224 * 224. Localization masks for COVID-19 cases were extracted by applying threshold to the attention maps. Bounding boxes for other pneumonia were produced by simply enclosing the localization masks with rectangles. IoU was calculated to evaluate the quality of localization. Image showed that the attention module we proposed could roughly indicate the position of different type of pneumonia with over 0.25 IoU score. Attention map emphasized the influential part from the input image effectively.

E. Distribution Analysis
As we imported multiple fine-grained classes into this topic, it was necessary to report the distribution of our prediction result, which has been shown using confusion matrix in Fig. 8. MAG-SD has been selected to generate the charts to represent the classification result of deep learning models. It could be inferred that the model was suitable for searching definitive features from cases showed in dataset A and B as most of the cases were located on the diagonal line of matrices. In dataset C, classification result between viral pneumonia and bacterial pneumonia was significantly inferior than others, which impacted the global performance of the classification model. These results proved the arguments reviewed in Section II-A, indicated that the CXR visual appearance between viral and bacterial pneumonia was insufficient to make accurate diagnosis.

V. CONCLUSION
We have presented MAG-SD for automatic COVID-19 CXR image classification that reached the state-of-the-art on our dataset. The proposed novel method treated this topic as a fine-grained image classification task, utilizing local features efficiently under the guidance of attention mechanism. Attention maps were generated using multiscale features then used as a reference to data augmentation, helping the model to overcome the lack of COVID-19 cases. The proposed network learned to weight the predictions from both primary and auxiliary training pathways by calculating soft distances between vectors, gaining improvements by screening noise generated by augmentations.
Findings of our exploration were demonstrated and discussed in Section IV. The results indicated the great potential of applying advanced pattern recognition model to clinical diagnosis and epidemic screening. Trained on the clinical knowledge acquired by physicians, our model was capable to extract fine-grained spatial features for COVID-19. Attention was applied in both feature extraction and augmentation stage, which helped to localize pneumonia infection and accrete the data effectively as part of weakly supervised method. Attention module also shows its capability in different models. It could be interesting to design more auxiliary training strategies to guide the model to an optimal solution. Positive feedback on soft distance regularization proved that our method considered auxiliary predictions and eliminated label noise simultaneously, however, hard threshold may limit its adaptability in complicated data.
Although deep learning methods seem promising in clinical diagnosis and pandemic screening, lacking of prior knowledge is always the Achilles' Heel. Supervised learning method, such as MAG-SD we proposed, have to be trained on expensive labeled data. Newly occurred or rare diseases without available data may not be classified properly. Abnormal detecting and clustering model could be proposed as a guidance for supervised models to alleviate the limitations, which is part of our future work.