Long time sequence prediction method based on generative adversarial space-time attention network

By combining the generative adversarial spatiotemporal attention network and the generative adversarial network and the spatiotemporal attention network, the problems of missing value processing and comprehensive consideration of spatiotemporal characteristics in complex, high-dimensional and nonlinear time series data are solved, and more efficient data loss filling and timing prediction effects are achieved.

CN119537799APending Publication Date: 2025-02-28HEFEI INSTITUTE OF PHYSICAL SCIENCE CHINESE ACADEMY OF SCIENCES
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411424455.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

When the prior art deals with complex, high-dimensional and nonlinear time series data, it is difficult to effectively deal with the problem of data loss, and lacks comprehensive consideration of spatiotemporal characteristics in timing prediction.

Method used

The long-term series prediction method based on the generation of adversarial spatiotemporal attention network is adopted. By combining the generation of adversarial network and the spatiotemporal attention network, the missing values ​​of the timing data are processed, and the convolutional neural network, long-term memory network and multi-head attention mechanism are used to capture the spatiotemporal characteristics in the timing data for prediction.

Benefits of technology

It improves the accuracy and robustness of data loss filling, enhances the processing ability of the timing prediction model to complex, high-dimensional and nonlinear time series data, and can more effectively capture spatiotemporal features, thereby improving the accuracy and reliability of prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537799A_ABST
    Figure CN119537799A_ABST
Patent Text Reader

Abstract

The invention discloses a long time sequence prediction method based on a generative adversarial space-time attention network, and relates to the technical field of deep learning and time sequence prediction, the generative adversarial space-time attention network comprises a generative adversarial network and a space-time attention network, and the training process comprises the following steps: obtaining a time sequence data set and carrying out deletion processing; constructing a generative adversarial network, training the generative adversarial network by using the time sequence data after missing processing, the generative adversarial network being used for recovering the time sequence data after missing processing; preprocessing the recovered time series data set, and obtaining a training set and a test set; a space-time attention network is constructed, the training set and the test set are used to train the space-time attention network, and a space-time attention network model is used to predict the recovered time series data; and performing error analysis on a predicted result and an original time sequence data set. The method aims at solving the problem of missing values of the time sequence data, and meanwhile the limitation of a time sequence prediction model in the process of processing complex, high-dimensional and nonlinear time sequence data is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning and time series prediction, and in particular to a long time series prediction method based on generating adversarial spatiotemporal attention networks. Background Art

[0002] With the rapid development of sensor technology, the Internet, and the Internet of Things (IoT), the speed and scale of time series data are growing exponentially. However, various problems are inevitably encountered during data collection, such as equipment failure, network interruption, and physical environment interference, resulting in missing data points. These technical limitations have prompted researchers to develop efficient methods to handle missing data to ensure the integrity and availability of the data. Therefore, how to accurately and effectively fill in these data has become a key link in improving the accuracy and reliability of data analysis.

[0003] Currently, time series data analysis and prediction still face many challenges, including but not limited to the complexity of high-dimensional time series, identification of nonlinear relationships, and capture of long-term and short-term dependencies. Early processing of missing values ​​mainly relied on statistical methods, such as deletion, regression interpolation, KNN proximity, etc. Although these methods are simple and practical, they are limited in effectiveness for complex, nonlinear, or periodic time series data. With a deeper understanding of data characteristics, more advanced statistical models have been developed, such as Kalman filtering and state space models, which can better process time series data with dynamic effects.

[0004] In recent years, the rapid development of deep learning technology has provided new solutions for missing value filling of time series data. These methods can learn complex patterns in data, such as long-term dependencies, periodicity, trends, etc. of time series. They have been successfully applied to missing value filling of time series data, significantly improving the accuracy and robustness of filling.

[0005] Although existing models such as recurrent neural networks (RNNs) and their variants LSTM have improved these problems to a certain extent, they still have limitations in processing spatial features and dynamically focusing on important parts of the sequence. At the same time, generative adversarial networks (GANs) have shown great potential in generating realistic data, but have not yet been fully applied to the accurate prediction of spatiotemporal sequences. Therefore, it is particularly urgent to develop a model that effectively handles the problem of missing data values ​​and comprehensively considers spatiotemporal features for effective prediction. Summary of the invention

[0006] In order to overcome the defects in the above-mentioned prior art, the present invention provides a long time series prediction method based on generative adversarial spatiotemporal attention network, which is intended to be used to deal with the missing value problem of time series data, and at the same time solve the limitations of time series prediction models in processing complex, high-dimensional and nonlinear time series data.

[0007] To achieve the above object, the present invention adopts the following technical solutions, including:

