# Dual Hybrid Attention Mechanism-Based U-Net for Building Segmentation in Remote Sensing Images
## 2 Methodology  
### DHA Module  
In order to effectively segment urban buildings in remote sensing images and accurately mask the background information, such as roads, grass, trees, and cars, this paper adopts the attention mechanism as the key approach. The attention mechanism not only helps determine where the model should focus its attention but also enhances the representativeness of relevant information, emphasizing target features while suppressing irrelevant ones. To address the problems of confusing segmentation results, the insufficient extraction of building information and numerous false segmentations, we propose a novel model called Dual Hybrid Attention (DHA) in this paper that is specifically designed for the complex and variable nature of remote sensing images. The DHA model comprises two parallel hybrid attention modules, each consisting of the channel attention and spatial attention in series. The channel attention uses a global set and a multi-layer perceptron to select a representative value for each channel. The spatial attention uses a channel-based global set whose results are then processed by a multilayer perceptron to provide spatial matrix transformations for all layers. The DHA model's structure is depicted in Figure 1.  
Figure 1a shows a hybrid attention structure in the DHA module, called HAM-1. The channel attention mechanism reshapes the input \(X\) into a feature map of size \(A_{1}\) by globally averaging pooling across all channels to consolidate the spatial information of the input, where \(X\) represents a \(C\times H\times W\) input layer and \(A_{1}\) represents a \(C\times 1\times 1\) layer. Subsequent layers like \(A_{2},B_{1},B_{2}\) follow a similar pattern. The globally averaged pooled feature map \(A_{1}\) is compressed by a multilayer perceptron with a compression rate of \(r\). Then, the channel attention feature value \(E_{1}\) is determined by the multilayer perceptron and the Sigmoid activation function. Each value in \(E_{1}\) represents the weight of the channel used for feature extraction, which is multiplied by the input feature map \(X\) to obtain the spatial attention input feature map \(P_{1}\), and the mathematical expression of \(P_{1}\) is shown in Equation (1). The spatial attention mechanism selects the maximum value of all channel feature maps located at pixel position \(i\times j\) by global maximum pooling, forming a single feature map \(F_{1}\) of size \(1\times H\times W\). After performing the convolution processing (filter size \(3\times 3\), step size 1) and Sigmoid activation function processing on \(F_{1}\), a weight map \(G_{1}\) with one channel is obtained. \(G_{1}\) is multiplied by the input feature map of the spatial attention graph \(P_{1}\) to obtain the feature map output, whose mathematical expression is shown in Equation (2). Figure 1b shows another hybrid attention structure in the DHA module, called HAM-2, which has the same structure to HAM-1, but differs in how it processes the input data. For the channel attention in HAM-2, instead of using global average pooling as in HAM-1, it utilizes global maximum pooling. This means that the maximum value for each channel is extracted to represent the channel-wise information. For spatial attention in HAM-2, it employs global average pooling, whereas HAM-1 uses global maximum pooling. The  
Figure 1: DHA model structure. (**a**) HAM-1; (**b**) HAM-2. expressions of the output and of the channel, and spatial attention in the HAM-2, are shown in Equations (3) and (4). Finally, the outputs \(Y_{1}\) and \(Y_{2}\) of the HAM-1 and the HAM-2 are superimposed to obtain the output \(Y\) of the DHA module. The expressions are presented in Equation (5).