A dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism

By introducing a dynamic spatiotemporal neural network based on attention mechanism in traffic prediction, combining three-dimensional convolution and periodic modeling, the problems of unconsidered space-time correlation and periodicity in the existing technology are solved, and the traffic flow prediction is significantly improved accuracy and robustness.

CN115662128BInactive Publication Date: 2025-01-03LIAONING TECHNICAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211312456.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-25
Publication Date
2025-01-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing urban traffic prediction methods cannot effectively consider spatiotemporal correlation and historical periodicity, resulting in low prediction accuracy. Traditional deep learning models ignore spatial correlation factors and cannot capture the degree of correlation in long-distance areas.

Method used

Using a dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism, through three-dimensional convolution and periodic modeling, combining spatial attention mechanism and temporal attention mechanism, local dynamic prediction module and global correlation prediction module are constructed, and ResPlus is integrated Unit, extracts the spatiotemporal characteristics of traffic data and dynamically adjusts the influence weights.

Benefits of technology

It improves the accuracy and robustness of urban traffic flow prediction, can better capture the liquidity and dynamic spatiotemporal correlation of traffic data, and significantly improves prediction performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115662128B_ABST
    Figure CN115662128B_ABST
Patent Text Reader

Abstract

The present invention discloses a dynamic spatiotemporal neural network traffic flow prediction method based on an attention mechanism, and the steps are: modeling flow input, flow output and periodic components; constructing a local dynamic prediction module; constructing a global correlation prediction module; and constructing a fusion prediction module. First, by modeling the most recent cycle dependency, daily cycle dependency and weekly cycle dependency of traffic data, a three-dimensional convolutional neural network is used on each component to extract high-dimensional features of urban traffic. Then, an improved residual structure is used to capture the relevance of a long-distance region to a prediction region, and the spatial attention and temporal attention mechanisms are fused to capture the dynamic correlation between traffic flows in different regions and different time periods. Finally, a parameter matrix-based method is used to weightedly fuse the outputs of the three components to obtain a prediction result. Experimental analysis and results show that compared with existing prediction methods, the present invention has better prediction accuracy and robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of traffic prediction, and in particular relates to a dynamic spatiotemporal neural network traffic flow prediction method based on an attention mechanism. Background Art

[0002] The existing urban traffic prediction methods mainly include: statistical methods, machine learning methods and deep learning methods. The main statistical methods include historical average model, average autoregression model, etc. These statistical methods require data to meet certain specific assumptions. In practical applications, these statistical methods usually perform poorly due to the complexity of traffic data. Machine learning methods can model more complex data, but they require careful selection of data features for prediction and cannot consider the spatiotemporal correlation of traffic data. Deep learning methods can use deeper neural networks to capture the spatiotemporal characteristics of traffic data. Traditional deep learning models rely too much on time correlation factors and ignore complex spatial correlation factors. They cannot capture the degree of correlation between distant areas and the prediction area. Although high-level features of data can be extracted through deep neural networks, they lack modeling of periodicity or dynamic correlation of traffic flow. At present, there is no related work to model traffic data by considering both spatiotemporal correlation and historical periodicity. Summary of the invention

[0003] In view of the deficiencies in the prior art, the technical problem to be solved by the present invention is to provide a dynamic spatiotemporal neural network traffic flow prediction method based on an attention mechanism, which improves the accuracy of urban traffic flow prediction through three-dimensional convolution and periodic modeling of traffic data.

[0004] In order to solve the above technical problems, the present invention is implemented by the following technical solutions:

[0005] The present invention provides a dynamic spatiotemporal neural network traffic flow prediction method based on an attention mechanism, comprising the following steps:

[0006] Step 1: Model the flow input, flow output and periodic components. Each component includes a local dynamic prediction module and a global correlation prediction module.

[0007] Step 2: Construct a local dynamic prediction module. The local dynamic prediction module captures the fluidity of spatiotemporal data through a three-dimensional convolutional neural network and models the dynamic correlation of neighboring areas in terms of time and space.

[0008] Step 3: Construct a global correlation prediction module. The global correlation prediction module obtains the spatial correlation and temporal correlation of traffic data through the spatial attention mechanism and the temporal attention mechanism, and integrates the ResPlus unit to further explore the dependency of the distant area on the prediction area.

