## 4 Principle and Implementation
### Water Segmentation Model
#### 4.2.2 Encoder Design
Except for the first stage where the convolution parameter is set to \(K=7,S=4,P=3\), the other three stages are uniformly set to \(K=3,S=2,P=1\). \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Stages** & **Output Size** & **Layer Name** & **CTA-B0** & **CTA-B1** & **CTA-B2** & **CTA-B3** \\ \hline \multirow{4}{*}{1} & & Overlapping & & \(K_{1}=7\); \(S_{1}=4\); \(P_{1}=3\) & \\  & & Path Embedding & \(C_{1}=32\) & & \(C_{1}=64\) & \\ \cline{2-6}  & & Multiscale Convolutional & & & & \\  & & Attention Encoder & \(L_{1}=3\) & \(L_{1}=2\) & \(L_{1}=3\) & \(L_{1}=3\) \\ \hline \multirow{4}{*}{2} & & Overlapping & & \(K_{2}=3\); \(S_{2}=2\); \(P_{2}=1\) & \\ \cline{2-6}  & & Path Embedding & \(C_{2}=64\) & \(C_{2}=128\) & \\ \cline{2-6}  & & Multiscale Convolutional & & & & \\  & & Attention Encoder & \(L_{2}=3\) & \(L_{2}=2\) & \(L_{2}=3\) & \(L_{2}=5\) \\ \hline \multirow{4}{*}{3} & & Overlapping & & \(K_{3}=3\); \(S_{3}=2\); \(P_{3}=1\) & \\ \cline{2-6}  & & Path Embedding & \(C_{3}=160\) & & \(C_{3}=320\) & \\ \cline{2-6}  & & & & & & \\ \cline{1-1} \cline{2-6}  & & Transformer Encoder & & \(R_{3}=2\) & \(R_{3}=2\) & \(R_{3}=2\) & \(R_{3}=2\) \\ \cline{1-1} \cline{2-6}  & & Transformer Encoder & & \(N_{3}=5\) & \(N_{3}=5\) & \(N_{3}=5\) & \(N_{3}=5\) \\ \cline{1-1} \cline{2-6}  & & & \(E_{3}=4\) & \(E_{3}=4\) & \(E_{3}=4\) & \(E_{3}=4\) \\ \cline{1-1} \cline{2-6}  & & & \(L_{3}=2\) & \(L_{3}=2\) & \(L_{3}=6\) & \(L_{3}=18\) \\ \hline \multirow{4}{*}{4} & & Overlapping & & \(K_{4}=3\); \(S_{4}=2\); \(P_{4}=1\) & \\ \cline{2-6}  & & Path Embedding & & \(C_{4}=256\) & & \(C_{4}=512\) & \\ \cline{1-1} \cline{2-6}  & & & & & & \\ \cline{1-1} \cline{2-6}  & & & \(R_{4}=1\) & \(R_{4}=1\) & \(R_{4}=1\) & \(R_{4}=1\) & \(R_{4}=1\) \\ \cline{1-1} \cline{2-6}  & & Transformer Encoder & & \(N_{4}=8\) & \(N_{4}=8\) & \(N_{4}=8\) & \(N_{4}=8\) \\ \cline{1-1} \cline{2-6}  & & & \(E_{4}=4\) & \(E_{4}=4\) & \(E_{4}=4\) & \(E_{4}=4\) \\ \cline{1-1} \cline{2-6}  & & & \(L_{4}=2\) & \(L_{4}=3\) & \(L_{4}=3\) & \(L_{4}=3\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Detailed settings of backbone. The multiscale convolutional attention block [29], shown in Figure 4a, is a core module in the encoder of this paper. Its overall structure is similar to ViT, but instead of using the self-attention mechanism, a multiscale convolutional attention block is redesigned using convolution, as shown in Figure 4b. The multiscale convolutional attention block consists of three parts: a deep convolution for aggregating local information, a multibranch convolution for capturing multiscale contexts, and a convolution for mixing different channel relationships. Mathematically, the multiscale convolutional attention module can be written as Equation (3). \[ \begin{split} Att&=Conv_{1\times 1}\left(\sum_{i=0}^{3}Scale _{i}(DWConv(F))\right)\\ out&=Att\otimes F\end{split}  \tag{3}\]  
where \(out\) denotes the output feature map, \(Att\) denotes the convolutional attention weight map, \(F\) denotes the input feature map, \(\otimes\) denotes the matrix corresponding position element multiplication, and \(DWConv\) denotes the depth separable convolution. Another important module used in this encoder is the existing Transformer block in the original SegFormer, as shown in Figure 5. The core difference between this building block and the traditional Transformer block is the replacement of the multi-headed attention. The efficient self-attentive layer proposed in the original paper is able to reduce the computational complexity, which is implemented by compressing the sequence length using the scaling reduction mentioned in PVT [30], i.e. \[ \begin{split}\hat{K}&=\text{Reshape}\left(\frac{N} {R},C\cdot R\right)(K)\\ K&=\text{Linear}(C\cdot R,C)(\hat{K})\end{split}