# A Novel 1-D CCANet for ECG Classification
## 3 Proposed Method
### Neural Feature Extraction
#### 3.2.3 Second Convolution Layer and Extraction Stage  
The second layer is identical to the previous one, except for the fact that the input is different. Indeed, before the first convolution, each lead of a heartbeat was represented by a single vector of length \(m\). After the first convolution, each lead is now represented by \(L_{1}\) vectors of length \(m\). Let's walk through the second layer with the notations used so far.  
The \(x_{h,cat,l}=x_{h,cat}*W_{h,l}\), \(l=1,\dots,L_{1}\) produced after the first convolutional layer are the input of the second layer. Since we initially considered \(N\) training heartbeats, it means that this layer has a total number of \(N\times L_{1}\) input vectors corresponding to lead \(1\) and \(N\times L_{1}\) input vectors corresponding to lead \(2\). The same segmentation and zero-centering process as in the first layer gives \(\mathbf{Y}_{h}\in\mathbb{R}^{k\times mNL_{1}}\)\((h=1,2)\), the matrices of the concatenated segments for all the input vectors, for each lead.  
Applying the CCA-SVD filter extraction technique with \(\tilde{S}_{hh^{\prime}}=(\mathbf{Y}_{h})(\mathbf{Y}_{h^{\prime}})^{T}\) leads us to perform the SVD of \(\tilde{M}_{1}=\tilde{S}_{11}^{-1}\tilde{S}_{12}\tilde{S}_{22}^{-1}\tilde{S}_{21}\) and \(\tilde{M}_{2}=\tilde{S}_{22}^{-1}\tilde{S}_{21}\tilde{S}_{11}^{-1}\tilde{S}_{12}\), for the first and second lead, respectively. The filters are then found exactly as in the first convolutional layer and we denote as \(\tilde{W}_{1,\ell}\) and \(\tilde{W}_{2,\ell}\), \(\ell=1,\dots,L_{2}\), the \(L_{2}\) filters of size \(k\) extracted for the first and second lead, respectively.  
As for the convolutions, for each initial lead \(h=1,2\) and channel \(l\in\{1,\dots,L_{1}\}\), the signal \(x_{h,cat,l}\) yields \(L_{2}\) outputs \(x_{h,cat,l,\ell}=x_{h,cat,l}*\tilde{W}_{h,\ell}\), \(\ell=1,\dots,L_{2}\). At this stage, each initial lead of a heartbeat is now represented by \(L_{1}\times L_{2}\) vectors of size \(m\).  
The second extraction step is the same as after the first convolutional layer except for a few points. First, for each heartbeat, the output of the second convolutional layer is converted to a decimal signal as per \(\tilde{T}_{l}=\sum_{\ell=1}^{L_{2}}2^{\ell-1}H([x_{1,cat,l,\ell},x_{2,cat,l,\ell} ])\in\mathbb{R}^{2m}\), \(l\in\{1,\dots,L_{1}\}\). The second feature vector for the heartbeat is obtained as per \(f^{2}=[Bhist(\tilde{T}_{1}),Bhist(\tilde{T}_{2}),\dots,Bhist(\tilde{T}_{L_{1}})]\). The _Bhist_ are built with a block size and an overlapping parameter equal to \(u_{2}\) and \(R_{2}\), respectively.  
The third and fourth convolutional layers are built similarly. \(f^{3}\) and \(f^{4}\) refer to the third and fourth feature vectors extracted for a heartbeat after each layer. We denote as \(L_{3}\) and \(L_{4}\), the number of filters for the third and fourth layers, respectively. \(u_{3}\) and \(u_{4}\) are the block sizes for the construction of _Bhist_ after the third and fourth convolutional layers, respectively. Finally, we denote as \(R_{3}\) and \(R_{4}\), the overlapping parameters for the last two layers.