[0009] Step 4: Construct a fusion prediction module. The fusion prediction module integrates the outputs of the three components using a parameter matrix-based fusion method.

[0010] Preferably, the specific steps of step 1 are as follows:

[0011] Step 1.1: Divide the city into several grids of the same size according to longitude and latitude, each grid represents an area, and convert all the inflow and outflow trajectory traffic maps of the city into a two-channel image matrix;

[0012] Step 1.2: Construct the latest cycle component, daily cycle component and weekly cycle component respectively.

[0013] Furthermore, the specific steps of step 2 are as follows:

[0014] Three-dimensional convolution is used to extract the spatiotemporal features of traffic data and capture the information of the time and space dimensions of traffic data. The traffic network of a city at a certain moment can be regarded as a frame in the video. For three-dimensional convolution, the filter dimension is (3,3,3). The filter is convolved with a cube composed of consecutive frames. A feature map is connected to multiple frames of the previous layer to capture time information.

[0015] Furthermore, the specific steps of step 3 are as follows:

[0016] Step 3.1: Use residual units to obtain the spatial dependencies between regions of different distances;

[0017] Step 3.2: Traffic flows in different areas influence each other in the spatial dimension, and this influence is dynamic; during holidays, tourist areas and residential areas will maintain dynamic connections, and the dynamic correlation between different areas in the spatial dimension can be adaptively captured by using the spatial attention mechanism; in the temporal dimension, there is a correlation between traffic flows on different time slices, and the correlation is different in different situations. The temporal attention mechanism is used to dynamically mine the temporal attributes of traffic data.

[0018] Preferably, the specific steps of step 4 are as follows:

[0019] When fusion output is obtained, the influence weight of each component is different. Some areas have obvious peak traffic flow during the morning rush hour. When fusion output of the three components is obtained, the influence weight of different components is considered. The calculation method of the final prediction result of the fusion prediction module is as follows:

[0020] Y=W h ×Y h +W d ×Y d +W w ×Y w

[0021] Where, × is the Hadamard product, W h , W d and W w is a weight parameter, which reflects the influence of the three components on the prediction target.

[0022] From the above, the dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism of the present invention has the following beneficial effects:

[0023] The present invention takes spatiotemporal data as input, models the most recent cycle dependency, daily cycle dependency, and weekly cycle dependency respectively, uses three-dimensional convolution to extract the spatiotemporal features of traffic data, models the geographic correlation of non-adjacent areas through an improved residual structure, and integrates the spatiotemporal attention mechanism, which can better capture the mobility and dynamic spatiotemporal correlation of traffic data, and dynamically adjust the influence of the three components on the prediction target through a fusion method based on a parameter matrix. Experimental results show that the dynamic spatiotemporal neural network traffic flow prediction model based on the attention mechanism proposed in the present invention has high prediction accuracy and robustness in urban area traffic flow prediction.

[0024] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following is a detailed description in combination with the preferred embodiments and the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings of the embodiment are briefly introduced below.

[0026] Figure 1 It is a solution block diagram of the present invention;

[0027] Figure 2 Residual structure diagram for integrating spatiotemporal attention;

[0028] Figure 3 This is a comparison chart of the prediction effect of each method on the TaxiBJ dataset;

[0029] Figure 4 This is a comparison chart of the prediction effect of each method on the BikeNYC dataset;

[0030] Figure 5 This is a comparison chart of the impact of different learning rates on model performance;

[0031] Figure 6 The following is a comparison chart of the prediction performance of data sets from different years. DETAILED DESCRIPTION

[0032] The following is a detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings, which is a part of this specification and illustrates the principles of the present invention through examples. Other aspects, features and advantages of the present invention will become clear from the detailed description. In the referenced drawings, the same or similar components in different figures are represented by the same reference numerals.

[0033] The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism of the present invention is mainly applied to the current popular traffic prediction and neural network fields, and its overall processing flow is as follows:

[0034] (1) By integrating the temporal attention mechanism and the spatial attention mechanism, an improved residual structure is constructed.

[0035] (2) A dynamic spatiotemporal neural network traffic flow prediction model based on attention mechanism was constructed, and the prediction accuracy of urban traffic flow was improved through local dynamic prediction module, global correlation prediction module and fusion prediction module.

