## 3 Proposed Method
### Convolutional Cross-Substitution Transformer Module
#### 3.2.1 Convolutional Cross-Substitution Attention Block
\[V_{ant}=soft\max(\frac{(Q_{pool}\times K^{T})}{\sqrt{d_{K}}})\times Q \tag{10}\]  
Subsequently, in the second stage, the original \(Q\) is deployed as the query vector, whereas \(K_{pool}\) functions as the substitute for the original key vector \(K\). In this configuration, \(V_{ant}\), derived from the preceding stage, serves as the value vector. Therefore, a second round of attention computation is conducted among \(Q\), \(K_{pool}\), and \(V_{ant}\) to facilitate sustained information exchange, ultimately yielding the final global output \(O_{ant}\), as presented in Equation (11). \[O_{ant}=soft\max(\frac{(Q\times K_{pool}^{T})}{\sqrt{d_{K_{pool}}}})\times V_{ant} \tag{11}\]  
In order to present the computational processes of the convolutional cross-substitution attention module more clearly, we separately elaborated on the computational processes for the convolutional cross-substitution attention used for spatial feature extraction and the one used for spectral feature extraction within the dual-branch structure, as detailed in Algorithms 1 and 2. Considering complexity aspects, assuming the sizes of \(Q\) and \(K\) are \(N\times d\), while the sizes of \(Q_{pool}\) and \(K_{pool}\) post-pooling are both \(n\times d\), the original attention module's complexity is \(O(2N^{2}d)\). Conversely, the proposed cross-substitution attention entails a complexity of \(O(4 Nnd)\). Thus, when \(n<\frac{N}{2}\), the computational complexity of the proposed model is lower than that of the original attention module. Figure 4: Convolutional cross-substitution attention block. ```
1:\(x\): Input tensor of shape (Batch_Size, Channels, Width, Height). 2:\(dim\): Number of input channels (default = 24). 3:proj_kernel: Size of the convolutional kernel (default = 3). 4:heads: Number of attention heads (default = 4). 5:dim_head: Dimension of each attention head (default = 16). 6:Initialize:
7:inner_dim \(\leftarrow\) dim_head \(*\) heads. 8:padding \(\leftarrow\) proj_kernel //2. 9:to_q \(\leftarrow\) DepthWiseConv2d\((dim,inner\_dim,proj\_kernel,padding)\). 10:to_k \(\leftarrow\) DepthWiseConv2d\((dim,inner\_dim,proj\_kernel,padding)\). 11:pool_q \(\leftarrow\) MaxPool2d\(((3,3),stride=(3,3))\). 12:pool_k \(\leftarrow\) MaxPool2d\(((3,3),stride=(3,3))\). 13:to_out \(\leftarrow\) Sequential\((Conv2d(inner\_dim,dim,kernel\_size=1),Dropout(dropout))\). 14:Function Forward(x):
15:shape \(\leftarrow\) x.shape. 16:\(b,n,ww,hh,h\leftarrow\) shape, heads. // Linear projections
17:\(q\gets\) to_q(x). 18:\(k\gets\) to_k(x). 19:// Pooling of queries and keys
20:pool_q \(\leftarrow\) pool_q(q). 21:pool_k \(\leftarrow\) pool_k(k). 22:// Compute attention for first stage
23:\(attn1\gets attention(pool\_q,k,q)\). // Compute output values based on first attention
24:\(out\_v\gets attn1\). // Compute attention for second stage
25:\(attn2\gets attention(q,pool\_k,out\_v)\). // Compute final output
26:\(out\gets attn2\). // Reshape to output format
27:\(out\gets rearrange(out,^{\prime}(bh)(xy)d->b(hd)xy^{\prime},h=h,y=hh)\). // Apply final linear layer
28:return\(to\_out(out)\). ```  
**Algorithm 1** Convolutional cross-substitution Attention used for spatial feature extraction