## 3 Materials and Methods
### Spatial Attention Mechanism Based on Statistical Analysis  
The SAR ship target image is usually divided into two parts: the nearshore and the far sea. The most important feature of ship targets is that ship targets only appear in the ocean. There can be many objects on land exhibiting the same strong scattering effect as the target, which affects the accuracy of the ship detector. It is necessary to eliminate land interference to effectively detect ship targets. As mentioned above, the spatial attention mechanism is usually used to focus on the target area and eliminate the scattering disturbance near the ground and coast. However, the detection speed of the attention mechanism of traversing samples is limited. The contribution of this paper is the proposal of a spatial attention mechanism based on statistical analysis, which can improve the detection efficiency while ensuring the detection effect. The ship image of the example SAR showed that the entire image had the characteristics of a large range of background information, and the amount of background information was much greater than the foreground information (ship target). When the neural network processes information, it treats background information and foreground information equally. In this case, there are no targets in the background (i.e., land), and the probability of large-scale sea targets in the open sea is also small. Targets generally appear in fixed routes and offshore areas. We designed an attention mechanism that was primarily used to learn the probability information of the target existing in the corresponding regional background and was applied in the front part of the large-scale neural network. At this stage, the attention mechanism based on statistical analysis was used to remove part of the background information, reduce the computing resources occupied by the background information, and reduce the operation of the corresponding area during gradient descent. At the front end of the neural network, through feature. extraction, the network was trained to learn the importance of segmented regions. The probability of ship targets appearing in this area is calculated as follows. Step 1: Divide the whole into small areas equal in size. Step 2: Use convolution to build a neural network and count the probability of the occurrence of the target in this area. The value At is between 0 and 1. According to statistical analysis, some areas in a picture are defined as \"unimportant\" areas (for example, land, where the probability of target occurrence is At = 0.1), and the areas where targets appear are \"important\" areas (for example, ocean, where the probability of target occurrence is At = 0.7). Some area divisions include both ocean and land conditions; this usually occursin a near-shore area, also marked as an \"important\" area. Based on statistical analysis, we found that \"unimportant\" regions are usually connected to \"unimportant\" regions. Step 3: Map the calculation result of the statistical analysis of the grid back to the previous network and reflect the importance of the corresponding grid area in the original image. Through such front-end processing, the calculation amount of the subsequent neural network is reduced, and the target detection neural network can focus the calculation on the area corresponding to the larger attention by adjusting the parameters. In this way, the detection effect is ensured, the detection efficiency is improved, and the computational burden of the neural network is reduced. Using the above importance learning steps, the importance relationship between different regions can be found spontaneously through the weight matrix. The attention mechanism based on statistical analysis used in this paper initializes n groups of Q, K, and V matrices, where the value of n refers to the number of additional channels that form features. The expressions of the corresponding matrices are shown in Equations (1) and (2).