## 3 Materials and Methods
### ShadeNet: A Novel Approach to High-Precision Shade House Extraction
#### 3.2.2 Backbone of ShadeNet: Swin Transformer
The intermediate tensors generated by each layer are commonly referred to as \"feature maps\". The term \"hierarchical\" refers to merging the feature maps from one layer with those from the subsequent layer, which effectively reduces the spatial dimensions of the feature maps (i.e., downsampling) and forms multi-scale feature representations. These hierarchical feature maps maintain the same spatial resolution as those of ResNet [40]. This is intentional to ensure that existing vision task solutions can easily replace traditional ResNet backbone networks [40] with the Swin Transformer [17]. Compared to CNNs, the  
Figure 7: The structure of the Swin Transformer. The H, W, and C represent the height, width, and number of channels of the feature map at each stage, respectively. In Stage 1, H/4 \(\times\) W/4 \(\times\) 48 indicates that the input image is divided into 4\(\times\)4 patches, with each patch containing 48 features. As the network progresses, H and W decrease with Patch Merging, while C increases to capture more complex features. Stage 1 represents the first feature extraction stage, with Stage 2, Stage 3, and Stage 4 following a similar pattern, representing different levels of feature extraction. \(\times\)2 and \(\times\)18 denote the number of Swin Transformer blocks in each stage, with x2 indicating two blocks in Stage 1 and \(\times\)18 indicating 18 blocks in Stage 3, following a similar pattern for the other stages. In Stage 2, the feature map size is H/8 \(\times\) W/8 \(\times\) 2C, in Stage 3 H/16 \(\times\) W/16 \(\times\) 4C, and in Stage 4 H/32 \(\times\) W/32 \(\times\) 8C. Swin Transformer [17] possesses a stronger ability to learn global information and can more efficiently capture information at different scales and abstraction levels when processing complex image tasks. Therefore, the Swin Transformer [17] provides a novel and efficient solution for shade house extraction in remote sensing images. Patch Merging: Hierarchical feature maps are generated by progressively merging and downsampling the spatial resolution of feature maps. CNNs, like, ResNet [40] use convolution operations to downsample feature maps. Therefore, feature map downsampling can also be performed without using convolutions. The downsampling technique used in Swin Transformer is called Patch Merging. In this process, the smallest unit in the feature map is referred to as a \"patch\". A 14 \(\times\) 14 feature map contains 14 \(\times\) 14 = 196 patches. To perform n-fold downsampling on the feature map, patch merging concatenates the features of each group of n \(\times\) n consecutive patches. Swin Transformer Block: Swin Transformer uses window based multi-head self-attention (W-MSA) and shifted window multi-head self-attention (SW-MSA) modules to replace the multi-head self-attention (MSA) module commonly used in ViT [41]. The Swin Transformer module consists of two smaller sub-units. Each sub-unit consists of a multilayer perceptron (MLP) layer, an attention module, an additional normalization layer, and a normalization layer (Figure 8). The first sub-unit uses the W-MSA module, and the second sub-unit uses the SW-MSA module. The standard MSA used in ViT [41] is employed for global self-attention, which computes the associations between each patch and other patches. For high-resolution features, this leads to quadratic complexity in the number of patches. Swin Transformer uses a window-based MSA technique as a solution. Simply put, a window is a set of patches, and attention is only computed within each window. The window-based MSA calculates attention only within each window, where the window size is 2 \(\times\) 2 patches. The disadvantage of window-based MSA is that it requires self-attention within each window, thus limiting the network's modeling capability. To address this, Swin Transformer uses the SW-MSA module after the W-MSA module. In the Shifted Window MSA, the windows shift by M/2, where M is the window size.