A spatiotemporal sequence prediction method and device based on multi-layer attention mechanism

Through the multi-layer attention mechanism and LSTM network, multiple factors of the spatio-temporal sequence are divided and integrated, which solves the problem of difficulty in capturing spatial relationships and multiple influences in the existing technology, and achieves high-precision spatio-temporal sequence prediction.

CN114492978BActive Publication Date: 2024-10-29HARBIN ENG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210067402.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2024-10-29
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

Existing spatiotemporal sequence prediction methods are difficult to capture the highly dynamic spatial relationships between sequences, and fail to consider the multiple effects of periodicity and mutation at the same time, resulting in a need to improve prediction accuracy.

Method used

Using a spatiotemporal sequence prediction method based on a multi-layer attention mechanism, by dividing direct influencing factors, indirect influencing factors and cross-domain factors, the spatial correlation between monitoring sites is calculated and multiple features are integrated to extract historical data features and combined with LSTM coding The decoder and decoder respectively capture long-term, medium-term development patterns and short-term mutation information, calculate the influence weight of multiple temporal relationships, and integrate multi-span historical data for prediction.

Benefits of technology

Without introducing noise, it makes full use of neighborhood data to capture the spatial dependence of spatio-temporal sequences, which improves prediction accuracy. It can simultaneously capture long-term and mid-term development patterns and short-term mutation information, enhancing the reliability of predictions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114492978B_ABST
    Figure CN114492978B_ABST
Patent Text Reader

Abstract

The present invention proposes a method and device for predicting spatiotemporal series based on a multi-layer attention mechanism. Based on the attention mechanism, the present invention integrates multi-dimensional features step by step to construct historical data features according to the cross-influence of cross-domain data. Without introducing noise, the present invention makes full use of neighborhood data to enrich the feature information of the target area and capture the spatial dependencies of spatiotemporal series in different regions. The LSTM encoder is used to capture the long-term and medium-term development patterns and short-term mutation information of the time series respectively, and the attention mechanism is gradually used to dynamically capture the impact of multiple temporal relationships on the future. The impact weights of the corresponding historical information are calculated step by step, and finally the LSTM decoder is used to fully integrate the historical data of multiple spans to predict the spatiotemporal series. The present invention can make full use of neighborhood data to enrich the feature information of the target area and capture the spatial dependencies of spatiotemporal series in different regions without introducing noise.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of spatiotemporal sequence prediction, and in particular relates to a spatiotemporal sequence prediction method and device based on a multi-layer attention mechanism. Background Art

[0002] As a key technology for spatiotemporal data analysis, spatiotemporal series prediction has been widely used in smart city construction, smart manufacturing upgrades and other fields. In the process of smart city construction, accurate air quality prediction helps regulatory authorities to scientifically issue air pollution warnings, quickly complete accident prevention and resource allocation, and improve people's quality of life. In the field of smart manufacturing, accurate supply chain output value prediction helps companies make correct production decisions, strengthen organic collaboration among companies in the supply chain, and improve the overall production capacity of the industrial field.

[0003] The performance of spatiotemporal series prediction models is constrained by many factors, including: (1) Lack of neighborhood information. Most existing studies use spatial interpolation methods to solve the problem of data sparsity, which introduces a lot of noise and affects prediction accuracy. (2) Rough spatial view. Most existing studies use convolutional neural networks as a spatial view capture method, but do not thoroughly mine spatial relationships. (3) Single temporal relationship. Most existing studies use sequence neural networks as a single temporal relationship capture method, only considering the long-term development pattern of spatiotemporal series, or only considering the direct effect of short-term data, without considering the multiple effects of periodicity and short-term mutations at the same time, and making insufficient use of existing time series data. Effective spatiotemporal series modeling is extremely challenging because the spatial dependency of the sequence is dynamically constrained by multiple factors and the temporal dependency has both periodicity and mutation.

[0004] In the field of spatiotemporal series prediction, the commonly used analysis methods currently include traditional spatiotemporal series prediction methods and prediction methods based on machine learning. As a traditional data modeling method, the autoregressive differential moving average model (ARIMA) can only capture the linear relationship between data, and cannot fit the complex nonlinear correlation between sequences, and the prediction accuracy of spatiotemporal series is low. As a data-driven machine learning method, artificial neural network (ANN) uses the integrated structure of linear threshold units to represent complex nonlinear functions, which can be used to obtain the medium- and long-term trends of time series to a certain extent, but its results are seriously affected by the initial random weights and thresholds, and the model prediction performance is unstable, which cannot meet the requirements of model reliability in scenarios such as industrial production. Support vector machine (SVM) uses kernel functions to map input vectors to high-dimensional space according to preset nonlinear transformations, and uses linear algorithms to analyze the nonlinear characteristics of samples, which significantly improves the accuracy of time series prediction models. However, the model is sensitive to parameters and kernel functions, and it is necessary to combine relevant field knowledge to determine parameters, making it difficult to establish a general prediction model for multiple fields. Random forest uses ensemble algorithms to train multiple decision trees to jointly perform sequence prediction. It can effectively extract complex nonlinear relationships between high-dimensional feature sequences. However, it is prone to overfitting when data noise problems are serious, making it difficult to perform accurate spatiotemporal sequence predictions based on low-quality industrial big data.