[0036] like Figures 1 to 6 As shown, the dynamic spatiotemporal neural network traffic flow prediction method based on the attention mechanism of the present invention comprises the following steps:

[0037] Step 1: Model the flow input, flow output and periodic components, each of which contains a local dynamic prediction module and a global correlation prediction module.

[0038] Step 1.1: Divide the city into several grids of the same size according to longitude and latitude, each grid represents an area, and convert all the inflow and outflow trajectory traffic maps of the city into a two-channel (In and Out) image matrix;

[0039] Step 1.2: Construct the latest cycle component, daily cycle component and weekly cycle component respectively.

[0040] Step 2: Construct a local dynamic prediction module. The local dynamic prediction module captures the fluidity of spatiotemporal data through a three-dimensional convolutional neural network and models the dynamic correlation of neighboring areas in terms of time and space.

[0041] Three-dimensional convolution is used to extract the spatiotemporal features of traffic data, effectively capturing the information of the temporal and spatial dimensions of traffic data.

[0042] Step 3: Construct a global correlation prediction module. The global correlation prediction module obtains the spatial correlation and temporal correlation of traffic data through the spatial attention mechanism and the temporal attention mechanism, and integrates the ResPlus unit to further explore the dependency of the distant area on the prediction area.

[0043] Step 3.1: Use residual units to obtain the spatial dependencies between regions of different distances;

[0044] Step 3.2: Traffic flows in different areas affect each other in the spatial dimension, and this influence is dynamic. For example, during holidays, tourist areas and residential areas will maintain dynamic connections, so the dynamic correlation between different areas in the spatial dimension is adaptively captured by using the spatial attention mechanism; in the temporal dimension, there is a correlation between traffic flows on different time slices, and the correlation is different in different situations, so the temporal attention mechanism is used to dynamically mine the temporal attributes of traffic data.

[0045] Step 4: Construct a fusion prediction module. The fusion prediction module integrates the outputs of the three components using a parameter matrix-based fusion method.

[0046] The city grid division method in step 1.1 divides the city into m×n grids, and the set of all regions can be expressed as: R = {r 1,1 ,...,r 1,n ,...,r m,1 ,...,r m,n ,|m∈M,n∈N}. In the inflow and outflow division method in step 1.1, let the number of all trajectories in the continuous time interval {t-1, t, t+1} be Q, then for time t, the inflow of area (m, n) is The outflow is

[0047] In the method of constructing three period components in step 1.2, assume that the sequence length of the forecast period is l p , the lengths of the input sequences of the recent, daily and weekly components are l h , l d and l w , the inflow and outflow of traffic in the urban area at a certain moment can be regarded as two channels of the picture, from which the most recent cycle dependency, daily cycle dependency and weekly cycle dependency sequences are extracted respectively, then the most recent cycle dependency sequence is expressed as

[0048]

[0049] The daily cycle dependency sequence is expressed as:

[0050]

[0051] The weekly cycle dependent sequence is expressed as:

[0052]

[0053] In step 2, three-dimensional convolution is used to extract the spatiotemporal features of traffic data. Urban traffic prediction belongs to the problem of spatiotemporal data prediction. Spatiotemporal data contains two dimensions, time and space. There is a strong correlation between adjacent time intervals and traffic flow in urban areas. The traffic network of a city at a certain moment can be regarded as a frame in a video. For three-dimensional convolution, the filter dimension is (3,3,3). The filter is convolved with a cube composed of continuous frames. A feature map is connected to multiple frames of the previous layer to capture time information. Taking the most recent period component as an example, the three-dimensional modeling of spatiotemporal data can be expressed as:

[0054]

[0055] Among them, * represents the three-dimensional convolution operation, is the input of the kth layer of the three-dimensional convolution, and W and b are the learning parameters of the three-dimensional convolution.

[0056] In step 3.1, the method of modeling the spatial correlation between regions at different distances is used. The residual structure ResPlus unit can capture the spatial dependency between regions at different distances. It includes a ConvPlus module and a convolution layer. The ConvPlus module performs a channel separation operation on the traffic flow map. One of the separated channels performs a local ordinary convolution operation, and the other channel performs a global convolution operation. The global convolution kernel size is (3,3). Then, the two channels are merged and the convolution of the next layer is continued. The residual operation can be defined as follows:

[0057]

[0058] Where F is the residual function, is the input vector of the lth layer.

[0059] Furthermore, the spatial attention and temporal attention in step 3.2 are calculated as follows:

[0060] (1) The calculation method of spatial attention is:

[0061]

[0062] (2) The calculation method of temporal attention is:

[0063]

[0064] In the parameter matrix-based fusion method in step 4, the influence weight of each component is different when the fusion output is generated. Some areas have obvious peak traffic flow during the morning rush hour, so the output of the daily cycle component and the weekly cycle component is more critical. The traffic flow in some areas does not have obvious periodicity, so the daily cycle and weekly cycle have little impact. Therefore, when fusing the outputs of the three components, the influence weights of different components need to be considered. The calculation method for the final prediction result of the fusion prediction module is:

[0065] Y=W h ×Y h +W d ×Y d +W w ×Y w (8)

[0066] Where, × is the Hadamard product, W h , W d and W w is a weight parameter, which reflects the influence of the three components on the prediction target.

[0067] The present invention uses TensorFlow to implement a dynamic spatiotemporal traffic flow prediction model based on the spatiotemporal attention mechanism. The hyperparameters are set as follows: the number of iterations num_epoch is 1500, the number of iterations per round batch_size is 32, and the learning rate lr is 2×10 -5 The present invention uses Adam as the optimizer of the model. Specific embodiments

[0069] The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism proposed in this invention has a solution block diagram as shown in the following figure: Figure 1 The following describes the specific implementation process of the present invention and the description of each important stage in conjunction with Table 1.

[0070] Step 1: Preprocess the traffic flow data to generate time series data with spatiotemporal attributes, as shown in Table 1.

[0071] Table 1. Examples of nonlinear traffic data with spatiotemporal attributes

[0072]

[0073] Step 1.1: Divide the city into regions according to longitude and latitude. Each unit represents an area of ​​the city, and the size of each area is exactly the same.

[0074] Step 1.2: Count the inflow and outflow of each area every 30 minutes or 60 minutes, and normalize them. 1,1 ,...,r1,n ,...,r m,1 ,...,r m,n ,|m∈M,n∈N} and the inflow of area (m,n) and outflow To convert the inflow / outflow of the city in each time interval into a two-channel image matrix.

[0075] Step 2: Construct a local dynamic prediction module.

[0076] Step 2.1: For three-dimensional convolution, its filter has three dimensions. Taking the nearest cycle component as an example, its input dimension is (nb_flow, len_closeness, map_height, map_width), where nb_flow is the flow input, len_closeness is the nearest cycle sequence length, map_height is the map length, and map_width is the map width. The number of filters in the first layer of 3D convolution is 64, the convolution kernel size is (6, 3, 3), the step size is (1, 1, 1), and the activation function is ReLU; the number of filters in the second layer of 3D convolution is 64, the convolution kernel size is (3, 3, 3), the step size is (3, 1, 1), and the activation function is ReLU; the number of filters in the third layer of 3D convolution is 64, the convolution kernel size is (3, 3, 3), and the step size is (3, 1, 1). Then construct a layer of two-dimensional convolution with 64 filters. Finally, convert the dimension to (64, map_height, map_width).

[0077] Step 3: Construct a global correlation prediction module to calculate the correlation of traffic flow data in different areas and at different times by constructing a residual unit that integrates the spatiotemporal attention mechanism.

[0078] Step 3.1: Construct a residual unit. First, pass a layer of 2D convolution, with 64 convolution kernels, a convolution kernel size of (3,3), and an activation function of ReLU, then pass a layer of batchNorm layer, and finally input into the next layer for spatiotemporal correlation calculation;

[0079] Step 3.2: Integrate the temporal attention mechanism and the spatial attention mechanism into the residual unit, such as Figure 2As shown in the figure, the input dimension of the previous layer is (nb_flow, len_seq, map_height, map_width). Through three-dimensional convolution, the number of filters is 8, the first dimension of the convolution kernel is len_seq, the second dimension of the convolution kernel is 1, the third dimension of the convolution kernel is 1, border_mode is "valid", the activation function is ReLU, and then the spatial correlation is calculated by formula (6), the temporal correlation is calculated by formula (7), and finally the result is sent to the fusion prediction module for the next step of calculation.

