# Dual Hybrid Attention Mechanism-Based U-Net for Building Segmentation in Remote Sensing Images
## 2 Methodology
### DHA Module
\[P_{1} =X\cdot Sigmoid\{C_{3}[C_{2}(C_{1}(\delta_{1}(X)))]\}, \tag{1}\] \[Y_{1} =Sigmoid(C_{4}(\epsilon_{2}(P_{1}))),\] (2) \[P_{2} =X\cdot Sigmoid\{C_{3}[C_{2}(C_{1}(\epsilon_{1}(X)))]\},\] (3) \[Y_{2} =Sigmoid(C_{4}(\delta_{2}(P_{2}))),\] (4) \[Y =cat(Y_{1},Y_{2}), \tag{5}\]  
where \(C_{1}\), \(C_{2}\), and \(C_{3}\) denote convolutional kernels of size \(1\times 1\) and \(C_{4}\) denotes convolutional kernels of size \(3\times 3\). \(\delta_{1},\epsilon_{1}\) denote the two feature extraction method, global average pooling and global maximum pooling, relying on a single feature map, respectively, to form a spatial squeezing map on each channel. \(\delta_{2}\), \(\epsilon_{2}\) denote the global average pooling and global maximum pooling interspersed in each feature map located at the pixel position \(i\times j\), respectively. The expressions \(\delta_{1}\), \(\delta_{2}\), \(\epsilon_{1}\), \(\epsilon_{2}\) are shown in Equations (6)-(9). \[\delta_{1} =\frac{1}{H\times W}\sum_{i=1}^{H}\sum_{j=1}^{W}X_{m}(i,j) \tag{6}\] \[\epsilon_{1} =Max\{X_{m}(i,j)\}\] (7) \[\delta_{2} =\frac{1}{C}\sum_{m=1}^{C}X_{m}(i,j),\] (8) Figure 1:0 Figure 1:1 (9) Figure 1:2  
where the specific meaning is as follows, given the set of input feature channels \(X\in R^{C\times H\times W}\), \(X=X_{1},X_{2},\cdots X_{m},\cdots,X_{C}\), where \(X_{m}\in R^{H\times W},m=1,2,\cdots,C\) denotes any of the channel feature maps. The variables \(H\), \(W\) and \(C\) are the spatial height, spatial width, and the number of input channels, respectively. The design of the DHA module takes into consideration the following two points: (1) The error induced in the feature extraction process mainly comes from two aspects, the increase in the variance of the estimate caused by the limited size of the relevant neighborhood, and the deviation of the estimated mean caused by the error of the convolution layer parameters. The average pooling method can reduce the within-group variance and retain more image foreground information, while the maximum pooling method can increase the between-group variance and retain more texture information. From the overall view of the DHA module, the two parallel models have the same structure, but their respective channel attention and spatial attention pooling methods are different, which aim to extract and collect more channel and spatial detail information from different pooling perspectives to improve the accuracy of building segmentation. (2) The DHA model focuses on highlighting channels that contain crucial target information in the feature map, as well as important spatial locations. This is accomplished by linking the channel attention and spatial attention in a series. The input channel importance is first assessed, followed by spatial matrix operations on the feature map. This enhances the channel information first and then the spatial information changes, which significantly improves the extraction and utilization of the building information, enhances the recognition of buildings by the network, preserves more detailed building edge information, and reduces the proportion of the background information.