## 2 Feature Extraction Module of Attention-Based Neural Network
### Time-Frequency Analysis Module of Attention-Based Neural Network  
As a classical time-frequency analysis method, the short-time Fourier transform (STFT) can reflect the frequency change of ship radiated noise over time. Firstly, TFA-ATNN uses a set of 1D-CKs to embed the Fourier transform into the neural network, so that the neural network is able to extract time-frequency features. Secondly, the attention mechanism is conducted to improve the perception ability of the neural network for frequency. Discrete Fourier transform (DFT) can decompose frequency components from complex time-domain waveforms and is an important method for signal analysis and processing. In this paper, DFT is realized based on 1D-CK. DFT can be expressed as Equations (3) and (4):  
\[X(k)=\text{DFT}[x(n)]=\sum_{n=0}^{N-1}x(n)\cdot\text{e}^{-\frac{\text{j}2\pi \text{i}}{N}n}, \tag{3}\]  
\[x(n)=\text{IDFT}[X(k)]=\frac{1}{N}\sum_{k=0}^{N-1}X(k)\cdot\text{e}^{\frac{ \text{j}2\pi\text{i}}{N}n}, \tag{4}\]  
where \(x(n)\) denotes the time-domain signal sequence, and the discrete Fourier transform and its inverse transform are \(\text{DFT}[\cdot]\) and \(\text{IDFT}[\cdot]\). In order to realize the discrete Fourier transform by convolution neural layer, Equation (3) is expressed in matrix form, as follows:  
\[ \begin{bmatrix}X(0)\\ X(1)\\ \vdots\\ X(N-1)\end{bmatrix} = \begin{bmatrix}W^{0}&W^{0}&\cdots&W^{0}\\ W^{0}&W^{1\times 1}&\cdots&W^{(N-1)\times 1}\\ \vdots&\vdots&&\vdots\\ W^{0}&W^{1\times(N-1)}&\cdots&W^{(N-1)\times(N-1)}\end{bmatrix}\begin{bmatrix}x (0)\\ x(1)\\ \vdots\\ x(N-1)\end{bmatrix} , \tag{5}\]  
where \(W\) is used to replace \(\text{e}^{-\frac{\text{j}2\pi}{N}}\). In addition, according to the Euler formula, Equation (3) can be decomposed into the representation of an imaginary component and a real component. The decomposition is as follows:  
\[X(k)=\sum_{n=0}^{N-1}x(n)\cos[(\frac{2\pi}{N})nk]-\text{j}\sum_{n=0}^{N-1}x(n) \sin[(\frac{2\pi}{N})nk]. \tag{6}\]  
The typical convolutional neural network layer is represented by Equation (7):  
\[\mathbf{x}_{j}^{l}=f\Bigg{(}\sum_{i=1}^{D_{l-1}}\mathbf{x}_{i}^{l-1}*\mathbf{ k}_{ij}^{l}+b_{j}^{l}\Bigg{)}, \tag{7}\]  
where \(\mathbf{x}_{j}^{l}\) represents the output feature, \(\mathbf{k}_{ij}^{l}\) represents the convolution kernel, \(D_{l-1}\) represents the feature set, \(b_{j}^{l}\) represents the bias, \(j\) denotes the convolution kernel number, \(l\) denotes the layer number,  
Fourier transform, we set two groups of convolution kernels to calculate the imaginary component and real component of the Fourier transform, respectively. The weights of these two groups of convolution kernels can be fixed according to the sine basis functions and cosine basis functions in Equation (6). The number of convolution kernels is constrained by the number of points in the Fourier transform, and it is also equal to the number of points in the Fourier transform divided by two and plus one. Therefore, a one-dimensional convolution layer based on removing bias, activation function and padding can realize Fourier transform operation. Furthermore, the STFT with different time resolution and frequency resolution can be realized by optimizing the size, step length and basis function of the convolution kernel, as shown in Figure 5. This module is called the basic STFT module based on the convolutional neural network (BSTFT-CNN). In addition, in order to attenuate sidelobe height and weaken the impact of spectrum leakage, Hanning window action on convolution kernels. Specifically, the Hanning window with length \(M\) is expressed as Equation (9):  
\[windows(n)=\left\{ \begin{matrix}0.5+0.5\cos\left(\frac{2\pi n}{M-1}\right),0 \leq n\leq M-1\\ 0,else\end{matrix} \right. \tag{9}\]  
Since the parameters of convolution kernels in the BSTFT-CNN are initialized by the standard sine basis functions and cosine basis functions, the network after the BSTFT-CNN will learn the frequency components extracted by the BSTFT-CNN indiscriminately.