[0008] A long time series prediction method based on a generative adversarial spatiotemporal attention network, wherein the generative adversarial spatiotemporal attention network includes a generative adversarial network and a spatiotemporal attention network, and the training process includes the following steps:

[0009] S1, obtain the time series data set and perform missing processing;

[0010] S2, constructing a generative adversarial network, using the time series data after the missing processing to train the generative adversarial network, and the generative adversarial network is used to restore the time series data after the missing processing;

[0011] S3, preprocessing the restored time series data set to obtain a training set and a test set;

[0012] S4, construct a spatiotemporal attention network, use the training set and the test set to train the spatiotemporal attention network, and the spatiotemporal attention network model is used to predict the restored time series data;

[0013] S5, perform error analysis on the predicted results and the original time series data set.

[0014] Preferably, in step S1, a time series data set is obtained, and the time series data is processed with random block missing and random discrete missing respectively to obtain missing data under different missing conditions.

[0015] Preferably, the specific method of step S2 is as follows:

[0016] S21, constructing a generative adversarial network, including a generator and a discriminator; the generator is used to generate missing data according to the original data and the mask; the discriminator is used to discriminate between the data generated by the generator and the original data;

[0017] S22, define Hint vector, each element of Hint vector has a certain probability of being set to 1, and the rest of the elements are set to 0;

[0018] S23, during the training process, the generator generates missing value estimates based on the mask M. When the discriminator receives the combination of the original data and the generated data and the Hint vector, the discriminator not only has to judge the original data and the data generated by the generator, but also has to consider the clues provided by the Hint vector;

[0019] In each iteration, the Adam optimizer is first used to update the discriminator parameters so that the discriminator can accurately distinguish between original data and generated data; then the generator parameters are updated so that the generator generates missing values ​​close to the distribution of the original data. During the iteration process, the Hint vector provides additional contextual information to guide the learning process of the discriminator and generator.

[0020] Preferably, in step S2, the frequency domain transformation technology is also introduced into the generative adversarial network to process the original data, that is, the time domain data. The specific steps are as follows:

[0021] (1) Convert the time domain data into frequency domain representation through Fourier transform:

[0022] X fft =F(X mb )

[0023] Among them, X mb represents time domain data, X fft represents frequency domain data; F(·) represents Fourier transform;

[0024] (2) For each scale, generate Gaussian noise of corresponding intensity and add it to the frequency domain data:

[0025] X fft_noisy =X fft +noise

[0026] Among them, X fft_noisy Represents the frequency domain data after adding noise;

[0027] (3) Generate binary mask freq mask , with a 50% probability of selecting a certain frequency, add noise to the selected frequency:

[0028] X' fft_noisy =X fft_noisy *freq mask +X fft *(1-freq mask )

[0029] Among them, X′ fft_noisy represents the frequency domain data after adding noise at the selected frequency;

[0030] (4) Generate a low-pass filter and high pass filter

[0031]

[0032] Where, f represents data;

[0033] Apply a low-pass filter and a high-pass filter:

[0034]

[0035] Among them, X low_fft_noisy Represents frequency domain data X' fft_noisy The data obtained after low-pass filter, X high_fft_noisy Represents frequency domain data X' fft_noisy The data obtained after high-pass filter;

[0036] (5) The frequency domain data obtained in step (4) after being passed through the low-pass filter and the high-pass filter is converted back into time domain data to obtain enhanced time domain data.

[0037] Preferably, in step S24,

[0038] Discriminator loss function D loss for:

[0039]

[0040] Where N is the number of samples; M is the i is the i-th element of the mask vector, which indicates whether a part of the data is missing or known; D is the discriminator function, which receives the output processed by the generator. and Hint vector H' i , and output a probability value, which is expressed as the probability of the real data, that is, the original data;

[0041] The loss function G of the generator loss for:

[0042]

[0043] in,

[0044]

[0045] Where N is the number of samples; M is the mask of the original data, and G is the generator function that receives the original data. and mask M, and generate the data of the missing part, α is a hyperparameter.

[0046] Preferably, in step S4, the spatiotemporal attention network STAN includes a convolutional neural network CNN, a long short-term memory network LSTM, and a multi-head attention mechanism MultiheadAttention.

[0047] Preferably, the design of the convolutional neural network CNN is as follows:

[0048] First, the convolutional layer is used to extract local features in the time series data, and the input time series data X∈R is defined N*W*I, where N is the batch size, W is the sliding window size, and I is the number of input features; apply a one-dimensional convolution operation to generate a feature map C k :

[0049] C k =f Conv1D (X,k,lstm_units,'relu')