[0005] With the development of deep learning technology, neural networks with rich hidden layers have shown strong capabilities in extracting abstract features and internal laws of sample data, and the accuracy of model recognition and prediction has been continuously improved. In recent years, breakthroughs have been made in spatiotemporal series prediction. Convolutional neural networks can mine the spatial correlation of data through operations such as convolution and pooling, but the spatial dependency of sequences will be affected by the cross-influence of complex cross-domain features. Existing studies only use convolutional neural networks to construct spatial views, which makes it difficult to capture highly dynamic spatial relationships between sequences, and the prediction performance needs to be improved. Recurrent neural networks can use the back-propagation algorithm to continuously update the weight parameters in the model, thereby extracting the historical development laws of time series, but most existing studies only use recurrent neural networks to capture a single time series relationship, only consider the long-term development model of time series, or only consider the direct effect of short-term historical data, without considering the multiple effects of periodicity and mutation at the same time, and do not make full use of existing time series data.

[0006] In summary, the main problem with current research is that it is difficult to capture the highly dynamic spatial relationship between sequences, and the multiple effects of periodicity and mutation are not considered at the same time, and the prediction accuracy needs to be improved. Summary of the invention

[0007] In order to solve the problems in the prior art, the present invention proposes a spatiotemporal sequence prediction method and device based on a multi-layer attention mechanism.

[0008] The present invention is implemented by the following technical scheme. The present invention proposes a spatiotemporal sequence prediction method based on a multi-layer attention mechanism, and the method specifically comprises the following steps:

[0009] Step 1. Obtain all historical monitoring data of the spatiotemporal series related to the spatiotemporal series to be predicted;

[0010] Step 2. According to whether various types of spatiotemporal sequences will diffuse and propagate between regions, the spatiotemporal sequences of the input model are divided into direct influencing factors, indirect influencing factors, and cross-domain factors;

[0011] Step 3. Calculate the spatial correlation between each monitoring site, and then integrate the composite impact of multiple features on the spatiotemporal series to extract historical data features;

[0012] Step 4. Based on the output of step 3, calculate the multi-granularity spatiotemporal sequence relationship;

[0013] Step 5. Calculate the influence weights of different granularity time series relationships on the spatiotemporal series to be predicted;

[0014] Step 6. Combine the influence weights obtained in step 5 to fuse different time series relationships and obtain the spatiotemporal sequence to be predicted.

[0015] Furthermore, the step 1 is specifically as follows: the set of all nodes in the spatial region is S = {s1, s2, ..., s N}, N is the number of nodes, La=(la1,la2,…,la N )∈R N Respectively represent the latitude position of each node, Lo = (lo1, lo2, ..., lo N )∈R N Indicates the longitude position of each node; given a historical time window T = {t1, t2, …, t H}, H is the time length. When the historical time window length is H, all the spatiotemporal sequence historical monitoring data related to the sequence to be predicted are collected through sensors, which is expressed as X = (x1, x2, ..., x H )∈R P×N×H , where P is the number of related space-time sequences.

[0016] Furthermore, in step 2:

[0017] Use I=(i1,i2,…,i H )∈R G×N×H It represents the features that will have a direct impact on the spatiotemporal series to be predicted. Such features will not diffuse between regions, where G is the number of direct influencing factors;

[0018] Use O=(o1,o2,…,oH )∈R K×N×H It represents the features that will indirectly affect the spatiotemporal series to be predicted, where K is the number of indirect influencing factors;

[0019] Use V=(v1,v2,…,v H )∈R D×N×H It represents the cross-domain factors that will affect the spatiotemporal sequence between adjacent nodes, where D is the number of cross-domain factors.

[0020] Furthermore, the step 3 is specifically as follows:

[0021] Extract the impact of indirect influencing factors on the target spatiotemporal sequence: take the latitude position La∈R of each node as the N , the longitude position of each node Lo∈R N and cross-domain factor V = (v1, v2, ..., v H )∈R D×N×H As input, the dynamic correlation between each site is extracted with "hour" as the granularity; the indirect influencing factor extraction method is as follows:

[0022] Assume the target site is s i , historical time point is t, qualitatively judge all sites s j With the target site i Relevance If the site j The state at time step t will be the target site s i If it has an impact, then the correlation The value of is 1, otherwise it is 0. The specific calculation method is as follows:

[0023]

[0024] Among them, la i is the latitude of the target site, lo i is the longitude position of the target site, la j Neighborhood sites j The latitude of the location, lo j Neighborhood sites j Longitude position, Neighborhood sites j The wind speed u at time step t, Neighborhood sites j v wind speed at time step t;

