# Deep Learning-Based Classification of High-Resolution Satellite Images for Mangrove Mapping
## 2 Materials and Methods
### Attention U\({}^{2}\)-Net Model for Mangrove Detection  
#### 2.3.1 Structure of the Attention U\({}^{2}\)-Net  
A combination of the deep learning model U\({}^{2}\)-Net and attention gate, hereafter called attention U\({}^{2}\)-Net, was adopted in this study for automatic mangrove detection from the high-resolution imagery. Attention U\({}^{2}\)-Net is based on U\({}^{2}\)-Net, which is a network for salient object detection proposed by [PERSON] et al. [22]. As shown in Figure 3, the architecture of the network is a two-layer nested U structure. U\({}^{2}\)-Net consists of 6 coding layers, 5 decoding layers, and a full connection layer. Instead of a single convolution layer or deconvolution layer, each encoding and decoding layer embeds a complete ReSidual U-block (RSU) structure, which can extract multi-scale features during the sampling process. The RSU integrates the characteristics of the receptive field at different scales. This architecture allows researchers to train the deep network from scratch and improve the recognition efficiency by extracting multi-scale features layer by layer.  
Figure 3: The structure of the attention U\({}^{2}\)-Net.  
The mangrove training sample is a high-resolution satellite image that contains many-grows and other land cover types. The training sample is transmitted downward through resampling of the encoder, which reduces the spatial resolution but increases the feature dimension. The encoder can learn the low-level and high-level features of mangroves from the training sample. The resampled training sample is then transmitted to the decoder, which increases the spatial resolution but reduces the feature dimension. The decoder can reconstruct the mangrove map from the features learned by the encoder. The loss function is calculated at each level of the decoder, which measures the difference between the identified mangrove map and the ground truth map. The loss function is minimized through continuous iteration, which can update the network parameters and optimize the network performance. After traversing all the encoding layers and decoding layers, the feature extraction results are concentrated in the fully connected layer, which outputs the final mangrove extraction result. The final mangrove extraction result has the same size as the training sample, and it shows the location and shape of mangroves.  
By embedding the attention gate into the U\({}^{2}\)-Net model, irrelevant regional features can be suppressed, and the model will pay more attention to the salient features of targets [23]. Figure 4 shows the structure of the attention gate. The attention gate consists of three parts: an input gate, an output gate, and an attention coefficient. The input gate receives the input features from the encoder and the decoder and performs a convolution operation on them. Firstly, one-dimensional convolution is performed on the input feature (x) downsampling from the top and gating signal (g) upsampling from the map below x. The purpose of convolution is to make the channel numbers of x and g consistent. Then, g and x are combined after the convolution operation, and the attention coefficient \(\alpha\) [0, 1] is calculated through the ReLU function, one-dimensional convolution, and the sigmoid function on the input gate, which can assign different weights to different regions of the input features. The output gate performs another convolution operation on the input features and then multiplies them with the attention coefficient. Finally, the original x and \(\alpha\) are multiplied to obtain the attention weight. The results of the attention gate are then concatenated with the upsampled results.