[0050] Among them, f Conv1D Represents a one-dimensional convolution function, k is the convolution kernel size, lstm_units is the number of output channels, and 'relu' is the activation function;

[0051] The second is a maximum pooling layer, which is used to reduce the dimension and extract the significant features P. k :

[0052] P k =f MaxPooling1D (C k ,3)

[0053] Among them, f MaxPooling1D represents the maximum pooling function, 3 is the pooling window size;

[0054] Finally, the Dropout layer is applied to randomly discard some neurons to reduce the risk of overfitting:

[0055] D k =f Dropout (P k ,dropout)

[0056] Among them, f Dropout is the Dropout function, dropout is the discard probability, D k It is the feature output by the Dropout layer.

[0057] Preferably, the long short-term memory network LSTM includes an input gate, a forget gate, and an output gate, and manages the operation process of data through a gating unit; at the same time, a cell state and a hidden state are added, and the cell state is responsible for long-term memory storage, and controls the forgetting, preservation and updating of data information through a sophisticated gating mechanism to maintain the model's dependence on long sequences; the hidden state reflects the decision made by the model at the current time step based on historical information, which is used for further processing or as a basis for final prediction.

[0058] Preferably, the design of the multi-head attention mechanism is based on LSTM, reshaping the output of LSTM according to the number of heads and the dimension of each head, preparing a separate Query, Key and Value matrix for each head; performing a dot product on each head, calculating the attention weight, i.e., the attention score, and weighted summing the scores to obtain the output of each head:

[0059]

[0060] Among them, Q, K, and V represent query, key, and value matrices respectively. k is the dimension of the Key vector;

[0061] Next, the outputs of all attention scores are concatenated along the last dimension to form a new feature vector.

[0062] Then, the attention score is converted into a probability distribution, i.e., attention_weight, through the Softmax function:

[0063] AttntionWeight=softmax(AttentionScores)

[0064] Finally, by multiplying the attention weights and weighted summing the features of all time steps, we get AttentionApplied and simplify it to a single vector AttntionOut using a Lambda layer:

[0065] AttentionApplied=LSTMOutput*AttentionWeight

[0066] AttntionOut=∑AttentionApplied

[0067] The output of the LSTM is weighted averaged according to the weights of each time step to generate a comprehensive feature representation for the final prediction.

[0068] The present invention also provides a computer program product, which includes a computer program / instructions, which, when executed by a processor, implements the above-mentioned long time series prediction method based on generating adversarial spatiotemporal attention networks.

[0069] The advantages of the present invention are:

[0070] (1) A generative adversarial network (GAN) model was constructed, and an innovative data enhancement method based on frequency domain transformation technology was introduced. The purpose was to increase the diversity and complexity of the data by introducing random perturbations in the frequency domain, thereby improving the generalization ability and robustness of the model when facing new data.

[0071] (2) The Hint mechanism is introduced to add an additional information flow based on the Generative Adversarial Network (GAN) to improve the missing data filling process. This aims to solve the problem that the interaction between the generator and the discriminator alone may not be enough to provide enough information to fill in the missing parts.

[0072] (3) Spatial-temporal attention network (STAN), after the data preprocessing stage, uses an advanced deep learning architecture - convolutional neural network (CNN), long short-term memory network (LSTM) and multi-head attention mechanism. CNN is responsible for capturing local features in time series data, LSTM is used to extract long-term dependencies, and the attention mechanism ensures that the model can focus on the most critical feature information in the sequence when making predictions, which together improve the accuracy and robustness of the prediction.

[0073] (4) Multi-head attention mechanism: The attention mechanism is decomposed into multiple heads. Each head can focus on different subspaces or feature dimensions of the input sequence to capture different types of time series patterns, such as short-term fluctuations, long-term trends, and cyclical changes. At the same time, combined with LSTM units, the model can further strengthen its learning of long-term and short-term dependencies in sequence data and parse the information structure in the sequence more finely. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 It is the overall flow chart of the present invention.

[0075] Figure 2 This is the GASTAN (Generative Adversarial Spatiotemporal Attention Network) model architecture diagram of the present invention.

[0076] Figure 3 This is a comparison chart of the experimental results of the present invention and the benchmark experiment in a random discrete missing scenario.

[0077] Figure 4 This is a comparison chart of the experimental results of the present invention and the benchmark experiment in a random block missing scenario. DETAILED DESCRIPTION

[0078] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0079] Depend on Figure 1 and Figure 2 As shown, the long time series prediction method based on generating adversarial spatiotemporal attention network of the present invention comprises the following steps:

[0080] S1, obtain the time series data set and perform missing processing. The time series data set includes the power data set provided by the State Grid, the weather data set provided by the National Meteorological Administration, and the traffic flow data set provided by the Beidou Satellite Navigation System. The time series data set is processed with random block missing and random discrete missing. Specifically, the three data sets of power data, weather data, and traffic flow data are processed with 10%, 20%, and 30% random discrete missing and 10%, 20%, and 30% random block missing respectively.

[0081] Furthermore, for the random discrete missing data processing method, first extract the data set and convert it into a two-dimensional matrix. Set the missing rate miss_rate to 0.1, 0.2, and 0.3, that is, the expected proportion of elements to be simulated as missing values. Generate a mask matrix of the same size as the data set matrix based on the missing rate to indicate which elements in the original data are missing. Multiply these two matrices to obtain random discrete missing data sets under different missing rate conditions.

[0082] Furthermore, for the random block missing processing method, first define the block missing parameters, including: block missing length, whether to randomly determine the block missing starting position, and the probability of each data point becoming the starting point of the block missing. Loop through all columns, randomly select the starting position of the missing value, and insert the missing value at the selected starting position.

[0083] S2, use the generative adversarial network to restore the missing time series data.

[0084] Generative Adversarial Network (GAN), which consists of a generator and a discriminator.

[0085] The task of the generator is to generate a reasonable estimate of the missing part given the original data and the mask (the time series data after the missing processing), starting from the pre-defined random vector and Hint vector, and transforming this vector into a sample with a distribution similar to the original data by reconstructing the data. The generator consists of convolutional layers, including upsampling operations, to increase the spatial dimension of the data and generate continuous and time-series data fragments, thereby effectively filling the missing part and maintaining the continuity and dynamic characteristics of the data.

[0086] The task of the discriminator is to distinguish between the original data and the data generated by the generator. The discriminator also uses a convolutional neural network architecture, and the output layer is a fully connected layer, which is used to generate a probability score, indicating the probability that the input data is real data (original data) or data generated by the generator.

[0087] The specific process of step S2 is as follows:

[0088] S21, build a generative adversarial network, including a generator and a discriminator. The generator is used to generate the missing data based on the input original data and mask, so that the whole looks like real complete data. The discriminator is used to distinguish the original data from the data generated by the generator. Each part consists of a multi-layer fully connected neural network, and the weights are initialized using Xavier to promote better training performance.

[0089] S22, define Hint vector, Hint vector (i.e. hint rate) is sampled from binary distribution according to a certain ratio. In Generative Adversarial Networks (GANs), each element of Hint vector has a certain probability of being set to 1, while the rest of the elements are set to 0, which is equivalent to randomly selecting a part of features as hints to tell the discriminator which features need to be focused on.

[0090] S23, during the training process, the original data, mask M and Hint vector H′ are used together. Specifically, the generator generates missing value estimates based on the mask M. When the discriminator receives the combination of original data and generated data and the Hint vector, it not only has to determine which data is real, but also takes into account the clues provided by the Hint vector.

[0091] In each iteration, the Adam optimizer is first used to update the discriminator parameters so that it can more accurately distinguish between real data and generated data. Then the generator parameters are updated so that it can produce missing values ​​that are closer to the real data distribution. In this process, the Hint vector provides additional contextual information to guide the learning process of the discriminator and generator.

[0092] When constructing the GAN model, the present invention also introduces an innovative data enhancement method of frequency domain transformation technology, the purpose of which is to increase the diversity and complexity of data by introducing random perturbations in the frequency domain, thereby improving the generalization ability and robustness of the model when facing new data. The specific steps are as follows:

[0093] (1) Through Fourier transform, the original data is converted from the time domain to the frequency domain:

[0094] X fft =F(X mb )

[0095] Among them, X mb represents time domain data, X fft represents frequency domain data; F(·) represents Fourier transform.

[0096] For a discrete time sequence x[n] of length N, convert it to a complex sequence X[k] of length N, and the DFT can be expressed as:

[0097]

[0098] Among them, x[n] represents the time domain signal, n represents the time index; X[k] represents the frequency domain information, j is the imaginary unit, is a complex exponential function, representing the rotation factor.

[0099] (2) Multi-scale noise: For each scale, Gaussian noise of corresponding intensity is generated and added to the frequency domain data, which increases the diversity of the data while maintaining the basic characteristics of the data.

[0100] X fft_noisy =X fft +noise

[0101] noise~N(0,scale*σ 2 )

[0102] Among them, X fft_noisv Represents the frequency domain data after adding noise.

[0103] (3) Frequency selective noise: Generate binary mask freq mask , a certain frequency is selected with a 50% probability, and noise is added to the selected frequency to simulate a more complex noise environment.

[0104] X' fft_noisy =X fft_noisy *freq mask +X fft *(1-freq mask )