[0025] Qualitatively determine that all states at time step t will affect the target site s i After the affected site is found, the influence of all sites on the target site at time step t is quantitatively calculated as follows:

[0026]

[0027] Among them, s j All requirements are met monitoring station, if the monitoring station s j At time step t and target site s i Relevance is 0, then the monitoring station s j At time step t, i The degree of influence is also 0; α is a constant;

[0028] With the cross-domain factor V = (v1, v2, ..., v D )∈R D×N×H As input, a convolutional neural network is used to extract the dynamic correlation between each site hour by hour, and the indirect impact of each node on the spatiotemporal sequence of other nodes is obtained:

[0029]

[0030] in, is the cross-domain factor of target node i at time step t, and b are both trainable parameters, f is the activation function, is the indirect influence of node i on neighboring nodes at time step t; is the influence degree of node i at time step t;

[0031] Assume the target node is s i , then the neighboring node s j The degree of indirect influence on the target node is

[0032] In order to accurately measure the influence of all nodes on the target node sequence, the similarity between the target node and each neighboring node is calculated according to the node feature matrix, and the influence of each neighboring node j on node i is calculated using the vector product. Then, the softmax function is used to calculate the influence of all nodes on the target node s at time step t. i Normalize the influence of to ensure that the sum of the influence weights of all neighboring nodes on the target is 1:

[0033]

[0034] Two trainable parameters are used to adaptively adjust the indirect features of the target node i under the combined influence of itself and cross-domain factors, and the indirect historical features of the target node under the influence of itself and all other neighboring nodes are obtained. The calculation method is as follows:

[0035]

[0036] Among them, σ is the RELU function, and W1 and W2 are both trainable parameters; For sites i Indirect history features at time step t; represents the indirect feature of target node i, Represents the indirect features between the target node i and other neighboring nodes j;

[0037] After comprehensively considering the cross-domain impact of indirect factors, the joint effect of indirect and direct features on the target node at time step t is considered, and the direct and indirect influencing factors of node i at time step t are spliced ​​in the channel dimension to obtain site s i The historical features at time step t are:

[0038]

[0039] in, Indicates site i Unit history characteristics at time step t;

[0040] The above extraction method is executed for each time step, so that the complex dynamic correlation between nodes can be fully considered and the historical data feature Z = (z1, z2, ..., z H )∈R (G+K)×N×H .

[0041] Further, in step 4: the calculating of multi-granularity spatiotemporal sequence relations includes an implementation method for extracting a long-term development pattern of the spatiotemporal sequence;

[0042] The specific implementation method for extracting the long-term development pattern of spatiotemporal series is as follows:

[0043] First, after obtaining the historical data feature Z=(z1,z2,…,z H )∈R (G+K)×N×H Under the premise of assuming that the target time is f, first extract the development pattern of the target data one week before f, that is, the long-term development pattern. The extraction steps are as follows:

[0044] The historical features of each day in the week before the target time f are input into LSTM respectively, and the encoder structure is used to extract the corresponding spatiotemporal sequence development pattern:

[0045]

[0046] Where D d is the spatiotemporal sequence evolution pattern of d days before f, || represents the serial operation in the channel dimension; h d and c d are the hidden state and cell state of LSTM in the previous d days, h t0 represents the initial hidden state, ct0 represents the initial cell state;

[0047] According to the development pattern of the spatiotemporal sequence of each day in a week, in the decoder structure, the attention mechanism is used to quantitatively calculate the influence of daily sequence features on the long-term development pattern, comprehensively consider the actual situation of each day, and accurately extract the long-term development pattern L f , the specific calculation process is as follows:

[0048]

[0049] Among them, h f-1 is the hidden state of the decoder at time step f-1, W d is a trainable parameter.

[0050] Further, in step 4: the calculation of the multi-granularity spatiotemporal sequence relationship includes an implementation method of extracting the mid-term development mode of the spatiotemporal sequence:

[0051] The specific implementation method for extracting the medium-term development pattern of the spatiotemporal series is as follows:

[0052] The historical features of the 24 hours before the target time f extracted previously are input into the LSTM unit respectively to obtain the corresponding hidden state for each hour:

[0053] H t ,(h t ,c t )=LSTM(X t ,(h t0 ,c t0 ))

[0054] Among them, H t is the data feature of time step t, h t and c t is the hidden state and cell state of LSTM at the last time step;

[0055] According to the hourly historical data features, in the decoder structure, the attention mechanism is used to quantitatively calculate the impact of hourly data features on the medium-term development model, and the medium-term development model M of the spatiotemporal sequence is extracted. f , the calculation process is as follows:

[0056]

[0057] Among them, h f-1 is the hidden state of the decoder at time step f-1, W t is a trainable parameter.

[0058] Further, in step 4: the calculation of multi-granularity spatiotemporal sequence relations includes an implementation method for extracting short-term mutation information of the spatiotemporal sequence;

