# A Quality Control Method for High Frequency Radar Data Based on Machine Learning Neural Networks
## 2 Materials and Methods
### Prediction-Based Anomaly Detector
#### 2.2.2 Bi LSTM Neural Network  
Introduced by [PERSON] and [PERSON] in 1997 [22], the LSTM neural network model enhances the memory mechanism inherent in Recurrent Neural Networks (RNNs). Traditional RNNs often encounter the \"vanishing gradients\" problem, leading to challenges in learning long-term dependencies. LSTM addresses this by integrating \"gate\" units. These gate units control the processes of reading, writing, and erasing information in memory cells, thus enabling the LSTM to capture and learn from long-term dependencies in data sequences more effectively. Various LSTM variants have been developed over the years. However, research [23] indicates that these adaptations offer no significant improvement over the standard LSTM  
Figure 2: Model anomaly detection process flowchart. model. In light of this, our study utilizes the conventional LSTM model, as depicted in Figure 3. The model is characterized as follows:  
Inputs and gates: At a given time step \(t\), the LSTM unit accepts the output from the previous time step, \(h_{t-1}\), and the current input vector, \(x_{t}\). These inputs interact with three crucial gate units:  
Forget gate (\(f_{t}\)): Determines the extent of information in the memory cell \(c_{t}\) to be discarded. \[f_{t}=\sigma\Big{(}W_{f^{\prime}}[h_{t-1}\,,x_{t}]+b_{f}\Big{)} \tag{1}\]  
Input gate (\(i_{t}\)): Decides the magnitude of new information to be written into the memory cell. \[i_{t}=\sigma(W_{i}[h_{t-1}\,,x_{t}]+b_{i}) \tag{2}\]  
Output gate (\(o_{t}\)): Establishes the output \(h_{t}\) for the current time step. \[o_{t}=\sigma(W_{o}[h_{t-1}\,,x_{t}]+b_{o}) \tag{3}\]  
\[h_{t}=o_{t}\text{-}\tan h(C_{t}) \tag{4}\]  
Memory cell update: The memory cell's state is updated based on the outputs from the forget and input gates. \[\widetilde{C}_{t}=\tan h(W_{C}\text{-}[h_{t-1}\,,x_{t}]+b_{C}) \tag{5}\]  
\[C_{t}=f_{t}\text{-}C_{t-1}+i_{t}\text{-}\widetilde{C}_{t} \tag{6}\]  
Key Parameters:  
\(W_{f}\), \(W_{i}\), \(W_{o}\), and \(W_{c}\): Weights for the respective gates and cell update. \(b_{f}\), \(b_{i}\), \(b_{o}\), and \(b_{c}\): Biases for the respective gates and cell update. \(\sigma\): The sigmoid activation function, responsible for introducing nonlinearity. The above formulas and terminologies present a comprehensive picture of the LSTM's underlying computations, highlighting its ability to capture and learn long-term dependencies in data sequences. A vast body of research has proven that the Long Short-Term Memory (LSTM) neural network model is effective for analyzing time series data. The unique architecture of LSTMs enables them to effectively capture long-term dependencies within time series data. Figure 3: Diagrammatic illustration of the LSTM cell architecture. Building upon this foundation, we further adopted the Bidirectional LSTM (Bi-LSTM) model. The concept of the Bi-LSTM neural network is derived from bidirectional recurrent neural networks (RNNs) [24]. Unlike the traditional unidirectional LSTM, the Bi-LSTM incorporates both forward and backward LSTM layers (as illustrated in Figure 4), endowing it with bidirectional data processing capabilities. The bidirectionality of Bi-LSTM offers a holistic perspective on ocean-current behaviors, considering both historical and anticipated data. This approach is especially pertinent to the complex patterns of ocean currents, ensuring that detected anomalies are substantial and not fleeting disturbances. The bidirectional structure provides a rich contextual framework for our predictive model, enhancing the precision and reliability of anomaly detection. Numerous studies have affirmed the utility of Bi-LSTM in scenarios requiring consideration of contextual information, such as classification [25; 26], speech recognition [27; 28], and time series forecasting [29; 30]. Neural network structures typically consist of three main components: the input layer, the hidden layers, and the output layer.