[0105] Among them, X′ fft_noisy Represents the frequency domain data after adding noise at the selected frequencies.

[0106] (4) Frequency domain filtering: generating a low-pass filter and high pass filter Simulating different signal processing effects increases the robustness of the data.

[0107]

[0108] Where, f represents data;

[0109] Apply a low-pass filter and a high-pass filter:

[0110]

[0111] Among them, X low_fft_noisy Represents frequency domain data X' fft_noisy The data obtained after low-pass filter, X high_fft_noisyRepresents frequency domain data X' fft_noisy The data obtained after high-pass filter;

[0112] (5) The frequency domain data obtained in step (4) after being passed through the low-pass filter and the high-pass filter is converted back into time domain data to obtain enhanced time domain data.

[0113] In the framework of generative adversarial networks, proper design of the loss functions of the discriminator and the generator is crucial to the success of training. In order to make both the discriminator and the generator learn effectively, the loss function is designed to take into account the missing values ​​and the prompt vector H'. The discriminator loss function D loss The correctness of its prediction and the difference between the generator-generated value and the true value are calculated. The generator loss function G loss The algorithm tries to minimize this difference while maximizing the confusion of the discriminator. The two are antagonistic to better handle the problem of filling missing values.

[0114] The purpose of the discriminator is to learn to distinguish between real data (original data) and data generated by the generator. In GANs, the discriminator needs to consider not only the data itself, but also the mask vector M and the prompt vector H' to help the discriminator understand which parts are real observed data and which parts are generated data. The discriminator loss function D loss Specifically:

[0115]

[0116] Where N is the number of samples; M is the i is the i-th element of the Mask vector (mask), indicating whether a part of the data is missing or known; D is the discriminator function, which receives the processed output and Hint vector H i , and outputs a probability value, indicating the probability that the data point comes from real data (original data) rather than generated data.

[0117] Item 1 For the known data part, the discriminator should predict a high probability, that is, close to 1; the second term For the missing data part, the discriminator should predict low probability, that is, close to 0.

[0118] The goal of the generator is to fill in the missing values ​​as accurately as possible when the discriminator does not make a judgment. Therefore, the generator loss function contains two main parts, namely adversarial loss and reconstruction loss.

[0119] The purpose of adversarial loss is to confuse the discriminator and make it think that the generated data is real. This part of the loss is opposite to the discriminator and can be expressed as:

[0120]

[0121] The reconstruction loss is to ensure that the generated data is as close to the real data (original data) as possible. The mean square error MSE is used to measure the difference between the generated data and the real data (original data):

[0122]

[0123] The total loss function of the generator can be expressed as a weighted sum of these two parts:

[0124]

[0125] Among them, α is a hyperparameter used to balance the relative importance of adversarial loss and reconstruction loss; M is the mask of missing data; G is the generator function that receives the original data and mask M, and output the missing data.

[0126] In summary, D loss and G loss By optimizing the interaction of the iterative process, the generator can effectively fill in the missing values ​​in the data set, and the discriminator can accurately identify the difference between the generated data and the real data. Finally, the generated filled data is denormalized to maintain the scale consistency and integrity with the original time series data. Finally, the filled data is returned.

[0127] S3, preprocess the time series data set generated by the generator to obtain the training set and test set, as shown below:

[0128] S31, using sliding windows to process in batches according to the periodicity, trend, and seasonal characteristics of time series data. Taking the power transformer data set as an example, the data set contains 2*365*24=17420 data points, each of which contains 8 dimensions, including date, predicted value "oil temperature" and other 6 different types of data features. Oil temperature refers to the temperature of the insulating oil inside the transformer, which is one of the important indicators for evaluating the health of the transformer and predicting the remaining service life. The sliding window calculation formula is as follows:

[0129] F i =F |24-i| %241≤i≤17420

[0130] Among them, F i represents the oil temperature; i represents the data volume, and 24 represents the sliding window size (based on one day).

[0131] S32, by standardizing the data set, the data set is unified in the interval [0,1], and the calculation formula is as follows:

[0132]

[0133] Among them, value represents the standardized value; original value Represents the original data; min represents the minimum value in the data; max represents the maximum value in the data.

[0134] S33, divide the first 80% of the data set into a training set, and the last 20% into a test set, that is, a long sequence of 3484 time points is used as prediction data, and error analysis is performed with the test set to achieve long time series prediction capabilities.

[0135] S4, build a spatiotemporal attention network (STAN), input the training set and test set to complete the training of the spatiotemporal attention network.

[0136] The spatiotemporal attention network (STAN) is a composite deep learning model that combines convolutional neural networks (CNN), long short-term memory networks (LSTM), and multi-head attention mechanisms (MultiheadAttention).

