## 2 Materials and Methods
### Sequence Modeling Classifier  
#### 2.3.1 Recurrent Neural Network  
Recurrent Neural Network (RNN) is a type of artificial neural network architecture with recurrent connections to process input data [12]. RNN is categorized as a deep learning technique due to an automatic process of feature calculation without predetermining some appropriate features [28]. RNN has \"memory\", namely, state \((s_{t})\) that captures information about all input elements \((x_{t})\) to output \(\hat{y}_{t}\)[29]. Original RNN, also known as vanilla RNN, has similar forward pass and backward pass processes as other artificial neural networks. The difference is only in the backpropagation process where the term being backpropagation is defined through time (BPTT) [30].  
The model refers to three matrix weights in Figure 3, namely the weight between the input and hidden layers \(\left(w_{lux}\in R^{hwx}\right)\), the weight between two hidden layers \(\left(w_{hh}\in R^{hwh}\right)\), and the weights between hidden and output layers \(\left(w_{yh}\in R^{wh}\right)\). Otherwise, the bias is added to the hidden layer \(\left(b_{h}\in R^{h}\right)\), and the bias vector is added to the output layer \(\left(b_{y}\in R^{y}\right)\). The RNN model can be represented in Equations (1) to (3):  
\[h_{t}=f_{w}(h_{t-1},x_{t}) \tag{1}\]  
\[h_{t}=f(w_{lux}x_{t}+w_{ht}x_{t-1}+b_{h}) \tag{2}\]  
\[\hat{y}_{t}=f\big{(}w_{yh}h_{t}+b_{y}\big{)}. \tag{3}\]  
It is also well known that the RNN method is sequentially trained method with supervised learning. For step time \(t\), the error results from the difference between the predictions and actual is defined as \((\hat{y}_{t}-y_{t})\), where, the error or loss \(\ell\) is the sum of loss at the time step from \(t\) to \(T\) :  
\[\ell(\hat{y},y)=\sum_{t=1}^{T}\ell(\hat{y}_{t},y_{t}) \tag{4}\]  
Theoretically, the original RNN can handle input dependencies in the long-term, but in practice, the training process of such networks will result to vanishing problems or exploding gradients which is more inefficient when the number of time spans in the input sequence increases [18]. Suppose the ECG data have a total error in all time steps \(T\):  
\[\frac{\partial E}{\partial W}=\sum_{t=1}^{T}\frac{\partial E_{t}}{\partial W} \tag{5}\]  
By applying the chain rules, Equation (5) can be explained as  
\[\frac{\partial E}{\partial W}=\sum_{t=1}^{T}\frac{\partial E}{\partial y_{t}} \frac{\partial y_{t}}{\partial h_{t}}\frac{\partial h_{t}}{\partial h_{t}} \frac{\partial h_{k}}{\partial W} \tag{6}\]  
Figure 3: The forward and backward pass in recurrent neural network (RNN) standard [18].  
Equation (6) is a derivative of a hidden state that stores memory at time \(t\) which is related to the hidden state at the previous time \(k\). This phase involves the Jacobians matrix for the current time \(t\) and one-time \(k\):  
\[\frac{\partial h_{t}}{\partial h_{k}}=\frac{\partial h_{t}}{\partial h_{t-1}} \frac{\partial h_{t-1}}{\partial h_{t-2}}\ldots\frac{\partial h_{k+1}}{ \partial h_{k}}=\prod_{i=k+1}^{t}\frac{\partial h_{i}}{\partial h_{i-1}} \tag{7}\]  
The Jacobian matrix in Equation (7) displays the Eigen Decomposition is given by \(W^{T}diag[f^{\prime}(h_{t-1})]\); the eigenvalues are produced \(\lambda_{1},\lambda_{2},\ldots,\lambda_{n}\), where \(|\lambda_{1}|>\)\(|\lambda_{2}|\ldots|\lambda_{n}|\) and that corresponds to eigenvectors \(\
u_{1},\
u_{2},\ldots v_{n}\). If the largest eigenvalue is produced \(\lambda_{i}<1\) there will be vanishing gradient, on the contrary, if the value of \(\lambda_{i}>1\), then there will be an exploding gradient. To overcome vanishing and exploding gradient problems on RNN standard, LSTM and GRU can be used [18].