Road network traffic flow prediction method of deep space-time neural network based on weight sharing
Patent Information
- Application Number
- CN202411316822.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-20
Smart Images

Figure CN119314323A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of road network traffic flow prediction, and in particular to a road network traffic flow prediction method based on a deep spatiotemporal neural network with weight sharing. Background Art
[0002] As an important branch of intelligent transportation systems, traffic flow prediction can provide theoretical support for application scenarios such as traffic congestion prediction and path planning. The main task of traffic flow prediction is to predict the number of vehicles in a certain area or along a specified road in the future given historical traffic flow data. At present, many achievements have been made in the research on traffic flow prediction, which can be basically divided into image-based traffic flow prediction and graph-based traffic flow prediction. Among them, the image-based traffic flow prediction method does not require additional graph structure storage space, the model training speed is faster, the algorithm is more efficient, and the image data can be visualized, which can intuitively show the traffic conditions. However, the image-based traffic flow prediction model also has some shortcomings. For example, in the process of converting the road network into a two-dimensional image, the spatiotemporal characteristics of each layer of the image cannot be obtained, and the spatiotemporal correlation of the road network cannot be better captured; secondly, the impact of complex emergencies on the model has not been fully considered, and there may be limitations in dealing with more complex application scenarios. Summary of the invention
[0003] The present invention provides a road network traffic flow prediction method based on a weight-sharing deep spatiotemporal neural network to overcome the technical problems that existing traffic flow prediction methods cannot better capture the spatiotemporal correlation of road networks; and do not fully consider the impact of complex emergencies, resulting in limitations of the prediction model when dealing with more complex application scenarios.
[0004] In order to achieve the above object, the technical solution of the present invention is:
[0005] A road network traffic flow prediction method based on a weight-sharing deep spatiotemporal neural network, the specific steps include:
[0006] S1: Obtain a road structure diagram, and divide the road structure diagram into grids according to the quadtree technology and the filling rate to obtain a traffic grid;
[0007] S2: Obtaining traffic flow observation values, mapping the road section to the traffic grid according to the position of the center point of the road section in the road structure diagram and the traffic flow observation values, and obtaining a traffic grid having the road section information and the traffic flow observation values;
[0008] S3: splitting the traffic grid with the road section information and the traffic flow observation value according to the set time step and the length of the input sequence of the current time module, the previous day module and the previous week module to obtain the current time traffic grid, the previous day traffic grid and the previous week traffic grid;
[0009] S4: Acquire information that affects traffic flow, where the information that affects traffic flow includes time data and weather data;
[0010] S5: establishing an initial traffic flow prediction model, wherein the initial traffic flow prediction model includes a spatiotemporal feature extraction module, an external module, a fusion module, and a weight sharing module;
[0011] Wherein, the spatiotemporal feature extraction module includes a current time module, a previous day module and a previous week module;
[0012] The current moment module is used to extract the temporal and spatial characteristics of the traffic grid at the current moment; the previous day module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day; the previous week module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day;
[0013] The external module is used to extract features of time data and weather data;
[0014] The fusion module is used to fuse the features extracted by the spatiotemporal feature extraction module and the external module;
[0015] The weight sharing module is used to store the optimal weight parameters of the spatiotemporal feature extraction module and the fusion module;
[0016] S6: Based on the information affecting traffic flow, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid, the initial traffic flow prediction model is trained to obtain a trained traffic flow prediction model, and traffic flow prediction is performed based on the trained traffic flow prediction model.
[0017] Further, the current moment module includes a ConvLSTM unit, a first convolutional layer, a first DenseNet unit, a second convolutional layer and a third convolutional layer connected in sequence; the ConvLSTM unit is used to extract the spatial features of the traffic grid at the current moment, obtain a first feature map, and transmit the first feature map to the first convolutional layer; the first convolutional layer is used to extract the horizontal edge features of the first feature map, obtain a second feature map, and transmit it to the first DenseNet unit; the first DenseNet unit is used to extract the time features of the second feature map, obtain a third feature map, and transmit it to the second convolutional layer; the second convolutional layer is used to extract the vertical edge features of the third feature map, obtain a fourth feature map, and transmit it to the third convolutional layer; the third convolutional layer is used to extract the texture features of the fourth feature map to obtain the feature vector at the current moment;
[0018] The previous day module includes a fourth convolutional layer, a second DenseNet unit, a fifth convolutional layer and a sixth convolutional layer connected in sequence; the fourth convolutional layer is used to extract the horizontal edge features of the traffic grid of the previous day, obtain the fifth feature map, and transmit it to the second DenseNet unit; the second DenseNet unit is used to extract the time features of the fifth feature map, obtain the sixth feature map, and transmit it to the fifth convolutional layer; the fifth convolutional layer is used to extract the vertical edge features of the sixth feature map, obtain the seventh feature map, and transmit it to the sixth convolutional layer; the sixth convolutional layer is used to extract the texture features of the seventh feature map to obtain the feature vector of the previous day;
[0019] The previous week module includes a seventh convolutional layer, a third DenseNet unit, an eighth convolutional layer and a ninth convolutional layer connected in sequence. The seventh convolutional layer is used to extract the horizontal edge features of the traffic grid of the previous week to obtain the eighth feature map, and transmit it to the third DenseNet unit; the third DenseNet unit is used to extract the time features of the eighth feature map, obtain the ninth feature map, and transmit it to the eighth convolutional layer; the eighth convolutional layer is used to extract the vertical edge features of the ninth feature map, obtain the tenth feature map, and transmit it to the ninth convolutional layer; the ninth convolutional layer is used to extract the texture features of the tenth feature map to obtain the feature vector of the previous week.
[0020] Further, the external module includes a one-hot encoding unit, a fully connected layer unit, a reshaping unit and a first self-attention unit;
[0021] The one-hot encoding unit is used to encode the time data and the weather data to obtain the encoded time data and the weather data;
[0022] The fully connected layer unit is used to extract information from the encoded time data and weather data to obtain feature vectors of the weather data and time data;
[0023] The reshaping unit is used to adjust the size of the feature vectors of the weather data and the time data to obtain a reshaped weather feature vector and a time feature vector, and the reshaped weather feature vector and the time feature vector have the same size as the feature vector of the current moment, the feature vector of the previous day, and the feature vector of the previous week;
[0024] The first self-attention unit is used to perform weighted summation on the weather feature vector and the time feature vector to obtain third output data.
[0025] Further, the fusion module includes a first fusion unit and a second fusion unit;
[0026] The first fusion unit includes a second self-attention unit and a tenth convolutional layer;
[0027] The second self-attention unit is used to perform weighted summation on the feature vector at the current moment, the feature vector of the previous day, and the feature vector of the previous week to obtain first output data, and transmit it to the tenth convolutional layer;
[0028] The tenth convolutional layer is used to perform feature extraction on the first output data to obtain second output data;
[0029] The second fusion unit is used to add the second output data and the third output data to obtain the fourth output data, obtain the traffic flow prediction result, and process the fourth output data through the tanh function layer to obtain the error between the real value and the predicted value of the traffic flow.
[0030] Furthermore, when the initial traffic flow prediction model is trained based on the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid are input into the initial traffic flow prediction model in a layer-by-layer detailed manner, namely:
[0031] The actual resolution of the traffic grid with road section information and traffic flow observation values is divided according to the set number of training rounds, so as to obtain the sizes of the current traffic grid, the previous day's traffic grid and the previous week's traffic grid input in each round, and input them into the initial traffic flow prediction model in turn.
[0032] Furthermore, during the training process of the initial traffic flow prediction model, the weight sharing module is used to store the optimal weight parameters obtained by each unit and the convolution layer in the current moment module, the previous day module and the previous week module in each round of training, and the optimal weight parameters obtained by the second self-attention unit and the tenth convolution layer in the fusion module in each round of training, and dimensionally fill the parameters of the ConvLSTM unit in the current moment module and the optimal weight parameters in the fusion module according to the set filling rules, and then use them as the initial weight parameters for the next round of training, repeat the training filling operation until the training is completed, and obtain the final spatiotemporal feature extraction module weight parameters and fusion module weight parameters;
[0033] The set filling rules include: using a zero filling strategy to fill the dimensions of the parameters of the ConvLSTM unit in the spatiotemporal feature extraction module;
[0034] A fixed 1 padding strategy is used to fill the dimensions of the optimal weight parameters in the fusion module.
[0035] Beneficial effects: The present invention splits the traffic grid with road section information and traffic flow observation values, and inputs them into the initial traffic flow prediction model respectively, so as to better capture the spatiotemporal correlation of the road network. At the same time, a weight sharing module is proposed to simplify the calculation process, accelerate the training process of the initial traffic flow prediction model, and help improve the generalization ability of the model. The traffic flow prediction method proposed in the present invention, by combining the spatiotemporal feature extraction ability of deep learning with the flexibility of the self-attention mechanism, not only achieves a significant improvement in accuracy, but also shows stronger adaptability when dealing with complex traffic scenes, and can effectively deal with the uncertainty of traffic flow. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0037] Figure 1 It is a flow chart of the road network traffic flow prediction method based on the weight-sharing deep spatiotemporal neural network in the present invention;
[0038] Figure 2 This is an example diagram of a road structure in an embodiment of the present invention;
[0039] Figure 3 A traffic grid diagram with road section information and traffic flow observation values in an embodiment of the present invention;
[0040] Figure 4 This is an example diagram of multiple rounds of input of the WSDSNN model in an embodiment of the present invention;
[0041] Figure 5 : is a structural diagram of a ConvLSTM unit in an embodiment of the present invention;
[0042] Figure 6 : is a structural diagram of the i-th unit in the ConvLSTM unit in an embodiment of the present invention;
[0043] Figure 7 Schematic diagram of the processing of the WSDSNN model in an embodiment of the present invention;
[0044] Figure 8 1 is a graph showing experimental comparison results of several models in an embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0046] This embodiment provides a road network traffic flow prediction method based on a weight-sharing deep spatiotemporal neural network. Figure 1 As shown, the specific steps include:
[0047] S1: Obtain a road structure diagram, and divide the road structure diagram into grids according to the quadtree technology and the filling rate to obtain a traffic grid;
[0048] S2: Obtain traffic flow observation values, map the road section to the traffic grid according to the position of the center point of the road section in the road structure diagram and the traffic flow observation values, and obtain a traffic grid with road section information and traffic flow observation values, such as Figure 3 As shown;
[0049] Specifically, the road structure diagram is initially divided according to the quadtree technology, and then the initially divided grid is further divided based on the set filling rate threshold to obtain a traffic grid that meets the filling rate requirements; wherein the road structure diagram is as follows Figure 2When the road structure diagram is initially divided according to the quadtree technology, if the input round is 4, the road structure diagram is iteratively divided 4 times according to the quadtree technology to obtain road structure diagrams of different grid sizes; there are different filling rate requirements for specific data sets. In this embodiment, the traffic flow observation value uses the Wuhan taxi trajectory data from April 8 to May 5, 2015, and the filling rate is set to 85%.
[0050] Specifically, in this embodiment, the center point of the road segment is used to represent the road segment, so that the road segment information is mapped to the traffic grid TGrid. The road segment information includes the road traffic flow observation values {RX1, RX2, ..., RX t-1}, the traffic grid with road section information is represented as {TGrid1, TGrid2,…, TGrid t-1}.
[0051] S3: splitting the traffic grid with the road section information and the traffic flow observation value according to the time steps of the current time module, the previous day module and the previous week module to obtain the current time traffic grid, the previous day traffic grid and the previous week traffic grid;
[0052] Specifically, after splitting the traffic grid with road section information, the current traffic grid TGrid is obtained. r The sequence is {TGrid t-kr ,…,TGrid t-2 ,TGrid t-1}, TGrid r The length of is kr;
[0053] Previous day traffic grid TGrid d The sequence is
[0054] {TGrid (t-ld)±kd ,…,TGrid (t-ld)±1 ,TGrid (t-ld)}, TGrid d The length of is 2kd+1, ld is the total number of time periods in a day;
[0055] Traffic Grid TGrid of the previous week w The sequence is
[0056] {TGrid (t-lw)±kw ,…,TGrid (t-lw)±1 ,TGrid (t-lw)}, TGrid w The length of lw is 2kw+1, where lw is the total number of time periods in a week.
[0057] Specifically, in this embodiment, when the initial traffic flow prediction model is trained based on the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid, in order to express the local-overall relationship of traffic flow, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid are input into the initial traffic flow prediction model in a layer-by-layer detailed manner, that is:
[0058] The actual resolution of the traffic grid with road section information and traffic flow observation values is divided according to the set number of training rounds, so as to obtain the sizes of the current traffic grid, the previous day's traffic grid and the previous week's traffic grid input in each round, and input them into the initial traffic flow prediction model in turn.
[0059] Specifically, assuming that the actual resolution of TGrid is 192×192, and the input rounds are set to 4, TGrid is detailed layer by layer into 24×24, 48×48, 96×96, and 192×192 according to the input rounds, and then the 24×24, 48×48, 96×96, and 192×192 TGrids are split to obtain the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid of the corresponding resolutions. Therefore, the resolutions of the traffic grids input in each round are 24×24, 48×48, 96×96, and 192×192, respectively. Figure 4 shown.
[0060] S4: Obtain information that affects traffic flow, train the initial traffic flow prediction model based on the information that affects traffic flow, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid to obtain a trained traffic flow prediction model, and perform traffic flow prediction based on the trained traffic flow prediction model.
[0061] S5: Establish Figure 7 The initial traffic flow prediction model WSDSNN (Weight Sharing Deep Spatiotemporal Neural Networks) shown in the figure includes a spatiotemporal feature extraction module, an external module, a fusion module and a weight sharing module; wherein the spatiotemporal feature extraction module includes a current moment module, a previous day module and a previous week module;
[0062] The current moment module is used to extract the temporal and spatial characteristics of the traffic grid at the current moment; the previous day module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day; the previous week module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day;
[0063] The external module is used to extract features of time data and weather data;
[0064] The fusion module is used to fuse the features extracted by the spatiotemporal feature extraction module and the external module;
[0065] The weight sharing module is used to store the optimal weight parameters of the spatiotemporal feature extraction module and the fusion module;
[0066] In a specific embodiment, the current moment module includes a ConvLSTM unit, a first convolutional layer, a first DenseNet unit, a second convolutional layer and a third convolutional layer connected in sequence, the ConvLSTM unit is used to extract the spatial features of the traffic grid at the current moment, obtain a first feature map, and transmit the first feature map to the first convolutional layer; the first convolutional layer is used to extract the horizontal edge features of the first feature map, obtain a second feature map, and transmit it to the first DenseNet unit; the first DenseNet unit is used to extract the time features of the second feature map, obtain a third feature map, and transmit it to the second convolutional layer; the second convolutional layer is used to extract the vertical edge features of the third feature map, obtain a fourth feature map, and transmit it to the third convolutional layer; the third convolutional layer is used to extract the texture features of the fourth feature map, obtain the current moment feature vector, and the current moment feature vector contains all the above-extracted features;
[0067] Specifically, the first convolution unit and the second convolution unit are both 3×3 convolution layers; where the current traffic grid TGrid r The sequence is {TGrid t-kr ,…,TGrid t-2 ,TGrid t-1}, TGrid r The length of is kr;
[0068] The previous day module includes a fourth convolutional layer, a second DenseNet unit, a fifth convolutional layer and a sixth convolutional layer connected in sequence, wherein the fourth convolutional layer is used to extract the horizontal edge features of the traffic grid of the previous day, obtain the fifth feature map, and transmit it to the second DenseNet unit; the second DenseNet unit is used to extract the time features of the fifth feature map, obtain the sixth feature map, and transmit it to the fifth convolutional layer; the fifth convolutional layer is used to extract the vertical edge features of the sixth feature map, obtain the seventh feature map, and transmit it to the sixth convolutional layer; the sixth convolutional layer is used to extract the texture features of the seventh feature map, obtain the feature vector of the previous day, and the feature vector of the previous day contains all the features extracted above; specifically, the third convolutional unit and the fourth convolutional unit are both 3×3 convolutional layers;
[0069] Among them, the previous day's traffic grid TGrid d The sequence is
[0070] {TGrid (t-ld)±kd,…,TGrid (t-ld)±1 ,TGrid (t-ld)}, TGrid d The length of is 2kd+1, ld is the total number of time periods in a day;
[0071] The previous week module includes a seventh convolutional layer, a third DenseNet unit, an eighth convolutional layer and a ninth convolutional layer connected in sequence, wherein the seventh convolutional layer is used to extract the horizontal edge features of the previous week traffic grid to obtain the eighth feature map, and transmit it to the third DenseNet unit; the third DenseNet unit is used to extract the time features of the eighth feature map to obtain the ninth feature map, and transmit it to the eighth convolutional layer; the eighth convolutional layer is used to extract the vertical edge features of the ninth feature map to obtain the tenth feature map, and transmit it to the ninth convolutional layer; the ninth convolutional layer is used to extract the texture features of the tenth feature map to obtain the previous week feature vector, and the previous week feature vector contains all the above extracted features; specifically, the fifth convolutional unit and the sixth convolutional unit are both 3×3 convolutional layers;
[0072] Among them, the traffic grid TGrid of the previous week w The sequence is
[0073] {TGrid (t-lw)±kw ,…,TGrid (t-lw)±1 ,TGrid (t-lw)}, TGrid w The length of lw is 2kw+1, where lw is the total number of time periods in a week.
[0074] Specifically, in this embodiment, the current time module extracts the spatiotemporal characteristics of the current traffic grid, and uses the latest data to predict the change of traffic flow, reflecting the time consistency. The previous day module and the previous week module extract the spatiotemporal characteristics of traffic flow data according to the time change trend and periodicity.
[0075] Specifically, the ConvLSTM unit is an architecture that combines a convolutional neural network (CNN) and a long short-term memory network (LSTM). First, the input and recursive transformation of ConvLSTM both use convolution operations, which retains the spatial local characteristics of the input data and helps to better capture the spatial information in time series data; secondly, ConvLSTM has the ability to model time series, which is conducive to extracting the temporal characteristics of the input data and can handle complex dynamic spatiotemporal changes in the input data; finally, the weight parameters in ConvLSTM are shared in the spatial dimension, which greatly reduces the number of model parameters and improves computational efficiency. The structure of ConvLSTM is as follows: Figure 5 As shown, in this embodiment, there are kr ConvLSTMs in total. Specifically, the calculation of each ConvLSTM includes:
[0076] Input and Output of ConvLSTM
[0077] The input of ConvLSTM includes: given time t, TGrid t-kr+i ∈R m×n ,h t-kr+(i-1) and C t-kr+(i-1) ∈R m×n , kr is the length of the input sequence of ConvLSTM, m×n represents the resolution of the input image; where h t-kr+(i-1) represents the output of the hidden unit in the i-1th ConvLSTM, and its value is initialized to 0; C t-kr+(i-1) represents the output of the cell state in the i-1th ConvLSTM, and its value is randomly initialized; the output of ConvLSTM is h t-1 ∈R m×n .
[0078] The calculation process of ConvLSTM:
[0079] The structure of the i-th unit in ConvLSTM is as follows Figure 6 As shown, the calculation formula is:
[0080] f t-kr+i =σ([h t-kr+(i-1) ,TGrid t-kr+i ,C t-kr+(i-1) ]*W f +b f ) (1)
[0081] i t-kr+i =σ([h t-kr+(i-1) ,TGrid t-kr+i ,C t-kr+(i-1) ]*W i +b i ) (2)
[0082] O t-kr+i =σ([h t-kr+(i-1) ,TGrid t-kr+i ,C t-kr+(i-1) ]*W o +b o ) (3)
[0083]
[0084] h t-kr+i =O t-kr+i ⊙tanh(C t-kr+i ) (6)
[0085] Among them, W f, W i , W o , W c is the weight parameter to be learned, and W f , W i , W o ∈R (3n)×n , W c ∈R (2n)×n ; b f , b i , b c , b o is the bias value, and b f , b i , b c , b o ∈R m×n ;f t-kr 、i t-kr , C t-kr , O t-kr Respectively represent the output of the forget gate, input gate, unit state, and output gate, and f t-kr 、i t-kr , C t-kr , O t-kr ∈R m×n .
[0086] According to formulas (1) to (6) and the input sequence of the module at the current moment {TGrid t-kr ,…,TGrid t-2 ,TGrid t-1}It can be seen that the final output of ConvLSTM is h t-1 , and h t-1 ∈R m×n Then h t-1 Input to the batch normalization BN layer, the BN layer can accelerate deep network training by reducing internal covariate shift. The calculation formula is as follows:
[0087] S r1 =BN (γ,β) (h t-1 ) (7)
[0088] Among them, γ and β are learnable parameters, S r1 is the output of the ConvLSTM unit, and S r1 ∈R m×n .
[0089] S r1 After a 3×3 convolutional layer, we get The formula is shown in (8):
[0090]
[0091] Among them, W conv is the weight parameter to be learned, b conv is the bias that needs to be learned, which can also be identified as a weight parameter in this design.
[0092] Specifically, DenseNet is a specific type of CNN that makes the most of all features obtained during model training by densely connecting all previous layers with the following layers, thereby reducing the number of parameters and alleviating the gradient vanishing problem, and is able to extract spatial features from sparse road traffic flow images. Dense blocks are the basic structure of DenseNet. Each dense block consists of one or several convolutional layers that interact in a special way. Each convolutional layer is a BRConv unit, which is composed of a BN layer, a nonlinear unit layer (in which the activation function ReLU is used), and a convolutional layer (Conv). Two dense blocks are spliced together through a transition layer. The transition layer usually uses 1x1 convolution to reduce the number of channels, and performs pooling operations to reduce the size of the feature map, further reducing the computational complexity of the model.
[0093] DenseNet input and output
[0094] The input of DenseNet is The output of DenseNet is
[0095] The calculation process of DenseNet
[0096] Then, As the input of each dense block, the calculation formula of each dense block is:
[0097]
[0098] Where p is the number of BRConv in the dense block, Con[·] represents the connection of elements, And l0=1, if but By analogy, we can get Y p is the output of a dense block, H p (·) is the BRConv operation, including BN layer, Relu layer and Conv layer.
[0099] Since DenseNet consists of a series of interconnected dense blocks, the output is derived from a DenseNet with k dense blocks using formula (10) The formula is:
[0100]
[0101] Among them, g is the growth rate of the network, μ(·) is the DenseNet operation,
[0102] Then, the output of the first DenseNet unit is sequentially input into the first convolution unit and the second convolution unit. The calculation of the first convolution unit and the second convolution unit is shown in formula (11):
[0103]
[0104] Among them, W conv1 and W conv2 is the weight parameter to be learned, b conv1 and b conv2 is the bias to be learned, which can also be identified as a weight parameter in this design. Relu(·) is a nonlinear transformation function, S r4 is the final output of the module at the current moment, and S r4 ∈R 1×m×n .
[0105] The structures of the previous week module and the previous day module are similar to those of the current moment module, but ConvLSTM is not used. Therefore, the input of the previous day module, i.e. Then use formulas (8) to (10) to derive the output from a DenseNet with k dense blocks That is S d1 Then, use formula (11) to calculate S d2 and S d3 The output, S d3 is the final output of the module on the previous day and S d3 ∈R 1×m×n Similarly, the final output of the previous week's module can be derived as S w3 , and S w3 ∈R 1×m×n .
[0106] Based on the above design process, it can be seen that the optimal weight parameters of each unit and convolution layer in the current moment module, the previous day module and the previous week module obtained in each round of training are stored in the weight sharing module for subsequent use.
[0107] In a specific embodiment, the information affecting traffic flow includes time data and weather data, and the external module includes a one-hot encoding unit, a fully connected layer unit, a reshaping unit, and a first self-attention unit;
[0108] The one-hot encoding unit is used to encode the time data and the weather data to obtain the encoded time data and the weather data;
[0109] The fully connected layer unit is used to extract information from the encoded time data and weather data to obtain feature vectors of the weather data and time data;
[0110] The reshaping unit is used to adjust the size of the feature vectors of the weather data and the time data to obtain a reshaped weather feature vector and a time feature vector, and the reshaped weather feature vector and the time feature vector have the same size as the feature vector of the current moment, the feature vector of the previous day, and the feature vector of the previous week;
[0111] The first self-attention unit is used to perform weighted summation on the weather feature vector and the time feature vector to obtain third output data.
[0112] Specifically, the external module integrates external information into the WSDSNN model, such as weekdays, holidays, weather and road conditions, and uses the self-attention mechanism to assign different weights to the external information obtained, selectively focusing on more important information, and further improving the performance and generalization ability of the WSDSNN model. In this embodiment, the time data and weather data are input into the external module, and the processing process is as follows: first, the date and weather data are encoded using one-hot encoding. For time data, one-hot encoding is used, and the encoding length is 8 bits, where the first seven bits represent the day of the week, and the last bit represents the information of the weekday or weekend. For example, {1, 0, 0, 0, 0, 0, 0, 1} represents Monday on weekdays,
[0113] {0, 0, 0, 0, 1, 0, 0} represents Saturday in the weekend; for weather data, the weather is divided into 17 types, including sunny, cloudy, overcast, rainy, sporadic light rain, moderate rain, heavy rain, rainstorm, thunderstorm, freezing rain, snow, light snow, moderate snow, heavy snow, foggy, sandstorm and dust, using one-hot encoding, the encoding length is 17 bits, if the weather is sunny, the first bit is 1, and the rest are 0, that is, {1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}. In this embodiment, the fully connected layer unit includes an input layer, a first hidden layer, a second hidden layer and an output layer; wherein the first hidden layer is used to extract hidden features of the data, and the second hidden layer is used to expand the size of the hidden output vector of the first layer to make it the same as the size of the feature vector at the current moment, the feature vector of the previous day and the feature vector of the previous week.
[0114] The self-attention mechanism weights different parts of the input data, that is, assigns different weights to different parts. This allows the WSDSNN model to pay more attention to the key information in the input sequence, thereby improving the accuracy and efficiency of the WSDSNN model. The self-attention mechanism includes:
[0115] 1) Input and output of the self-attention mechanism
[0116] The input of the self-attention mechanism is S e_weather , S e_time ∈R m×n , the output is S ex ∈R m ×n , m and n represent S e_weather , S e_time The dimensions of the vector.
[0117] 2) Calculation process of self-attention mechanism
[0118] First, we need to calculate the query, key, and value. The query is used to calculate the association or relationship between the current information and other information, and the key can extract the key information in the current information. The calculation formula is:
[0119]
[0120]
[0121] Among them, i represents time or weather; is the weight parameter that needs to be learned, and Q e_i , K e_i 、V e_i ∈R m×n .
[0122] Then calculate the attention weight attn e_i , that is, dot product operation is performed on query (Query) and key (Key), then divided by a normalization factor, and finally normalized by softmax function. The formula is:
[0123]
[0124] Among them, i represents time or weather; K e_i The dimensions of the row vector are m, attn e_i ∈R m×m .
[0125] Finally, the final output S of the external module is calculatedex , that is, the attention weight and the value are weighted and summed, the formula is:
[0126]
[0127] Among them, S ex ∈R m×n .
[0128] In a specific embodiment, the fusion module includes a first fusion unit and a second fusion unit;
[0129] The first fusion unit includes a second self-attention unit and a tenth convolutional layer;
[0130] The second self-attention unit is used to perform weighted summation on the feature vector at the current moment, the feature vector of the previous day, and the feature vector of the previous week to obtain first output data, and transmit it to the tenth convolutional layer;
[0131] The tenth convolutional layer is used to perform feature extraction on the first output data to obtain second output data;
[0132] The second fusion unit is used to add the second output data and the third output data to obtain the fourth output data, obtain the traffic flow prediction result, and process the fourth output data through the tanh function layer to obtain the error between the real value and the predicted value of the traffic flow.
[0133] Specifically, in this embodiment, the traffic flow prediction model WSDSNN performs two data fusions; the first fusion is to fuse the outputs of the current moment module, the previous day module, and the previous week module using a fusion method based on the self-attention mechanism. The fusion method based on the self-attention mechanism can reasonably combine the output results of different modules through the weights in the self-attention mechanism, making the prediction results more flexible and interpretable, and can better capture the complex dynamic changes of traffic flow, improve the generalization ability of the model, and improve the stability and robustness of the prediction. The first fusion is achieved through the first fusion unit, and the output of the first fusion unit can be obtained as S through the general calculation formula (12) to (16) of the self-attention mechanism. f1 ∈R 1 ×m×n Before the second fusion, the output of the first fusion is input to the tenth convolutional layer. The tenth convolutional layer is a 3×3 convolutional layer. Its function is to extract features from the first output data again and obtain S f1conv , this operation can improve the accuracy of the prediction model and reduce the model error. The calculation formula of the tenth convolutional layer is:
[0134] S f1conv =W conv3 *S f1 +bconv3 (17)
[0135] Among them, W conv3 is the weight parameter that needs to be learned; b conv3 is the bias that needs to be learned, which can also be identified as a weight parameter in this design, W conv3 ∈R m×m , b conv3 ∈R m×n , S f1conv ∈R 1×m×n .
[0136] Based on the above design process, it can be seen that the optimal weight parameters of the second self-attention unit and the tenth convolutional layer in the fusion module obtained in each round of training are stored in the weight sharing module for subsequent use.
[0137] Specifically, the second fusion is to combine the output S of the external module ex The output S of the tenth convolutional layer f1conv To merge, such as Figure 7 As shown, S f1conv With S ex The fourth output data is obtained by direct addition, and in order to ensure that the output value is between -1 and 1, the fourth output data is processed by the tanh function layer to obtain the error RX between the actual value and the predicted value of the traffic flow t , as shown in formula (18):
[0138] RX t =tanh(S f1conv +S ex ) (18)
[0139] In a specific embodiment, when the initial traffic flow prediction model is trained based on the current traffic grid, the previous day's traffic grid and the previous week's traffic grid, a layer-by-layer detailed method is used to input the current traffic grid, the previous day's traffic grid and the previous week's traffic grid into the initial traffic flow prediction model in multiple rounds.
[0140] In a specific embodiment, during the training process of the initial traffic flow prediction model, the weight sharing module is used to store the optimal weight parameters obtained by each unit and the convolution layer in the current moment module, the previous day module and the previous week module in each round of training, and the optimal weight parameters obtained by the second self-attention unit and the tenth convolution layer in the fusion module in each round of training, and according to the set filling rules, the parameters of the ConvLSTM unit in the current moment module and the optimal weight parameters in the fusion module are dimensionally filled, and then used as the initial weight parameters for the next round of training, and the training filling operation is repeated until the training is completed to obtain the final spatiotemporal feature extraction module weight parameters and fusion module weight parameters; the set filling rules include: using a zero filling strategy to fill the dimensions of the parameters of the ConvLSTM unit in the spatiotemporal feature extraction module; using a filling strategy with a fixed value of 1 to fill the dimensions of the optimal weight parameters in the fusion module.
[0141] Specifically, in the model initialization stage, the weight parameters are randomly initialized. When the first round of input data enters the model, the loss function is updated according to the back-propagation algorithm. The loss function is the mean absolute error (MAE) and the root mean square error (RSME). The weight parameters are learned and updated. The weight parameters learned after the first round of input training are retained as the initial weight parameters for the next round of input training. However, since the input of the model is multi-round input and the dimensions of each round of input are different, such as Figure 4 As shown in , when a new round of input enters the model training, the dimensions of some weights need to be filled. In the spatiotemporal feature extraction module, the input and output dimensions need to be consistent, so the ConvLSTM unit will h t-kr+(i-1) , C t-kr+(i-1) Fill an appropriate number of elements (usually zeros), i.e., the zero-padding strategy. The main purpose of this padding strategy is to maintain the consistency of the spatial dimensions, i.e., width and height, after the convolution operation, which helps to process boundary information more effectively. In the fusion module, the weight parameter W of the second self-attention unit is Q , W K , W V The dimension of W is the same as the dimension of the feature vector of the current moment, the feature vector of the previous day, and the feature vector of the previous week. When the dimension of the input data of the model changes, a fixed value of 1 is used for W Q , W K , W V The dimension is filled with a fixed value of 1, which can effectively retain the boundary information of the input data and prevent the loss of boundary features.
[0142] The present invention uses Wuhan taxi trajectory data and weather data set, and divides the data set into two sets: about 60% of the data is used for training, and the remaining 40% is used for testing. In general, the WSDSNN model proposed in the present invention is compared with the existing models (STNN, ST-Res, VAR, ARIMA) under the single-step prediction condition, and its root mean square error (RMSE) is reduced by about 40%, and the mean absolute error (MAE) is reduced by about 20%. The model comparison results are shown in Figure 2. Figure 8 As shown, the comparison results show that the WSDSNN model proposed in the present invention is effective in single-step prediction, and the error is reduced more, and the prediction result is more accurate.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A road network traffic flow prediction method based on a weight-sharing deep spatiotemporal neural network, characterized in that: The specific steps include: S1: Obtain a road structure diagram, and divide the road structure diagram into grids according to the quadtree technology and the filling rate to obtain a traffic grid; S2: Obtaining traffic flow observation values, mapping the road section to the traffic grid according to the position of the center point of the road section in the road structure diagram and the traffic flow observation values, and obtaining a traffic grid having the road section information and the traffic flow observation values; S3: splitting the traffic grid with the road section information and the traffic flow observation value according to the set time step and the length of the input sequence of the current time module, the previous day module and the previous week module to obtain the current time traffic grid, the previous day traffic grid and the previous week traffic grid; S4: Acquire information that affects traffic flow, where the information that affects traffic flow includes time data and weather data; S5: establishing an initial traffic flow prediction model, wherein the initial traffic flow prediction model includes a spatiotemporal feature extraction module, an external module, a fusion module, and a weight sharing module; Wherein, the spatiotemporal feature extraction module includes a current time module, a previous day module and a previous week module; The current moment module is used to extract the temporal and spatial characteristics of the traffic grid at the current moment; the previous day module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day; the previous week module is used to extract the temporal and spatial characteristics of the traffic grid of the previous day; The external module is used to extract features of time data and weather data; The fusion module is used to fuse the features extracted by the spatiotemporal feature extraction module and the external module; The weight sharing module is used to store the optimal weight parameters of the spatiotemporal feature extraction module and the fusion module; S6: Based on the information affecting traffic flow, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid, the initial traffic flow prediction model is trained to obtain a trained traffic flow prediction model, and traffic flow prediction is performed based on the trained traffic flow prediction model.
2. The method for predicting road network traffic flow based on a weight-sharing deep spatiotemporal neural network according to claim 1 is characterized in that: The current moment module includes a ConvLSTM unit, a first convolutional layer, a first DenseNet unit, a second convolutional layer and a third convolutional layer connected in sequence; the ConvLSTM unit is used to extract the spatial features of the traffic grid at the current moment, obtain a first feature map, and transmit the first feature map to the first convolutional layer; the first convolutional layer is used to extract the horizontal edge features of the first feature map, obtain a second feature map, and transmit it to the first DenseNet unit; the first DenseNet unit is used to extract the time features of the second feature map, obtain a third feature map, and transmit it to the second convolutional layer; the second convolutional layer is used to extract the vertical edge features of the third feature map, obtain a fourth feature map, and transmit it to the third convolutional layer; the third convolutional layer is used to extract the texture features of the fourth feature map, and obtain the feature vector at the current moment; The previous day module includes a fourth convolutional layer, a second DenseNet unit, a fifth convolutional layer and a sixth convolutional layer connected in sequence; the fourth convolutional layer is used to extract the horizontal edge features of the traffic grid of the previous day, obtain the fifth feature map, and transmit it to the second DenseNet unit; the second DenseNet unit is used to extract the time features of the fifth feature map, obtain the sixth feature map, and transmit it to the fifth convolutional layer; the fifth convolutional layer is used to extract the vertical edge features of the sixth feature map, obtain the seventh feature map, and transmit it to the sixth convolutional layer; the sixth convolutional layer is used to extract the texture features of the seventh feature map to obtain the feature vector of the previous day; The previous week module includes a seventh convolutional layer, a third DenseNet unit, an eighth convolutional layer and a ninth convolutional layer connected in sequence. The seventh convolutional layer is used to extract the horizontal edge features of the traffic grid of the previous week to obtain the eighth feature map, and transmit it to the third DenseNet unit; the third DenseNet unit is used to extract the time features of the eighth feature map to obtain the ninth feature map, and transmit it to the eighth convolutional layer; the eighth convolutional layer is used to extract the vertical edge features of the ninth feature map to obtain the tenth feature map, and transmit it to the ninth convolutional layer; the ninth convolutional layer is used to extract the texture features of the tenth feature map, and obtain the feature vector of the previous week.
3. The method for predicting road network traffic flow based on a weight-sharing deep spatiotemporal neural network according to claim 2 is characterized in that: The external module includes a one-hot encoding unit, a fully connected layer unit, a reshaping unit, and a first self-attention unit; The one-hot encoding unit is used to encode the time data and the weather data to obtain the encoded time data and the weather data; The fully connected layer unit is used to extract information from the encoded time data and weather data to obtain feature vectors of the weather data and time data; The reshaping unit is used to adjust the size of the feature vectors of the weather data and the time data to obtain a reshaped weather feature vector and a time feature vector, and the reshaped weather feature vector and the time feature vector have the same size as the feature vector of the current moment, the feature vector of the previous day, and the feature vector of the previous week; The first self-attention unit is used to perform weighted summation on the weather feature vector and the time feature vector to obtain third output data.
4. The method for predicting road network traffic flow based on a weight-sharing deep spatiotemporal neural network according to claim 3 is characterized in that: The fusion module includes a first fusion unit and a second fusion unit; The first fusion unit includes a second self-attention unit and a tenth convolutional layer; The second self-attention unit is used to perform weighted summation on the feature vector at the current moment, the feature vector of the previous day, and the feature vector of the previous week to obtain first output data, and transmit it to the tenth convolutional layer; The tenth convolutional layer is used to perform feature extraction on the first output data to obtain second output data; The second fusion unit is used to add the second output data and the third output data to obtain the fourth output data, obtain the traffic flow prediction result, and process the fourth output data through the tanh function layer to obtain the error between the real value and the predicted value of the traffic flow.
5. The method for predicting road network traffic flow based on a weight-sharing deep spatiotemporal neural network according to claim 1, characterized in that: When the initial traffic flow prediction model is trained based on the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid, the current traffic grid, the previous day's traffic grid, and the previous week's traffic grid are input into the initial traffic flow prediction model in a layer-by-layer detailed manner, namely: The actual resolution of the traffic grid with road section information and traffic flow observation values is divided according to the set number of training rounds, so as to obtain the sizes of the current traffic grid, the previous day's traffic grid and the previous week's traffic grid input in each round, and input them into the initial traffic flow prediction model in turn.
6. The method for predicting road network traffic flow based on a weight-sharing deep spatiotemporal neural network according to claim 1, characterized in that: During the training process of the initial traffic flow prediction model, the weight sharing module is used to store the optimal weight parameters obtained by each unit and the convolution layer in the current moment module, the previous day module and the previous week module in each round of training, and the optimal weight parameters obtained by the second self-attention unit and the tenth convolution layer in the fusion module in each round of training, and fill the dimensions of the parameters of the ConvLSTM unit in the current moment module and the optimal weight parameters in the fusion module according to the set filling rules, and then use them as the initial weight parameters for the next round of training, repeat the training filling operation until the training is completed, and obtain the final spatiotemporal feature extraction module weight parameters and fusion module weight parameters; The set filling rules include: using a zero filling strategy to fill the dimensions of the parameters of the ConvLSTM unit in the spatiotemporal feature extraction module; A filling strategy with a fixed value of 1 is used to fill the dimensions of the optimal weight parameters in the fusion module.
Citation Information
Patent Citations
Urban road traffic flow prediction method and device based on space-time deep learning model
CN111009129A
Optimized traffic flow prediction model based on space-time diagram convolutional network
CN113505536A
Traffic speed prediction method based on multi-component attention map neural network
CN117133129A
Traffic flow prediction method based on multi-feature fusion
CN117727175A
Traffic performance index prediction method and device based on GIS map information
WO2022142418A1