[0137] Convolutional Neural Networks (CNNs) are mainly used to capture the spatial features of input sequences. By using filters and convolutional layers of different sizes, CNNs can identify local patterns and structures in sequences. By extracting features from local areas of the data, dependencies such as trends, cycles, and seasonality in time series can be discovered.

[0138] Long short-term memory (LSTM) is a recurrent neural network that is used to better handle long-term dependency problems. LSTM controls the inflow, storage, and outflow of information through its unique gating mechanism, thereby retaining important information in a long sequence and forgetting irrelevant information. In time series data prediction, LSTM can learn the time patterns and trends in the sequence, and is suitable for capturing the dynamic changes of time series.

[0139] The multi-head attention mechanism is introduced from the Transformer model. The multi-head attention mechanism allows the model to focus on different parts of the input sequence in parallel from different representation subspaces. In time series data, the multi-head attention mechanism can enhance the model's sensitivity to key information in the sequence, enabling the model to dynamically weight different parts of the sequence according to the needs of the current prediction task, especially those elements that have a greater impact on the prediction results. This method improves the model's ability to understand complex sequence patterns.

[0140] The processing of time series data in the STAN model is a composite deep learning method. First, the data is preprocessed and divided into fixed-length sequences, each of which is used as the input of the convolutional neural network (CNN). CNN scans these sequences through multiple convolutional layers, using different filters to learn and extract local spatiotemporal features of the data, including periodicity, trend, and seasonality. The feature sequence extracted by CNN enters the long short-term memory network (LSTM). With its unique gating mechanism, LSTM can selectively forget old information, update new information, and decide which information needs to be passed to the next step, thereby efficiently capturing and retaining long-term dependencies in the sequence. After LSTM, a multi-head attention mechanism is introduced to give different degrees of attention to different parts of the sequence according to their relevance to the prediction target. This process is achieved by calculating the attention weights of the query (Q), key (K), and value (V), ensuring that the model can focus on the most critical part of the sequence for prediction, further improving the model's ability to identify complex sequence models.

[0141] The specific process of step S4 is as follows:

[0142] S41, Design of Convolutional Neural Network (CNN):

[0143] First, the convolutional layer is used to extract local features and patterns in the time series data. Define the input time series data X∈R N *W*I , where N is the batch size, W is the sliding window size, and I is the number of input features. Apply a one-dimensional convolution operation to generate a feature map C k :

[0144] C k =f Conv1D (X,k,lstm_units,'relu')

[0145] Among them, f Conv1D Represents a one-dimensional convolution function, k is the convolution kernel size, lstm_units is the number of output channels, and 'relu' is the activation function.

[0146] Secondly, there is a maximum pooling layer (MaxPooling1D) with a pooling window size of 3, which is used to reduce the dimension and extract more significant features:

[0147] P k =f MaxPooling1D (C k ,3)

[0148] Among them, f MaxPooling1D represents the maximum pooling function, and 3 is the pooling window size.

[0149] Again, apply the Dropout layer to randomly drop a portion of neurons to reduce the risk of overfitting:

[0150] D k =f Dropout (P k ,dropout)

[0151] Among them, f Dropout It is the Dropout function, and dropout is the discard probability.

[0152] S42, Long Short-Term Memory Network (LSTM) is designed to capture long-distance dependencies in long sequences. The LSTM introduces input gates, forget gates, and output gates to manage the data operation process through gating units.

[0153] At the same time, cell state and hidden state are added. Cell state is responsible for long-term memory storage. It controls the forgetting, preservation and updating of data information through a sophisticated gating mechanism to maintain the model's dependence on long sequences. The hidden state reflects the decision made by the model at the current time step based on historical information, which is used for further processing or as the basis for the final prediction. The two work together to enable LSTM to perform well in time series prediction.

[0154] S43, the design of the multi-head attention mechanism (MultiheadAttention) is based on LSTM, reshaping the output of LSTM according to the number of heads and the dimensions of each head, and preparing a separate Query, Key and Value matrix for each head. Perform a dot product on each head, calculate the attention weight, or attention score, and then weighted sum it to get the output of each head:

[0155]

[0156] Among them, Q (Query), K (Key), and V (Value) represent query, key, and value matrices respectively. k is the dimension of the Key vector.

[0157] Apply the mask mechanism to avoid the model's learning and dependence on invalid positions and reduce the amount of calculation.

[0158] Next, the outputs of all attention scores are concatenated along the last dimension to form a new feature vector.

[0159] Then, the attention score is converted into a probability distribution through the Softmax function, namely attention_weight:

[0160] AttntionWeight=softmax(AttentionScores)

[0161] This means that the weights of all time steps sum to 1, and each time step reflects its importance relative to the other time steps.

[0162] Finally, by multiplying the attention weights and weighted summing the features of all time steps, we get AttentionApplied and simplify it to a single vector AttntionOut using a Lambda layer:

[0163] AttentionApplied=LSTMOutput*AttentionWeight

[0164] AttntionOut=∑AttentionApplied

[0165] The output of the LSTM is weighted averaged according to the weights of each time step to generate a comprehensive feature representation for the final prediction.

[0166] S5, perform error analysis on the predicted results and the original time series data set. The indicators used here to evaluate the prediction model error are mean absolute error (MAE) and root mean square error (RMSE).

[0167] MAE measures the average absolute difference between the predicted value and the true value. It gives equal weight to all errors, regardless of the direction of the error. The formula for MAE is:

[0168]

[0169] Where N is the number of samples, y i is the true value of the i-th sample, is the model's predicted value for this sample.

[0170] RMSE is the square root of the average of the squared prediction errors. Compared to MAE, it gives a greater penalty for larger errors because the errors are squared when calculated. The formula for RMSE is:

[0171]

[0172] Similarly, N is the number of samples, y i and represent the true value and the predicted value respectively.

[0173] In this embodiment, through comprehensive experimental analysis and evaluation, Figure 3 and Figure 4It can be seen that under six different random missing rates of the three data sets, the generative adversarial network model GAN ​​shows excellent performance in handling missing data filling tasks. By comparing with a series of widely recognized traditional methods (such as iterative multiple interpolation method MICE, KNN neighbor value method, polynomial interpolation method POLY), the study shows that the generative adversarial network achieves the best prediction effect.

[0174] In summary, this application not only verifies the advancedness of GAN in missing data filling tasks, but also provides a powerful solution for dealing with complex data incompleteness in practical problems. With its excellent generation ability and deep understanding of complex data structures, GAN has shown great potential in the field of data restoration and opened up new perspectives and approaches for data preprocessing and analysis.

[0175] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A long time series prediction method based on generative adversarial spatiotemporal attention network, characterized in that: The Generative Adversarial Spatiotemporal Attention Network includes the Generative Adversarial Network and the Spatiotemporal Attention Network. The training process includes the following steps: S1, obtain the time series data set and perform missing processing; S2, constructing a generative adversarial network, using the time series data after the missing processing to train the generative adversarial network, and the generative adversarial network is used to restore the time series data after the missing processing; S3, preprocessing the restored time series data set to obtain a training set and a test set; S4, construct a spatiotemporal attention network, use the training set and the test set to train the spatiotemporal attention network, and the spatiotemporal attention network model is used to predict the restored time series data; S5, perform error analysis on the predicted results and the original time series data set.

2. According to claim 1, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: In step S1, a time series data set is obtained, and the time series data is processed with random block missing and random discrete missing respectively to obtain missing data under different missing conditions.

3. According to claim 1, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: The specific method of step S2 is as follows: S21, constructing a generative adversarial network, including a generator and a discriminator; the generator is used to generate missing data according to the original data and the mask; the discriminator is used to discriminate between the data generated by the generator and the original data; S22, define Hint vector, each element of Hint vector has a certain probability of being set to 1, and the rest of the elements are set to 0; S23, during the training process, the generator generates missing value estimates based on the mask M. When the discriminator receives the combination of the original data and the generated data and the Hint vector, the discriminator not only has to judge the original data and the data generated by the generator, but also has to consider the clues provided by the Hint vector; In each iteration, the Adam optimizer is first used to update the discriminator parameters so that the discriminator can accurately distinguish between the original data and the generated data; The generator parameters are then updated so that the generator generates missing values ​​close to the original data distribution. During the iteration process, the Hint vector provides additional contextual information to guide the learning process of the discriminator and generator.

4. According to claim 3, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: In step S2, the frequency domain transformation technology is also introduced into the generative adversarial network to process the original data, that is, the time domain data. The specific steps are as follows: (1) Convert the time domain data into frequency domain representation through Fourier transform: X fft =F(X mb ) Among them, X mb represents time domain data, X fft represents frequency domain data; F(·) represents Fourier transform; (2) For each scale, generate Gaussian noise of corresponding intensity and add it to the frequency domain data: X fft_noisy =X fft +noise Among them, X fft_noisy Represents the frequency domain data after adding noise; (3) Generate binary mask freq mask , with a 50% probability of selecting a certain frequency, add noise to the selected frequency: X’ fft_noisy =X fft_noisy *freq mask +X fft *(1-freq mask ) Among them, X' fft_noisy represents the frequency domain data after adding noise at the selected frequency; (4) Generate a low-pass filter and high pass filter Where, f represents data; Apply a low-pass filter and a high-pass filter: Among them, X low_fft_noisy Represents frequency domain data X' fft_noisy The data obtained after low-pass filter, X high_fft_oisy Represents frequency domain data X' fft_oisy The data obtained after high-pass filter; (5) The frequency domain data obtained in step (4) after being passed through the low-pass filter and the high-pass filter is converted into time domain data to obtain enhanced time domain data.