[0080] Step 4: Construct a fusion prediction module. Perform weighted calculations on the prediction results of the most recent cycle, daily cycle, and weekly cycle, and calculate the relevance of different cycle modules to the traffic flow in the prediction area by updating parameters. The calculation method is Y = W h ×Y h +W d ×Y d +W w ×Y w Finally, the predicted value and the true value are calculated to obtain RMSE and MAE, thereby obtaining the prediction effect. Among them, nb_epoch (number of training rounds) is 1500 rounds, batch_size (batch size) is 32, and lr (learning rate) is 2×10 -5 , lp (prediction sequence length) is 4, lh (most recent cycle dependence sequence length) is 6, ld (daily cycle dependence sequence length) is 4, and lw (weekly cycle dependence sequence length) is 6.

[0081] In order to further test the effect and performance of the method of the present invention, the TaxiBJ dataset and the BikeNYC dataset were selected in this example to illustrate the prediction accuracy of the present invention. TaxiBJ is a Beijing taxi dataset, which collects the trajectory set generated by all taxis in Beijing in a continuous time period from July 1, 2013 to April 10, 2016 through GPS information. The dataset uses (32,32) to represent the size of the Beijing traffic map after gridding. The number of channels for flow input is 2, In (inflow) and Out (outflow), the statistical time interval is 30 minutes, the number of vehicles counted is about 34,000, and the total number of statistical time intervals is 22,459; the last 10 days are taken as the test set, and the rest are the training set. BikeNYC is a New York City shared bicycle dataset, which collects the trajectory set generated by all shared bicycles in New York City from April 1 to September 30, 2014, including the travel time period, start and end station ID and start and end time. This dataset uses (16,8) to represent the gridded size of the New York City traffic map. The number of channels for flow input is 2, namely In (inflow) and Out (outflow). The statistical time interval is 60 minutes, the number of vehicles counted is approximately 6,800, and the total number of statistical time intervals is 4,392. The last 10 days are taken as the test set, and the rest are the training set.

[0082] The following are the test results of the traffic prediction effect on the above-mentioned TaxiBJ and BikeNYC datasets using the method of the present invention. The default values ​​of the parameters in the method of the present invention are given in Table 2. All experiments were implemented using the TensorFlow framework, and the computer configuration was CPU 2.30GHz i5-6300HQ, RAM 8.00GB, and Windows 10 operating system. The prediction effect of the method of the present invention (AST-3DGN) was compared with the existing methods HA, LSTM, ST-ResNet, and ST-3DGN.

[0083] HA: Historical mean method, a method of forecasting using the average value.

[0084] LSTM: Long Short-Term Memory Network, which solves the problem of short-term memory by controlling the input gate, output gate and forget gate, so that the recurrent neural network can effectively use training data in a larger range to improve performance. However, it does not consider the mobility of the traffic network and cannot effectively extract the high-level features of spatiotemporal data.

[0085] ST-ResNet: A spatiotemporal neural network model that integrates residual structures. It can capture the spatiotemporal characteristics of traffic data and improve the problem of gradient vanishing or gradient exploding in deep neural networks. It takes into account long-term dependencies and short-term dependencies through residual structures and deep convolutional neural networks. It can capture the temporal and spatial characteristics of traffic data, but lacks modeling of dependencies between long-distance regions.

[0086] ST-3DGN: A dynamic spatiotemporal neural network model that models urban traffic maps by using three-dimensional convolution instead of two-dimensional convolution, and uses an early fusion mechanism to stabilize the model prediction performance, but does not model the daily cycle dependency. The daily traffic flow in the city has temporal similarities. ST-3DGN models the correlation between long-distance regions, but does not consider that the temporal correlation between regions is dynamically changing, and does not model the daily cycle dependency.

[0087] Table 2. Default values ​​of various parameters of the present invention

[0088]

[0089] The experimental performance test is mainly carried out from the following aspects:

[0090] (1) Performance comparison of different methods on two data sets: The present invention uses root mean square error (RMSE) and mean absolute error (MAE) as evaluation indicators to verify the effect of the prediction model. The calculation methods of the two evaluation indicators are as follows:

[0091]

[0092]

