# Multi-Scale Twin Networks for Coastal Zone Change Detection in Remote Sensing Imagery
## 3 Principles and Methods
### Change Result Generation  
As shown in Figure 7, this paper inputs the three feature maps \(F^{i(4)}(\forall i\in\{1,2,3\})\), integrated by the spatio-temporal difference attention module into the foreground attention module to obtain the foreground feature map \(F^{(5)}\). They are then passed into the classifier to produce the change result map \(P\). We simulated the human eye's observation mechanism, where attention gradually shifts from the background to the foreground, and designed the foreground attention module to enhance coastal zone change detection accuracy by integrating multi-scale feature maps, thereby mitigating the effects of class imbalance. In change detection, the foreground typically represents the changed region, while the background corresponds to the unchanged or irrelevant areas. The foreground attention module integrates features from different scales based on multi-scale feature extraction, allowing the model to explore the relationship between changing and unchanged regions during training, thereby improving the learning of change information. The structure of the foreground attention module is shown in Figure 7. We first aligned the feature maps at different scales by applying a \(1\times 1\) convolutional layer to adjust their channel sizes. Next, the feature maps were resized to the same size through a sampling operation. The feature maps were then concatenated along the channel dimension to form a fine feature map \(F_{a}\). The fine feature was then passed through four consecutive dilated convolution layers, with the output channels set to [512, 512, 512, 256] to further integrate the contextual information with a larger receptive field. Finally, the output of the dilated convolution layers was multiplied element-wise with the original fine feature map to obtain the final foreground feature map \(F^{(5)}\), as denoted by Equations (17) and (18). \[F_{a}=\mathrm{C}_{i=1}^{3}\big{(}\mathrm{Samp}\Big{(}\odot\big{(}F^{i(4)} \big{)}\Big{)}\big{)} \tag{17}\]  
Figure 6: Schematic diagram of the central feature map. \[F^{(5)}=F_{a}\otimes(F_{a}\odot\mathrm{D}_{1}(r)\odot\mathrm{D}_{2}(r)\odot \mathrm{D}_{3}(r)\odot\mathrm{D}_{4}(r)) \tag{18}\]  
where Samp refers to the sampling operation, \(\mathrm{C}(\cdot)\) refers to concatenating the three feature maps along the channel dimension, and \(\mathrm{D}_{\mathrm{k}}(r)\) refers to a series of dilated convolution layers with a dilation rate, r (dilation rate of 3, 4 layers). In this model, the coastal zone change detection network can better correlate the contextual information related to the changes and focus more on the changed regions, effectively mitigating the imbalance problem. Figure 8 shows examples of the coastal zone change detection dataset and the corresponding foreground feature maps obtained after FAM processing. The foreground feature map examples are presented in the form of heatmaps, highlighting the areas of the feature map that the model focuses on during the multi-scale feature map integration stage. Compared to Figures 3 and 6, it is evident that the model pays more attention to the change areas with higher precision, and false positives and missed detections are significantly reduced. However, to further improve the model's detection ability, the design of the loss function is crucial. An effective loss function can optimize the model training process and reduce the impact of random errors on the model. Therefore, we have optimized the loss function design. Figure 7: Illustration of our foreground attention module (FAM). Optimal Design of the Loss Function  
The output feature map \(F^{(5)}\) is passed to the classifier to produce three change result maps, \(P_{1}\), \(P_{2}\), and \(P_{3}\). The focal loss and dice loss for each change result map are calculated separately. The sum of these two loss values gives the loss for each change result map, and the total loss for the change detection task is the sum of the losses for the three change result maps.