5. According to claim 3, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: In step S23, Discriminator loss function D loss for: Where N is the number of samples; M is the i is the i-th element of the mask vector, which indicates whether a part of the data is missing or known; D is the discriminator function, which receives the output processed by the generator. and Hint vector H' i , and output a probability value, which is expressed as the probability of the real data, that is, the original data; The loss function G of the generator loss for: in, Where N is the number of samples; M is the mask of the original data, and G is the generator function that receives the original data. and mask M, and generate the data of the missing part, α is a hyperparameter.

6. According to claim 1, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: In step S4, the spatiotemporal attention network STAN includes a convolutional neural network CNN, a long short-term memory network LSTM, and a multi-head attention mechanism MultiheadAttention.

7. The long time series prediction method based on generative adversarial spatiotemporal attention network according to claim 6 is characterized in that: The design of the convolutional neural network CNN is as follows: First, the convolutional layer is used to extract local features in the time series data, and the input time series data X∈R is defined N*W*I , where N is the batch size, W is the sliding window size, and I is the number of input features; apply a one-dimensional convolution operation to generate a feature map C k : C k =f Conv1D (X,k,lstm_units,'relu') Among them, f Conv1D Represents a one-dimensional convolution function, k is the convolution kernel size, lstm_units is the number of output channels, and 'relu' is the activation function; The second is a maximum pooling layer, which is used to reduce the dimension and extract the significant features P. k : P k =f MaxPooling1D (C k ,3) Among them, f MaxPooling1D represents the maximum pooling function, 3 is the pooling window size; Finally, the Dropout layer is applied to randomly discard some neurons to reduce the risk of overfitting: D k =f Dropout (P k ,dropout) Among them, f Dropout is the Dropout function, dropout is the dropout probability, D k It is the feature output by the Dropout layer.

8. According to claim 6, a long time series prediction method based on generative adversarial spatiotemporal attention network is characterized in that: The long short-term memory network LSTM includes an input gate, a forget gate, and an output gate, and manages the data operation process through the gating unit; at the same time, cell state and hidden state are added. The cell state is responsible for long-term memory storage, and controls the forgetting, preservation and updating of data information through a sophisticated gating mechanism to maintain the model's dependence on long sequences; the hidden state reflects the decision made by the model at the current time step based on historical information, which is used for further processing or as the basis for the final prediction.

9. The long time series prediction method based on generative adversarial spatiotemporal attention network according to claim 6, characterized in that: The design of the multi-head attention mechanism is based on LSTM. The output of LSTM is reshaped according to the number of heads and the dimensions of each head, and a separate Query, Key, and Value matrix is ​​prepared for each head. The dot product is performed on each head, and the attention weight, i.e., the attention score, is calculated, and the output of each head is obtained by weighted summation: Among them, Q, K, and V represent query, key, and value matrices respectively. k is the dimension of the Key vector; Next, concatenate the outputs of all attention scores along the last dimension to form a new feature vector; Then, the attention score is converted into a probability distribution, i.e., attention_weight, through the Softmax function: AttntionWeight=softmax(AttentionScores) Finally, by multiplying the attention weights and weighted summing the features of all time steps, we get AttentionApplied and simplify it to a single vector AttntionOut using a Lambda layer: AttentionApplied=LSTMOutput*AttentionWeight AttntionOut=∑AttentionApplied The output of the LSTM is weighted averaged according to the weights of each time step to generate a comprehensive feature representation for the final prediction.

10. A computer program product, characterized in that It includes a computer program / instruction, which, when executed by a processor, implements a long time series prediction method based on generating adversarial spatiotemporal attention networks as described in any one of claims 1 to 9.

Citation Information

Cited By

  • Magnetotelluric missing data recovery method and system considering space-time characteristics

    CN120009995A

  • Inter-bank network time sequence prediction method based on generative adversarial hierarchy fusion model

    CN120180049A

  • An Inter-bank Network Time Series Prediction Method Based on a Generative Adversarial Hierarchical Fusion Model

    CN120180049B

  • Improved hemodialysis data generation method and system based on generative adversarial network

    CN121144817A