[0059] The specific implementation method of extracting short-term mutation information of spatiotemporal series is as follows: taking historical data features as input, assuming that the target time is f, before extracting short-term mutation information, it is necessary to determine whether the target time step f is the first time step in the entire sequence to be predicted. If the target is the first time step, the historical feature X of the previously extracted f-1 time step is used as the input. f-1 As input, the LSTM unit is input to obtain the corresponding hidden state of the neural network as the short-term mutation information S f ; If the target time step f is not the first time step in the entire sequence to be predicted, the decoder's prediction result Y for the previous time step is f-1 As short-term mutation information S f , ensuring the timeliness of short-term mutation information.

[0060] Furthermore, the step 5 is specifically as follows:

[0061] When predicting time step f, the decoder’s hidden state h at time step f-1 is used f-1 As the query vector, the attention mechanism is used to quantitatively calculate the influence of long-term development mode, medium-term development mode and short-term mutation information on the future target sequence, and the softmax function is used to normalize the influence weights of the three:

[0062]

[0063]

[0064]

[0065] in, is the weight of the impact of long-term and medium-term development patterns and short-term mutation information on time step f, h f -1 is the hidden state of the decoder at time step f-1, W L , W M With W S These are all trainable parameters.

[0066] Furthermore, the step 6 is specifically as follows:

[0067] After extracting the long-term and medium-term development patterns and short-term mutation information of the target sequence, the historical data information contained in the three patterns is comprehensively used to predict the value of the target sequence at time f. The specific calculation method is as follows:

[0068]

[0069] Y f =LSTM(C f )

[0070] Where L f 、M f and S f They are the long-term development pattern, medium-term development pattern and short-term mutation information of the spatiotemporal sequence extracted by the model based on different historical information, C f is the input of the decoder at time f, Y f That is the prediction result of the model's future time-space sequence; Y = (y 1 ,y 2 ,…,y F )∈R F×N It is the target spatiotemporal sequence value of N nodes in the next F time steps, that is, the output result of the model.

[0071] The present invention also proposes an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the spatiotemporal sequence prediction method based on the multi-layer attention mechanism when executing the computer program.

[0072] Compared with the prior art, the beneficial effect of the present invention is that it fully utilizes the neighborhood data to enrich the characteristic information of the target area without introducing noise, and captures the spatial dependency of the spatiotemporal sequences in different regions. The present invention can also capture the long-term and medium-term development patterns and short-term mutation information of the spatiotemporal sequence respectively, and use the weights of the impact of multiple temporal relationships on the future to fuse multi-span historical data to predict the spatiotemporal sequence. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Figure 1 It is a diagram of the calculation method of historical data characteristics;

[0074] Figure 2 It is a diagram of multiple temporal relationship fusion method;

[0075] Figure 3 This is a structural diagram of the spatiotemporal sequence prediction method based on the multi-layer attention mechanism;

[0076] Figure 4 It is a flow chart of the spatiotemporal sequence prediction method based on the multi-layer attention mechanism. DETAILED DESCRIPTION

[0077] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings 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.

[0078] The purpose of the present invention is to address the problem of spatiotemporal sequence, overcome the deficiencies of the prior art, and provide a spatiotemporal sequence prediction method based on a multi-layer attention mechanism. Based on the attention mechanism, the present invention integrates multidimensional features step by step to construct historical data features according to the cross-domain data's cross-influence, and fully utilizes the neighborhood data to enrich the feature information of the target area without introducing noise, and captures the spatial dependencies of spatiotemporal sequences in different regions. The LSTM encoder is used to capture the long-term and medium-term development patterns and short-term mutation information of the time series respectively, and the attention mechanism is gradually used to dynamically capture the impact of multiple temporal relationships on the future, and the impact weights of the corresponding historical information are calculated step by step. Finally, the LSTM decoder is used to fully integrate the multi-span historical data to predict the spatiotemporal sequence.

[0079] Combination Figure 1-4 The present invention proposes a spatiotemporal sequence prediction method based on a multi-layer attention mechanism, and the method specifically comprises the following steps:

[0080] Step 1. Obtain all historical monitoring data of the spatiotemporal series related to the spatiotemporal series to be predicted;

[0081] The step 1 is specifically as follows: the set of all nodes in the spatial region is S = {s1, s2, ..., s N}, N is the number of nodes, La=(la1,la2,…,la N )∈R N Respectively represent the latitude position of each node, Lo = (lo1, lo2, ..., lo N )∈R N Indicates the longitude position of each node; given a historical time window T = {t1, t2, …, t H}, H is the time length. When the historical time window length is H, all the spatiotemporal sequence historical monitoring data related to the sequence to be predicted are collected through sensors, which is expressed as X = (x1, x2, ..., x H )∈R P×N×H , where P is the number of related space-time sequences.