[0093] Among them, Y i is the predicted value, y i is the true value. The performance comparison of different methods on TaxiBJ and BikeNYC datasets is shown in Table 3.

[0094] Table 3 Performance comparison of different methods on TaxiBJ and BikeNYC datasets

[0095]

[0096] By comparison, it is found that the prediction results of the traditional time series analysis method (HA) are relatively unsatisfactory, which shows that this type of method has limited modeling capabilities for complex and nonlinear traffic data. The prediction performance of the traditional deep learning method (LSTM) is better than that of the time series analysis method. This is because the recurrent neural network is more conducive to processing time series problems. The LSTM model improves the recurrent neural network by controlling the input gate, output gate and forget gate to solve the problem of short-term memory, so that the recurrent neural network can effectively use training data in a larger range to improve performance. The prediction effect of the spatiotemporal neural network (ST-ResNet, ST-3DGN) based on deep learning is stronger than that of the LSTM model. This is because although the traditional deep learning method can model nonlinear traffic data, it does not consider the mobility of the traffic network and cannot effectively extract the high-level features of spatiotemporal data. ST-ResNet considers long-term dependence and short-term dependence through residual structure and deep convolutional neural network, which can capture the temporal and spatial characteristics of traffic data, but lacks modeling of long-distance regional dependencies. ST-3DGN uses three-dimensional convolution instead of two-dimensional convolution to model the urban traffic map, and uses an early fusion mechanism to stabilize the model prediction performance, but does not model the daily cycle dependency. The daily traffic flow in the city has temporal similarity. ST-3DGN models the correlation of long-distance regions, but does not consider that the temporal correlation between regions is dynamically changing, and does not model the daily cycle dependency. Experimental results show that the addition of the temporal attention mechanism significantly improves the prediction performance of the model. AST-3DGN uses a three-dimensional convolutional neural network to extract the spatial and temporal characteristics of traffic data; it captures the periodic dependency of traffic data by modeling the nearest cycle, daily cycle, and weekly cycle dependency; it improves the ResPlus module, considers the impact of geographic location on traffic flow, and integrates spatial attention and temporal attention mechanisms to dynamically capture the spatial and temporal correlations of traffic flow data; it uses a fusion method based on a parameter matrix to consider the degree of influence of different periodic dependencies on the prediction results. Experimental results show that the prediction performance of the AST-3DGN model is better than that of previous advanced models without adding spatial attention and temporal attention mechanisms, which shows the superiority of the model in describing the spatiotemporal characteristics of traffic data. AST-3DGN combined with the spatiotemporal attention mechanism outperforms the comparison methods in prediction performance on both datasets, with improvements of 12.8% and 20.9% respectively compared to the ST-ResNet method, and 2.66% and 3.97% respectively compared to the ST-3DGN method.

[0097] (2) The influence of hyperparameter settings on prediction performance: The setting of hyperparameters often depends on the experience of researchers and has a great influence on model performance. In order to make the prediction performance of the method of the present invention more ideal and the training process more stable, different learning rates were set to experiment with the model. The experiment used one-tenth of the training set as the validation set, and used the early stopping method to control the number of training rounds. The parameter "patients" was set to 50, that is, if the performance of the validation set did not improve within 50 rounds of training, then the training was terminated. MSE was used as the loss function of the validation set. The MSE calculation method is as follows, where Y i is the predicted value, y i is the true value.

[0098]

[0099] When the learning rate is set to 2×10 -3 , 2×10 -4 and 2×10 -6 When the learning rate is set to 1×10, the number of model training rounds is small. This is because the performance of the model on the validation set is not improved within 50 rounds due to the excessively large or small learning rate, which causes the training to stop prematurely. -5 , 2×10 -5 and 3×10 -5 When , the training is relatively stable, and the learning rate is 2×10 -5 The performance of the validation set is the best, so we use 2×10 -5 As the learning rate hyperparameter of the model.

[0100] (3) Robustness test of different models on sub-datasets: The experiment tested the robustness of the AST-3DGN model. The TaxiBJ dataset was divided into three sub-datasets according to time, namely 2013 / 7 / 1~2013 / 10 / 30, 2014 / 3 / 1~2014 / 6 / 30 and 2015 / 3 / 1~2015 / 6 / 30. The comparison results are shown in Table 4. The experimental results show that the AST-3DGN model performs better than ST-ResNet on each sub-dataset, which shows that the method of the present invention has high robustness.

