Traffic flow prediction method and system based on auxiliary node enhanced space-time perception
By filtering the auxiliary nodes with the highest correlation with the target nodes and using the time and space attention mechanism to integrate spatiotemporal features, the limitations of traditional models in traffic flow prediction accuracy and graph structure processing are solved, and more efficient and accurate traffic flow prediction is achieved.
Patent Information
- Application Number
- CN202411876266.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Modern transportation systems have highly nonlinear and dynamic variation characteristics. Traditional mathematical statistical models and machine learning models are difficult to meet the requirements in traffic flow prediction accuracy, and deep learning models have limitations in graph structure and heterogeneity processing, resulting in a decrease in the accuracy of prediction results.
By filtering the auxiliary nodes with the highest correlation with the target node in the traffic flow sequence, the interference of unrelated nodes to the prediction accuracy is reduced, the temporal attention mechanism and the spatial and temporal attention mechanism are adopted, the spatio-temporal characteristics of the target node and the auxiliary node are integrated, and multi-scale and global characteristics are extracted to predict traffic flow.
It significantly improves the accuracy and computing efficiency of traffic flow forecasting, adapts to complex traffic flow changes, and is suitable for many application fields such as urban planning, traffic management and public safety.
Smart Images

Figure CN119851464A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic flow prediction, and in particular to a traffic flow prediction method and system based on auxiliary node enhanced spatiotemporal perception. Background Art
[0002] With the rapid advancement of global urbanization, the number of urban population and vehicles has increased year by year, and traffic congestion has become increasingly serious. As an important technical means to alleviate urban traffic pressure, the Intelligent Transportation System (ITS) has gradually played an indispensable role in modern cities. The Intelligent Transportation System is an integrated system that combines information technology, communication technology, sensor networks and control technology. It can achieve efficient information exchange and coordinated control between roads, vehicles and traffic management, aiming to improve the smoothness of traffic flow and travel safety.
[0003] Among the various functional modules of the intelligent transportation system, the traffic flow prediction system, as a core component, undertakes the key tasks of traffic data collection, analysis and prediction. The system can predict the traffic flow and congestion conditions of different sections of roads in the future by collecting real-time road data, analyzing historical data and applying a variety of machine learning algorithms. Accurate traffic forecasts not only help drivers plan the best route before departure and reduce time wasted due to traffic jams, but also help freight logistics companies optimize itineraries and reduce transportation costs. At the same time, traffic forecast information can also provide a scientific basis for traffic management departments, enabling them to deploy management personnel in a timely manner, adjust the duration of traffic lights, optimize the road network structure, and respond to emergencies in emergencies to relieve congested sections, thereby improving overall traffic efficiency and the city's operational capabilities.
[0004] However, modern transportation systems are highly nonlinear and dynamically changing. Traditional mathematical statistics models and machine learning models often fail to meet the demand for prediction accuracy. Therefore, more and more research has turned to deep learning models, such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), graph neural networks (GNNs), and graph convolutional networks (GCNs). These deep learning methods can capture spatial correlations using the features of adjacent nodes, but in actual road network structures, some non-adjacent nodes may also have strong correlations. This limitation may cause the graph structure to fail to truly reflect the actual dependencies, and even cause key information to be ignored or lost. In addition, GNNs tend to treat all nodes equally during the prediction process, ignoring the heterogeneity between variables. Although nodes with similar trends help improve prediction performance, those with different trends may have an adverse effect on the prediction results, thereby reducing the accuracy of the overall prediction. Summary of the invention
[0005] The purpose of the present invention is to provide a traffic flow prediction method and system based on auxiliary node enhanced spatiotemporal perception, by screening the auxiliary nodes with the highest correlation with the target node in the traffic flow sequence to reduce the interference of irrelevant nodes on the prediction accuracy, so as to achieve accurate prediction of traffic flow data.
[0006] In a first aspect of the present invention, a method for traffic flow prediction based on auxiliary node enhanced spatiotemporal perception is provided, the method comprising:
[0007] S101, obtaining the location of each node and the traffic flow sequence;
[0008] S102, selecting a target node, calculating the distance between the target node and other nodes according to the position of each node, and selecting several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes;
[0009] S103, embedding the traffic flow sequence of the target node point by point, and extracting the local features of the target node;
[0010] S104, performing variable embedding on the traffic flow sequences of the target node and the auxiliary node respectively, and extracting the global features of the target node and the auxiliary node;
[0011] S105, using the temporal attention mechanism to fuse the local features and the global features of the target node to obtain the multi-scale features of the target node, and using the spatial interactive attention mechanism to fuse the multi-scale features of the target node and the global features of the auxiliary node to obtain a fused feature;
[0012] S106: Predict the traffic flow of the target node at the next moment based on the fused features.
[0013] In some embodiments, step S101 further includes:
[0014] The traffic flow sequence data of each node is normalized, and the specific formula is as follows:
[0015]
[0016] Among them, X norm is the normalized value, X is the original traffic flow data, X max is the maximum value in the original traffic flow data, X min It is the minimum value in the original traffic flow data.
[0017] In some embodiments, step S103 includes:
[0018] The traffic flow sequence of the auxiliary node is globally encoded, and the traffic flow sequence of the target node is sampled by combining point-by-point encoding and global encoding. Point-by-point encoding is used to extract local features of the traffic flow sequence, and global encoding provides spatiotemporal information of the target node and the auxiliary node to enhance the perception of traffic flow changes.
[0019] Point-by-point embedding: Extract local features of the traffic flow sequence of the target node, that is, embed the traffic flow sequence of the target node {X i t-T+1 ,...,X i t} Embedding is performed point by point to extract the fine-grained expression of the historical traffic flow information of the target node. The calculation formula is as follows:
[0020] P i =Point-Embedding(X i t-T+1 ,...,X i t )
[0021] in, is the target node X i The feature vector of the traffic flow sequence after point-by-point encoding, X i t is the target node X i Traffic flow data at time t, T represents the data volume of the traffic flow sequence of the target node; represents a matrix with t time steps and D features; Point-Embedding represents the point-by-point encoding function;
[0022] Variable embedding: Global feature extraction is performed on the traffic flow sequences of the target node and the auxiliary node, and the traffic flow sequence is embedded as a whole variable token. By globally expressing and processing it, it can better reflect the dynamic change law of traffic flow and improve the model's ability to capture data; the global encoding is expressed by the following formula:
[0023]
[0024] in, is the traffic flow sequence of the target node, is the traffic flow sequence of the jth auxiliary node corresponding to the target node, V i , It is the feature vector of the two after global encoding, which contains the global information of historical traffic flow; Represents a 1*D feature matrix, where D is the feature dimension; VariatEmbedding is the global encoding function.
[0025] In some embodiments, step S104 includes:
[0026] The temporal relevance of the target node in the temporal dimension is extracted through the temporal attention mechanism, that is, the local encoding information and the global encoding information of the target node are combined to extract multi-scale features and effectively capture the temporal dynamic changes of traffic flow;
[0027] By input sequence [P i ,V i ] Generate query Q through different linear mappings i , key K i Sum value V i , using the temporal attention mechanism to calculate the correlation of the internal time series of the target node:
[0028]
[0029] Among them, the feature matrix Q of the target node i l ,K i l ,V i l It is obtained by fusing the point-by-point encoding information of the target node with the global encoding information in the lth layer of the model and then passing through the fully connected layer. is the weight matrix of the fully connected layer, represents the deviation, d k is the feature dimension; Attn l It is the output of the temporal attention mechanism of the lth layer of the model, that is, the multi-scale feature; Softmax() represents the Softmax function.
[0030] In some embodiments, step S105 includes:
[0031] The spatial interactive attention mechanism is introduced to fuse the spatiotemporal information of the target node and the auxiliary node; based on the cross-attention mechanism, the information between different sequences is associated to improve the spatial modeling accuracy of traffic flow prediction;
[0032] The multi-scale features of the target node and the feature vector of the auxiliary node after global encoding are used as input to extract the spatial correlation between the nodes, and the effective fusion of information is achieved by assigning different weights. The specific formula is as follows:
[0033]
[0034] Among them, the feature matrix Q of the target node icross l ,K icross l ,V icrossl It is obtained in the lth layer of the model by fusing the target node and auxiliary node information and then passing through the fully connected layer. is the weight matrix of the fully connected layer, represents the deviation, d k is the feature dimension; Attn cross l It is the output of the spatial interaction attention mechanism of the lth layer of the model, that is, the fusion feature; Softmax() represents the Softmax function.
[0035] In some embodiments, step S106 includes:
[0036] The fused features are sequentially input into the feedforward layer, projection layer, and linear layer, and reasoning is performed from the feature representation to generate the traffic flow of the target node at the next moment.
[0037] In some embodiments, the loss function adopts the SmoothL1 loss function, and its formula is as follows:
[0038]
[0039] Among them, x is the predicted value of the model, y is the true value, β is a hyperparameter, and SmoothL1Loss(x,y) is the model loss;
[0040] The traffic flow prediction model sets the number of layers to 3, the batch size of each layer to 32, the hidden layer dimension to 64, the number of attention heads to 8, and the feedforward layer dimension to 256.
[0041] According to a second aspect of the present invention, a traffic flow prediction system based on auxiliary node enhanced spatiotemporal perception is provided for implementing the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to any one of the first aspects, the system comprising:
[0042] Data acquisition module, used to obtain the location of each node and traffic flow sequence;
[0043] The auxiliary node selection module is used to select the target node, calculate the distance between the target node and other nodes according to the position of each node, and select several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes;
[0044] The node embedding module is used to embed the traffic flow sequence of the target node point by point, extract the local features of the target node, and embed the traffic flow sequences of the target node and the auxiliary node respectively, and extract the global features of the target node and the auxiliary node;
[0045] The temporal correlation modeling module is used to fuse the local features and global features of the target node using the temporal attention mechanism to obtain the multi-scale features of the target node;
[0046] The spatial dependency modeling module is used to fuse the multi-scale features of the target node and the global features of the auxiliary node using the spatial interaction attention mechanism to obtain the fused features;
[0047] The prediction output layer module is used to predict the traffic flow of the target node at the next moment based on the fusion features.
[0048] According to a third aspect of the present invention, there is provided an electronic device comprising: a processor and a memory, the memory storing programs or instructions executable on the processor, the programs or instructions when executed by the processor implementing the steps of the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception as described in any one of the first aspects.
[0049] According to a fourth aspect of the present invention, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception as described in any one of the first aspects are implemented.
[0050] In general, the traffic flow prediction method and system based on auxiliary node enhanced spatiotemporal perception conceived by the present invention have significant technical advantages over the existing technology, especially in terms of prediction accuracy, computational efficiency, adaptability and flexibility.
[0051] (1) Improved prediction accuracy: The present invention uses an auxiliary node selection module to accurately identify the auxiliary node with the highest correlation with the target node, enhances the spatial dependency modeling capability of the target node, and significantly improves the accuracy of traffic prediction.
[0052] (2) Efficient processing capability: Based on global coding, the present invention combines point-by-point coding and global coding to effectively extract local and global feature information of nodes, thereby deeply exploring complex spatial dependencies while maintaining high computing efficiency, thereby improving the computing efficiency of long-term traffic flow prediction.
[0053] (3) Spatiotemporal feature fusion: The present invention effectively fuses the spatial and temporal information of the target node and the auxiliary node through the spatiotemporal attention module, captures the complex dependency between the two, ensures excellent performance in long-term prediction tasks, and adapts to the complex changes in traffic flow.
[0054] (4) Wide application: The present invention shows strong adaptability in intelligent traffic flow prediction, can provide accurate traffic flow prediction for urban transportation systems, support the supply and demand balance and stable operation of transportation systems, and is suitable for multiple application fields such as urban planning, traffic management and public safety.
[0055] In summary, the present invention provides an innovative solution and system for traffic flow prediction, which has significant advantages in long-term prediction accuracy, computational efficiency and adaptability, and provides strong support for the development of modern intelligent transportation systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A flow chart of a traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception provided in an embodiment of the present application;
[0057] Figure 2 A schematic diagram of an auxiliary node selection module provided in an embodiment of the present application;
[0058] Figure 3 A node embedding process diagram provided in an embodiment of the present application;
[0059] Figure 4 A spatiotemporal attention network module diagram provided in an embodiment of the present application;
[0060] Figure 5 An architecture diagram of a traffic flow prediction system based on auxiliary node enhanced spatiotemporal perception provided in an embodiment of the present application;
[0061] Figure 6 A schematic diagram of the hardware structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0063] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0064] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0065] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0066] The present application provides a traffic flow prediction method and system that utilizes auxiliary nodes to capture local and global features. By selecting auxiliary nodes in multivariate spatiotemporal series data, data dependency modeling is achieved, which is suitable for multiple application fields such as urban planning, traffic management, and public safety.
[0067] The embodiment of the present application provides a traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception, which solves the problem of insufficient dependency modeling capabilities of multi-node traffic flow data and improves prediction accuracy. Figure 1 A flow chart of a traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the method comprises the following steps:
[0068] S101, obtaining the location of each node and the traffic flow sequence;
[0069] S102, selecting a target node, calculating the distance between the target node and other nodes according to the position of each node, and selecting several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes;
[0070] S103, embedding the traffic flow sequence of the target node point by point, and extracting the local features of the target node;
[0071] S104, performing variable embedding on the traffic flow sequences of the target node and the auxiliary node respectively, and extracting the global features of the target node and the auxiliary node;
[0072] S105, using the temporal attention mechanism to fuse the local features and the global features of the target node to obtain the multi-scale features of the target node, and using the spatial interactive attention mechanism to fuse the multi-scale features of the target node and the global features of the auxiliary node to obtain a fused feature;
[0073] S106: Predict the traffic flow of the target node at the next moment based on the fused features.
[0074] Specifically, the specific technical solution includes the following modules and steps:
[0075] Step S101, collect traffic flow data and perform data preprocessing: obtain node information and distance and other related data from the traffic data set, and record the traffic flow. Use normalization processing to unify the data scale and eliminate the difference in feature dimensions. The specific formula is as follows:
[0076]
[0077] Among them, X norm is the normalized value, X is the original traffic flow data, X max is the maximum value in the training data, X min is the minimum value in the training data.
[0078] Step S102, auxiliary node selection module design: an auxiliary node selection module is designed to extract spatial features. Figure 2 As shown in the figure, based on the traffic sequence of the target node, other nodes with the highest correlation with the target node are calculated to capture spatial dependencies. This module uses the Euclidean distance to divide the feature space and filter out auxiliary nodes related to the target node. The specific calculation formula of the distance is as follows:
[0079]
[0080] n=[1,...,N],n≠i
[0081] Wherein, i is the target node number, n is the number of other nodes, and the embodiment of the present application adopts the Euclidean distance formula to calculate the distance between nodes, that is, it is implemented through the Dis function.
[0082] After calculating the distances between all target nodes and other nodes, a distance set is obtained. The distance set is sorted from small to large using the Argsort function to obtain sorted_distances. The specific formula is as follows:
[0083] (d 1→i ,d 2→i ,...,d N→i ) = Argsort(distances)
[0084] sorted_distances=(d 1→i ,d 2→i ,...,d N→i )
[0085] Among them, (d 1→i ,d 2→i ,...,d N→i ) represents the distance value after sorting.
[0086] Then select auxiliary nodes. For example, set a preset distance threshold, and select nodes with distance values less than the preset distance threshold as auxiliary nodes of the target node. For another example, select the first several nodes with the smallest distance values as auxiliary nodes; illustratively, select the first 5 nodes with the smallest distance values as auxiliary nodes of the target node.
[0087] Finally, the traffic flow information of the corresponding auxiliary node is obtained through the selected node index:
[0088] Step S103, node embedding module design: globally encode the auxiliary nodes, and use a combination of point-by-point and global encoding methods for the target nodes, such as Figure 3 Point-by-point coding is used to extract local features of historical traffic, and global coding provides spatiotemporal information of target nodes and auxiliary nodes to enhance the perception of traffic flow changes.
[0089] (1) Point-by-point embedding: The local features of the historical traffic information of the target node in the traffic sequence are extracted. Specifically, Embedding is performed point by point to extract a fine-grained expression of the node's historical information. The relevant calculation formula is as follows:
[0090] P i =Point-Embedding(X i t-T+1 ,...,X it )
[0091] in, is the target node X i The vector after point-by-point encoding. Point-Embedding represents the point-by-point encoding function.
[0092] (2) Variable embedding: In the traffic sequence, global feature extraction operations are performed on both the target and auxiliary nodes, and the traffic sequence features are embedded as a whole variable token. By expressing and processing them globally, the dynamic changes of traffic flow can be better reflected and the model's ability to capture data can be improved. The specific operation of global encoding can be expressed by the following formula:
[0093]
[0094] in, is the historical traffic information of the target node, is the historical traffic information of the jth auxiliary node corresponding to the target node, V i , It is the feature vector after global encoding, which contains the global information of historical traffic flow. VariatEmbedding is the global encoding function.
[0095] Step S104, time correlation modeling module design: extract the correlation of the target node in the time dimension through the time attention mechanism, such as Figure 4 This module combines the local and global encoding information of the target node to extract multi-scale features and effectively capture the temporal dynamic changes of traffic.
[0096] The temporal attention module consists of an input sequence [P i ,V i ] Generate query Q through different linear mappings i , key K i Sum value V i , the self-attention mechanism is used to calculate the correlation of the internal time series of the node. The calculation formula is as follows:
[0097]
[0098] Among them, the feature matrix Q of the target node i l ,K i l ,V i l , which is represented as in the lth layer of the model, is obtained by fusing the point-by-point encoding information with the global encoding information and passing through the fully connected layer; is the weight matrix of the fully connected layer, represents the deviation, dk is the feature dimension, Attn l is the output of the l-th layer temporal attention module.
[0099] Step S105, spatial dependency modeling module design: introduce spatial interaction attention mechanism to fuse the spatiotemporal information of target nodes and auxiliary nodes, such as Figure 4 This module is based on the cross-attention mechanism and associates information between different sequences to improve the spatial modeling accuracy of traffic flow prediction.
[0100] The processed target node vector and the globally encoded auxiliary node vector are used as input to extract the spatial correlation between nodes and achieve effective fusion of information by assigning different weights. The specific formula is as follows:
[0101]
[0102] Among them, the feature matrix Q of the target node icross l ,K icross l ,V icross l It is represented as the information obtained by fusion of target node and auxiliary node in the model layer l and then passing through the fully connected layer; is the weight matrix of the fully connected layer, represents the deviation, d k is the feature dimension, Attn cross l is the output of the l-th layer spatial interaction attention module.
[0103] Step S106, prediction output layer design: through the projection layer and the linear layer, reasoning is performed from the feature representation to generate the prediction results of future traffic flow and output the long-term traffic flow prediction value. Figure 1 As shown in the figure, the projection layer and the linear layer together form the prediction head, and there is a feed-forward layer before the prediction head.
[0104] Step S107, model training and optimization: Implement the traffic flow prediction model using Python code and perform experiments on Pytorch. Optimize the hyperparameters of the model and select the optimal hyperparameters to make the model prediction more accurate. The relevant technical solutions are as follows:
[0105] (1) Loss function: The SmoothL1 loss function is used, which combines the advantages of L1 loss (absolute error) and L2 loss (mean square error). When the error is small, it is similar to L2 loss, and when the error is large, it is similar to L1 loss. Therefore, it is more robust than using L1 or L2 loss alone. Its formula is as follows:
[0106]
[0107] Among them, x is the predicted value of the model, y is the true value, and β is a hyperparameter with a default value of 1.
[0108] (2) Model parameters: The proposed traffic flow prediction model sets the number of layers to 3, the batch size of each layer to 32, the hidden layer dimension to 64, the number of attention heads to 8, and the feedforward layer dimension to 256. During the training process, the number of iterations of the model is set to 150.
[0109] (3) Optimization algorithm: The Adam optimization algorithm is used for model training to accelerate convergence and improve prediction performance.
[0110] (4) Hyperparameter adjustment: The initial learning rate is set to 0.001, and the learning rate is automatically updated to optimize the model performance.
[0111] Step S108, model evaluation: the prediction effect of the prediction model is tested through performance evaluation and comparative experiments, and the prediction effect of the model is evaluated using performance indicators such as absolute error and mean square error.
[0112]
[0113] in, is the true value of the i-th node in the data set at time t, is the predicted value output by the model at that moment.
[0114] This application also compares the model proposed in the embodiments of this application with the widely used baseline model and SOTA model.
[0115] Three datasets are selected for the data set, and the detailed information is shown in Table 1. In the experiment, three types of models, namely the classic traditional model, the model based on graph neural network, and the deep learning model based on Transformer, are selected as the benchmark models. These models represent different technical routes in the current field of traffic flow prediction and can provide a comprehensive comparative evaluation. The comparison results are shown in Table 2.
[0116] Table 1 Dataset description table
[0117]
[0118] According to the prediction results shown in Table 2, it can be clearly seen that the model of this application is MAE 、E MAPE 、E RMSE Compared with SATEFormer on PeMS04 and PeMS08 datasets, E MAE and E RMSEThey were reduced by 8.66%, 4.80% and 10.13%, 8.75%, respectively, verifying the effectiveness and generalization ability of the model. This is attributed to the fact that the model effectively uses auxiliary nodes to assist in prediction, thereby extracting the global features of the variables, and carefully considers the local features of the target nodes. By fusing the local and global features of the nodes, the perception ability of the spatiotemporal attention network is enhanced, and the accuracy of the prediction is improved. In summary, the model proposed in this application can provide reliable prediction results in long-term demand traffic flow prediction and achieve better performance than other baseline methods.
[0119] Table 2 Prediction performance comparison experiment table
[0120]
[0121] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from that here. For example, step S103 can be before step S104 or after step S104.
[0122] The embodiments of the present application also provide a point cloud generation device and a classification device, which are used to implement the above embodiments and preferred implementation modes, and will not be repeated here. As used below, the terms "module", "unit", "subunit", etc. can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0123] Figure 5 This is a structural block diagram of a traffic flow prediction system based on auxiliary nodes to enhance spatiotemporal perception in an embodiment of the present application. Different from the traditional method of constructing a spatiotemporal graph network based on neighboring relationships, the present application reduces the interference of irrelevant nodes on prediction accuracy by screening the auxiliary nodes with the highest correlation with the target node in the traffic flow sequence. Figure 5 As shown, the system includes: a data acquisition module 201, an auxiliary node selection module 202, a node embedding module 203, a time correlation modeling module 204, a spatial dependency modeling module 205 and a prediction output layer module 206;
[0124] The data acquisition module 201 is used to obtain the location of each node and the traffic flow sequence;
[0125] The auxiliary node selection module 202 is used to select a target node, calculate the distance between the target node and other nodes according to the position of each node, and select several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes;
[0126] The node embedding module 203 is used to embed the traffic flow sequence of the target node point by point, extract the local features of the target node, and embed the traffic flow sequences of the target node and the auxiliary node respectively, and extract the global features of the target node and the auxiliary node; this module is used to process the differences between the target node and the auxiliary node, and embed the local and global information of the target node and the global information of the auxiliary node into the model to enhance the spatiotemporal features;
[0127] The temporal correlation modeling module 204 is used to fuse the local features and global features of the target node using the temporal attention mechanism to obtain the multi-scale features of the target node; this module is used to extract the temporal correlation of the target node and improve the processing accuracy of the temporal features;
[0128] The spatial dependency modeling module 205 is used to fuse the multi-scale features of the target node and the global features of the auxiliary node using the spatial interactive attention mechanism to obtain the fused features; the module fuses the global information of the auxiliary node with the information of the target node to capture the interactive relationship between the two and enhance the prediction performance of the long-term traffic flow;
[0129] The prediction output layer module 206 is used to predict the traffic flow of the target node at the next moment based on the fusion features.
[0130] Through the coordinated operation of the above modules, accurate prediction of traffic flow data is achieved, which is suitable for fields such as urban planning, traffic management and public safety.
[0131] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0132] In addition, combined Figure 1 The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception of the embodiment of the present application described can be implemented by a computer device. Figure 6 Schematic diagram of the hardware structure of the computer device of the embodiment of the present application. Figure 6 As shown, the device may include a processor 301 and a memory 302 storing computer program instructions.
[0133] Specifically, the processor 301 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0134] Among them, the memory 302 may include a large capacity memory for data or instructions. For example, but not limitation, the memory 302 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 302 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 302 may be inside or outside the data processing device. In a specific embodiment, the memory 302 is a non-volatile memory. In a specific embodiment, the memory 302 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0135] The memory 302 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 301 .
[0136] The processor 301 reads and executes the computer program instructions stored in the memory 302 to implement any one of the traffic flow prediction methods based on auxiliary node enhanced spatiotemporal perception in the above embodiments.
[0137] In some embodiments, the point cloud generation device may further include a communication interface 303 and a bus 300. Figure 6 As shown, the processor 301, the memory 302, and the communication interface 303 are connected via a bus 300 and communicate with each other.
[0138] The communication interface 303 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 303 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0139] The bus 300 includes hardware, software, or both, and couples the components of the point cloud generation device to each other. The bus 300 includes, but is not limited to, at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 300 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of the above. Bus 300 may include one or more buses, where appropriate. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0140] The computer device can use the traffic flow sequence data of each node to execute the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception in the embodiment of the present application, thereby realizing the combination of Figure 1 The described traffic flow prediction method based on auxiliary nodes enhanced spatiotemporal perception.
[0141] In addition, in combination with the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception in the above embodiments, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the traffic flow prediction methods based on auxiliary node enhanced spatiotemporal perception in the above embodiments is implemented.
[0142] It should be pointed out that the technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. In addition, according to the needs of implementation, the various steps / components described in this application can be split into more steps / components, and two or more steps / components or partial operations of steps / components can be combined into new steps / components to achieve the purpose of the present invention.
[0143] It is easy for a person skilled in the art to understand that the above-mentioned embodiments only express several implementation methods of the present application, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception, characterized in that: The method includes: S101, obtaining the location of each node and the traffic flow sequence; S102, selecting a target node, calculating the distance between the target node and other nodes according to the position of each node, and selecting several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes; S103, embedding the traffic flow sequence of the target node point by point, and extracting the local features of the target node; S104, performing variable embedding on the traffic flow sequences of the target node and the auxiliary node respectively, and extracting the global features of the target node and the auxiliary node; S105, using the temporal attention mechanism to fuse the local features and the global features of the target node to obtain the multi-scale features of the target node, and using the spatial interactive attention mechanism to fuse the multi-scale features of the target node and the global features of the auxiliary node to obtain a fused feature; S106: Predict the traffic flow of the target node at the next moment based on the fused features.
2. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 1 is characterized in that: Step S101 also includes: The traffic flow sequence data of each node is normalized, and the specific formula is as follows: Among them, X norm is the normalized value, X is the original traffic flow data, X max is the maximum value in the original traffic flow data, X min It is the minimum value in the original traffic flow data.
3. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 1 is characterized in that: Step S103 includes: The traffic flow sequence of the auxiliary node is globally encoded, and the traffic flow sequence of the target node is sampled by combining point-by-point encoding and global encoding. Point-by-point encoding is used to extract local features of the traffic flow sequence, and global encoding provides spatiotemporal information of the target node and the auxiliary node to enhance the perception of traffic flow changes. Point-by-point embedding: Extract local features of the traffic flow sequence of the target node, that is, embed the traffic flow sequence of the target node {X i t-T+1 ,...,X i t } Embedding is performed point by point to extract the fine-grained expression of the historical traffic flow information of the target node. The calculation formula is as follows: P i =Point-Embedding(X i t-T+1 ,...,X i t ) in, is the target node X i The feature vector of the traffic flow sequence after point-by-point encoding, X i t is the target node X i Traffic flow data at time t, T represents the data volume of the traffic flow sequence of the target node; represents a matrix with t time steps and D features; Point-Embedding represents the point-by-point encoding function; Variable embedding: Global feature extraction is performed on the traffic flow sequences of the target node and the auxiliary node, and the traffic flow sequence is embedded as a whole variable token. By globally expressing and processing it, it can better reflect the dynamic change law of traffic flow and improve the model's ability to capture data; the global encoding is expressed by the following formula: in, is the traffic flow sequence of the target node, is the traffic flow sequence of the jth auxiliary node corresponding to the target node, It is the feature vector of the two after global encoding, which contains the global information of historical traffic flow; Represents a 1*D feature matrix, where D is the feature dimension; VariatEmbedding is the global encoding function.
4. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 3 is characterized in that: Step S104 includes: The temporal relevance of the target node in the temporal dimension is extracted through the temporal attention mechanism, that is, the local encoding information and the global encoding information of the target node are combined to extract multi-scale features and effectively capture the temporal dynamic changes of traffic flow; By input sequence [P i ,V i ] Generate query Q through different linear mappings i , key K i Sum value V i , use the temporal attention mechanism to calculate the correlation of the internal time series of the target node: Among them, the feature matrix Q of the target node i l ,K i l ,V i l It is obtained by fusing the point-by-point encoding information of the target node with the global encoding information in the lth layer of the model and then passing through the fully connected layer. is the weight matrix of the fully connected layer, represents the deviation, d k is the feature dimension; Attn l It is the output of the temporal attention mechanism of the lth layer of the model, that is, the multi-scale feature; Softmax() represents the Softmax function.
5. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 4 is characterized in that: Step S105 includes: The spatial interactive attention mechanism is introduced to fuse the spatiotemporal information of the target node and the auxiliary node; based on the cross-attention mechanism, the information between different sequences is associated to improve the spatial modeling accuracy of traffic flow prediction; The multi-scale features of the target node and the feature vector of the auxiliary node after global encoding are used as input to extract the spatial correlation between the nodes, and the effective fusion of information is achieved by assigning different weights. The specific formula is as follows: Among them, the feature matrix Q of the target node icross l ,K icross l ,V icross l It is obtained in the lth layer of the model by fusing the target node and auxiliary node information and then passing through the fully connected layer. is the weight matrix of the fully connected layer, represents the deviation, d k is the feature dimension; Attn cross l It is the output of the spatial interaction attention mechanism of the lth layer of the model, that is, the fusion feature; Softmax() represents the Softmax function.
6. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 1 is characterized in that: Step S106 includes: The fused features are sequentially input into the feedforward layer, projection layer, and linear layer, and reasoning is performed from the feature representation to generate the traffic flow of the target node at the next moment.
7. The traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception according to claim 6 is characterized in that: The loss function adopts the SmoothL1 loss function, and its formula is as follows: Among them, x is the predicted value of the model, y is the true value, β is a hyperparameter, and SmoothL1Loss(x,y) is the model loss; The traffic flow prediction model sets the number of layers to 3, the batch size of each layer to 32, the hidden layer dimension to 64, the number of attention heads to 8, and the feedforward layer dimension to 256.
8. A traffic flow prediction system based on auxiliary node enhanced spatiotemporal perception for implementing the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception as described in any one of claims 1 to 7, characterized in that: The system includes: Data acquisition module, used to obtain the location of each node and traffic flow sequence; The auxiliary node selection module is used to select the target node, calculate the distance between the target node and other nodes according to the position of each node, and select several nodes whose distance is less than a preset distance threshold or the first several nodes with the smallest distance as auxiliary nodes; The node embedding module is used to embed the traffic flow sequence of the target node point by point, extract the local features of the target node, and embed the traffic flow sequences of the target node and the auxiliary node respectively, and extract the global features of the target node and the auxiliary node; The temporal correlation modeling module is used to fuse the local features and global features of the target node using the temporal attention mechanism to obtain the multi-scale features of the target node; The spatial dependency modeling module is used to fuse the multi-scale features of the target node and the global features of the auxiliary node using the spatial interaction attention mechanism to obtain the fused features; The prediction output layer module is used to predict the traffic flow of the target node at the next moment based on the fusion features.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception as described in any one of claims 1 to 7 are implemented.
10. A readable storage medium, characterized in that: Programs or instructions are stored thereon, and when the programs or instructions are executed by the processor, the steps of the traffic flow prediction method based on auxiliary node enhanced spatiotemporal perception as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Route recommendation model training method and device, equipment and medium
CN111782974A
Graph clustering method and device based on self-supervised graph neural network, and storage medium
CN113221950A
Traffic flow prediction method based on space-time diagram network
CN115796007A
POI-based double-layer graph convolutional network traffic prediction method
CN116863683A
Traffic flow prediction method
CN117275230A