# Convolutional Neural Network with an Elastic Matching Mechanism for Time Series Classification
## 3 Proposed Method
### Em-Cnn  
In this section, three EM-CNN architectures including elastic matching FCN (EM-FCN), elastic matching ResNet (EM-ResNet) and elastic matching Inception (EM-Inception) are proposed. The architectures in Figures 3 and 4 are EM-FCN and EM-ResNet. The backbone of the EM-FCN and EM-ResNet are FCN and ResNet which are strong baselines for  
Figure 2: Structure of the matching convolutional (MConv) layer.  
TSC [22]. The EM-FCN is similar to FCN; the difference between FCN and EM-FCN is the convolutional layers in FCN are replaced by the MConv layers in EM-FCN. The EM-FCN comprises three basic modules, one global average pooling (GAP) layer, and one FC layer. Each basic module contains one MConv layer, one batch normalization (BN) layer, and one Rectified Linear Unit (ReLU) layer. The kernel sizes and numbers of kernels corresponding to the three MConv layers are 8, 5, and 3 and \(128,256\), and \(128\), respectively.  
Compared with the EM-FCN, the EM-ResNet is deeper. It has three bottlenecks, which consist of three basic modules like EM-FCN. The number of kernels corresponding to three bottlenecks is \(64,128\), and \(128\), respectively. Convolutional layers are only replaced by MConv layers in the residual branches for stable training.  
Compared with the EM-FCN and EM-ResNet, EM-Inception (Figure 5) is based on Inception [24] which extracts features in a multiscale manner. Inception is composed of two bottlenecks, one GAP layer, and one FC layer.  
Each bottleneck has three basic Inception modules. Multiple paralleled convolutional operators of different kernel sizes in conjunction with a max-pooling operator are performed in each module in Figure 6. Like EM-ResNet, a shortcut connection is used between the consecutive bottlenecks, and the MConv layers only take the place of the convolutional layers in the residual branches.  
Figure 4: Architecture of EM-ResNet, MConv1D denotes the one-dimensional MConv layer.  
Figure 5: Architecture of EM-Inception.  
Figure 3: Architecture of EM-FCN, MConv1D denotes the one-dimensional MConv layer.  
The MConv layer is the core of the EM-CNN. The matching matrix \(M\) in the MConv layer is learned by backpropagation. Similar to the derivation in [25; 26], the details for calculating the gradients needed for the backpropagation algorithm are as follows. Figure 2 illustrates that, assuming the response in each location for the MConv layer is \(y\), and the optimized objective function \(J(W,M)\) is as follows:  
\[J(W,M)=\underset{W,M}{min}\{\frac{1}{2}\|y-W^{\mathrm{T}}MX\|^{2}\}. \tag{8}\]  
Equation (8) becomes the objective function of CNN if \(M\) is an identity matrix. The gradient descent for the CNN is easy to calculate:  
\[\frac{dW_{t}}{dt}=X(y-W_{t}^{\mathrm{T}}X)^{\mathrm{T}}W_{t}. \tag{9}\]  
Similar to the derivation of Equation (9), we let \(\hat{W}=W^{\mathrm{T}}M\) using the chain rule, and the gradient descent for the EM-CNN can be calculated as shown in Equation (10):  
\[\frac{d\hat{W}_{t}}{dt}=M_{t}^{\mathrm{T}}M_{t}X^{T}(y-W_{t}^{\mathrm{T}}X)+X^{ T}(y-W_{t}^{\mathrm{T}}X)W_{t}^{\mathrm{T}}W_{t}, \tag{10}\]  
where \(W_{0}\) is initialized using the Xavier method, and \(M_{0}\) is initialized with an identity matrix.