## 2 Proposed ECG Authentication Algorithm Using Residual Depthwise Separable CNN  
To simplify the ECG authentication process, the proposed method in this paper requires only two stages, including the segmentation stage and the classification stage. The segmentation stage carried out ECG beat detection and segmentation, while the classification stage performed feature extraction and classification. ECG beat detection is performed using [PERSON]'s methods [18; 19]. The segmentation is based on the relative position of the \(R_{peak}\), and occurs \(\frac{1}{4}N\) before \(R_{peak}\) and \(\frac{3}{4}N\) after \(R_{peak}N\) depends on the sampling frequency and is set to 256 samples for both ECG-ID and MIT-BIHdatabases. Note that preprocessing has been performed on both databases to eliminate baseline drift and to remove powerline and high-frequency noises [10]. Therefore, it can be assumed that the ECG signals from both databases were ready to be used for further processing. The second stage, or classification stage, is realized by implementing the Residual Depthwise Convolutional Neural Network. The CNN used in this second stage is 1D-CNN that contains 28 layers. The 21 layers consist of seven layers of residual depthwise separable convolution neural network (RDSCNN) repeated three times, as illustrated in Figure 1.  
As shown in Figure 1, there are seven layers repeated three times, including a max pooling layer, three layers of 1D-CNN (Conv1D), a batch normalization layer, an activation layer, and an add layer. This structure is called as Residual Depthwise Separable Convolution implementation. The residual implementation uses a shortcut Max Pooling layer, while depthwise separable convolution implementation uses three Conv1D layers with the filter size [5 1 5], respectively. The summary of the proposed CNN model will be discussed in more detail in Section 3.3. There are 10 Conv1D layers in the proposed algorithm, which can be calculated using Equation (1) to (4), as follows [20]:  
\[x_{k}^{l}=\beta_{k}^{l}+\sum_{i=1}^{N_{l-1}}conv1D\Big{(}\alpha_{ik}^{l-1},s_{ i}^{l-1}\Big{)} \tag{1}\]  
\[\Delta s_{k}^{l}=\sum_{i=1}^{N_{l+1}}conv1 Dz\Big{(}\Delta_{i}^{l+1},rev\Big{(} \omega_{ik}^{l}\Big{)}\Big{)} \tag{2}\]  
\[\frac{\partial E}{\partial\omega_{ik}^{l}}=conv1D\Big{(}s_{k}^{l},\Delta_{i}^{ l+1}\Big{)} \tag{3}\]  
\[\frac{\partial E}{\partial\beta_{k}^{l}}=\sum_{n}\Delta_{k}^{l}(n) \tag{4}\]  
where \(l\) is the layer number, \(k\) is the filter number at the particular layer, \(i\) is the index coefficient \(w\) of the filter, \(x_{k}^{l}\) is the input and \(\omega_{ik}^{l-1}\) is the kernel (weight) from the \(i\)-th neuron at layer \(l-1\) to the \(k\)-th neuron at layer \(l\). \(s_{i}^{l-1}\) is the output of the \(i\)-th neuron at layer \(l-1\) and \(\beta_{k}^{l}\) is the bias, which can be assumed to be zero. \(conv1 Dz(\cdot,\cdot)\) performs full convolution in 1-D with \(K-1\) zero padding. \(\Delta s_{k}^{l}\)  
Figure 1: The proposed algorithm using 28 layers of residual depthwise separable convolution neural network. is the input difference after filtering and \(rev(\cdot)\) flips the array. \(\Delta_{i}^{l+1}\) is the delta error according to the loss function. \(\frac{\partial F}{\partial u_{ik}^{l}}\) denotes error change with respect to the filter coefficients, while \(\frac{\partial F}{\partial\beta_{k}^{l}}\) denotes error change with respect to the bias. To maximize the accuracy, the CNN model in this paper is optimized using two methods, i.e., Depthwise Separable [12; 13] and Residual [15].