[0082] Step 2. According to whether various types of spatiotemporal sequences will diffuse and propagate between regions, the spatiotemporal sequences of the input model are divided into direct influencing factors, indirect influencing factors, and cross-domain factors;

[0083] In step 2:

[0084] Use I=(i1,i2,…,i H )∈R G×N×H It represents the features that will have a direct impact on the spatiotemporal series to be predicted. Such features will not diffuse between regions, where G is the number of direct influencing factors;

[0085] Use O=(o1,o2,…,o H )∈R K×N×H It represents the features that will indirectly affect the spatiotemporal series to be predicted, where K is the number of indirect influencing factors;

[0086] Use V=(v1,v2,…,v H )∈R D×N×H It represents the cross-domain factors that will affect the spatiotemporal sequence between adjacent nodes, where D is the number of cross-domain factors.

[0087] Step 3. Calculate the spatial correlation between each monitoring site, and then integrate the composite impact of multiple features on the spatiotemporal series to extract historical data features;

[0088] The step 3 is specifically as follows:

[0089] Extract the impact of indirect influencing factors on the target spatiotemporal sequence: take the latitude position La∈R of each node as the N , the longitude position of each node Lo∈R N and cross-domain factor V = (v1, v2, ..., v H )∈R D×N×H As input, the dynamic correlation between each site is extracted with "hour" as the granularity; the indirect influencing factor extraction method is as follows:

[0090] Assume the target site is s i , historical time point is t, qualitatively judge all sites s j With the target site i Relevance If the site j The state at time step t will be the target site s i If it has an impact, then the correlation The value of is 1, otherwise it is 0. The specific calculation method is as follows:

[0091]

[0092] Among them, la i is the latitude of the target site, lo i is the longitude position of the target site, la j Neighborhood sites j The latitude of the location, lo j Neighborhood sites j Longitude position, Neighborhood sites j The wind speed u at time step t, Neighborhood sites j v wind speed at time step t;

[0093] Qualitatively determine that all states at time step t will affect the target site s i After the affected site is found, the influence of all sites on the target site at time step t is quantitatively calculated as follows:

[0094]

[0095] Among them, s j All requirements are met monitoring station, if the monitoring station s j At time step t and target site s i Relevance is 0, then the monitoring station s j At time step t, i The degree of influence is also 0; α is a constant;

[0096] With the cross-domain factor V = (v1, v2, ..., v D )∈R D×N×H As input, a convolutional neural network is used to extract the dynamic correlation between each site hour by hour, and the indirect impact of each node on the spatiotemporal sequence of other nodes is obtained:

[0097]

[0098] in, is the cross-domain factor of target node i at time step t, and b are both trainable parameters, f is the activation function, is the indirect influence of node i on neighboring nodes at time step t; is the influence degree of node i at time step t;

[0099] Assume the target node is s i , then the neighboring node s j The degree of indirect influence on the target node is

[0100] In order to accurately measure the influence of all nodes on the target node sequence, the similarity between the target node and each neighboring node is calculated according to the node feature matrix, and the influence of each neighboring node j on node i is calculated using the vector product. Then, the softmax function is used to calculate the influence of all nodes on the target node s at time step t. i Normalize the influence of to ensure that the sum of the influence weights of all neighboring nodes on the target is 1:

[0101]

[0102] Two trainable parameters are used to adaptively adjust the indirect features of the target node i under the combined influence of itself and cross-domain factors, and the indirect historical features of the target node under the influence of itself and all other neighboring nodes are obtained. The calculation method is as follows:

[0103]

[0104] Among them, σ is the RELU function, and W1 and W2 are both trainable parameters; For sites i Indirect history features at time step t; represents the indirect feature of target node i, Represents the indirect features between the target node i and other neighboring nodes j;

[0105] After comprehensively considering the cross-domain impact of indirect factors, the joint effect of indirect and direct features on the target node at time step t is considered, and the direct and indirect influencing factors of node i at time step t are spliced ​​in the channel dimension to obtain site s i The historical features at time step t are:

[0106]

[0107] in, Indicates site i Unit history characteristics at time step t;

[0108] The above extraction method is executed for each time step, so that the complex dynamic correlation between nodes can be fully considered and the historical data feature Z = (z1, z2, ..., z H )∈R (G+K)×N×H .

[0109] Step 4. Based on the output of step 3, calculate the multi-granularity spatiotemporal sequence relationship;

[0110] In step 4: the calculation of multi-granularity spatiotemporal sequence relations includes an implementation method for extracting a long-term development pattern of the spatiotemporal sequence;

[0111] The specific implementation method for extracting the long-term development pattern of spatiotemporal series is as follows:

[0112] First, after obtaining the historical data feature Z=(z1,z2,…,z H )∈R (G+K)×N×H Under the premise of assuming that the target time is f, first extract the development pattern of the target data one week before f, that is, the long-term development pattern. The extraction steps are as follows:

[0113] The historical features of each day in the week before the target time f are input into LSTM respectively, and the encoder structure is used to extract the corresponding spatiotemporal sequence development pattern:

[0114]

[0115] Where D d is the spatiotemporal sequence evolution pattern of d days before f, || represents the serial operation in the channel dimension; h d and c d are the hidden state and cell state of LSTM in the previous d days, h t0 represents the initial hidden state, c t0 represents the initial cell state;

[0116] According to the development pattern of the spatiotemporal sequence of each day in a week, in the decoder structure, the attention mechanism is used to quantitatively calculate the influence of daily sequence features on the long-term development pattern, comprehensively consider the actual situation of each day, and accurately extract the long-term development pattern L f , the specific calculation process is as follows:

[0117]

[0118] Among them, h f-1 is the hidden state of the decoder at time step f-1, W d is a trainable parameter.

[0119] In step 4: the calculation of the multi-granularity spatiotemporal sequence relationship includes the implementation method of extracting the mid-term development pattern of the spatiotemporal sequence:

[0120] The specific implementation method for extracting the medium-term development pattern of the spatiotemporal series is as follows:

[0121] The historical features of the 24 hours before the target time f extracted previously are input into the LSTM unit respectively to obtain the corresponding hidden state for each hour:

[0122] H t ,(h t ,c t )=LSTM(X t ,(h t0 ,c t0 ))

[0123] Among them, H t is the data feature of time step t, h t and c t is the hidden state and cell state of LSTM at the last time step;

[0124] According to the hourly historical data features, in the decoder structure, the attention mechanism is used to quantitatively calculate the impact of hourly data features on the medium-term development model, and the medium-term development model M of the spatiotemporal sequence is extracted. f , the calculation process is as follows:

[0125]

[0126] Among them, h f-1 is the hidden state of the decoder at time step f-1, W t is a trainable parameter.

[0127] In step 4: the calculation of multi-granularity spatiotemporal sequence relations includes a method for extracting short-term mutation information of the spatiotemporal sequence;

[0128] The specific implementation method of extracting short-term mutation information of spatiotemporal series is as follows: taking historical data features as input, assuming that the target time is f, before extracting short-term mutation information, it is necessary to determine whether the target time step f is the first time step in the entire sequence to be predicted. If the target is the first time step, the historical feature X of the previously extracted f-1 time step is used as the input. f-1 As input, the LSTM unit is input to obtain the corresponding hidden state of the neural network as the short-term mutation information S f ; If the target time step f is not the first time step in the entire sequence to be predicted, the decoder's prediction result Y for the previous time step is f-1 As short-term mutation information S f , ensuring the timeliness of short-term mutation information.

[0129] Step 5. Calculate the influence weights of different granularity time series relationships on the spatiotemporal series to be predicted;

[0130] The step 5 is specifically as follows:

[0131] When predicting time step f, the decoder’s hidden state h at time step f-1 is used f-1 As the query vector, the attention mechanism is used to quantitatively calculate the influence of long-term development mode, medium-term development mode and short-term mutation information on the future target sequence, and the softmax function is used to normalize the influence weights of the three:

[0132]

[0133]

[0134]

[0135] in, is the weight of the impact of long-term and medium-term development patterns and short-term mutation information on time step f, h f -1 is the hidden state of the decoder at time step f-1, W L , W M With W S These are all trainable parameters.

[0136] Step 6. Combine the influence weights obtained in step 5 to fuse different time series relationships and obtain the spatiotemporal sequence to be predicted.

[0137] The step 6 is specifically as follows:

[0138] After extracting the long-term and medium-term development patterns and short-term mutation information of the target sequence, the historical data information contained in the three patterns is comprehensively used to predict the value of the target sequence at time f. The specific calculation method is as follows:

[0139]

[0140] Y f =LSTM(C f )

[0141] Where L f 、M f and S f They are the long-term development pattern, medium-term development pattern and short-term mutation information of the spatiotemporal sequence extracted by the model based on different historical information, C f is the input of the decoder at time f, Y f That is the prediction result of the model's future time-space sequence; Y = (y 1 ,y 2 ,…,y F )∈R F×N is the target spatiotemporal sequence value of N nodes in the next F time steps, that is, the model output result. Since the prediction of each time step does not completely depend on the output of the previous time step, this method also avoids the common error accumulation problem in long-term sequence prediction.

[0142] The present invention also proposes an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the spatiotemporal sequence prediction method based on the multi-layer attention mechanism when executing the computer program.

[0143] The spatiotemporal sequence prediction method based on the multi-layer attention mechanism disclosed in the present invention can achieve the following beneficial effects: without introducing noise, it can make full use of the neighborhood data to enrich the characteristic information of the target area and capture the spatial dependency of spatiotemporal sequences in different regions. The present invention can also capture the long-term and medium-term development patterns and short-term mutation information of the spatiotemporal sequence respectively, use the weights of the impact of multiple temporal relationships on the future, and fuse multi-span historical data to predict the spatiotemporal sequence.

