# An Interpretable Deep Learning Approach for Detecting Marine Heatwaves Patterns
## 2 Methods
### Prediction Using the LSTM Network
#### 2.1.2 LSTM Model  
Due to the design of gating mechanisms and memory units, the LSTM model [30] is able to flexibly store, forget, and update information in time series data. This allows LSTM to effectively capture long-term dependencies in time series and demonstrate excellent performance in tasks such as prediction and sequence generation. Additionally, this model aids in decomposing internal signals. In the context of the marine heatwave problem, the model used in this study consists of an LSTM layer and a dense layer to predict sea surface temperature. The SST at each station is treated as time series data. The model takes the daily [P,U,V] of the previous 180 time steps as the input sequence \([x_{t}]\) (\(t\in[1,T]\), \(T=180\)) to predict the sea surface temperature and identify occurrences of marine heatwave events. The LSTM network operates in a chain-like manner, passing information through recurrent units and performing long-term memory and nonlinear transformations through the computation of cell states and hidden states. The LSTM includes a cell state vector \([c_{t}]\) that maintains the network's long-term memory and a  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Station** & **Latitude** & **Longitude** & **Mean Pressure (Pa)** & \begin{tabular}{c} **Mean Wind** \\ **Speed (m/s)** \\ \end{tabular}  & **Mean SST (\({}^{\circ}\)C)** \\ \hline \hline \ \begin{tabular}{c} [PERSON] (LYG) \\ [PERSON] (LSI) \\ [PERSON] (SSN) \\ [PERSON] (DCN) \\ [PERSON] (DSN) \\ [PERSON] (NJI) \\ [PERSON] (BSG) \\ [PERSON] (ZLG) \\ [PERSON] (BSG) \\ [PERSON] (ZLG) \\ Beibu Gulf (BBG) \\ Nansha Islands (NSI) \\ \end{tabular}  &
\begin{tabular}{c} 119.4\({}^{\circ}\) E \\ 32.1\({}^{\circ}\) N \\ 32.1\({}^{\circ}\) N \\  
hidden state vector \([h_{t}]\) that serves as the non-linear transform output of the cell state. At each time step \(t\), the recurrent unit receives the cell state and hidden state from the previous unit (\(c_{t-1}\) and \(h_{t-1}\)) as well as the current input (\(x_{t}\)), and computes the current cell state and hidden state (\(c_{t}\) and \(h_{t}\)) for use by subsequent units. The hidden state of the last time step is then mapped to a single neuron through the dense layer to obtain the prediction result. Figure 3 illustrates the structure of a single LSTM unit. Figure 3 presents the architecture of an LSTM unit, which includes four multilayer perceptrons that are based on the prior hidden state and current input to calculate the forget gate (\(f_{t}\)), candidate cell state (\(c_{t}\)), input gate (\(i_{t}\)), and output gate (\(o_{t}\)). It then linearly updates the cell state (\(c_{t-1}\)). Using the output gate and the new cell state (\(c_{t}\)), a nonlinear transformation is applied to produce the hidden state (\(h_{t}\)). The operations of the LSTM can be represented with the following mathematical expressions:  
\[ \begin{array}{l}f_{t}=\sigma\Big{(}W_{fx}x_{t}+W_{fh}h_{t-1}+b_{f}\Big{)}\\ \bar{c}_{t}=\tanh(W_{cx}x_{t}+W_{dh}h_{t-1}+b_{\bar{c}})\\ i_{t}=\sigma(W_{ix}x_{t}+W_{ih}h_{t-1}+b_{i})\\ o_{t}=\sigma(W_{ox}x_{t}+W_{uh}h_{t-1}+b_{o})\\ c_{t}=f_{t}\odot c_{t-1}+i_{t}\odot\bar{c}_{t}\\ h_{t}=o_{t}\odot\tanh(c_{t})\end{array}  \tag{1}\]  
where \(W_{\square}\) and \(b_{\square}\) are weights and biases that need to be determined during training, \(\sigma(\cdot)\) and \(\tanh(\cdot)\) denote the sigmoid function and the hyperbolic tangent function, respectively, and \(\odot\) signifies element-wise multiplication. Within the model, three gates control the flow of information; \(c_{t}\) amalgamates prior and current information, while \(h_{t}\) considers the input across all time steps. The \(c_{t}\) and \(h_{t}\) of a multi-unit LSTM followed by a fully connected layer are used to reduce dimensionality for predictions. The training process employs the Adaptive Moment Estimation (Adam) algorithm [31] alongside an early stopping strategy to prevent overfitting.