# An Attention-Based Full-Scale Fusion Network for Segmenting Roof Mask from Satellite Images
## 3 The Proposed Attention-Based Full-Scale Fusion Network  
### Attention-Based Residual Ublock  
The core of U2 Net [44] is the residual ulblock (RSU) module. RSU is proposed to capture intra-stage multi-scale features. The structure of RSU-L is presented in Figure 2a. As can be seen, RSU-L is composed of four basic modules stacked together: \(Conv+BN\), \(Conv+BN+ReLU\), \(Downsample+Conv+BN+ReLU\), and \(Upsample+Conv+BN+ReLU\). The definitions of \(Conv\), \(BN\), \(Downsample\), \(Upsample\), and \(ReLU\) are shown in Table 1, and \(+\) represents that the two modules before and after it are connected in series. Take the \(Conv+BN+ReLU\) block with a parameter of \((C_{in},3\times 3,d=1,C_{out})\) in Figure 2a as an example: it consists of a convolutional layer, batch-norm layer, and an \(ReLU\) activation layer. The kernel size, stride size, and dilation size of the convolutional layer are \(3\times 3\), \(1\), and \(1\), respectively. The numbers of the channel of the input feature and output feature of the \(Conv+BN+ReLU\) block are \(C_{in}\) and \(C_{out}\), respectively. Given a feature map \(x_{C_{in}\times H\times W}\), where \(C_{in}\)refers to the number of channels in \(x_{C_{in}\times H\times W}\), and \(H\) and \(W\) denote the height and width of \(x\), respectively, it is first input into a \(Conv+BN+ReLU\) block to extract the local features \(x_{C_{out}\times H\times w}^{0}\). Then, \(x_{C_{out}\times H\times w}^{0}\) is processed by a UNet-like symmetric encoder-decoder structure with a height of \(L\) to produce the multi-scale contextual feature \(x_{C_{out}\times H\times w}=\mu\left(x_{C_{out}\times H\times W}^{0}\right)\). Note that the first basic block of RSU-L's encoder is a \(Conv+BN+ReLU\) with a dilation size of \(1\), the last basic block of RSU-L's encoder is \(Conv+BN+ReLU\) with a dilated size of \(2\), and the remaining \(L-2\) modules of the encoder use \(Downsample+Conv+BN+ReLU\); for the decoder, the first basic block is a \(Conv+BN+ReLU\) with a dilated size of \(1\), and the remaining \(L-2\) modules use \(Upsample+Conv+BN+ReLU\). Finally, the local features \(x_{C_{out}\times H\times w}^{0}\) and \(x_{C_{out}\times H\times w}\) are summarized by a residual connection to produce the output of the RSU-L block: \(x_{C_{out}\times H\times w}=x_{C_{out}\times H\times w}^{0}+x_{C_{out}\times H \times w}\). In order to better extract features from small-resolution feature maps, the pooling layer and upsampling layer in the RSU-4 block are replaced with dilated convolution to form RSU-4F so that all intermediate features have the same resolution as the input feature maps. Different objects (e.g., roofs) may have different scales, such that multi-scale features also need to be considered in image segmentation. The RSU module is a feature pyramid network, which can provide rich feature information, enabling segmentation models to better distinguish the boundaries and regions of different objects. Compared with the UNet [37] network, the RSU in this work is equivalent to applying the idea of two feature pyramids, which can better capture features of different scales. **Residual block with attention:** The Squeeze-and-Excitation (SE) block [46] is an attention proposed to model the channel relationship and enhance the important features so that the model can focus more on features related to the target to be segmented. The SE block consists of two operations: squeeze and excitation. The squeeze operation is designed to compute the global information representation vector. Given an input feature \(x_{C\times H\times w}\), the SE block first applies the global average pooling to each channel:  
\[g_{k}=F_{sq}(x_{k})=\frac{1}{W\times H}\sum_{i=1}^{W}\sum_{j=1}^{H}x_{k}(i,j), \tag{1}\]  
where \(g_{k}\) refers to the global information representation value of the \(k-th\) channel. Then, the global information representation vector \(g\), which consists of the global information representation value of all channels, is processed by the excitation operation.