## 2 Feature Extraction Module of Attention-Based Neural Network
### Time-Frequency Analysis Module of Attention-Based Neural Network
However, there are obvious frequency domain characteristics in ship radiated noise. The attention module of the short-time Fourier transform adopts the full connection layer with shared parameters (FCSP), hoping that the neural network can learn to automatically fuse the stable frequency components in the input signal and achieve a more stable recognition effect than before. This paper embeds an attention mechanism into the BSTFT-CNN to construct a convolution neural network time-frequency feature extraction module with an attention mechanism, which is called TFA-ATNN, as shown in Figure 6. The TFA-ATNN adopts the FCSP, hoping that the neural network will automatically extract the stable frequency components in the input signal to improve the stability of the recognition algorithm. The TFA-ATNN is mainly divided into three stages. In stage 1, the TFA-ATNN uses two FCSPs to learn the information that stably exists in the imaginary or real component and combine the components and phase spectrum as a combined features. In stage 2, the FCSP is used to fuse the combined feature. Feature fusion generates two attention maps, which are used for enhancement of imaginary and real components, respectively. In the  
Figure 5: The schematic diagram of the BSTFT-CNN. last stage, a learnable factor is used to combine the enhanced spectrum generated by the result of enhancement. Finally, the combination result is the output features that could be sent to the network for embedding and extracting. Specifically, the size of one of the component outputs by the BSTFT-CNN is \((T,NF)\), where \(T\) is the number of time points and \(NF\) is the number of frequency points. In order to make it easier for the model to capture the stable frequency distribution, FCSP is proposed to constrain the relationship between frequency components. Its operation is expressed as Equation (10):  
\[\left\{ \begin{aligned} & B_{\text{i,1}}=A_{\text{i}}F_{\text{i,1}}\\ & B_{\text{r,1}}=A_{\text{r}}F_{\text{r,1}}\end{aligned} ,\right. \tag{10}\]  
where \(A\) is one of the output features of the BSTFT-CNN, which includes features of real components and imaginary components. \(F\) is the parameter matrix of the FCSP, and its size is \((NF,NF)\) in stage 1, which depends on input and output. \(B\) is the matrix output by the FCSP. i represents the imaginary component, r represents the real component, and subscript 1 represents stage 1. The number of neural units in the single layer of the FCSP is equal to the number of frequency points. In stage 2, the TFA-ATNN combines the imaginary component, the real component and the phase component together, which is different from the classical attention mechanisms, such as SENet [37] and CBAM [38], to obtain attention information from the current layer to ensure that the model has sufficient information to extract the relationship between frequency components. The feature matrix is fused by concat, and the fused matrix is called \(C\). After the \(C\) is obtained, it is input into the FCSP of stage 2, as in Equation (11):  
\[\left\{ \begin{aligned} & B_{\text{i,2}}=f(C\text{F}_{\text{i,2}})\\ & B_{\text{r,2}}=f(C\text{F}_{\text{r,2}})\end{aligned} ,\right. \tag{11}\]  
where \(f(\cdot)\) is the gate function, here it is sigmoid. \(B_{\text{i,2}}\) dot multiplication \((1+A_{\text{i}})\) to get \(D^{\prime}{}_{\text{i}}\), which is called the enhancement imaginary component. \(B_{\text{r,2}}\) dot multiplication \((1+A_{\text{r}})\) to get \(D^{\prime}{}_{\text{r}}\), called the enhancement real component. Finally, the weight factor \(p\) with learning ability is used to fuse enhanced spectrums of the real and imaginary components. It is convenient for the neural network to initialize the weights of attention  
Figure 6: The schematic diagram of TFA-ATNN. mechanisms adaptively according to tasks and parameters. Equation (12) describes the enhancement process:  
\[\left\{ \begin{aligned} & M_{1}=\sqrt{{D^{\prime}}_{i}{}^{2}+A_{x}^{2}} \\ & M_{2}=\sqrt{A_{1}^{2}+{D^{\prime}}_{i}{}^{2}}\\ & M=pM_{1}+(1-p)M_{2}\end{aligned}