A classification method for ultra-long multidimensional time series based on double-layer nested LSTM
By using a double-layer nested LSTM network to segment and fuse features of ultra-long multi-dimensional time series, the problems of long training time and gradient disappearance are solved, and a more efficient classification effect is achieved.
Patent Information
- Application Number
- CN202310623774.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-05-30
AI Technical Summary
Existing technologies are unable to effectively process ultra-long multi-dimensional time series data, resulting in long training time, slow parameter updates, and even gradient vanishing, which affects classification accuracy.
A two-layer nested LSTM network is used to split the ultra-long time series into equal-length segments, and then perform feature extraction and fusion. The fully connected layer and the Softmax layer are combined to realize an end-to-end classification model.
It improves the classification accuracy of ultra-long multi-dimensional time series data, avoids the problems of long training time and gradient vanishing, and enhances the stability and feature extraction capabilities of the model.
Smart Images

Figure CN116644378B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of time series data mining, and in particular to a super-long multi-dimensional time series classification method based on a double-layer nested LSTM. Background Art
[0002] A multidimensional time series is a data sequence obtained by sampling the values of multiple variables of an observed object at a specific time interval over a period of time. It faithfully records the state of the observed object at each measurement point and objectively reflects the object's true operating status. Multidimensional time series data is real-valued sequence data characterized by large data volume, high dimensionality, and continuous data updates. Over the past decade, the rapid development of the Internet of Things (IoT) and big data technologies has led to explosive growth in data. Multidimensional time series data has ushered in a golden age of growth with the rapid iteration of hardware devices. Multidimensional time series are now ubiquitous across various industries, including electrocardiogram (ECG) time series data in the medical industry, financial time series data in the financial industry, and traffic index time series data in the transportation industry. By deeply studying multidimensional time series data in various industries, we can uncover the hidden information within this data and leverage this information to guide the further development of each industry.
[0003] Currently, traditional solutions to the classification problem of multidimensional time series mainly include distance-based methods, feature-based methods, and ensemble learning-based methods. Distance-based methods mainly calculate the similarity between two time series by defining a distance function, then distinguish the class to which each time series instance belongs based on the instance closest to the training data, and finally classify the sequence instance into the corresponding class. Feature-based methods generally include two steps: first, designing a feature representation method to convert the sequence into a feature vector, and then training a classifier based on the sequence features to classify the sequence. Ensemble learning-based methods combine different classifiers into a new classifier. Using a neural network as the base classifier of ensemble learning can improve the network's generalization ability and classification effect. All of the above methods require complex data preprocessing or complex and arduous feature engineering, especially feature-based methods.
[0004] Deep learning, a mainstream field in machine learning, leverages massive amounts of data to automatically extract deep and abstract feature representations, often replacing manually designed features. Deep learning algorithms are end-to-end representation learning algorithms that require only data input and corresponding target output, eliminating the need for manual feature extraction. This distinguishes deep learning from traditional algorithms. If manual feature extraction is used, the quality of the extracted features determines classification accuracy. Manually extracted features are not only simple but also unstable, which affects model quality and makes them ineffective for time series data. Therefore, compared to traditional algorithms, deep learning models often achieve superior performance for time series data classification.
[0005] Since multidimensional time series data are arranged in sequence according to the order of sampling moments, there is a strong time dependence between the previous and next data, and multidimensional time series data also show correlation between variables. The first row of data in the data matrix corresponds to the sampling value of the previous moment, and the second row of data corresponds to the sampling value of the second moment. Exchanging two rows of data will cause the information contained in the current sequence to change; each sequence contains multiple time variables, each variable represents a dimension of the sequence, and multiple dimensions are combined into a whole. Adding or deleting variables will become a completely different sequence; there may be some unknown linear or nonlinear correlation between different dimensions. Different types of sequences may have different correlations between their dimensions. Therefore, this correlation is also important information contained in the sequence. In addition, the real multidimensional time series data collected in various actual industrial application scenarios often have the problem of high sampling frequency. The higher the sampling frequency, the richer the information that can be obtained. According to the calculation expression
[0006]
[0007] Where t is the total sampling time; N is the number of sampling points; and fs is the sampling frequency. Given a fixed number of sampling points, the higher the sampling frequency, the shorter the total sampling time corresponding to the data acquisition. Taking electrocardiogram (ECG) data from the field of medical abnormality diagnosis as an example, it contains information on multiple dimensions, such as the P wave, PR segment, PR interval, QRS complex, ST segment, T wave, QT interval, and U wave. This is effectively multidimensional time series data. When acquiring ECG data, a high sampling frequency is often selected. However, this high sampling frequency may result in an ECG sequence with a large number of sampling points (i.e., a long time series length) only representing its changes within a relatively short sampling period. When slicing the ECG sample, the slice length is typically made as large as possible to ensure that the sliced ECG sample contains all the features required for classification, resulting in extremely long sequence samples. Using deep learning models to process these extremely long sequences often leads to problems such as long training time, slow parameter updates, and even vanishing gradients. Therefore, developing an efficient and feasible classification method for real-world extremely long multidimensional time series data has significant research and application value. Summary of the Invention
[0008] In order to solve the above-mentioned deficiencies in the prior art, the present invention proposes a very long multidimensional time series classification method based on a double-layer nested LSTM to achieve the purpose of improving the classification accuracy of very long multidimensional time series data.
[0009] The present invention is proposed to solve the classification problem of real time series data collected from various practical application scenarios, and can be widely used in fields such as medical anomaly diagnosis, financial anomaly detection, and traffic flow control.
[0010] In order to achieve the above-mentioned purpose of the invention, the present invention is based on the idea of deep learning, utilizes a nested two-layer long short-term memory network (LSTM), and combines the idea of "first split, then splice" to propose a classification model for ultra-long multi-dimensional time series. Among them, by nesting (as opposed to stacking) to increase the layer depth of the LSTM network, it is possible to effectively extract the time-related features of ultra-long time series samples and obtain better classification performance. The technical solution adopted by the present invention is: a classification method for ultra-long multi-dimensional time series based on a two-layer nested LSTM, which includes the following steps:
[0011] S1: Obtain multidimensional time series and label their categories;
[0012] S2: Connect the input layer, a network composed of i LSTM networks in parallel, an LSTM network, three fully connected layers, two Batch Normalization layers, and a Softmax layer in series to obtain a two-layer nested LSTM model.
[0013] S3: Input the time series samples of known categories as training data into the double-layer nested LSTM model for classification training to obtain the trained double-layer nested LSTM model;
[0014] S4: Use the trained two-layer nested LSTM model to classify and identify target time series samples of unknown categories.
[0015] Furthermore, in various practical application scenarios, professional instruments or technical means are used to obtain multi-dimensional time series data in real time, and the categories of these data are labeled based on the professional knowledge in this field. Taking the recognition of abnormal electrocardiogram data in the field of medical diagnosis as an example, a dynamic electrocardiograph is used to collect all the user's electrocardiogram data in real time, including data information of multiple dimensions such as P wave, PR segment, PR interval, QRS complex, ST segment, T wave, QT interval and U wave. The electrocardiogram data showing normal data are labeled as "normal", and the electrocardiogram data showing abnormal data such as tachycardia, bradycardia, atrial fibrillation, atrial flutter, atrial premature beats, ventricular premature beats, etc. are labeled as "abnormal";
[0016] Furthermore, the LSTM memory unit at time t converts the time series data x at time t into t , the hidden layer state h output by the LSTM memory unit at time t-1 t-1 And the cell state C output by the LSTM memory unit at time t-1 t-1 As input, and output the hidden layer state h of the LSTM memory unit at time t t and the cell state C of the LSTM memory unit at time t t , h t And C t The calculation expression of the sum is
[0017] i t =σ(W i ·[h t-1 ,x t ]+b i )
[0018] f t =σ(W f ·[h t-1 ,x t ]+b f )
[0019]
[0020] o t =σ(W o ·[h t-1 ,x t ]+b o )
[0021] h t =o t tanh(C t )
[0022]
[0023] Among them, W i 、W f 、W C and W o are weights; b i 、b f 、b C and b o All are biased; f t is the forget gate of the LSTM memory unit at time t; i t is the input gate of the LSTM memory unit at time t; is the candidate value of the cell state of the LSTM memory unit at time t; o t is the output gate of the LSTM memory unit at time t; tanh(·) is the hyperbolic tangent function; σ(·) represents the sigmoid function; the hidden layer state output by the LSTM memory unit at the last moment is the final output of an LSTM network, with a dimension of (128, None, 64), where 128 refers to the time step of the time series sample segmentation after cutting, None refers to the number of samples captured in one training, and 64 refers to the output dimension.
[0024] Furthermore, after the input time series samples pass through the input layer of the double-layer nested LSTM model, they are first segmented into i time series sample slices of the same length; then, these i time series sample slices are input into i parallel LSTM networks respectively to extract the time-related features within each time series sample slice. And Splice in sequence to obtain splicing features Then Input to the next LSTM network to extract the time-related features between the i time series sample slices and obtain the final features of the input time series sample Finally, Mapped to the sample label space through multiple fully connected layers.
[0025] In the double-layer nested LSTM model, the Split operation is first used to split the entire input time series sample into i time series sample slices, and then the Concat operation is used to combine the features of the i time series sample slices. Perform feature fusion to obtain the final feature The purpose is to avoid the problems that often occur when directly using LSTM networks to process ultra-long multi-dimensional time series, such as long training time, slow parameter updates, and even gradient disappearance. At the same time, using the Concat operation for feature fusion enables the model to regain the global information of the entire input time series sample. The dimension is (None, 64), The dimension is (i,None,64).
[0026] Furthermore, the parameter of the first fully connected layer is 64, the parameter of the second fully connected layer is 32, the parameter of the third fully connected layer is P, and the number of categories of the Softmax layer is P, which must correspond to the number of categories of all time series data.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] The method of the present invention is applicable to ultra-long multidimensional time series in various practical application scenarios, and can effectively process ultra-long time series data collected from these real-world scenarios without problems such as long training time, slow parameter updates, and even gradient disappearance. At the same time, the method has a memory function, which can effectively mine the implicit time series information in real time series data, and the trained model has high fitting accuracy and strong stability. In addition, the introduction of the "split first, then splice" idea enables the use of this method to more comprehensively extract all the features of ultra-long time series data and effectively improve the classification effect of time series data. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 Schematic diagram of the process of the ultra-long multidimensional time series classification method based on double-layer nested LSTM of the present invention;
[0030] Figure 2 This is a schematic diagram of the temporal logic structure of the LSTM network;
[0031] Figure 3 This is a schematic diagram of the double-layer nested LSTM model structure of the present invention. DETAILED DESCRIPTION
[0032] The specific embodiments of the present invention are further described below with reference to the accompanying drawings and specific examples.
[0033] like Figure 1 As shown in FIG, the ultra-long multidimensional time series classification method based on a double-layer nested LSTM includes the following steps:
[0034] S1: Obtain multidimensional time series and label their categories;
[0035] S2: Connect the input layer, a network composed of i LSTM networks in parallel, an LSTM network, three fully connected layers, two Batch Normalization layers, and a Softmax layer in series to obtain a two-layer nested LSTM model.
[0036] S3: Input the time series samples of known categories as training data into the double-layer nested LSTM model for classification training to obtain the trained double-layer nested LSTM model;
[0037] S4: Use the trained two-layer nested LSTM model to classify and identify target time series samples of unknown categories.
[0038] In various practical application scenarios, professional instruments or technical means are used to acquire multi-dimensional time series data in real time, and the categories of these data are labeled based on professional knowledge in the field. Taking the identification of abnormal electrocardiogram data in the field of medical abnormality diagnosis as an example, a dynamic electrocardiograph is used to collect all the user's electrocardiogram data in real time, including data information on multiple dimensions such as P wave, PR segment, PR interval, QRS complex, ST segment, T wave, QT interval, and U wave. ECG data showing normal data are labeled as "normal", and ECG data showing abnormal data such as tachycardia, bradycardia, atrial fibrillation, atrial flutter, atrial premature beats, and ventricular premature beats are labeled as "abnormal".
[0039] LSTM networks, also known as long-short-term memory networks, are a specialized structure within recurrent neural networks (RNNs). An LSTM network consists of multiple LSTM memory cells. Building on the RNN architecture, it introduces a cell state for each LSTM cell. Three gating mechanisms—input, forget, and output gates—are used to enable the network to learn when to "remember," "forget," and "output" information. The input gate and tanh function in the LSTM cell determine which information to retrieve from the previous moment. Combined with the forget and input gates, information can be discarded or preserved, resulting in the current cell state and, ultimately, the current hidden layer state. The forgetting function of LSTM reduces the likelihood of vanishing and exploding gradients and can also address long- and short-term dependencies that RNNs struggle to address.
[0040] The LSTM network can complete the splicing of a cell at different times, that is, it is actually the state of a cell at different times. The connection diagram of the cell at time t-1, time t, and time t+1 is as follows: Figure 2 As shown. The LSTM memory unit at time t converts the time series data x at time t into t , the hidden layer state h output by the LSTM memory unit at time t-1t-1 And the cell state C output by the LSTM memory unit at time t-1 t-1 As input, and output the hidden layer state h of the LSTM memory unit at time t t and the cell state C of the LSTM memory unit at time t t , h t And C t The calculation expression of the sum is
[0041] i t =σ(W i ·[h t-1 ,x t ]+b i )
[0042] f t =σ(W f ·[h t-1 ,x t ]+b f )
[0043]
[0044] o t =σ(W o ·[h t-1 ,x t ]+b o )
[0045] h t =o t tanh(C t )
[0046]
[0047] Among them, W i 、W f 、W C and W o are weights; b i 、b f 、b C and b o All are biased; f t is the forget gate of the LSTM memory unit at time t; i t is the input gate of the LSTM memory unit at time t; is the candidate value of the cell state of the LSTM memory unit at time t; o tis the output gate of the LSTM memory unit at time t; tanh(·) is the hyperbolic tangent function; σ(·) represents the Sigmoid function; the hidden layer state output by the LSTM memory unit at the last moment is the final output of an LSTM network, with a dimension of (128, None, 64), where 128 refers to the time step of the time series sample slice after cutting, None refers to the number of samples captured in one training, and the specific value can be freely set according to the actual situation, and 64 refers to the output dimension.
[0048] like Figure 3 As shown in the figure, after the input time series sample passes through the input layer of the double-layer nested LSTM model, it is first split into i time series sample slices of the same length; then, these i time series sample slices are input into i parallel LSTM networks respectively to extract the time-related features within each time series sample slice. And Splice in sequence to obtain splicing features Then Input to the next LSTM network to extract the time-related features between the i time series sample slices and obtain the final features of the input time series sample Finally, Mapped to the sample label space through multiple fully connected layers.
[0049] In the double-layer nested LSTM model, the Split operation is first used to split the entire input time series sample into i time series sample slices, and then the Concat operation is used to combine the features of the i time series sample slices. Perform feature fusion to obtain the final feature The purpose is to avoid the problems that often occur when directly using LSTM networks to process ultra-long multi-dimensional time series, such as long training time, slow parameter updates, and even gradient disappearance. At the same time, using the Concat operation for feature fusion enables the model to regain the global information of the entire input time series sample. The dimension is (None, 64), The dimension is (i,None,64).
[0050] In this embodiment, since the second layer of the double-layer nested LSTM model is a network synthesized by i LSTMs in parallel, and the input dimension of the LSTM network is 3, it is necessary to use the input layer to split the input time series sample into i time series sample slices, and at the same time, convert the dimension of the time series sample slice into 3 dimensions, namely (batch_size, time_step, input_size), where batch_size represents the number of time series sample slices input at the same time; time_step represents the length of the time series sample slice, and also represents the number of sampling points of the time series sample slice; input_size represents the dimension input at each time point. The length of the time series sample slice after segmentation is 128, that is, a time series sample slice has 128 time steps, and each time series sample slice has S dimensions of data, so a time sample sequence slice can be represented by a matrix of S*128. At this time, time_step is 128 and input_size is S. To facilitate the input of time series sample slices into the LSTM network, it is necessary to convert the S*128 time series sample slice matrix into a 128*S matrix, and then convert the dimension of the time series sample slice into (None, 128, S) through the input layer.
[0051] In this example, the hidden_size parameter of each of the i parallel LSTM networks is set to 64; the hidden_size parameter of the subsequent LSTM network is set to 64; the parameter of the first fully connected layer is set to 64, and the ReLU activation function is used for processing, followed by a Batch Normalization layer with a parameter set to 64; the parameter of the second fully connected layer is set to 32, and the ReLU activation function is used for processing, followed by a BatchNormalization layer with a parameter set to 32; the parameter of the third fully connected layer is set to P, and the output of the third fully connected layer is input into a Softmax layer with P categories, mapping it to the sample label space to achieve classification. Where P is the number of categories in the total time series data.
[0052] In this example, 60% of a real multidimensional time series dataset was collected as the training set, 20% as the validation set, and 20% as the test set. During training, the batch size (batch_size) was set to 32, the number of epochs (epochs) was set to 150, the learning rate was set to 0.001, and the optimization algorithm was set to Adam. After 150 rounds of training, the final trained model was obtained. At this point, the trained model was used to predict the time series samples whose categories were unknown, and the final predicted labels were obtained.
Claims
1. A very long multidimensional time series classification method based on a double-layer nested LSTM, characterized by: The following steps are involved: S1: Obtain multidimensional time series samples and label their categories to obtain time series samples with known categories; S2: Connect the input layer, a network composed of i LSTM networks in parallel, an LSTM network, three fully connected layers, two Batch Normalization layers, and a Softmax layer in series to obtain a two-layer nested LSTM model. The two-layer nested LSTM model specifically includes: After the input time series sample passes through the input layer of the double-layer nested LSTM model, it is first divided into i time series sample slices of the same length; then, the i time series sample slices are input into i parallel LSTM networks respectively to extract the time-related features within each time series sample slice. , , ..., , and put , , ..., Splice in sequence to obtain splicing features ; then Input to the next LSTM network to extract the time-related features between i time series sample slices and obtain the final features of this input time series sample ; Finally, through the fully connected layer, Batch Normalization layer and Softmax layer Mapping to sample label space; S3: Input the time series samples of known categories as training data into the double-layer nested LSTM model for classification training to obtain the trained double-layer nested LSTM model; S4: Use the trained two-layer nested LSTM model to classify and identify target time series samples of unknown categories.
2. The ultra-long multidimensional time series classification method based on double-layer nested LSTM according to claim 1 is characterized in that: In step S2, the LSTM network includes: The LSTM memory unit at time t converts the time series data at time t into , the hidden layer state output by the LSTM memory unit at time t-1 And the cell state of the LSTM memory unit output at time t-1 As input, and output the hidden layer state of the LSTM memory unit at time t and the cell state of the LSTM memory unit at time t , and The calculation expression of the sum is: ; ; ; ; ; ; in, 、 、 and All are weights; 、 、 and All are biased; is the forget gate of the LSTM memory unit at time t; is the input gate of the LSTM memory unit at time t; is the candidate value of the cell state of the LSTM memory unit at time t; is the output gate of the LSTM memory unit at time t; is the hyperbolic tangent function; Represents the Sigmoid function; The hidden layer state output by the LSTM memory unit at the last moment is the final output of an LSTM network, with a dimension of (128, None, 64). 128 refers to the time step of the time series sample slice after cutting, None refers to the number of samples captured in one training, and 64 refers to the output dimension.
3. The ultra-long multidimensional time series classification method based on double-layer nested LSTM according to claim 1 is characterized in that: Use the Split operation to split the input time series sample into i time series sample slices of the same length.
4. The ultra-long multidimensional time series classification method based on double-layer nested LSTM according to claim 1 is characterized in that: Use the Concat operation to , , ..., Feature fusion is performed by sequential splicing.
5. The ultra-long multidimensional time series classification method based on double-layer nested LSTM according to claim 1 is characterized in that: Time-related features , , ..., The dimension is (None, 64), splicing features The dimension is (i, None, 64).
6. The ultra-long multidimensional time series classification method based on double-layer nested LSTM according to claim 1 is characterized in that: In step S2, the parameter of the first fully connected layer is 64, the parameter of the second fully connected layer is 32, the parameter of the third fully connected layer is P, and the number of categories of the Softmax layer is P. The number of categories P of the Softmax layer corresponds to the number of categories of the multidimensional time series samples in step S1.