FPGA-based underwater acoustic target recognition acceleration method and system
By using signal feature extraction and differential Transformer neural network modules on the FPGA side, the problem of insufficient accuracy and computational efficiency of underwater acoustic target recognition methods in complex environments is solved, realizing efficient and accurate underwater acoustic target recognition, which is suitable for underwater monitoring equipment with limited resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DALIAN UNIV OF TECH
- Filing Date
- 2026-01-08
- Publication Date
- 2026-06-02
AI Technical Summary
Existing underwater acoustic target identification methods suffer from low accuracy, insufficient computational efficiency, and poor adaptability in complex marine environments. Furthermore, traditional algorithms struggle to meet the data processing needs of underwater monitoring equipment with limited resources.
An FPGA-based underwater acoustic target recognition method is adopted. Feature extraction and classification are performed through signal feature extraction and differential Transformer neural network module on the FPGA side. Combined with pre-emphasis, frame windowing, FFT, Mel filtering and other processing, efficient feature extraction and intelligent recognition are achieved.
It achieves high target recognition accuracy in complex underwater environments, reduces the influence of human subjectivity, is compatible with resource-limited equipment, has low power consumption and fast response capabilities, and is suitable for a variety of underwater monitoring scenarios.
Smart Images

Figure CN122131285A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of acoustic target recognition technology, specifically to an FPGA-based method and system for accelerating underwater acoustic target recognition. Background Technology
[0002] In recent years, with the rapid development of marine resource development and defense technology, underwater acoustic target identification technology has become increasingly important in areas such as submarine detection, marine life monitoring, illegal fishing supervision, and underwater facility maintenance. The widespread use of maritime transportation, submarine communication pipelines, and energy exploration has led to a continuous increase in demand for underwater acoustic systems, bringing broad application prospects to related industries. However, the acoustic signals in the underwater environment are extremely complex and susceptible to interference from factors such as ocean noise, multipath effects, and propagation attenuation. Once identification is mishandled, it can lead to target misjudgment and frequent safety incidents, such as inaccurate submarine positioning, deviations in resource surveys, or failure of marine ecological monitoring—all with serious consequences.
[0003] Current underwater acoustic target identification methods include traditional feature extraction-based pattern matching, statistical learning classifiers, spectral analysis methods, and manual observation and listening tests. However, they generally have limitations: they are not only susceptible to clutter interference leading to high false alarm rates and weak identification capabilities, but manual feature extraction also relies on expert experience and is prone to missing effective information. Furthermore, they suffer from the problem of singular analysis of sonar signal time sequence and spectral features. At the same time, traditional algorithms have insufficient generalization performance and imbalanced data samples, while manual identification has high training costs, reliability is greatly affected by subjective state, and is difficult to adapt to the limited resources of underwater monitoring equipment and the needs of massive data stream processing.
[0004] Neural network-based intelligent recognition technology has become a development trend in underwater acoustic target recognition. It can achieve automated and accurate recognition and is compatible with multi-dimensional feature analysis. However, existing related algorithms still have shortcomings in terms of targeting, computational efficiency and practical deployment adaptability. Summary of the Invention
[0005] The purpose of this invention is to propose an accelerated underwater acoustic target recognition method and system based on FPGA, which overcomes the problems of low sensitivity, limited detection range, instability, and excessive energy consumption of existing recognition and classification technologies.
[0006] According to a first aspect of the present disclosure, an FPGA-based underwater acoustic target recognition acceleration method is provided, comprising the following steps: Collect different types of underwater acoustic signals and construct an underwater acoustic signal dataset; The underwater acoustic signal feature extraction module on the FPGA is used to extract features from the dataset. The features are then processed sequentially by pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain an underwater acoustic signal feature map. The feature map is input into the differential Transformer neural network module on the FPGA. After feature segmentation, linear mapping, encoding iterative enhancement, classification head conversion and softmax classification, the underwater acoustic target recognition result is output. The recognition rate of various underwater acoustic signals is output and displayed through serial communication.
[0007] In one embodiment, the pre-emphasis is used to enhance the high-frequency energy of the underwater acoustic signal and remove random noise; the frame-segmentation and windowing divides the denoised signal into multiple short-time data frames, enabling a smooth transition between data frames; the FFT converts the time-domain signal to the frequency-domain signal; the modulus squaring squares the FFT result to obtain the linear spectrum energy; the enhanced Mel filtering converts the energy spectrum into a Mel spectrogram; and the energy compression maps the energy data of the Mel spectrogram to a unified interval.
[0008] In one embodiment, the feature segmentation and linear mapping are implemented as follows: The feature segmentation layer takes the underwater acoustic signal feature map output by the underwater acoustic signal feature extraction module as input, and uses an overlapping sliding window method to crop the feature map. By filling the boundary at the end of the time dimension of the feature map, the time dimension sliding window is aligned to obtain multiple fixed-size patch vectors. Each patch vector is flattened and then converted into an embedding vector of a set dimension through a linear mapping layer. The embedding vector is added to the corresponding position code of the same dimension and concatenated with a category label vector of the same dimension to form a feature sequence, which is then input to the encoder. In the overlapping sliding window method, the overlap step size of adjacent patches in the time dimension and frequency dimension is consistent.
[0009] In one embodiment, the processing flow for the encoding iteration enhancement is as follows: The feature sequence is first normalized by the first root mean square normalization layer, after which the feature dimension remains unchanged. Subsequently, the normalized feature vectors are transformed by two sets of query vector transformation matrices. Two sets of key vector transformation matrices and a set of value vector transformation matrices Projecting yields the query vector Q, key vector K, and value vector V, and Q and K are grouped accordingly into ( , )and( , Two groups; to implement the multi-head differential attention mechanism, the two groups Q, two groups K, and one group V are split into dimensions according to the preset number of attention heads, and the sub-vectors corresponding to each group are obtained after splitting. , , , as well as The vector, where n is the number of attention heads, and the dimensions of the subvector matrix corresponding to each attention head remain consistent; The differential balance coefficients are adaptively updated according to time windows at the multi-head differential attention mechanism layer. All tokens within the same time window share the same attention across all heads. The difference balance coefficient The generation process includes: The feature sequence is divided into segments according to a sliding window with a set length and step size. Each time window is defined as its starting index and the set of covered frames on the original time frame. Based on Mel spectral features Calculate the high-frequency subband energy within each time window. With full-band energy : Noise fraction is defined based on high-frequency subband energy and full-band energy. : in, For the preset high-frequency subband set, For the total number of frequency bands, To avoid division by zero constants; Difference balance coefficients are generated through linear mapping and truncation functions: in These are trainable parameters or offline calibrated parameters. This is a truncation function used to truncate... It is restricted to the interval [0,1].
[0010] In one embodiment, the differential fusion process of the multi-head differential attention mechanism layer is as follows: for those belonging to the same time window The token serves as the corresponding row vector set for the query end, sharing the differential balance coefficient. Perform adaptive time-window-based differential operations on the i-th head to obtain the single-head differential attention weights: in, , These are the results of the softmax operation on the row sets of the two attention weight submatrices; through dynamic adjustment Achieving a balance between noise cancellation and target feature preservation; The output processing flow of the multi-head differential attention mechanism layer is as follows: The single-head differential attention weights are compared with their corresponding value vectors. Weighted summation yields single-head output The outputs of all attention heads are concatenated according to the last dimension, and the multi-head feature information is integrated through a linear projection matrix. Then, the input and output of this mechanism layer are added in alignment through a residual connection layer to obtain the residual output of the differential attention sublayer.
[0011] In one embodiment, the feedforward network in the encoder adopts a Swiglu structure. The specific processing flow is as follows: after the residual output passes through the second root mean square normalization layer, it is connected to the parallel linear branch in two paths to obtain the feature vector U and the gate vector Vg, respectively. After performing the Swish activation operation on U, it is multiplied element-wise with Vg, and then projected back to the original feature dimension through the linear layer to complete the nonlinear transformation. The feature vector U is used to carry the candidate discriminative features of the target voiceprint, and the gate vector Vg is used to suppress the noise-dominated invalid response and highlight the feature components related to the target category. The enhancement of key time-frequency evidence and the suppression of redundant noise are achieved through gate fusion. The output of the SwiGLU structure is added to the input features of the structure via a residual connection mechanism to form the final output of the current coding layer. The coding layer consists of 6 layers, each with the same structure and independent parameters. The output of the previous coding layer is used as the input of the next layer, and the final output of the encoder is obtained after iterative processing.
[0012] In one embodiment, the classification head transformation and softmax classification are implemented as follows: The classification head layer first performs dimensional transformation on the encoder output through the first linear layer, then performs non-linear transformation through the tanh activation layer, and finally transforms it through the second linear layer to obtain the category logits of the set dimensions. The first linear layer and the second linear layer adapt the dimensions to meet the feature transfer requirements. The softmax function normalizes the probability of each category logits to obtain the probability value of each category. The sum of the probability values is 1. The optimal category index is determined based on the order of the probability values, thus realizing the classification and recognition of underwater acoustic targets.
[0013] According to a second aspect of the present disclosure, an FPGA-based underwater acoustic target recognition acceleration system is provided, comprising: The dataset construction module collects different types of underwater acoustic signals and constructs an underwater acoustic signal dataset. The feature extraction module extracts features from the dataset through the underwater acoustic signal feature extraction module on the FPGA side. The features are processed sequentially by pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain an underwater acoustic signal feature map. The neural network classification module inputs the feature map into the differential Transformer neural network module on the FPGA, and outputs the underwater acoustic target recognition result after feature segmentation, linear mapping, encoding iterative enhancement, classification head transformation and softmax classification. The recognition result output module outputs and displays the recognition rate of various underwater acoustic signals via serial communication.
[0014] According to a third aspect of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the memory, wherein the processor executes the program to implement the FPGA-based underwater acoustic target recognition acceleration method.
[0015] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the FPGA-based underwater acoustic target recognition acceleration method.
[0016] The advantages of the above technical solutions adopted in this invention compared with the prior art are as follows: 1. This invention utilizes an automated underwater acoustic signal feature extraction and intelligent classification and recognition process, eliminating the need for manual observation and listening tests, thus significantly reducing human resource costs. Simultaneously, it avoids the influence of subjective human judgment on the recognition results, effectively reducing recognition discrepancies caused by subjective human judgment and ensuring the objectivity and consistency of the recognition results.
[0017] 2. By employing targeted feature extraction strategies such as pre-emphasis and enhanced Mel filtering, combined with the multi-head differential attention mechanism of the differential Transformer neural network and the SwiGLU activation function design, it can accurately capture the key time-frequency features of underwater acoustic targets, effectively counteracting interference from ocean noise and multipath effects, and achieving high recognition accuracy. At the same time, based on the parallel computing architecture of the FPGA hardware platform, the data processing and model calculation process is optimized, which has the advantages of fast response speed and convenient operation. Furthermore, the stability and sensitivity are improved through residual connections and root mean square normalization, making it suitable for the recognition needs of complex underwater environments.
[0018] 3. Compared with traditional CPU and GPU hardware platforms, this invention implements an overall acceleration architecture based on FPGA. The dedicated computing design of FPGA enables it to meet the recognition performance requirements while having lower power consumption, making it more suitable for resource-limited deployment scenarios such as underwater monitoring equipment. In addition, FPGA hardware is small in size and highly portable, making it easy to integrate into various underwater acoustic detection systems, thus expanding the practical application scenarios of the technology.
[0019] 4. The core architecture of this invention has good flexibility. As long as a sufficiently large labeled dataset is provided to train the neural network and the network parameters are adjusted as needed, it can adapt to the recognition needs of different marine environments (such as different water depths, signal-to-noise ratios, and sea conditions). It can not only expand the types of targets to be recognized, but also further optimize the recognition speed and accuracy. In addition, the design concept of this architecture can be transferred to other acoustic recognition-related fields, and has broad application expansion potential. Attached Figure Description
[0020] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0021] Figure 1 Here is a flowchart of the sound feature extraction module; Figure 2 A schematic diagram of cropping patch features from a spectrogram; Figure 3 This is a schematic diagram of the differential Transformer neural network model. Figure 4 This is a schematic diagram illustrating the principle of the differential attention mechanism. Figure 5 Hardware circuit diagram of the SwiGLU activation function module; Figure 6 This is the hardware circuit diagram of the multi-head differential attention mechanism layer module. Detailed Implementation
[0022] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.
[0023] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0024] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0025] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and systems according to various embodiments of this disclosure. It should be noted that each block in a flowchart or block diagram may represent a module, segment, or portion of code, which may include one or more executable instructions for implementing the logical functions specified in the various embodiments. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutively represented blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, may be implemented using a dedicated hardware-based system that performs the specified functions or operations, or using a combination of dedicated hardware and computer instructions.
[0026] Example 1: This embodiment provides an FPGA-based method for accelerating underwater acoustic target recognition, including the following steps: S1: Collect different types of underwater acoustic signals and construct an underwater acoustic signal dataset; Specifically, underwater acoustic signals are collected and an underwater acoustic signal dataset is constructed: raw signals from various underwater acoustic targets, such as sailboats, fishing boats, shellfish harvesting vessels, dredgers, and motorboats, are collected. Each type of signal is labeled with key attributes such as target category, propagation distance, and signal-to-noise ratio (SNR), forming a dataset containing 10,000 samples. To cover complex marine environments, samples with low SNR (SNR < 10dB) account for no less than 30% of the dataset. This dataset is used to train a differential Transformer recognition model, enabling the model to fully learn the discrimination features of underwater acoustic targets that remain stable under complex sea conditions, thereby improving the model's robustness in complex environments.
[0027] S2: The dataset is used to extract features through the underwater acoustic signal feature extraction module on the FPGA side, such as... Figure 1 As shown, the underwater acoustic signal feature map is obtained by sequentially performing pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression. Specifically, high-frequency signals attenuate significantly during underwater propagation, while key discrimination clues for many underwater acoustic targets are concentrated in the mid-to-high frequency bands. The pre-emphasis is used to boost the high-frequency components of the signal, compensating for the attenuation effect of the propagation channel on high-frequency signals, and making the signal spectrum flatter. The pre-emphasis processing is implemented as follows: Where s(n) is the nth sampling point of the signal, α is the preemphasis coefficient, and α is the preemphasis signal; The frame-segmentation and windowing process is used to divide the underwater acoustic signal into multiple short-time data frames, with each frame having 1024 sampling points. To ensure a smooth transition between adjacent data frames and avoid inter-frame abrupt changes interfering with subsequent processing, a Hamming window function is used to window each short-time data frame, outputting a stable signal for subsequent FFT processing. The Hamming window function is as follows: in Indicates frame length; for Hamming windows, The typical value is 0.46. Windowing of the framed signal is as follows: The FFT transforms a time-domain signal into a frequency-domain signal. Due to the symmetry of the Fourier transform factor, this process utilizes the Discrete Fourier Transform (DFT). Where n is the time variable, k is the frequency variable, and N is the length of the signal sequence; The modulus-squared processing is used to perform a modulus-squared operation on the frequency domain signal output by the FFT to obtain the linear spectral energy of the underwater acoustic signal. Since each frame of the signal has 1024 sampling points, the frequency domain signal output after Fourier transform has symmetry. Therefore, selecting the first 513 dimensions of the vector for modulus-squared operation is sufficient to fully characterize the linear spectral energy of the signal. Its spectral energy is as follows: in, Represents the real part of the signal after FFT transformation. Indicates the imaginary part; To address the frequency attenuation characteristics of underwater sound propagation—namely, "long propagation distance for low frequencies and rapid attenuation for high frequencies"—this invention improves the traditional Mel frequency conversion formula and designs an enhanced Mel filter module. This module consists of 128 Mel filters, and incorporates a depth attenuation factor related to the water depth at which the signal is acquired. ( (depth refers to the water depth for signal acquisition, in meters), making the filter bank more suitable for the frequency domain characteristics of underwater acoustic signals: The output of the Mel filter is calculated by multiplying the energy vector of the frame by the matrix product of the frequency response of the filter bank: in, For linear spectral energy, Let m be the frequency response of the m-th Mel filter. (M=128 is the number of filters), through The weights of mid-to-high frequency target features are increased to compensate for feature weakening caused by high-frequency attenuation.
[0028] The energy compression process is used to map the Mel spectrogram energy data output by the Mel filter module to a numerical range of -6 to 6 to adapt to the input requirements of the Transformer hardware accelerator. The energy compression is implemented as follows: Where dim is the dimension of the input signal. For frame number, This represents the numerical value of the Mel spectrum output by the Mel filter.
[0029] S3: Input the feature map into the differential Transformer neural network module on the FPGA. After feature segmentation, linear mapping, iterative enhancement of the coding layer, classification head transformation and softmax classification, the underwater acoustic target recognition result is output. The neural network structure used in this invention is a differential Transformer model derived from the classic Transformer network through adaptive improvements, such as... Figure 3 As shown. The improvement and implementation of this model are as follows: Input-side feature preprocessing optimization: A dedicated acoustic signal processing module is integrated at the front end of the Transformer structure to extract and preprocess the input underwater acoustic signal, converting it into an audio feature vector that can be directly input into the Transformer structure. This design can effectively reduce the interference of propagation attenuation, device gain differences, and sea state changes on feature distribution at the input end, thereby improving the effectiveness of subsequent feature learning.
[0030] The core differential attention mechanism is designed by using a subtraction of attention maps. Attention maps are generated by two independent sets of queries and key vectors, and then the two sets of attention maps are differentially calculated. This mechanism can accurately cancel common-mode attention noise, highlight the weights of key time-frequency regions that are strongly correlated with the underwater target category, thereby reducing the false detection rate and false negative rate in complex underwater environments and improving the robustness of the model.
[0031] The differential Transformer neural network module includes a feature block layer, a linear mapping layer, an encoding layer, a classification head layer, and a softmax classifier. The encoding layer incorporates two root mean square normalization layers, a multi-head differential attention mechanism layer, a residual connection layer, and a Swiglu activation function layer. The classification head layer consists of two linear layers and one tanh activation layer. The specific processing flow is as follows: The 128×100 underwater acoustic signal feature map output by the underwater acoustic signal feature extraction module is used as input. Considering that key discrimination clues of underwater acoustic targets often present a long and continuous energy distribution on the time-frequency map, direct hard segmentation can easily cause cross-block truncation of the line spectrum, loss of local evidence, and missed detections. Therefore, this feature segmentation layer uses an overlapping sliding window method to crop the 128×100 feature map: such as... Figure 2 As shown, the patch size is set to 16×16, and the overlap step of adjacent patches in both the time and frequency dimensions is set to 8, in order to improve the preservation of the time-frequency continuity information of underwater acoustic signals while controlling the computational load. Furthermore, to achieve sliding window alignment in the time dimension, the feature map is padded at the end of the time dimension, expanding the time length from 100 to 104. After padding, 12 sliding window positions can be formed in the time direction and 15 sliding window positions can be formed in the frequency direction, ultimately resulting in 15×12=180 16×16 patch vectors. Each patch vector is flattened to obtain a 1×256-dimensional patch vector, which is then converted into a 1×128-dimensional embedding vector through a linear mapping layer. This embedding vector is added to the positional encoding of the same dimension and concatenated with a 1×128-dimensional class label vector, ultimately forming an 181×128 feature sequence, which serves as the input to an encoder containing 6 coding layers.
[0032] like Figure 4 As shown, the feature sequence is first normalized by the first root mean square normalization layer, after which the feature dimension remains unchanged; subsequently, the normalized feature vectors are transformed by two sets of query vector transformation matrices. Two sets of key vector transformation matrices and a set of value vector transformation matrices The projection yields the query vector Q, key vector K, and value vector V, with Q and K grouped into (Q1, K1) and (Q2, K2) groups respectively. To implement the multi-head differential attention mechanism, the two groups of Q, two groups of K, and one group of V are split dimensionally according to the number of attention heads (4). The single-head dimension is 128 / 4 = 32. After splitting, we obtain... , , , as well as The vectors are all 181×32, and the matrix corresponding to each attention head is 181×32.
[0033] This invention introduces a differential balance coefficient that is adaptively updated according to a time window. Furthermore, all tokens within the same time window share the same attention across all heads. This allows for dynamic adjustment of the differential cancellation strength in response to abrupt and non-stationary changes in underwater noise over time. Specifically, the feature block layer is divided into Tp time windows (e.g., Tp=12) using a sliding window of length 16 and step size 8. Let the starting index of the tp-th time window in the original time frame be... Its covered frame set is Based on Mel spectral features Within this time window, the high-frequency sub-band energy and the full-band energy are calculated as follows: Where HF is a preset set of high-frequency sub-bands, and B is the total number of frequency bands; the noise fraction is defined based on the above energy calculation results: In the formula To avoid division by zero constants, difference balance coefficients are further generated through linear mapping and truncation functions: Where a and c are trainable parameters or offline calibration parameters, and clip() is a cutoff function used to restrict the value of λ(tp) to the interval [0,1].
[0034] During the differential fusion phase, tokens belonging to the same time window tp are used as the corresponding row vector set for the query end to share the differential balance coefficient. Perform adaptive time-window-based differential operations on the i-th head to obtain the single-head differential attention weights: in, , This differential operation can dynamically adapt to noise intensity: when underwater noise increases... Increase and strengthen the cancellation of common-mode noise components in the two attention maps; when the noise is weak. Reduce the weights to avoid excessively negating key voiceprint evidence of the target. Then, apply the single-head differential attention weights to the corresponding value vectors. Weighted summation yields single-head output After the independent calculations of the four attention heads are completed, the outputs of all heads are concatenated according to the last dimension to form a feature matrix with a dimension of 181×128. The multi-head feature information is integrated through a linear projection matrix, and then the input and output of the differential attention mechanism layer are added in alignment through a residual connection layer to obtain the residual output of the differential attention sub-layer.
[0035] The residual output, after being normalized by the second root mean square normalization layer, is input into a feedforward network with a SwiGLU structure to enhance the nonlinear discrimination representation of underwater acoustic targets under low signal-to-noise ratio and multipath conditions, thereby achieving gating enhancement and redundant noise suppression of key time-frequency evidence. The specific processing flow is as follows: the normalized 181×128-dimensional feature vector is fed into two parallel linear branches. The first branch is transformed by a 128×512-dimensional linear layer to obtain a 181×512-dimensional feature vector U (carrying candidate discrimination features of the target acoustic signature); the second branch is transformed by a 128×512-dimensional linear layer of the same dimension to generate a 181×512-dimensional gating vector Vg (suppressing noise-dominated invalid responses and highlighting target category-related feature components). After performing the Swish activation operation (Swish(x) = x·sigmoid(x)) on the feature vector U, it is multiplied element-wise with the gate vector Vg to obtain a 181×512-dimensional gated output feature. This is then projected through a 512×128-dimensional linear layer to restore the 181×128-dimensional feature vector, completing the nonlinear transformation of the SwiGLU layer. Subsequently, the input and output features of the SwiGLU layer are added in tandem through a residual connection mechanism to form the final output of the current coding layer. This coding layer output is input to subsequent coding layers with the same structure but independent parameters. After six layers of iterative processing, the final output of the encoder is obtained and used for subsequent underwater acoustic target classification.
[0036] The encoder output enters the classification head layer, and is processed sequentially through a 128×256-dimensional linear layer, a tanh activation layer, and a 256×4-dimensional linear layer to obtain 1×C-dimensional category logits. Finally, the softmax function is used to map the category logits to the probability distribution of each category, and the category index corresponding to the largest probability value is selected as the final underwater acoustic target recognition result.
[0037] It should be noted that the feature block layer can be composed of an input data RAMIP core, a row counter, a column counter, and an output data RAMIP core. First, the FPGA stores the underwater acoustic time-frequency feature map into the input data RAMIP core. To adapt to the input format of the differential Transformer coding layer, the 128*100 feature map is block-trimmed: the patch size is set to 16*16, and the overlap step for both the frequency and time dimensions is 8; through the coordinated control of the row and column counters, the feature map data is read block by block, ultimately resulting in 180 16*16 patch vectors. In terms of hardware implementation, there is no need to configure 180 independent RAMs. The read and write timing of a single set of output data RAMs is controlled only by a counter write enable signal: when pruning a single patch, the column counter increments from 0 to 15 to complete the reading of a single row. After the column reaches 15, the row counter increments by 1 and the column is cleared, until the row counter reaches 15, completing the reading of a single patch and writing it to the output RAM. After a single patch is written, the counter is reset, and all patches are stored sequentially. After reading, the 16*16 patch is flattened into a 1*256-dimensional vector. The flattened vector is linearly mapped to obtain a 1*128 embedding vector, which is superimposed with positional encoding of the same dimension, and then concatenated with a 1*128-dimensional class label vector to finally form an 181*128 feature sequence, which is used as the encoder input. The multi-head differential attention mechanism in the encoder can be composed of an input data RAMIP core, a weight parameter RAMIP core, a bias parameter RAMIP core, a multiplier IP core, a shift_ramIP core, an intermediate data RAMIP core, and an output data RAMIP core. The implementation of the multi-head differential attention mechanism is mainly accomplished by condition selection and matrix multiplication. First, the input data RAM stores the feature data. The shift_ramIP core synchronously shifts and delays the feature data and the three sets of weight parameters, ensuring that the feature column data and corresponding weights are aligned within the same clock cycle. The matrix multiplication operation is performed by a 16-bit signed multiplier IP core and a 16-bit adder. The multiplier outputs a 32-bit signed product, truncating 16 bits of the valid result. This accumulated result is then added to the value read from the bias parameter RAM to obtain Q. 1 / K 1 Q 2 / K 2 The matrix operation results of V are temporarily stored in intermediate data RAM. Then, the two sets of attention weight maps A_i are calculated separately. 1 A_i 2The difference operation is performed with the balance parameter ℷ, and the difference weights are weighted and summed with V to obtain a single-head output. The four head outputs are concatenated and linearly projected, and the final result is stored in the output data RAM. The root mean square normalization layer consists of an input data RAMIP core, a row counter, a column counter, a multiplier, a square root operation IP core, a shift_ramIP core, and an output data RAMIP core. First, the input data RAM stores 181*128-dimensional features to be normalized. The row and column counters read the features dimension by dimension and calculate the mean square value. The square root operation IP core obtains the root mean square. The shift_ramIP core synchronously shifts and times the input features and the root mean square to ensure timing alignment. The element-wise normalization operation is performed by the multiplier IP core, and the final normalization result is stored in the output data RAM, providing a stable feature distribution for subsequent networks. Figure 5 As shown, the Swiglu activation function layer can be composed of an input data RAMIP kernel, a weight parameter RAMIP kernel, a Sigmoid operation unit, a multiplier IP kernel, a shift_ramIP kernel, and an output data RAMIP kernel. This layer achieves nonlinear mapping through dual-branch parallel operation: First, the input data RAM stores feature data; the shift_ramIP kernel synchronously shifts and increments the feature data and two sets of weights, and the multiplier IP kernel performs matrix operations to obtain the feature vector U and the gate vector Vg, respectively; the Sigmoid operation unit calculates the Sigmoid value element-wise for U, and performs Swig activation with U through the element-wise multiplier IP kernel; the activation result is then multiplied element-wise with Vg, projected back to the original dimension through weight matrix operations, and the final result is stored in the output data RAM, completing the nonlinear transformation. The classification head layer consists of two linear layers and an intermediate tanh nonlinear activation layer. Since the tanh function expression is nonlinear: During hardware implementation, it is approximated as a piecewise linear function, as follows: The residual connection layer is deployed after the multi-head attention mechanism layer and the SwiGLU activation function layer. Its core function is to alleviate the gradient vanishing problem during model training and improve the stability of model training. This residual connection layer consists of a counter, a multiplier, and a storage unit. The specific workflow is as follows: it retrieves input and output signals of the same format as the preceding modules from the storage unit, performs bitwise addition on the two sets of signals, and then stores the result back into the storage unit. When the counter counts to the last bit, the entire operation process of the residual connection layer is completed. The softmax classifier consists of an input data RAMIP core, an exponentiation unit, a multiplier, a comparator IP core, and an output data RAMIP core. The specific processing flow of this module is as follows: first, it performs element-wise exponentiation on the input data; then, it uses a multiplier to divide each exponent value by the sum of all exponent values to obtain the probability distribution corresponding to each category; subsequently, it uses the comparator IP core to filter out the category index corresponding to the maximum probability; finally, it stores the probability distribution result and the category index into the output data RAMIP core to complete the final decision for underwater acoustic target recognition.
[0038] S4: Outputs and displays the recognition rate of various underwater acoustic signals via serial communication.
[0039] Example 2: This embodiment provides an FPGA-based underwater acoustic target recognition acceleration system, including: The dataset construction module collects different types of underwater acoustic signals and constructs an underwater acoustic signal dataset. The feature extraction module extracts features from the dataset through the underwater acoustic signal feature extraction module on the FPGA side. The features are processed sequentially by pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain an underwater acoustic signal feature map. The neural network classification module inputs the feature map into the differential Transformer neural network module on the FPGA, and outputs the underwater acoustic target recognition result after feature segmentation, linear mapping, encoding iterative enhancement, classification head transformation and softmax classification. The recognition result output module outputs and displays the recognition rate of various underwater acoustic signals via serial communication.
[0040] The above modules can be deployed on the same device or distributed devices; the division of modules is only a functional logic description and does not limit the specific physical boundaries or implementation order.
[0041] Example 3: An electronic device is provided for running the aforementioned "FPGA-based underwater acoustic target recognition acceleration method". The electronic device includes a processor, a memory, and optional communication interfaces / display devices / input devices, etc.; the memory stores a computer program that can run on the processor, and when the processor executes the program, it implements steps S1 to S4 of the method described in Embodiment 1, specifically including but not limited to: S1: Collect different types of underwater acoustic signals and construct an underwater acoustic signal dataset; S2: The underwater acoustic signal feature extraction module on the FPGA performs feature extraction on the dataset, and sequentially processes it through pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain the underwater acoustic signal feature map. S3: Input the feature map into the differential Transformer neural network module on the FPGA. After feature segmentation, linear mapping, iterative enhancement of the coding layer, classification head transformation and softmax classification, the underwater acoustic target recognition result is output. S4: Outputs and displays the recognition rate of various underwater acoustic signals via serial communication.
[0042] The electronic device hardware can be one of a server, personal computer, workstation, industrial controller, edge computing device, or mobile terminal; the processor is an FPGA; the memory can be RAM, ROM, flash memory, or a disk array. The device can interact with local / remote data storage (acquiring observation data and outputting inversion results) through a communication interface. The above hardware configuration does not constitute a limitation of the present invention.
[0043] Example 4: A computer-readable storage medium storing a computer program, which, when run on a processor of an electronic device, causes the program to perform the method steps S1 to S4 described in Embodiment 1; the storage medium may be a disk, optical disk, flash memory, solid-state drive, read-only memory, random access memory, or any combination of the above media.
[0044] Those skilled in the art will understand that the modules or steps described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, which can then be stored in a storage device for execution by a computer device. Alternatively, they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. This disclosure is not limited to any particular combination of hardware and software.
[0045] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0046] While the specific embodiments of this disclosure have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of this disclosure. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this disclosure are still within the scope of protection of this disclosure.
Claims
1. An FPGA-based method for accelerating underwater acoustic target recognition, characterized in that, Includes the following steps: Collect different types of underwater acoustic signals and construct an underwater acoustic signal dataset; The underwater acoustic signal feature extraction module on the FPGA is used to extract features from the dataset. The features are then processed sequentially by pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain an underwater acoustic signal feature map. The feature map is input into the differential Transformer neural network module on the FPGA. After feature segmentation, linear mapping, encoding iterative enhancement, classification head conversion and softmax classification, the underwater acoustic target recognition result is output. The recognition rate of various underwater acoustic signals is output and displayed through serial communication.
2. The FPGA-based underwater acoustic target recognition acceleration method according to claim 1, characterized in that, The pre-emphasis is used to enhance the high-frequency energy of the underwater acoustic signal and remove random noise; the frame-segmentation and windowing divides the denoised signal into multiple short-time data frames, so that the data frames transition smoothly. The FFT converts the time-domain signal to the frequency-domain signal; the modulus squaring step squares the FFT result to obtain the linear spectral energy. The enhanced Mel filtering converts the energy spectrum into a Mel spectrogram; the energy compression maps the energy data of the Mel spectrogram to a unified range.
3. The FPGA-based underwater acoustic target recognition acceleration method according to claim 1, characterized in that, The feature segmentation and linear mapping are implemented as follows: the feature segmentation layer takes the underwater acoustic signal feature map output by the underwater acoustic signal feature extraction module as input, and uses an overlapping sliding window method to crop the feature map. By filling the boundary at the end of the time dimension of the feature map, the time dimension sliding window is aligned to obtain multiple fixed-size patch vectors. Each patch vector is flattened and then converted into an embedding vector of a set dimension through a linear mapping layer. The embedding vector is added to the corresponding position code of the same dimension and concatenated with a category label vector of the same dimension to form a feature sequence, which is then input to the encoder. In the overlapping sliding window method, the overlap step size of adjacent patches in the time dimension and frequency dimension is kept consistent.
4. The FPGA-based underwater acoustic target recognition acceleration method according to claim 1, characterized in that, The processing flow for the encoding iteration enhancement is as follows: The feature sequence is first normalized by the first root mean square normalization layer, after which the feature dimension remains unchanged. Subsequently, the normalized feature vectors are transformed by two sets of query vector transformation matrices. Two sets of key vector transformation matrices and a set of value vector transformation matrices Projecting yields the query vector Q, key vector K, and value vector V, and Q and K are grouped accordingly into ( , )and( , Two groups; to implement the multi-head differential attention mechanism, the two groups Q, two groups K, and one group V are split into dimensions according to the preset number of attention heads, and the sub-vectors corresponding to each group are obtained after splitting. , , , as well as The vector, where n is the number of attention heads, and the dimensions of the subvector matrix corresponding to each attention head remain consistent; The differential balance coefficients are adaptively updated according to time windows at the multi-head differential attention mechanism layer. All tokens within the same time window share the same attention across all heads. The difference balance coefficient The generation process includes: The feature sequence is divided into segments according to a sliding window with a set length and step size. Each time window is defined as its starting index and the set of covered frames on the original time frame. Based on Mel spectral features Calculate the high-frequency subband energy within each time window. With full-band energy : Noise fraction is defined based on high-frequency subband energy and full-band energy. : in, For the preset high-frequency subband set, For the total number of frequency bands, To avoid division by zero constants; Difference balance coefficients are generated through linear mapping and truncation functions: in These are trainable parameters or offline calibrated parameters. This is a truncation function used to truncate... It is restricted to the interval [0,1].
5. The FPGA-based underwater acoustic target recognition acceleration method according to claim 4, characterized in that, The differential fusion process of the multi-head differential attention mechanism layer is as follows: for those belonging to the same time window The token serves as the corresponding row vector set for the query end, sharing the differential balance coefficient. Perform adaptive time-window-based differential operations on the i-th head to obtain the single-head differential attention weights: in, , These are the results of the softmax operation on the row sets of the two attention weight submatrices; through dynamic adjustment Achieving a balance between noise cancellation and target feature preservation; The output processing flow of the multi-head differential attention mechanism layer is as follows: The single-head differential attention weights are compared with their corresponding value vectors. Weighted summation yields single-head output The outputs of all attention heads are concatenated according to the last dimension, and the multi-head feature information is integrated through a linear projection matrix. Then, the input and output of this mechanism layer are added in alignment through a residual connection layer to obtain the residual output of the differential attention sublayer.
6. The FPGA-based underwater acoustic target recognition acceleration method according to claim 5, characterized in that, The feedforward network in the encoder adopts the Swiglu structure. The specific processing flow is as follows: after the residual output passes through the second root mean square normalization layer, it is connected to the parallel linear branch in two paths to obtain the feature vector U and the gate vector Vg respectively. After performing the Swish activation operation on U, it is multiplied element by element with Vg, and then projected back to the original feature dimension through the linear layer to complete the nonlinear transformation. The feature vector U is used to carry the candidate discriminative features of the target voiceprint, and the gate vector Vg is used to suppress noise-dominated invalid responses and highlight feature components related to the target category. The gate fusion is used to enhance key time-frequency evidence and suppress redundant noise. The output of the SwiGLU structure is added to the input features of the structure via a residual connection mechanism to form the final output of the current coding layer. The coding layer consists of 6 layers, each with the same structure and independent parameters. The output of the previous coding layer is used as the input of the next layer, and the final output of the encoder is obtained after iterative processing.
7. The FPGA-based underwater acoustic target recognition acceleration method according to claim 1, characterized in that, The implementation methods for classifier conversion and softmax classification are as follows: The classification head layer first performs dimensional transformation on the encoder output through the first linear layer, then performs non-linear transformation through the tanh activation layer, and finally transforms it through the second linear layer to obtain the category logits of the set dimensions. The first linear layer and the second linear layer adapt the dimensions to meet the feature transfer requirements. The softmax function normalizes the probability of each category logits to obtain the probability value of each category. The sum of the probability values is 1. The optimal category index is determined based on the order of the probability values, thus realizing the classification and recognition of underwater acoustic targets.
8. An FPGA-based underwater acoustic target recognition acceleration system, characterized in that, include: The dataset construction module collects different types of underwater acoustic signals and constructs an underwater acoustic signal dataset. The feature extraction module extracts features from the dataset through the underwater acoustic signal feature extraction module on the FPGA side. The features are processed sequentially by pre-emphasis, frame windowing, FFT, modulus square, enhanced Mel filtering, and energy compression to obtain an underwater acoustic signal feature map. The neural network classification module inputs the feature map into the differential Transformer neural network module on the FPGA, and outputs the underwater acoustic target recognition result after feature segmentation, linear mapping, encoding iterative enhancement, classification head transformation and softmax classification. The recognition result output module outputs and displays the recognition rate of various underwater acoustic signals via serial communication.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and running thereon, characterized in that, When the processor executes the program, it implements the FPGA-based underwater acoustic target recognition acceleration method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the FPGA-based underwater acoustic target recognition acceleration method according to any one of claims 1-7.