[0144] The above is a detailed introduction to the spatiotemporal series prediction method and device based on the multi-layer attention mechanism proposed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A spatiotemporal sequence prediction method based on a multi-layer attention mechanism, characterized by: The method specifically comprises the following steps: Step 1. Obtain all historical monitoring data of the spatiotemporal series related to the spatiotemporal series to be predicted; Step 2. According to whether various types of spatiotemporal sequences will diffuse and propagate between regions, the spatiotemporal sequences of the input model are divided into direct influencing factors, indirect influencing factors, and cross-domain factors; Step 3. Calculate the spatial correlation between each monitoring site, and then integrate the composite impact of multiple features on the spatiotemporal series to extract historical data features; The step 3 is specifically as follows: Extract the impact of indirect influencing factors on the target spatiotemporal sequence: take the latitude position La∈R of each node as the N , the longitude position of each node Lo∈R N and cross-domain factor V = (v1, v2, ..., v H )∈R D×N×H As input, the dynamic correlation between each site is extracted with "hour" as the granularity; the indirect influencing factor extraction method is as follows: Assume the target site is s i , historical time point is t, qualitatively judge all sites s j With the target site i Relevance If the site j The state at time step t will be the target site s i If it has an impact, then the correlation The value of is 1, otherwise it is 0. The specific calculation method is as follows: Among them, la i is the latitude of the target site, lo i is the longitude position of the target site, la j Neighborhood sites j The latitude of the location, lo j Neighborhood sites j Longitude position, Neighborhood sites j The wind speed u at time step t, Neighborhood sites j v wind speed at time step t; Qualitatively determine that all states at time step t will affect the target site s i After the affected site is found, the influence of all sites on the target site at time step t is quantitatively calculated as follows: Among them, s j All requirements are met monitoring station, if the monitoring station s j At time step t and target site s i Relevance is 0, then the monitoring station s j At time step t, i The degree of influence is also 0; α is a constant; With the cross-domain factor V = (v1, v2, ..., v D )∈R D×N×H As input, a convolutional neural network is used to extract the dynamic correlation between each site hour by hour, and the indirect impact of each node on the spatiotemporal sequence of other nodes is obtained: in, is the cross-domain factor of target node i at time step t, and b are both trainable parameters, f is the activation function, is the indirect influence of node i on neighboring nodes at time step t; is the influence degree of node i at time step t; Assume the target node is s i , then the neighboring node s j The degree of indirect influence on the target node is In order to accurately measure the influence of all nodes on the target node sequence, the similarity between the target node and each neighboring node is calculated according to the node feature matrix, and the influence of each neighboring node j on node i is calculated using the vector product. Then, the softmax function is used to calculate the influence of all nodes on the target node s at time step t. i Normalize the influence of to ensure that the sum of the influence weights of all neighboring nodes on the target is 1: Two trainable parameters are used to adaptively adjust the indirect features of the target node i under the combined influence of itself and cross-domain factors, and the indirect historical features of the target node under the influence of itself and all other neighboring nodes are obtained. The calculation method is as follows: Among them, σ is the RELU function, and W1 and W2 are both trainable parameters; For sites i Indirect history features at time step t; represents the indirect feature of target node i, Represents the indirect features between the target node i and other neighboring nodes j; After comprehensively considering the cross-domain impact of indirect factors, the joint effect of indirect and direct features on the target node at time step t is considered, and the direct and indirect influencing factors of node i at time step t are spliced ​​in the channel dimension to obtain site s i The historical features at time step t are: in, Indicates site i Unit history characteristics at time step t; The above extraction method is executed for each time step, so that the complex dynamic correlation between nodes can be fully considered and the historical data feature Z = (z1, z2, ..., z H )∈R (G+K)×N×H ; Step 4. Based on the output of step 3, calculate the multi-granularity spatiotemporal sequence relationship; Step 5. Calculate the influence weights of different granularity time series relationships on the spatiotemporal series to be predicted; Step 6. Combine the influence weights obtained in step 5 to fuse different time series relationships and obtain the spatiotemporal sequence to be predicted.

2. The method according to claim 1, characterized in that: The step 1 is specifically as follows: the set of all nodes in the spatial region is S = {s1, s2, ..., s N }, N is the number of nodes, La=(la1,la2,…,la N )∈R N Respectively represent the latitude position of each node, Lo = (lo1, lo2, ..., lo N )∈R N Indicates the longitude position of each node; given a historical time window T = {t1, t2, …, t H }, H is the time length. When the historical time window length is H, all the spatiotemporal sequence historical monitoring data related to the sequence to be predicted are collected through sensors, which is expressed as X = (x1, x2, ..., x H )∈R P×N×H , where P is the number of related space-time sequences.

