# Sequence-Information Recognition Method Based on Integrated mDTW
## 3 Methodology
### Joint Modeling with Sequence Processing Networks
Unlike CGRU, other neural networks we utilize, such as LSTM or Transformer, do not possess a designated conditional input c. To address these discrepancies, we employ a method where we concatenate the output probability distribution of mDTW with the normalized original sequence information before inputting it into the LSTM or Transformer model, as listed in Equation (18)  
\[i_{t}=concat(seq_{t},c) \tag{18}\]  
Among the many methods of time-series analysis and pattern recognition, dynamic time warping (DTW) and its multivariate version (mDTW) have proven to be effective tools, especially when dealing with time series of unequal lengths and varying speeds. However, traditional mDTW methods may be limited in handling large-scale, high-dimensional, and complex pattern data. In recent years, deep-learning models, such as Long Short  
Figure 4: Detailed presentation of the core parts of the framework. Term Memory Networks (LSTM) and Transformer, have achieved remarkable success in processing sequence data. These models can automatically extract useful features from raw data, allowing them to handle complex patterns and long-term dependencies. To combine the flexibility of mDTW with the powerful representation capabilities of deep-learning models, we propose a joint modeling method. The core idea of this method is to embed mDTW as a differentiable module into the deep-learning framework so that the parameters of mDTW and the parameters of the deep-learning model can be optimized during the end-to-end training process. In the process of joint modeling, model selection is a crucial step because it will directly affect the model's ability to handle specific tasks. For the problem we face, namely the analysis of time-series data, we need to choose among multiple deep-learning models. Long short-term memory networks (LSTM) have proven to be very effective in processing time-series data and are able to capture long-term dependencies in the data, which is crucial for many time-series tasks. However, the Transformer model's advantages in handling parallelization and self-attention mechanisms make it more efficient when processing large-scale data sets and capable of capturing complex interactions between different parts of the input sequence. After selecting a suitable deep-learning model, the next step is to embed the mDTW algorithm into this model. The key to this step is to ensure that mDTW can be combined with the deep-learning model in a differentiable way so that we can use the backpropagation algorithm to train the entire model. To achieve this, we need to make appropriate modifications to the mDTW algorithm so that the gradients generated during the calculation process can be effectively passed to the deep-learning model. In this way, the deep-learning model can update its parameters based on the gradient information provided by mDTW, therefore achieving more efficient processing of time-series data. In the model training phase, we need to design a joint loss function that will consider both the distance metric of mDTW and the classification or regression loss of the deep-learning model. In this way, we can ensure that the parameters of the mDTW algorithm and the deep-learning model are optimized simultaneously during the training process. This joint optimization method will enable the entire model to take into account the local shape characteristics of the data and capture the global structural information of the data when processing time-series data. \[L=-\sum_{i=1}^{N}y_{i}\log(p_{i})+(1-y_{i})\log(1-p_{i}) \tag{19}\]  
In the equation, \(L\) is the value of the loss function, \(N\) is the number of samples, \(y_{i}\) is the actual label of the \(i\)th sample, \(p_{i}\) is the predicted probability that the \(i\)th sample belongs to the positive class (with label 1), and log denotes the natural logarithm. Finally, in terms of model optimization, we will use appropriate optimization algorithms to update the model parameters.