## 3 Materials and Methods
### LSTM Processing of ECG Data  
LSTM networks have been specifically designed to find patterns over time [30]. Since ECG signals are sequences of peaks, the ability to memorize characteristic fragments of time series is critical when using LSTM in this area. Long-term and short-term memory is the main reason that the LSTM network is used as the basic structure of ECG signal recognition systems. In the present study, the deep LSTM network was used to classify ECG signals.  
Passing a signal through a standard LSTM network structure involves four stages. The first stage is the passage of the signal through the sigmoidal layer, which is designed to determine the desired information. The second stage consists of passing through the sigmoidal layer, which determines whether this or that information is relevant and transmits a signal to the hyperbolic layer, which defines a new vector of candidates. The  
Figure 4: Reverse DWT ECG signal, where \(S(t)\) is a noise-free ECG signal, \(2\uparrow\) is interpolation, \(\tilde{g}\) is a low-pass synthesis filter, \(\tilde{h}\) is a high-pass synthesis filter.  
third stage is to save a new vector of candidates. The fourth stage consists of passing through the sigmoidal layer, which is designed to determine the required information, and the hyperbolic tangent to display information in the range \([-1;1]\). Figure 5 shows a typical LSTM structure.  
To classify ECG signals, it is proposed to use an LSTM network with two input layers \(y_{1}\) and \(y_{2}\), which are combined into a two-dimensional vector \(x\). All calculations are performed according to the standard LSTM structure, which is shown in Figure 3, where \(x\) is the input two-dimensional vector, \(h_{t-1}\) is the output vector from the previous LSTM (\(h_{0}=0\)) block, \(h_{t}\) is the output vector of the LSTM block, \(C_{t-1}\) is the state vector from the previous LSTM (\(C_{0}=0\)) block, \(C_{t}\) is the state vector of the LSTM block, \(\sigma\) is the sigmoid activation function, \(tanh\) is the hyperbolic tangent activation function, \(\times\) is the multiplication operator, \(+\) is the addition operator.  
The forget gate vector \(f_{t}\) is the result of a computational step through the sigmoidal layer, which is intended to determine the desired information. The resulting vector determines what information needs to be \"memorized\" and is calculated by the formula:  
\[f_{t}=\ \sigma\Big{(}M_{f}[h_{t-1},x]+b_{f}\Big{)}, \tag{10}\]  
where \(M_{f}\) is a matrix of parameters, \(b_{f}\) is a vector of parameters. Update gate vector \(i_{t}\) checks the relevance of the information using the sigmoidal activation function:  
\[i_{t}=\ \sigma(M_{i}[h_{t-1},x]+b_{i}), \tag{11}\]  
where \(M_{i}\) is a matrix of parameters, \(b_{i}\) is a vector of parameters.  
The next step is to define a new state vector.  
\[C_{t}\ =f_{t}\times C_{t-1}+i_{t}\times tanh(M_{C}[h_{t-1},x]+b_{C}), \tag{12}\]  
where \(M_{C}\) is a matrix of parameters, \(b_{c}\) is a vector of parameters,\(\times\) is the multiplication operator.  
The output gate vector \(O_{t}\) that is a candidate for leaving the LSTM network is calculated by the formula:  
\[O_{t}=\ \sigma(M_{O}[h_{t-1},x]+b_{O}), \tag{13}\]  
where \(M_{O}\) is a matrix of parameters, \(b_{O}\) is a vector of parameters. The definition of the output vector \(h_{t}\) is made according to the formula:  
\[h_{t}=\ O_{t}\times\sigma(C_{t}). \tag{14}\]  
Figure 5: Standard LSTM structure.  
The rest of the LSTM network layers are standard and are used in neural networks to classify signals.