3. The method according to claim 2, characterized in that: In step 2: Use I=(i1,i2,…,i H )∈R G×N×H It represents the features that will have a direct impact on the spatiotemporal series to be predicted. Such features will not diffuse between regions, where G is the number of direct influencing factors; Use O=(o1,o2,…,o H )∈R K×N×H It represents the features that will indirectly affect the spatiotemporal series to be predicted, where K is the number of indirect influencing factors; Use V=(v1,v2,…,v H )∈R D×N×H It represents the cross-domain factors that will affect the spatiotemporal sequence between adjacent nodes, where D is the number of cross-domain factors.

4. The method according to claim 3, characterized in that: In step 4: the calculation of multi-granularity spatiotemporal sequence relations includes an implementation method for extracting a long-term development pattern of the spatiotemporal sequence; The specific implementation method for extracting the long-term development pattern of spatiotemporal series is as follows: First, after obtaining the historical data feature Z=(z1,z2,…,z H )∈R (G+K)×N×H Under the premise of assuming that the target time is f, first extract the development pattern of the target data one week before f, that is, the long-term development pattern. The extraction steps are as follows: The historical features of each day in the week before the target time f are input into LSTM respectively, and the encoder structure is used to extract the corresponding spatiotemporal sequence development pattern: Where D d is the spatiotemporal sequence evolution pattern of d days before f, || represents the serial operation in the channel dimension; h d and c d are the hidden state and cell state of LSTM in the previous d days, h t0 represents the initial hidden state, c t0 represents the initial cell state; According to the development pattern of the spatiotemporal sequence of each day in a week, in the decoder structure, the attention mechanism is used to quantitatively calculate the influence of daily sequence features on the long-term development pattern, comprehensively consider the actual situation of each day, and accurately extract the long-term development pattern L f , the specific calculation process is as follows: Among them, h f-1 is the hidden state of the decoder at time step f-1, W d is a trainable parameter.

5. The method according to claim 4, characterized in that: In step 4: the calculation of the multi-granularity spatiotemporal sequence relationship includes the implementation method of extracting the mid-term development pattern of the spatiotemporal sequence: The specific implementation method for extracting the medium-term development pattern of the spatiotemporal series is as follows: The historical features of the 24 hours before the target time f extracted previously are input into the LSTM unit respectively to obtain the corresponding hidden state for each hour: H t ,(h t ,c t )=LSTM(X t ,(h t0 ,c t0 )) Among them, H t is the data feature of time step t, h t and c t is the hidden state and cell state of LSTM at the last time step; According to the hourly historical data features, in the decoder structure, the attention mechanism is used to quantitatively calculate the impact of hourly data features on the medium-term development model, and the medium-term development model M of the spatiotemporal sequence is extracted. f , the calculation process is as follows: Among them, h f-1 is the hidden state of the decoder at time step f-1, W t is a trainable parameter.

6. The method according to claim 5, characterized in that: In step 4: the calculation of multi-granularity spatiotemporal sequence relations includes a method for extracting short-term mutation information of the spatiotemporal sequence; The specific implementation method of extracting short-term mutation information of spatiotemporal series is as follows: taking historical data features as input, assuming that the target time is f, before extracting short-term mutation information, it is necessary to determine whether the target time step f is the first time step in the entire sequence to be predicted. If the target is the first time step, the historical feature X of the previously extracted f-1 time step is used as the input. f-1 As input, input LSTM unit, and get the corresponding hidden state of neural network as short-term mutation information S f ; If the target time step f is not the first time step in the entire sequence to be predicted, the decoder's prediction result Y for the previous time step is f-1 As short-term mutation information S f , ensuring the timeliness of short-term mutation information.

7. The method according to claim 6, characterized in that: The step 5 is specifically as follows: When predicting time step f, the decoder’s hidden state h at time step f-1 is used f-1 As the query vector, the attention mechanism is used to quantitatively calculate the influence of long-term development mode, medium-term development mode and short-term mutation information on the future target sequence, and the softmax function is used to normalize the influence weights of the three: in, is the weight of the impact of long-term and medium-term development patterns and short-term mutation information on time step f, h f-1 is the hidden state of the decoder at time step f-1, W L , W M With W S These are all trainable parameters.

8. The method according to claim 7, characterized in that: The step 6 is specifically as follows: After extracting the long-term and medium-term development patterns and short-term mutation information of the target sequence, the historical data information contained in the three patterns is comprehensively used to predict the value of the target sequence at time f. The specific calculation method is as follows: Y f =LSTM(C f ) Where L f 、M f and S f They are the long-term development pattern, medium-term development pattern and short-term mutation information of the spatiotemporal sequence extracted by the model based on different historical information, C f is the input of the decoder at time f, Y f That is the prediction result of the model's future time-space sequence; Y = (y 1 ,y 2 ,…,y F )∈R F×N It is the target spatiotemporal sequence value of N nodes in the next F time steps, that is, the output result of the model.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Space-time attention mechanism method for traffic prediction

    CN110619430A

  • Convolutional long short-term memory network space-time sequence prediction method improved by utilizing attention mechanism

    CN112418409A