# Nailfold Microhemorrhage Segmentation with Modified U-Shape Convolutional Neural Network
## 3 Materials and Methods
### Method Description
#### 3.2.2 Dual Attention Fusion Module  
Automatic segmentation requires a solid way to generate high-quality predictions. It is a matter of fact that the classic U-shape architecture is worth further investigation despite the great success it has achieved [35], for instance, the redundant low-level expressions caused by skip connections, since the feature representation is rather poor in initial layers [21]. To fulfill this objective, we propose a dual attention fusion module (DAFM) inspired by CBAM [31] and FFM [33]. Our module utilizes both channel and spatial attention to guide the feature learning process in the network, followed by a thorough feature fusion. CBAM is a simple yet effective attention module for adaptive feature refinement. It captures the dependencies in the spatial and channel dimensions, respectively, and uses a sequential arrangement to obtain the final result. By improving the representation power  
Figure 2: The overall architecture of the proposed DAFM-Net. Our model takes as input the images of nailfold microhemorrhages and performs precise pixelwise classification. of CNNs, CBAM has been incorporated in several medical image segmentation tasks including nasopharyngeal carcinoma [36], oral leukoplakia [37], etc. Therefore, we opt to employ CBAM to U-Net and make the following observations. (1) Attention mechanism provides a certain performance gain compared to the original U-Net. (2) Both CAM and SAM deliver good performance when evaluated separately. However, concerning CBAM, a performance drop is observed. This may imply that CBAM is unable to take full advantage of the captured channel or spatial attention. The DAFM block we propose serves as an effective solution to these limitations. It enables the network to focus on the important features and further lifts the performance of nailfold microhemorrhage segmentation. DAFM generates two types of attention maps and adopts a parallel arrangement. For channelwise attention, CAM infers a 1D attention map \(M_{\text{c}}\)\(\in\)R(\({}^{\text{(1}\times\text{1}\times\text{C)}}\). Meanwhile, SAM generates a 2D spatial attention map \(M_{\text{S}}\)\(\in\)R(\({}^{\text{(H}\times\text{W}\times\text{1})}\), as shown in Figure 3. These attention matrixes model the interdependence via feature maps in separate dimensions. Then, the input features and the attention matrixes are multiplied elementwise to obtain refined feature maps. CBAM chooses to impose a channel-first sequential arrangement upon the outputs of these two attention modules, which could be less adequate because of the distinction of semantic levels [36]. Thus, we employ a feature fusion module (FFM) for better integration. As illustrated in Figure 3, given an intermediate feature map X\(\in\)R(\({}^{\text{(H}\times\text{W}\times\text{C)}}\), we feed it into two parallel attention modules, CAM and SAM. For CAM, both Avg pooling and Max pooling are utilized to generate the spatial descriptions we need, which are later transmitted to a multilayer perceptron (MLP) with one hidden layer. Then, an elementwise summation operation is performed on the outputs of MLP. After that, a sigmoid function is used to normalize the final channel attention map \(M_{\text{c}}\)\(\in\) R\({}^{\text{1}\times\text{1}\times\text{C}}\), which can be written as the following form:  
\[M_{\text{C}}(X)=\sigma\Big{(}MLP\big{(}Avgpool(X)\big{)}+MLP\big{(}Maxpool(X) \big{)}\Big{)} \tag{1}\]  
For SAM, we also use both Avg pooling and Max pooling to explore the spatial attention. However, unlike CAM, the outputs descriptors are concatenated and then fed to a convolution layer to generate the spatial attention map \(M_{\text{S}}\)\(\in\)R(\({}^{\text{(H}\times\text{W}\times\text{1})}\):  
\[M_{\text{S}}(X)=\sigma\Big{(}conv([Avgpool(X);Maxpool(X)])\Big{)} \tag{2}\]  
The refined feature maps \(F_{\text{C}}\) and \(F_{\text{S}}\) can be described as given below:  
\[F_{\text{C}}=M_{\text{C}}\otimes X \tag{3}\]  
\[F_{\text{S}}=M_{\text{S}}\otimes X \tag{4}\]  
Figure 3: The dual attention fusion module.