# LCAS-DetNet: A Ship Target Detection Network for Synthetic Aperture Radar Images
## 2 Methods
### Multi-Location Cross-Attention  
The success of ViT [33] has introduced the Transformer into visual computing, prompting increased discussion among researchers regarding the significance of attention mechanisms in computer vision. Inspired by [34; 35], this study proposes a Multi-Location Cross-Attention (MLCA) to further explore the utility of attention mechanisms in SAR images and ship detection tasks. As shown in Figure 2, MLCA consists of local and global branches, to obtain features at different scales and spatial coordinate location. This form of attention is referred to as cross-attention [36]. Within each branch, additional branches are embedded to acquire attention from both channel and spatial perspectives, named Multi-Location Attention (MLA). On one hand, this enables the stabilization of ship features against interference caused by noise from multiple dimensions. On the other hand, the spatial position of ships can be implicitly encoded through a correlation calculation. Figure 1: In the LCAS-DetNet network, the input SAR image is processed by a feature extractor to extract multi-scale semantic features. Subsequently, the neck layer fuses the features obtained from the feature extractor and pass them into the detection head. The final output is generated by the detection head layer. To maintain the plug-and-play characteristic of MLCA, the channel dimensions of the input and output, as well as the tensor shape, remain consistent after undergoing complex transformations. Assuming that the input \(x\in(h,w,c)\), the output \(y\in(h,w,c)\). After \(x\) undergoes normalization-convolution-activation, the channel dimension is increased \(x^{\prime}\in(h,w,2c)\), providing homologous raw materials for the dual-branch structure. As shown in Figure 3, after \(x^{\prime}\in(h,w,2c)\) is sliced along the channel dimension, it is separately input into the global and local branches. Different scales of patches are obtained through serialization, assuming the patch window is \(q\in N^{*(h,w)}\). Window \(q\) plays different roles in the two branches. In the global branch, \(q\) represents the number of patch windows, while in the local branch, \(q\) represents the size of a patch window. \(q\) is a hyperparameter that can take different values depending on the task and dataset. In the global branch, the serialized tensor \(x_{g}\in(q,(\frac{h}{q_{h}}\times\frac{w}{q_{w}}),2c)\). In the local branch, the serialized tensor \(x_{l}\in((\frac{h}{q_{h}}\times\frac{w}{q_{w}}),q,2c)\). MLCA obtains the spatial positions and receptive fields of different scales within the same layer. Such cross-attention introduces richer features and spatial information into the network. As illustrated in Figure 3a, the MLA module contains channels and spatial branches, taking the global branch as an example. In the channel branch, the input \(x_{g}\) is divided into two parts in the channel dimension, resulting in two different sequences of shape \((q,(\frac{h}{q_{h}}\times\frac{w}{q_{w}}),c)\), named \(cu\) and \(cv\). Among them, \(cu\) represents the input reserve, while \(cv\) serves as an index to search for features with high similarity. As shown in Equation (1), \(cu\) and \(cv\) measure spatial distance through dot product in the channel dimension, serving as the evaluation criterion for feature correlation. During backpropagation, it guides the weight update of \(cv\). We believe that such a design helps resist interference caused by water surface fluctuations and abnormal weather conditions at sea. This interference can cause water bodies that should be surface scattering to be easily confused with volume scattering from ships. \[\text{Att}_{\text{channel}}=\text{GELU}((cu\odot cv^{\prime})\pm esp) \tag{1}\]  
In the spatial branch, the emphasis is on pixel-level correlation on the spatial plane, that is, the \((h,w)\) dimension. As shown in Figure 3, when \(x_{g}\) is input into the spatial branch, it is divided into two along the \(h\) dimension, resulting in \(su\) and \(sv\).