Urban traffic flow prediction method based on deep learning
By constructing a multi-scale spatiotemporal memory network model and introducing external environmental factors, and combining knowledge distillation for model compression, the shortcomings of existing traffic flow prediction methods in multi-scale characteristics, multi-source data fusion and external environmental factors are solved, and more efficient and practical traffic flow prediction is achieved.
Patent Information
- Application Number
- CN202411881100.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-03-21
AI Technical Summary
The existing traffic flow prediction methods are difficult to effectively deal with multi-scale spatio-temporal characteristics, multi-source heterogeneous data fusion and external environmental factors, resulting in insufficient prediction accuracy and applicability, and large model complexity and computing overhead, making it difficult to meet real-time requirements.
The urban traffic flow prediction method based on deep learning is adopted, and a multi-scale spatio-temporal memory network model is constructed through real-time traffic data acquisition and fusion, an Attention mechanism and multi-modal external environment data are introduced, and a knowledge distillation is used for model compression to form a full-process traffic flow prediction solution.
It significantly improves the accuracy, real-time and applicability of traffic flow prediction, and can more comprehensively and accurately capture multi-scale spatiotemporal characteristics and external environmental factors in traffic data, reduces the parameter quantity and calculation complexity of the model, and is suitable for engineering deployment.
Smart Images

