# Data Independent Acquisition Based Bi-Directional Deep Networks for Biometric ECG Authentication
## 3 Methodology
### Models Overview
#### 3.3.2 Proposed Bidirectional RNN Architectures  
To investigate the use of RNN methods for ECG classification, we proposed the models based on different types of RNN techniques. The input training data can be set by \(S=(X_{n},O_{n}),n=1,...,N\), where the sample suggests the \(m\) numbers of samples in a signal with 251-sampled segments following the procedure used in the preprocessing phase, whereas 301-sampled segmented windows are for the ECG-ID dataset, where \(i\) denotes the number of \(O_{i}^{n}\) subject, which denotes the corresponding ground truth for each subject of the nth input. The ground truth values are determined as 1 for a given subject signal, and 0 for the other subjects, respectively. For a given sequence input, a classifier is trained to learn the probabilities of \(N\) classes.  
The first proposed model for the non-fiducial approach is based on a bidirectional RNN with an LSTM cell unit in the hidden state layer, and is called BLSTM, as shown in Figure 2(a). It is associated with the cell unit. The segmented signal inputs \(x_{1},...,x_{T}\) from the pre-processing section, are fed into the network for each time step \(t(t=1,...,T)\) for each LSTM cell. Each cell unit in a bi-directional manner consists of a parallel of LSTM tracks, known as forward and backward sequences, to capture the context from the past and future. During the final time step, the two parallel tracks of the LSTM cell unit are concatenated into a single vector. In the first hidden layer, the forward cell states \(h_{0}^{f}\), and the backward cell state \(h_{0}^{b}\) are initialized with zero for all layers \(N\). The input \(x_{t}\) at time \(t\), and previous cell states \(h_{t-1}\) to produce the output of the corresponding layer \(p_{t}^{n}\) at time \(t\) and at the \(n\)th layer for both backward or forward tracks given its parameter \(\theta^{n}\), can be defined as  
\[\begin{split}& o_{t}^{n},h_{t}^{n}=LSTM^{n}(h_{t-1}^{n},x_{t}; \theta^{n})\\ & o_{t}^{n},h_{t}^{n}=GRU^{n}(h_{t-1}^{n},x_{t};\theta^{n})\end{split} \tag{17}\]  
where \(\theta^{n}\) denotes the parameters \((b,U,W)\) of the respective cell unit for layer \(n\).  
For the next proposed model, see Figure 2(b), the only difference between BLSTM and the GRU gate units is the cell unit at the hidden layers. In addition, to address one of the most important challenges in deep neural networks, overfitting, the dropout layer is applied to each cell for all RNN-based methods. Sharing the similar outputs as in BLSTM at the last layer, the outputs from both forward and backward track, the late fusion for bidirectional networks is concatenated into a single vector. Then, the output is followed by a softmax activation function to achieve the N-dimensional output in the last layer. The overall model architecture is shown in Figure 7. As implemented based on a bi-directional manner, the forward track trains the input from left to right, while the backward track traces the input from right to left in both BLSTM and BGRU, and can be defined as follows:  
\[o_{t}^{f},h_{t}^{f},c_{t}^{f} =LSTM^{f}(c_{t-1}^{f},h_{t-1}^{f},x_{t};W^{f}) \tag{19}\] \[o_{t}^{b},h_{t}^{b},c_{t}^{b} =LSTM^{b}(c_{t-1}^{b},h_{t-1}^{b},x_{t};W^{b})\] (20) \[o_{t}^{f},h_{t}^{f},c_{t}^{f} =GRU^{f}(c_{t-1}^{f},h_{t-1}^{f},x_{t};W^{f})\] (21) \[o_{t}^{b},h_{t}^{b},c_{t}^{b} =GRU^{f}(c_{t-1}^{b},h_{t-1}^{b},x_{t};W^{b}) \tag{22}\]