Method and device for predicting traffic flow based on network reduction
The method addresses the challenges of large-scale traffic flow prediction by employing RWKV and GCN attention modules for network reduction, achieving efficient and accurate traffic flow prediction.
Patent Information
- Application Number
- CN202411349289.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-20
AI Technical Summary
Existing traffic flow prediction models struggle with large-scale datasets due to high memory and computational costs, and lack of effective methods to capture both spatial and temporal correlations, limiting their applicability to real-world traffic networks.
A method and device for predicting traffic flow using network reduction, incorporating time and space embedding with RWKV and GCN attention modules, reducing computational complexity while maintaining prediction accuracy.
The method ensures accurate and efficient traffic flow prediction by using high-dimensional embedding tensors and RWKV and GCN attention modules, effectively reducing memory and computational costs.
Smart Images

Figure CN119169823A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of spatiotemporal prediction in traffic control systems, and in particular to a method and device for predicting traffic flow based on network reduction. Background Art
[0002] With the development of transportation, people's travel methods are becoming more and more diverse and convenient. Especially driven by deep learning technology, the transportation network system is becoming more and more mature. With the increase of transportation resources, a series of problems have also been brought about. How to efficiently predict traffic flow has become an important research topic.
[0003] Traffic data is a kind of time series data recorded continuously at fixed time intervals by deployed sensors, which is a typical spatiotemporal data. In the past few decades, the datasets used by traditional traffic flow prediction methods are limited in size and relatively limited. For example, widely used benchmark datasets (such as PeMS03, 04, 07 and 08) contain only hundreds of nodes and edges, which cannot well reflect the real traffic network. However, the scale of traffic networks that need to be analyzed in the real world is usually much larger. For example, California alone has nearly 20,000 operating sensors. Since most of the current traffic prediction models are developed on small datasets, most of them cannot be extended to larger sensor networks. In addition, existing traffic datasets are also insufficient in terms of time coverage, usually with less than 6 months of data. This limited time span hinders the study of long-term seasonal patterns and limits the number of training instances for deep learning models. Therefore, the selection of large-scale traffic datasets is crucial for real-world traffic flow prediction.
[0004] Secondly, time series prediction methods based on deep learning have also developed rapidly. Specifically, recurrent neural networks (RNNs) and their variants, such as long short-term memory (LSTM) and gated recurrent units (GRUs), can model temporal dependencies from time series data. However, these methods have no way to capture spatial correlation. In addition, in recent years, spatiotemporal prediction methods based on deep learning have been widely used in traffic flow prediction tasks. Specifically, spatiotemporal graph convolutional neural networks (STGCNs), graph wave networks (Graph WaveNets), dynamic graph convolutional recurrent neural networks (DGCRNs), and attention-based spatiotemporal graph neural networks (ASTGNNs) can model spatiotemporal correlations and have relatively high prediction accuracy. However, the memory and computational complexity of these models grow quadratically with the length of the sequence. When they are applied to relatively large multivariate time series prediction datasets, the memory cost and computational cost increase significantly, so they cannot be extended to large-scale datasets. There is currently a lack of effective solutions to achieve accurate traffic flow prediction based on large-scale datasets and reduce memory and computational costs. Summary of the invention
[0005] In order to overcome the above technical defects, the embodiments of the present application provide a method and device for predicting traffic flow based on network reduction, which can reduce memory cost and computing cost and maintain prediction accuracy based on large-scale traffic data.
[0006] In a first aspect, an embodiment of the present application provides a method for predicting traffic flow based on network reduction, comprising:
[0007] S1. Using sensors to collect traffic flow data of continuous time steps in a designated road section and its vicinity, and preprocessing the acquired traffic flow data;
[0008] S2. Use the preprocessed traffic flow data as input data and perform time embedding and space embedding on it to obtain a high-dimensional embedding vector, where time embedding is to add location information to the time dimension of the input data, and space embedding is to add location information to the space dimension of the input data;
[0009] S3, inputting the high-dimensional embedding vector into the traffic flow prediction model to obtain the traffic flow prediction result corresponding to the specified road section;
[0010] The traffic flow prediction model includes L encoding layers and L decoder layers, where L is an integer greater than or equal to 2. One encoder layer is connected to one decoder layer, each encoder layer includes a weighted key value RWKV layer and a graph convolutional network GCN attention layer, and each decoder layer includes two RWKV layers and one GCN attention layer.
[0011] Optionally, in a possible implementation of the first aspect,
[0012] The steps of inputting the high-dimensional embedding vector into the traffic flow prediction model in S3 to obtain the traffic flow prediction result corresponding to the specified road section include:
[0013] S3.1, encoding processing: In each encoder layer, the RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the first feature representation tensor, and then the GCN attention layer determines the intermediate representation sequence according to the first feature representation tensor;
[0014] S3.2, decoding processing: In each decoder layer, the first RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the second feature representation tensor, and then the second RWKV layer performs attention calculation on the new representation sequence to obtain the third feature representation tensor. The new representation sequence is obtained by connecting the second feature representation tensor and the intermediate representation sequence. Finally, the GCN attention layer determines the traffic flow output sequence according to the third feature representation tensor;
[0015] S3.3, Linear processing: Linearly process the traffic flow output sequences output by all encoder layers to obtain the traffic flow prediction results.
[0016] Optionally, in a possible implementation of the first aspect, the backbone network in the RWKV layer adopts a stacked residual block structure, each residual block includes a time mixing sub-block and a channel mixing sub-block; the time mixing sub-block is used to realize time mixing and interpolate between the current time step and the previous time step; the channel mixing sub-block is used to perform weighted mixing of the current time step and the previous time step, and obtain the final feature representation through linear projection.
[0017] Optionally, in a possible implementation of the first aspect, the backbone network in the RWKV layer adopts a stacked residual block structure, each residual block includes a time mixing sub-block and a channel mixing sub-block; the time mixing sub-block is used to realize time mixing and interpolate between the current time step and the previous time step; the channel mixing sub-block is used to perform weighted mixing of the current time step and the previous time step, and obtain the final feature representation through linear projection.
[0018] Optionally, in a possible implementation of the first aspect, the location information is a relative position relationship between nodes represented by node coordinates, and the nodes are divided according to designated road sections, with one designated road section serving as a node; the step of using the preprocessed traffic flow data as input data to perform time embedding and spatial embedding on it to obtain a high-dimensional embedding vector in S2 specifically includes: adding the relative position relationship between nodes in the time dimension to the preprocessed traffic flow data to obtain a time embedding vector; adding the relative position relationship between nodes in the spatial dimension to the preprocessed traffic flow data to obtain a spatial embedding vector; and adding the time embedding vector and the spatial embedding vector to obtain a high-dimensional embedding tensor.
[0019] Optionally, in a possible implementation of the first aspect, the step of preprocessing the collected traffic flow data in S1 specifically includes: normalizing the collected traffic flow data to obtain the flow reading corresponding to each traffic flow data, and converting the time difference of the timestamp of each traffic flow data relative to midnight of the same day into a decimal form, and then connecting the flow reading of each traffic flow data and the timestamp represented in decimal form to obtain the processed traffic flow data.
[0020] Optionally, in a possible implementation manner of the first aspect, the objective optimization function of the traffic flow prediction model is:
[0021]
[0022] Among them, loss is the target optimization function of the efficient traffic flow prediction model, N represents the number of samples, f represents the time step of prediction, and X t represents the input state at time step t, represents the prediction at time step t.
[0023] Optionally, in a possible implementation of the first aspect, during the model training process of the traffic flow prediction model, the data set is divided into a training set, a validation set, and a test set in chronological order with a division ratio of 6:2:2 for training.
[0024] Optionally, in a possible implementation of the first aspect, the value of L is 2 or 3; in S1, the traffic flow data is obtained from the LargeST benchmark dataset.
[0025] In the second aspect, an embodiment of the present application provides a device for predicting traffic flow based on network reduction, characterized in that it includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein: the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method in any one of the first aspect and its implementation methods as described above.
[0026] The embodiment of the present application adopts the above technical solution to achieve the following technical effects: the traffic flow prediction model constructed by using the RWKV module and the GCN attention module, the GCN attention module can ensure the prediction accuracy of the prediction model, and the RWKV module can reduce the computational complexity. At the same time, the use of the RWKV module and the GCN attention module in both the encoding layer and the decoder layer can further improve the prediction efficiency of the traffic flow prediction model. In addition, the use of high-dimensional embedded tensors after time embedding and spatial embedding instead of directly using input data in the prediction process can further improve the prediction efficiency. Therefore, the method of predicting traffic flow based on network reduction in the present application can ensure the prediction accuracy and reduce the computational complexity in the prediction process, so as to achieve efficient and accurate prediction of traffic flow. . BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0028] Figure 1 A flow chart of a method for predicting traffic flow based on network reduction in an embodiment of the present application;
[0029] Figure 2 A flow chart of the prediction process in the traffic flow prediction model in the embodiment of the present application;
[0030] Figure 3 A schematic diagram of a network architecture of a traffic flow prediction model in an embodiment of the present application;
[0031] Figure 4 A network architecture diagram for accepting a weighted key value RWKV layer in an embodiment of the present application;
[0032] Figure 5 A structural diagram of a device for predicting traffic flow based on network reduction in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application 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 application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0034] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0035] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.
[0036] In order to achieve the accuracy of traffic flow prediction and reduce memory cost and computing cost, a method for predicting traffic flow based on network reduction is provided in an embodiment of the present application. Network reduction reduces the spatial complexity and time complexity to achieve the purpose of reducing computing cost and memory cost.
[0037] In order to facilitate understanding of the technical solutions in the embodiments of the present application, the following is a brief introduction to the technical terms involved in the present application:
[0038] The RWKV model is a clever recurrent neural network (RNN) architecture that enables it to be trained like a transformer. The core mechanism of this model is that RWKV does not use attention, but something similar to attention is called WKV. The RWKV layer in this application is designed based on the RWKV model.
[0039] Graph convolutional neural network GCN, which has the same function as convolutional neural network CNN, is a feature extractor, except that its object is graph data. GCN has ingeniously designed a method to extract features from graph data, so that we can use these features to perform node classification, graph classification, and link prediction on graph data, and also obtain graph embedding.
[0040] Embodiment 1
[0041] Next, see Figure 1 The method for predicting traffic flow based on network reduction in the embodiment of the present application is described as follows:
[0042] The method is applicable to a traffic flow prediction model including L encoding layers and L decoder layers, where L is an integer greater than or equal to 2, and one encoder layer is connected to one decoder layer, wherein each encoder layer includes a weighted key value RWKV layer and a graph convolutional network GCN attention layer, and each decoder layer includes two RWKV layers and one GCN attention layer.
[0043] The method specifically includes:
[0044] S1. Use sensors to collect traffic flow data of continuous time steps in a specified road section and its vicinity, and pre-process the traffic flow data.
[0045] Specifically, the traffic flow data includes flow readings and corresponding timestamps. The sensor may be a photoelectric sensor. The sensor collection limits the data source, but is not limited to real-time collection or not. For example, it may be a data set formed after the sensor collection. Optionally, in some possible implementations, the traffic flow data in S1 is obtained from the LargeST benchmark dataset, and the Largest benchmark dataset is used to reflect the real traffic network. The Largest benchmark dataset is notable not only for its wide graph scale, covering a total of 8,600 sensors in California, but also for its wide time coverage and rich node information. Each sensor contains 5 years of data and comprehensive metadata; the graph scale, for example, contains 8.4××-50.G×× nodes and 13.9×-729.6× edges.
[0046] Traffic flow data can be broadly defined as traffic information including the sensor coordinate location, the area where it is located, the highway or city road where it is located, and the direction of travel and number of lanes on the road.
[0047] A continuous time step refers to a continuous period of time, which can be 5 minutes, 10 minutes, 15 minutes, 20 minutes, etc. The specific time step can be selected based on the actual traffic flow conditions of the specified section and the impact of the specified period. For example, during holidays, the free traffic volume on highways is large, and the time step can be appropriately selected as a smaller value. Conversely, during non-holidays, the free traffic volume on highways is small, and the time step can be appropriately selected as a larger value.
[0048] Optionally, in some embodiments, the step of preprocessing the collected traffic flow data in S1 specifically includes: normalizing the collected traffic flow data to obtain the flow reading corresponding to each traffic flow data, and converting the time difference of the timestamp of each traffic flow data relative to midnight of the same day into a decimal form, and then connecting the flow reading of each traffic flow data and the timestamp represented in decimal form to obtain the processed traffic flow data.
[0049] S2. Use the preprocessed traffic flow data as input data and perform time embedding and space embedding on it to obtain a high-dimensional embedding vector, where time embedding is to add location information to the time dimension of the input data, and space embedding is to add location information to the space dimension of the input data.
[0050] The location information may be determined based on the sensor and divided according to different designated sections. A designated section is regarded as a node, and the location of the node may be represented by the location coordinates of the sensor.
[0051] Optionally, in some implementations, the position information added in the time dimension and the space dimension is a relative position relationship between nodes represented based on node coordinates, and the nodes are divided according to designated sections, and one designated section serves as a node;
[0052] In S2, the steps of using the preprocessed traffic flow data as input data to perform temporal embedding and spatial embedding to obtain a high-dimensional embedding vector specifically include:
[0053] First, the relative position relationship between nodes is added to the preprocessed traffic flow data in the time dimension to obtain a time embedding vector; the introduction of time embedding can help the traffic flow prediction model of the present application better identify the relative position relationship between each node.
[0054] Specifically, the time embedding vector can be expressed as the time embedding matrix E TP , whose expression is:
[0055]
[0056] Where d is half the index of the current dimension, 2d+1 indicates an odd dimension, t is the relative index of each node in the input, and d model is the embedding dimension.
[0057] Secondly, the relative position relationship between nodes is added to the preprocessed traffic flow data in the spatial dimension to obtain the spatial embedding vector;
[0058] Specifically, the spatial embedding vector is recorded as the spatial embedding matrix E SP , whose expression is:
[0059] E SP =GCN n (GCN n-1 (...GCN1(self.embedding(i))...));
[0060] Where self.embedding(i) is the initial embedding vector of node i generated by the embedding layer. The spatial embedding matrix method is to first assign an additional embedding vector to each node to obtain an initial spatial embedding matrix Then apply the GCN layer for Laplace smoothing and finally get the spatial embedding matrix E SP .
[0061] Finally, the temporal embedding vector and the spatial embedding vector are added together to obtain a high-dimensional embedding tensor.
[0062] Embedding time into E TP and spatial embedding E SPThe sum is the high-dimensional embedding tensor X, which is expressed as follows: X = E TP +E SP .
[0063] S3. Input the high-dimensional embedding vector into a traffic flow prediction model to obtain a traffic flow prediction result corresponding to the specified road section.
[0064] As shown above, the traffic flow prediction model in the embodiment of the present application is newly constructed, including L encoding layers and L decoder layers, L is an integer greater than or equal to 2, one encoder layer is connected to one decoder layer, each encoder layer includes a weighted key value RWKV layer and a graph convolution network GCN attention layer, and each decoder layer includes two RWKV layers and one GCN attention layer. Optionally, in some embodiments, the value of L is 2 or 3.
[0065] Optionally, in some embodiments, during the model training process of the traffic flow prediction model, the data set is divided into a training set, a validation set, and a test set in chronological order with a division ratio of 6:2:2. The above-mentioned efficient traffic flow prediction model is trained based on the above-mentioned training set; the performance of the trained efficient traffic flow prediction model is evaluated based on the above-mentioned validation set to obtain an efficient traffic flow prediction model that meets the performance requirements; the prediction results that meet the performance requirements are evaluated based on the above-mentioned test set to obtain the evaluation index corresponding to the traffic flow prediction model.
[0066] To be more specific, the three evaluation indicators used in this example include mean absolute error (MAE), root mean square error (RMSE) and mean absolute percentage error (MAPE). The lower the indicator, the better the performance. The specific formulas are as follows:
[0067]
[0068] Where N is the number of test samples, T is the time step, and They represent the true value and predicted value of traffic flow at time t respectively.
[0069] According to the loss function, the loss function is calculated based on the above-mentioned predicted value and the true value, the model parameters are updated based on the loss value, the efficient traffic flow prediction model is iteratively trained until the training is completed, and the optimal model parameters are saved to form a trained traffic flow prediction model.
[0070] Further optionally, in some embodiments, the above loss function is the target optimization function of the traffic flow prediction model, and its expression is:
[0071]
[0072] Among them, loss is the target optimization function of the efficient traffic flow prediction model, N represents the number of samples, f represents the time step of prediction, and X t represents the input state at time step t, represents the prediction at time step t.
[0073] In the technical solution implemented in the present application, a traffic flow prediction model is constructed using the RWKV module and the GCN attention module. The GCN attention module can ensure the prediction accuracy of the prediction model, and the RWKV module can reduce the computational complexity. At the same time, the use of the RWKV module and the GCN attention module in both the encoding layer and the decoder layer can further improve the prediction efficiency of the traffic flow prediction model. In addition, the use of high-dimensional embedding tensors after time embedding and space embedding instead of directly using input data in the prediction process can further improve the prediction efficiency. Therefore, the method for predicting traffic flow based on network reduction in the present application can ensure prediction accuracy while reducing the computational complexity in the prediction process, thereby achieving efficient and accurate prediction of traffic flow.
[0074] Embodiment 2
[0075] Next, see Figure 2 The prediction process in the traffic flow prediction model in the embodiment of the present application is described. In S3, the high-dimensional embedding vector is input into the traffic flow prediction model to predict the traffic flow prediction result corresponding to the specified road section, which mainly includes three main steps: encoding processing, decoding processing and linear processing, as follows:
[0076] S3.1. Encoding processing: In each encoder layer, the RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the first feature representation tensor, and then the GCN attention layer determines the intermediate representation sequence based on the first feature representation tensor.
[0077] S3.2. Decoding processing: In each decoder layer, the first RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the second feature representation tensor, and then the second RWKV layer performs attention calculation on the new representation sequence to obtain the third feature representation tensor. The new representation sequence is obtained by connecting the second feature representation tensor and the intermediate representation sequence. Finally, the GCN attention layer determines the traffic flow output sequence according to the third feature representation tensor.
[0078] S3.3, Linear processing: Linearly process the traffic flow output sequences output by all encoder layers to obtain the traffic flow prediction results.
[0079] Figure 3 Schematic diagram of the structure between the encoder layer and the decoder layer in the traffic flow prediction model in the embodiment of the present application, Figure 3The values of L and L′ are the same, and they only distinguish the encoder layer and the decoder layer.
[0080] See also Figure 2 and Figure 3 , in the GCN attention layer, determining the corresponding representation sequence according to the feature representation tensor can be achieved through the following calculation formula:
[0081] Q i =XW i Q , K i =XW i K , V i =XW i V , attention i =softmax(score i ), head i =attention i V i , output=concat(head1,...,head h )W O ,
[0082] Among them, X is the input feature matrix, Q i , K i 、V i They are query matrix, key matrix, value matrix, score matrix ij is the attention score, W i Q , W i K and W i V is the weight matrix of each head, d k is the dimension of the key vector, attention i is the attention weight matrix calculated by the softmax function, head i is the output of each attention head, by adding the attention weight matrix i Applied to value V i Get on, W O is the output weight matrix.
[0083] Optionally, in some embodiments, the backbone network in the RWKV layer adopts a stacked residual block structure, each residual block includes a time mixing sub-block and a channel mixing sub-block; the time mixing sub-block is used to realize time mixing and interpolate between the current time step and the previous time step; the channel mixing sub-block is used to perform weighted mixing of the current time step and the previous time step, and obtain the final feature representation through linear projection.
[0084] Specifically, if Figure 4 As shown in the figure, the RWKV backbone adopts a stacked residual block structure, each block contains a time mixing sub-block and a channel mixing sub-block, and the time mixing sub-block has a trainable variable, μ r , μ k , μ v is used as the current time step x t and the previous time step x t-1 To achieve simple time mixing, at the current time step x t and the previous time step x t-1 The weight coefficient μ r , μ k , μ v They are used to control the gate vector r t , key vector k t , value vector v t The weighting of the input of the current and previous time steps. Through the linear projection matrix W r , W k , W v , these interpolated results can be mapped to the corresponding dimensions to generate the final output; the channel mixing sub-block operation is to perform a weighted mixing of the input features, and then obtain the final feature representation through linear projection. Specifically, the channel mixing sub-block uses similar weight coefficients μ′ r and μ′ k Interpolate the channel features of the current and previous time steps to generate the gating vector r′ on the channel t and key vector k′ t , these vectors are nonlinearly activated and then passed through the linear projection matrix W′ r and W′ k The final feature representation is generated. The difference is that the time mixing sub-block focuses on the combination of time steps, while the channel mixing sub-block focuses on the combination of feature channels. The combination of the two can better model the dependencies between features in the time and channel dimensions.
[0085] Specifically, optionally, the linear projection in the time mixing sub-block may be implemented according to the following formula:
[0086] r t =W r ·(μr ⊙x t +(1-μ r )⊙x t-1 );
[0087] k t =W k ·(μ k ⊙x t +(1-μ k )⊙x t-1 );
[0088] v t =W v ·(μ v ⊙x t +(1-μ v )⊙x t-1 ).
[0089] Specifically, the operation in the channel mixing sub-block can be implemented according to the following formula:
[0090] r′ t =W′ r ·(μ′ r ⊙x t +(1-μ′ r )⊙x t-1 );
[0091] k′ t =W′ k ·(μ′ k ⊙x t +(1-μ′ k )⊙x t-1 ).
[0092] Finally, the final traffic flow prediction result Y is as follows:
[0093] Y=W g ·X dscoder +b g
[0094] Where W g and b g are the weights and biases of the linear layer, X decoder is the output of the decoder layer.
[0095] Embodiment 3
[0096] Figure 5The schematic diagram of the hardware architecture of a computer device 10000 suitable for implementing the method for predicting traffic flow based on network reduction according to the third embodiment of the present application is shown schematically. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Figure 5 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them:
[0097] The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (such as an SD or DX memory), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 10010 may be an internal storage module of the computer device 10000, such as a hard disk or a memory of the computer device 10000. In other embodiments, the memory 10010 may also be an external storage device of the computer device 10000, such as a plug-in hard disk equipped on the computer device 10000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 10010 may also include both the internal storage module of the computer device 10000 and its external storage device. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed in the computer device 10000, such as the program code of the method for predicting traffic flow based on network reduction, etc. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.
[0098] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.
[0099] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0100] It should be pointed out that Figure 5 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0101] In this embodiment, the method for predicting traffic flow based on network reduction stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.
[0102] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by general-purpose computer devices, they can be concentrated on a single computer device, or distributed on a network composed of multiple computer devices, optionally, they can be implemented by executable program codes of computer devices, so that they can be stored in a storage device and executed by the computer device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0103] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for predicting traffic flow based on network reduction, characterized in that: The following steps are involved: S1. Using sensors to collect traffic flow data of continuous time steps in a designated road section and its vicinity, and preprocessing the acquired traffic flow data; S2. Use the preprocessed traffic flow data as input data and perform time embedding and space embedding on it to obtain a high-dimensional embedding vector, where time embedding is to add location information to the time dimension of the input data, and space embedding is to add location information to the space dimension of the input data; S3. Input the high-dimensional embedding vector into the traffic flow prediction model to predict the traffic flow prediction result corresponding to the specified road section, wherein the traffic flow prediction model includes L encoding layers and L decoder layers, L is an integer greater than or equal to 2, and one encoder layer is connected to one decoder layer, wherein each encoder layer includes a weighted key value RWKV layer and a graph convolutional network GCN attention layer, and each decoder layer includes two RWKV layers and one GCN attention layer.
2. The method according to claim 1, characterized in that The step of inputting the high-dimensional embedding vector into the traffic flow prediction model in S3 to predict the traffic flow prediction result corresponding to the specified road section includes: S3.1, encoding processing: In each encoder layer, the RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the first feature representation tensor, and then the GCN attention layer determines the intermediate representation sequence according to the first feature representation tensor; S3.2, decoding processing: In each decoder layer, the first RWKV layer first performs attention calculation on the high-dimensional embedding tensor to obtain the second feature representation tensor, and then the second RWKV layer performs attention calculation on the new representation sequence to obtain the third feature representation tensor. The new representation sequence is obtained by connecting the second feature representation tensor and the intermediate representation sequence. Finally, the GCN attention layer determines the traffic flow output sequence according to the third feature representation tensor; S3.3, Linear processing: Linearly process the traffic flow output sequences output by all encoder layers to obtain the traffic flow prediction results.
3. The method according to claim 2, characterized in that The backbone network in the RWKV layer adopts a stacked residual block structure, each residual block includes a time mixing sub-block and a channel mixing sub-block; the time mixing sub-block is used to realize time mixing and interpolate between the current time step and the previous time step; the channel mixing sub-block is used to perform weighted mixing of the current time step and the previous time step, and obtain the final feature representation through linear projection.
4. The method according to claim 1, characterized in that: The position information is the relative position relationship between nodes represented by node coordinates, and the nodes are divided according to designated road sections, with one designated road section being a node; In S2, the steps of using the preprocessed traffic flow data as input data to perform temporal embedding and spatial embedding to obtain a high-dimensional embedding vector specifically include: The relative position relationship between nodes is added to the preprocessed traffic flow data in the time dimension to obtain the time embedding vector; The relative position relationship between nodes is added to the preprocessed traffic flow data in the spatial dimension to obtain a spatial embedding vector; The temporal embedding vector and the spatial embedding vector are added together to obtain a high-dimensional embedding tensor.
5. The method according to claim 1, characterized in that The steps of preprocessing the collected traffic flow data in S1 specifically include: After normalizing the collected traffic flow data, the flow reading corresponding to each traffic flow data is obtained, and the time difference of the timestamp of each traffic flow data relative to midnight of the same day is converted into decimal form, and then the flow reading of each traffic flow data and the timestamp expressed in decimal form are connected together to obtain the processed traffic flow data.
6. The method according to claim 1, characterized in that The objective optimization function of the traffic flow prediction model is: Among them, loss is the target optimization function of the efficient traffic flow prediction model, N represents the number of samples, f represents the time step of prediction, and X t represents the input state at time step t, represents the prediction at time step t.
7. The method according to claim 1, characterized in that During the model training process of the traffic flow prediction model, the data set is divided into a training set, a validation set, and a test set in chronological order with a division ratio of 6:2:2 for training.
8. The method according to claim 1, characterized in that The value of L is 2 or 3.
9. The method according to claim 1, characterized in that: In S1, the traffic flow data is obtained from the LargeST benchmark dataset.
10. A device for predicting traffic flow based on network reduction, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
Citation Information
Cited By
End-to-end automatic driving method based on linear time complexity
CN120763872A