[0101] Table 4 Prediction performance (RMSE) of different models on three sub-datasets

[0102]

[0103] Some relevant definitions of the present invention are as follows:

[0104] The city is divided into m×n grids, where m∈M, n∈N, M represents the number of rows in the grid, and N represents the number of columns in the grid. The triple (x, y, τ) is used to represent the movement data of individuals in the recording area. For individual u, (x, y) represents its position at time τ, and the movement trajectory of u can be expressed as T u ={p1,p1,...,p k ,...,p l}, where p k ∈R M×N Represents the trajectory T u The kth trajectory point in , l represents the trajectory T u The length of the area it passes through during the time interval t is expressed as For the region (m,n), represents a regional traffic record, where t∈{τ i} is a fixed time interval, and c is the number of channels. h , l d , l w are the sequence lengths of the most recent cycle dependency, daily cycle dependency, and weekly cycle dependency, respectively. q is a fixed period of time, and c represents the inflow or outflow channel. Given the historical measurement data of all areas on the traffic network, predict the traffic flow sequence of all areas in the city at the next time interval in represents the traffic flow starting from τ+1.

[0105] The above is only a preferred embodiment of the present invention, which certainly cannot be used to limit the scope of rights of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and changes can be made without departing from the principle of the present invention, and these improvements and changes are also regarded as the protection scope of the present invention.

Claims

1. A dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism, characterized in that: The following steps are involved: Step 1: Model the flow input, flow output and periodic components. Each component includes a local dynamic prediction module and a global correlation prediction module. Step 2: Construct a local dynamic prediction module. The local dynamic prediction module captures the fluidity of spatiotemporal data through a three-dimensional convolutional neural network and models the dynamic correlation of neighboring areas in terms of time and space. Step 3: Construct a global correlation prediction module. The global correlation prediction module obtains the spatial correlation and temporal correlation of traffic data through the spatial attention mechanism and the temporal attention mechanism, and integrates the ResPlus unit to further explore the dependency of the distant area on the prediction area. Step 4: Construct a fusion prediction module. The fusion prediction module integrates the outputs of the three components using a parameter matrix-based fusion method.

2. The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism as claimed in claim 1 is characterized in that: The specific steps of step 1 are as follows: Step 1.1: Divide the city into several grids of the same size according to longitude and latitude, each grid represents an area, and convert all the inflow and outflow trajectory traffic maps of the city into a two-channel image matrix; Step 1.2: Construct the latest cycle component, daily cycle component and weekly cycle component respectively.

3. The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism as claimed in claim 1, characterized in that: The specific steps of step 2 are as follows: Three-dimensional convolution is used to extract the spatiotemporal features of traffic data and capture the information of the time and space dimensions of traffic data. The traffic network of a city at a certain moment can be regarded as a frame in the video. For three-dimensional convolution, the filter dimension is (3,3,3). The filter is convolved with a cube composed of consecutive frames. A feature map is connected to multiple frames of the previous layer to capture time information.

4. The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism as claimed in claim 1, characterized in that: The specific steps of step 3 are as follows: Step 3.1: Use residual units to obtain the spatial dependencies between regions of different distances; Step 3.2: Traffic flows in different areas influence each other in the spatial dimension, and this influence is dynamic; during holidays, tourist areas and residential areas will maintain dynamic connections, and the dynamic correlation between different areas in the spatial dimension can be adaptively captured by using the spatial attention mechanism; in the temporal dimension, there is a correlation between traffic flows on different time slices, and the correlation is different in different situations. The temporal attention mechanism is used to dynamically mine the temporal attributes of traffic data.

5. The dynamic spatiotemporal neural network traffic flow prediction method based on attention mechanism as claimed in claim 1, characterized in that: The specific steps of step 4 are as follows: When fusion output is obtained, the influence weight of each component is different. Some areas have obvious peak traffic flow during the morning rush hour. When fusion output of the three components is obtained, the influence weight of different components is considered. The calculation method of the final prediction result of the fusion prediction module is as follows: Y=W h ×Y h +W d ×Y d +W w ×Y w Where, × is the Hadamard product, W h , W d and W w is a weight parameter, which reflects the influence of the three components on the prediction target.