## 3 Materials and Method
### Proposed Neural Network Models
#### 3.2.1 Temporal Convolutional Network (TCN) Model  
The TCN process begins by building a TCN model designed to handle time-series data effectively. The TCN model is initialized with an input shape that matches the length of the original ECG signal and is compiled using the Adam optimizer [25] and mean squared error (MSE) loss function. The original ECG signal, reshaped to fit the model input, serves as the training data.  
_Convolutional layers:_ The TCN uses dilated causal convolutions to handle temporal dependencies. The output of a dilated convolution at time step \(t\) with a dilation factor \(d\) is given by  
\[y_{t}=\sum_{i=0}^{k-1}w_{i}\cdot x_{t-d\cdot i} \tag{1}\]  
where \(w_{i}\) are the convolutional filter weights, \(k\) is the filter size, and \(x\) is the input sequence.  
In a causal convolutional model, the output at time step \(t\) depends only on the input from time step \(t\) and before, which is particularly important in the context of time series prediction or any sequential task in which knowledge of the forthcoming cannot be used to affect the former. Hence, the temporal order of the series is preserved without any leakage from the future.  
Dilation refers to the elements of the kernel being spaced in a convolutional operation. In a dilated convolution, the kernel gets'stretched out' with zeros in between such that it can have a wider receptive field without increasing the number of parameters. It permits the network to model dependencies over long time intervals. In the TCN model, the '_causal_' padding is used to ensure the same along with _dilation_rate_*_i_, where \(i\) is the layer index, efficiently increasing the dilation rate with each succeeding layer.  
_Residual connections:_ To facilitate training deeper networks, the TCN employs residual connections that add the input to the output of each convolutional block. Residual connections refer to shortcuts that connect the input of a layer directly to the output of a later layer, bypassing one or more intermediate layers. It is used for the model to learn the residual mapping, which means the difference between the output and the input rather than the whole transformation. Residual connections make it easier to train deep networks by enabling gradients to flow more directly through the network; that is, their use reduces the risk of vanishing gradients. Residual connections help stabilize the network and prevent overfitting by enabling some of the information from the previous layers to pass unchanged.  
\[y_{t}=x_{t}+F(x_{t}) \tag{2}\]  
where \(F(x_{t})\) represents the output of the convolutional layers.  
Once the model is trained, an initial set of time points, uniformly distributed over the signal length, is generated. The ECG values at these initial time points are calculated for the modified signal and interpolated to match the length of the original signal. The initial distance between the original and modified signals is computed using MSE. The residual layer is added with \(x=\textit{layers.Add}(0)[\{x, \textit{residual}\}]\). This line adds the output of the main convolutional layer \(x\) to the output of the residual branch. Adding the residual adds information from the input or a transformed version of the input to the output of the convolutional layer. Figure 3 provides a detailed representation of the flow of elements within the TCN model.