Figure CN119672957A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent transportation technology, and in particular to a method for predicting urban traffic flow based on deep learning. Background Art
[0002] With the acceleration of urbanization and the continuous growth of motor vehicle ownership, urban traffic congestion is becoming increasingly serious. Accurate traffic flow prediction is of great significance for urban traffic management and planning. At present, traffic flow prediction methods mainly include the following categories:
[0003] Traditional statistical methods are mainly based on time series models, such as the autoregressive moving average model (ARIMA), Kalman filtering, etc. These methods are simple to calculate, but difficult to handle nonlinear characteristics, and cannot effectively capture the long-term dependence of traffic flow, and the prediction accuracy is limited.
[0004] Machine learning-based methods, such as support vector machines (SVMs) and random forests, can handle nonlinear features, but they are not good at modeling time series data and cannot fully utilize the time-dependent features in historical data. These methods perform poorly when dealing with long-series prediction tasks.
[0005] In recent years, deep learning methods have shown good results in the field of traffic flow prediction. Recurrent neural networks (RNN) and their variants, long short-term memory networks (LSTM), can effectively process time series data, but existing methods still have the following shortcomings: most methods only focus on traffic characteristics at a single time scale, ignoring the regularity of traffic flow at different time scales, such as intraday fluctuations, weekday-weekend differences and other periodic characteristics; the fusion of multi-source heterogeneous traffic data is not sufficient, and traffic data from different sources such as GPS, video surveillance, and road tests cannot be effectively integrated, affecting the accuracy and robustness of the prediction; the lack of consideration of external environmental factors such as weather, road network structure, and distribution of points of interest leads to insufficient adaptability of the model in complex scenarios; the model structure is complex and the computational overhead is large, making it difficult to meet the real-time requirements in actual engineering deployment.
[0006] Therefore, there is an urgent need for a traffic flow prediction method that can comprehensively consider multi-scale spatiotemporal characteristics, multi-source data fusion, external environmental factors, and model efficiency, in order to improve the accuracy and practicality of the prediction. Summary of the invention
[0007] The present invention discloses a method for predicting urban traffic flow based on deep learning. The method integrates key technologies such as real-time traffic data perception, spatiotemporal traffic feature extraction, consideration of the impact of external environmental factors, and lightweight model design, forming a full-process solution from data collection, feature learning, multimodal fusion to model compression and engineering deployment. The method can significantly improve the accuracy, real-time and applicability of traffic flow prediction, and provide key support for intelligent traffic control.
[0008] Specifically, the method of the present invention comprises the following steps:
[0009] Step 1: Real-time traffic data collection and fusion. Multi-source heterogeneous traffic data is obtained by accessing vehicle-mounted GPS devices, road test equipment, and traffic monitoring videos, and pre-processing steps such as data cleaning, spatiotemporal alignment, and feature extraction are performed. Then, data fusion algorithms such as Kalman filtering and Bayesian inference are used to integrate multi-source data to obtain a unified, comprehensive and accurate representation of the real-time traffic status of the road network, forming real-time traffic flow data.
[0010] Step 2: Construct a multi-scale spatiotemporal memory network model. The model contains three LSTM units of different scales: LocalLSTM unit models short-term changes in traffic flow with a time step of 5-10 minutes, DailyLSTM unit models medium-term periodic changes in traffic flow with a time step of 1 day, and WeeklyLSTM unit models long-term changes in traffic flow with a time step of 1 week. The three LSTM units correspond to three hidden layers to extract and memorize the characteristics of traffic flow changes at different spatiotemporal scales. At each time step, the real-time traffic flow data is input into the three LSTM units for feature extraction to obtain hidden state vectors of three scales.
[0011] Step 3: Introduce the Attention mechanism to adaptively fuse the multi-scale hidden state vectors. The weight coefficients of the hidden states of each scale are calculated through Attention and weighted summation to obtain the fused hidden state vector, which takes into account the traffic characteristics of different spatiotemporal scales and can be adaptively adjusted according to the current traffic conditions to form a hierarchical, progressive, fused and complementary spatiotemporal memory representation.
[0012] Step 4: Introduce multimodal external environment data into the model. Collect various heterogeneous data such as weather, road network structure, and points of interest (POI), map them to a low-dimensional semantic space through representation learning methods such as graph embedding and topic model, and obtain feature vectors that represent external factors. At each time step, concatenate the feature vector with the fused hidden state vector in step 3 to form a comprehensive feature representation, which is input into the fully connected layer for traffic flow prediction.
[0013] Step 5: Model training and compression. The multi-scale spatiotemporal memory network is trained end-to-end using historical traffic data, using the mean square error loss function and L1 regularization. After training, the model is compressed using knowledge distillation technology. The trained teacher model is fixed, and a student model with fewer parameters is designed to fit the output of the teacher model, so that it can learn the prediction ability of the teacher model and obtain a compressed lightweight traffic flow prediction model.
[0014] Step 6: Online prediction. Deploy the compressed model to the online service, receive the integrated road network traffic status data in real time, generate traffic flow forecast results for the next hour every 5-10 minutes, and perform early warning, traffic guidance, signal light optimization control and other applications based on this.
[0015] Compared with the prior art, the present invention has the following beneficial effects:
[0016] By integrating multi-source heterogeneous traffic data such as vehicle-mounted GPS, road test radar, and video surveillance, and introducing data fusion algorithms, we can obtain a more comprehensive and accurate perception of the real-time traffic status of the road network, laying a data foundation for subsequent predictions.
[0017] The proposed multi-scale spatiotemporal memory network can model the temporal correlation and spatial dependence of traffic flow at local, daily, and weekly scales, and adaptively fuse them through the Attention mechanism. It can fully mine and utilize the multi-scale spatiotemporal characteristics contained in traffic data and significantly improve the accuracy of prediction.
[0018] Taking into account multimodal external environmental factors such as weather, road network, and points of interest into the model can expand the model's modeling capabilities for complex traffic environments and improve the applicability and robustness of the prediction.
[0019] Knowledge distillation is used to compress the model, which greatly reduces the number of model parameters and computational complexity while ensuring accuracy, making it easier to deploy in projects and having better real-time performance.
[0020] A full-process solution has been formed from data perception, feature extraction, cross-modal fusion, model training and optimization to engineering implementation, which can provide end-to-end key technical support for the smart transportation industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 It is a schematic diagram of real-time traffic data collection and fusion of the present invention;
[0023] Figure 2 It is a schematic diagram of the overall system architecture of the present invention;
[0024] Figure 3 A schematic diagram of the data preprocessing process for creating the present invention;
[0025] Figure 4 A schematic diagram of the structure of a multi-scale LSTM model is created for the present invention;
[0026] Figure 5 A schematic diagram of the model training and compression process of the present invention;
[0027] Figure 6 A schematic diagram of the process of creating an online prediction service according to the present invention. DETAILED DESCRIPTION
[0028] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. At the same time, it is explained here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement some known technologies; and the accompanying drawings are only for more specific description of the embodiments, and are not intended to specifically limit the present invention.
[0029] It should be noted that the references to "one embodiment", "an embodiment", "an exemplary embodiment", "some embodiments" and the like in the specification indicate that the embodiments described may include specific features, structures or characteristics, but not every embodiment may include the specific features, structures or characteristics. In addition, when a specific feature, structure or characteristic is described in conjunction with an embodiment, it should be within the knowledge of a person skilled in the art to implement such feature, structure or characteristic in conjunction with other embodiments (whether or not explicitly described).
[0030] In general, a term can be understood, at least in part, from its use in context. For example, depending, at least in part, on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending, at least in part, on the context, allow for the presence of other factors that are not necessarily explicitly described.
[0031] A method for predicting urban traffic flow based on deep learning, comprising the following steps:
[0032] like Figures 1 to 3As shown in the figure, step 1: real-time traffic data collection and fusion. Multi-source heterogeneous traffic data is obtained by accessing vehicle-mounted GPS equipment, road test equipment and traffic monitoring videos, and pre-processing steps such as data cleaning, spatiotemporal alignment and feature extraction are performed. Then, data fusion algorithms such as Kalman filtering and Bayesian inference are used to integrate multi-source data to obtain a unified, comprehensive and accurate representation of the real-time traffic status of the road network, forming real-time traffic flow data.
[0033] like Figure 4 As shown, step 2: construct a multi-scale spatiotemporal memory network model. The model contains three LSTM units of different scales:
[0034] (1) LocalLSTM unit, with a time step of 5-10 minutes, models the short-term trend of traffic flow;
[0035] (2) DailyLSTM unit, with a time step of 1 day, models the periodic variation of traffic flow on a medium-term scale;
[0036] (3) WeeklyLSTM unit, with a time step of 1 week, models the changing pattern of traffic flow on a long-term scale.
[0037] The three LSTM units correspond to three different hidden layers, which can extract and memorize the traffic flow change characteristics at different time and space scales. At each time step, the real-time traffic flow data is input into the three LSTM units for feature extraction to obtain the hidden state vectors of three scales.
[0038] Step 3: Introduce the Attention mechanism to adaptively fuse the multi-scale hidden state vectors. The weight coefficients of the hidden states of each scale are calculated by Attention, and then the weighted sum is performed to obtain the fused hidden state vector, which not only takes into account the traffic characteristics of different spatiotemporal scales, but also can be adaptively adjusted according to the current traffic conditions, forming a hierarchical, progressive, fused and complementary spatiotemporal memory representation.
[0039] Step 4: Introduce multimodal external environment data into the model. Collect various heterogeneous data such as weather, road network structure, and points of interest (POI), map them to a low-dimensional semantic space through representation learning methods such as graph embedding and topic model, and obtain feature vectors representing external factors. At each time step, concatenate the feature vector with the fused hidden state vector obtained in step 3 to form a comprehensive feature representation that includes internal and external influencing factors, and input it into the fully connected layer for traffic flow prediction.
[0040] like Figure 5As shown in Figure 5, step 5: model training and compression. The multi-scale spatiotemporal memory network is trained end-to-end using historical traffic data, using mean square error as the loss function, and adding L1 regularization to enhance model sparsity. After training, the model is compressed using knowledge distillation technology. Specifically, the above-trained multi-scale spatiotemporal memory network is fixed as the teacher model, and a student model with fewer parameters (such as halving the number of LSTM units) is designed. The student model is trained to fit the output of the teacher model so that it can learn the prediction ability of the teacher model and obtain a compressed lightweight traffic flow prediction model.
[0041] like Figure 6 As shown, step 6: online prediction. Deploy the compressed prediction model to the online service, receive the road network traffic status data integrated in step 1 in real time, generate traffic flow prediction results for the next hour every 5-10 minutes, and perform early warning, traffic guidance, and traffic light optimization control based on the prediction results.
[0042] The above is a complete implementation of the present invention. By integrating real-time traffic data, building a multi-scale spatiotemporal memory network, introducing external environmental factors, and adopting key technical links such as model compression, a full-process traffic flow prediction solution is formed. Ordinary technicians in this field can refer to the above content, reasonably set and optimize the neural network structure and model parameters according to actual needs, and write code for engineering implementation, and finally obtain a complete and usable traffic flow prediction system, which provides important data support for the application of smart transportation industry.
[0043] Example 1
[0044] A city has 1,000 intersections, each of which is equipped with vehicle-mounted GPS devices, road test radars, and high-definition cameras. These devices can collect vehicle trajectory data, vehicle speed data, queue length data, and intersection video image data. The above multi-source data is transmitted to the data center in real time via wired / wireless networks.
[0045] In the data center, the heterogeneous data is first preprocessed. The vehicle trajectory data is mapped and mapped to the road section to associate it with the road network topology; the speed data is synchronized in time and space to unify the time and space granularity; the video data is subjected to lane line detection and vehicle recognition to extract traffic flow and speed information. Then, information fusion algorithms such as multi-sensor Kalman filtering are used to consider the confidence of each data source, and the fusion estimation of traffic parameters such as vehicle speed and traffic flow is realized to obtain traffic flow status data of 1,000 intersections with a granularity of every 5 minutes.
[0046] Next, the data is used to train a multi-scale spatiotemporal memory network model. The model input is a 1000-dimensional intersection traffic flow vector and a traffic sequence of the past three time windows (current, previous 5 minutes, and previous 10 minutes). The LocalLSTM unit has 128 neurons, the DailyLSTM unit has 256 neurons, and the WeeklyLSTM unit has 64 neurons. The Attention layer receives the hidden states of the three LSTM units, calculates the fusion weight vector, and weights the three hidden states into a 256-dimensional spatiotemporal memory representation vector.
[0047] At the same time, the meteorological data (temperature, humidity, visibility, etc.), road network structure data (road length, width, speed limit, etc.), and point of interest data (business districts, schools, hospitals, etc.) of city C in the past year are collected, and the 64-dimensional external environment topic vector is obtained through the topic model LDA learning. At each time step, the topic vector is concatenated with the 256-dimensional hidden state vector fused with LSTM, input into the fully connected layer with 512 neurons, and then the traffic flow forecast values of 1000 intersections in 6 time slices in the next 1 hour are output.
[0048] The Adam optimization algorithm is used to train the model, with a batch size of 128 and a learning rate of 0.001. The model converges after 500 epochs. On the test set, the average MAE of multi-step prediction is 12.5 vehicles / 5 minutes, and the MAPE is 8.7%, which is better than other mainstream methods.
[0049] like Figure 5 As shown in the figure, in order to improve the efficiency of the model, the teacher-student knowledge distillation method is used to compress the model. Design the student model: the number of neurons in the three LSTM units is halved, and the number of neurons in the Attention layer and the fully connected layer is reduced to 1 / 4 of the original. The parameters of the teacher model are fixed, and the softened teacher model output is used as the soft target to train the student model. After distillation, the number of parameters of the student model is only 28% of that of the teacher model, but the performance decreases by no more than 1 percentage point, and the prediction speed is increased by 2.5 times.
[0050] Finally, the compressed student model is used as an online prediction service model. When the data center generates a 5-minute granularity real-time traffic flow status data of 1,000 intersections, it is immediately input into the model for prediction, and the traffic flow prediction results for 6 time slices in the next hour can be obtained within 10 seconds. The background automatically compares the predicted value with the national standard, and the road sections where the predicted flow exceeds the threshold are marked in red on the road heat map and generate warning information, which is sent to the traffic management department for reference; at the same time, combined with the road network structure and traffic flow prediction results, regional traffic demand estimation and overflow analysis are carried out, and the signal light timing plan in the next hour in key areas is optimized and adjusted. Through timely warning and active regulation, the city's traffic congestion situation has been significantly alleviated and traffic operation efficiency has been improved.
[0051] The above embodiments describe in detail the whole process of data collection, model training, model compression and model deployment of the present invention, reflecting the key ideas of integrating heterogeneous traffic data, mining spatiotemporal dependencies, considering external environmental impacts, and improving model practicality, and finally forming a complete and efficient end-to-end traffic flow prediction solution. Those skilled in the art can implement the present invention by referring to the above content, which has broad application prospects in the field of smart transportation.
[0052] The present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, but those skilled in the art can fully understand the present invention without the description of these details. In addition, in order to avoid unnecessary confusion about the essence of the present invention, well-known methods, processes, procedures, components and circuits are not described in detail.
[0053] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for predicting urban traffic flow based on deep learning, characterized by , including the following steps: S1. Real-time traffic data collection and fusion: Multi-source heterogeneous traffic data is obtained through vehicle-mounted GPS equipment, road test equipment and traffic monitoring videos. After data cleaning, spatiotemporal alignment and feature extraction preprocessing, Kalman filtering and Bayesian inference data fusion algorithms are used to integrate multi-source data to obtain a unified representation of the real-time traffic status of the road network and form real-time traffic flow data; S2. Construct a multi-scale spatiotemporal memory network model: The model contains three LSTM units of different scales. The LocalLSTM unit models the short-term changes of traffic flow with a time step of 5-10 minutes, the DailyLSTM unit models the medium-term periodic changes of traffic flow with a time step of 1 day, and the WeeklyLSTM unit models the long-term change pattern of traffic flow with a time step of 1 week. The three LSTM units correspond to three hidden layers to extract and memorize the characteristics of traffic flow changes at different spatiotemporal scales. At each time step, the real-time traffic flow data is input into the three LSTM units for feature extraction to obtain hidden state vectors of three scales. S3. Introduce the Attention mechanism to adaptively fuse the multi-scale hidden state vectors: use Attention to calculate the weight coefficients of the hidden states of each scale and perform weighted summation to obtain the fused hidden state vector; S4, introduce multimodal external environment data into the model: collect various heterogeneous data such as weather, road network structure, and points of interest (POI), map them to low-dimensional semantic space through representation learning methods such as graph embedding and topic model, and obtain feature vectors representing external factors; at each time step, concatenate the feature vector with the fused hidden state vector of step 3 to form a comprehensive feature representation, and input it into the fully connected layer for traffic flow prediction; S5. Model training and compression: Use historical traffic data to perform end-to-end training on the multi-scale spatiotemporal memory network, using the mean square error loss function and L1 regularization; after training, use knowledge distillation technology to compress the model, fix the trained teacher model, design a student model with fewer parameters to fit the teacher model output, and obtain a compressed lightweight traffic flow prediction model; S6. Online prediction: Deploy the compressed model to the online service, receive the integrated road network traffic status data in real time, generate traffic flow forecast results for the next hour every 5-10 minutes, and perform early warning, traffic induction, and traffic light optimization control based on this.
2. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,The data fusion algorithm in step 1 includes one or more of multi-sensor Kalman filtering, Bayesian inference, Dempster-Shafer evidence theory, and adaptive weight fusion.
3. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,In step 2, the LocalLSTM unit has a time step of 5-10 minutes, the DailyLSTM unit has a time step of 1 day, and the WeeklyLSTM unit has a time step of 1 week.
4. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,In step 2, the three LSTM units use 128, 256 and 64 neurons respectively.
5. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,In step 3, the Attention layer receives the hidden states of the three LSTM units and ,calculates the Attention weights, and uses weighted summation to fuse the three hidden states into a 256-dimensional ,spatial-temporal memory representation vector.
6. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,In step 4, the heterogeneous external environment data includes meteorological data, ,road network structure data and point of interest POI data, which are ,mapped to a 64-dimensional external environment topic vector using the ,topic model LDA.
7. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,In step 4, the external environment theme vector is concatenated with the 256-dimensional spatiotemporal memory representation vector in step 3 and then input into a fully connected layer containing 512 neurons.
8. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,Step 5 uses the Adam optimization algorithm to train the model, with a batch size of 128, a learning rate of 0.001, and training for 500 epochs until the model converges.
9. The urban traffic flow prediction method based on deep learning according to claim 1 is characterized in that ,The student model of knowledge distillation in step 5 reduces the number of neurons in the three LSTM units by half, and the number of neurons in the Attention layer and the fully connected layer is reduced to 1 / 4 of the original.
10. A city traffic flow prediction system based on deep learning, characterized by ,including multi-source heterogeneous traffic data acquisition module, data preprocessing and fusion module, multi-scale spatiotemporal memory network model, model training and compression module and online prediction service module; The multi-source heterogeneous traffic data acquisition module is used to obtain vehicle-mounted GPS data, road test equipment data and traffic monitoring video data; The data preprocessing and fusion module is used to clean, align space-time, extract features and fuse multi-source heterogeneous traffic data; the multi-scale space-time memory network model is used to extract and fuse multi-scale space-time traffic features and introduce external environmental factors; the model training and compression module is used to train and optimize the multi-scale space-time memory network and use knowledge distillation to compress the model; the online prediction service module is used to deploy lightweight prediction models online to provide real-time traffic flow prediction services.
Citation Information
Cited By
Dynamic traffic signal control method and device based on data fusion and medium
CN119992852A
Large-scale road network traffic control method based on deep reinforcement learning large model
CN120954238A