Traffic flow prediction method and device, electronic equipment and storage medium

By introducing transfer learning and deep knowledge distillation mechanisms into the traffic flow prediction model, freezing the encoder and decoder parameters, and fine-tuning only the output layer, the problem of insufficient generalization ability of cross-regional traffic flow prediction models is solved, achieving high-precision and efficient traffic flow prediction.

CN122050132APending Publication Date: 2026-05-15TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2026-02-03
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing traffic flow prediction models have poor generalization ability and low prediction accuracy when applied across regions, especially in areas with heterogeneous data distribution and sparse perception.

Method used

By constructing road network maps of data-rich areas and data-incomplete areas, and utilizing transfer learning and deep knowledge distillation mechanisms, the encoder and decoder parameters of the model are frozen, and only the output layer is fine-tuned, enabling the model to quickly adapt to the target area.

Benefits of technology

It improves the model's prediction accuracy and generalization ability in areas with incomplete data, reduces training time, and enhances the model's robustness and adaptability, making it suitable for short-term traffic flow prediction in complex traffic scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122050132A_ABST
    Figure CN122050132A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of traffic flow prediction, in particular to a traffic flow prediction method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining road connection data and sensor data of a first region and a second region, respectively constructing a first road network map of the first area and a second road network map of the second area based on the road connection data and the sensor data; training a traffic flow prediction model corresponding to the first region by using the first data set of the first region and the first road network map to obtain a first traffic flow prediction model; and migrating model parameters of the first traffic flow model to a traffic flow prediction model corresponding to a second area, training the traffic flow prediction model corresponding to the second area by using a second data set and a second road network map of the second area to obtain a second traffic flow prediction model, and keeping the model parameters unchanged in the model training process. Adjusting model parameters of a model output layer; and predicting second area traffic flow data by using the second traffic flow prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of traffic flow prediction technology, and in particular to a traffic flow prediction method, apparatus, electronic device and storage medium. Background Technology

[0002] In modern urban intelligent traffic management, accurate perception and situational prediction of road network operation status (traffic flow, speed, etc.) are prerequisites for optimized traffic light control and route guidance.

[0003] Related technologies rely on high-density roadside sensing devices to construct road network topology maps and combine graph theory models to extract spatiotemporal correlation features. However, in actual deployment and maintenance, low-sensing-density areas exist in newly built and expanded urban areas, urban-rural fringe areas, and equipment maintenance sections, making it difficult to guarantee the integrity of road network data. Predictive models trained in high-density sensing areas cannot adapt to sparsely sensed local road networks due to the statistical heterogeneity of data distribution, resulting in large errors in traffic parameter extrapolation. Summary of the Invention

[0004] This application provides a traffic flow prediction method, apparatus, electronic device, and storage medium to solve the problems of poor generalization ability and low prediction accuracy of traffic flow prediction models in related technologies.

[0005] The first aspect of this application provides a traffic flow prediction method, comprising the following steps: acquiring road connection data and sensor data for a first region and a second region respectively, and constructing a first road network map for the first region and a second road network map for the second region based on the corresponding road connection data and sensor data for the first and second regions respectively; acquiring a first dataset for the first region and a second dataset for the second region; training a traffic flow prediction model for the first region using the first dataset and the first road network map to obtain a first traffic flow prediction model; transferring the model parameters of the first traffic flow model to the traffic flow prediction model for the second region, and training the traffic flow prediction model for the second region using the second dataset and the second road network map to obtain a second traffic flow prediction model; during model training, keeping the model parameters of other layers of the model unchanged, and adjusting the model parameters of the output layer of the model; and using the second traffic flow prediction model to predict traffic flow data for a future target time period in the second region.

[0006] Optionally, the dataset includes historical traffic flow sequences and corresponding real traffic flow data. The traffic flow prediction model includes a network layer and an output layer. The network layer includes a first sub-network and a second sub-network in parallel. The first and second sub-networks have the same structure, including an encoder and a decoder. The encoder processes the road network map and historical traffic flow sequences to obtain a first feature vector. The decoder processes the road network map and the first feature vector to obtain a second feature vector. The output layer performs a linear mapping on the second feature vector output by the first and second sub-networks to obtain the predicted traffic flow data for the future target time period.

[0007] Optionally, the encoder and decoder have the same structure, including a diffusion graph convolutional layer and a gated recurrent unit layer. The diffusion graph convolutional layer in the encoder is used to extract spatial features of the road network map to obtain a spatial feature matrix. The gated recurrent unit layer in the encoder encodes historical traffic flow sequences to obtain a first temporal feature matrix. The spatial feature matrix and the first temporal feature matrix are fused to generate a first feature vector. The gated recurrent unit layer in the decoder performs temporal reconstruction on the first feature vector to obtain a second temporal feature matrix. The diffusion graph convolutional layer in the decoder performs spatial constraint processing on the road network map to obtain a spatial constraint matrix. The spatial constraint matrix and the second temporal feature matrix are fused to generate a second feature vector.

[0008] Optionally, a knowledge distillation module is provided between the first subnetwork and the second subnetwork. The knowledge distillation module is used to achieve collaborative optimization of the first subnetwork and the second subnetwork based on mutual learning mechanism and self-distillation mechanism during the training process of the traffic flow prediction model corresponding to the first region.

[0009] Optionally, during the training of the traffic flow prediction model corresponding to the first region and the traffic flow prediction model corresponding to the second region, the model parameters of the traffic flow prediction model are optimized based on backpropagation using the objective loss function. The objective loss function includes a first sub-loss function, a second sub-loss function, and a third sub-loss function. The first sub-loss function is used to measure the deviation between the predicted traffic flow data and the true traffic flow data. The second sub-loss function is used to measure the relative entropy divergence between the output probability distributions of the first sub-network and the second sub-network. The third sub-loss function is used to calculate the feature distribution difference between the first feature vector and the second feature vector of each of the first sub-network and the second sub-network, as well as the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network.

[0010] Optionally, it also includes: obtaining the training convergence state index of the traffic flow prediction model during the training process; and adjusting the weights of the first sub-loss function, the second sub-loss function, and the third sub-loss function according to the training convergence state index.

[0011] Optionally, based on the road connection data and sensor data corresponding to the first and second regions, a first road network map of the first region and a second road network map of the second region are constructed respectively, including: identifying the location coordinates of multiple sensors in the sensor data corresponding to each region, and abstracting each sensor as a node; constructing edges between nodes based on the road connection data of each region; calculating the Euclidean distance between every two nodes based on the location coordinates of the sensors, calculating the weight between every two nodes based on the Euclidean distance, and constructing a weighted adjacency matrix based on the weights; and constructing the road network map of the corresponding region based on the multiple nodes, the edges between nodes, and the weighted adjacency matrix.

[0012] A second aspect of this application provides a traffic flow prediction device, comprising: a construction module, configured to acquire road connection data and sensor data of a first region and a second region respectively, and construct a first road network map of the first region and a second road network map of the second region based on the corresponding road connection data and sensor data of the first region and the second region respectively; an acquisition module, configured to acquire a first dataset of the first region and a second dataset of the second region; a training module, configured to train a traffic flow prediction model corresponding to the first region using the first dataset and the first road network map to obtain a first traffic flow prediction model; a transfer module, configured to transfer the model parameters of the first traffic flow model to the traffic flow prediction model corresponding to the second region, train the traffic flow prediction model corresponding to the second region using the second dataset and the second road network map to obtain a second traffic flow prediction model, wherein during the model training process, the model parameters of other layers of the model remain unchanged, and the model parameters of the output layer of the model are adjusted; and a prediction module, configured to predict traffic flow data of the second region for a future target time period using the second traffic flow prediction model.

[0013] Optionally, the dataset includes historical traffic flow sequences and corresponding real traffic flow data. The traffic flow prediction model includes a network layer and an output layer. The network layer includes a first sub-network and a second sub-network in parallel. The first and second sub-networks have the same structure, including an encoder and a decoder. The encoder processes the road network map and historical traffic flow sequences to obtain a first feature vector. The decoder processes the road network map and the first feature vector to obtain a second feature vector. The output layer performs a linear mapping on the second feature vector output by the first and second sub-networks to obtain the predicted traffic flow data for the future target time period.

[0014] Optionally, the encoder and decoder have the same structure, including a diffusion graph convolutional layer and a gated recurrent unit layer. The diffusion graph convolutional layer in the encoder is used to extract spatial features of the road network map to obtain a spatial feature matrix. The gated recurrent unit layer in the encoder encodes historical traffic flow sequences to obtain a first temporal feature matrix. The spatial feature matrix and the first temporal feature matrix are fused to generate a first feature vector. The gated recurrent unit layer in the decoder performs temporal reconstruction on the first feature vector to obtain a second temporal feature matrix. The diffusion graph convolutional layer in the decoder performs spatial constraint processing on the road network map to obtain a spatial constraint matrix. The spatial constraint matrix and the second temporal feature matrix are fused to generate a second feature vector.

[0015] Optionally, a knowledge distillation module is provided between the first subnetwork and the second subnetwork. The knowledge distillation module is used to achieve collaborative optimization of the first subnetwork and the second subnetwork based on mutual learning mechanism and self-distillation mechanism during the training process of the traffic flow prediction model corresponding to the first region.

[0016] Optionally, during the training of the traffic flow prediction model corresponding to the first region and the traffic flow prediction model corresponding to the second region, the model parameters of the traffic flow prediction model are optimized based on backpropagation using the objective loss function. The objective loss function includes a first sub-loss function, a second sub-loss function, and a third sub-loss function. The first sub-loss function is used to measure the deviation between the predicted traffic flow data and the true traffic flow data. The second sub-loss function is used to measure the relative entropy divergence between the output probability distributions of the first sub-network and the second sub-network. The third sub-loss function is used to calculate the feature distribution difference between the first feature vector and the second feature vector of each of the first sub-network and the second sub-network, as well as the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network.

[0017] Optionally, it also includes: an adjustment module for obtaining the training convergence state index of the traffic flow prediction model during the training process; and adjusting the weights of the first sub-loss function, the second sub-loss function, and the third sub-loss function according to the training convergence state index.

[0018] Optionally, the construction module is further used to: identify the location coordinates of multiple sensors in the sensor data corresponding to each region, and abstract each sensor as a node; construct the edges between nodes based on the road connection data of each region; calculate the Euclidean distance between every two nodes based on the location coordinates of the sensors, calculate the weight between every two nodes based on the Euclidean distance, construct a weighted adjacency matrix based on the weights; and construct the road network map of the corresponding region based on multiple nodes, the edges between nodes, and the weighted adjacency matrix.

[0019] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the traffic flow prediction method as described above.

[0020] A fourth aspect of this application provides a computer-readable storage medium having a computer program or instructions stored thereon, which are executed by a processor to perform the traffic flow prediction method as described above.

[0021] Therefore, this application has at least the following beneficial effects: This application's embodiments can construct a first road network map of a data-rich first region and a second road network map of a data-incomplete second region. A traffic flow prediction model is trained based on the first dataset and the first road network map of the first region. The trained traffic flow model is then transferred to the second region, keeping other layer parameters unchanged. Only the output layer of the model is adjusted based on the second dataset and the second road network map of the second region, reducing convergence time and improving training efficiency. Finally, the adjusted traffic flow prediction model from the second region is used to predict traffic flow in the second region. This transfer learning approach allows for model adaptation with only a small amount of data from the second region, solving the problem of difficulty in modeling newly built urban areas or regions with missing data. It maintains stable prediction performance even in data-incomplete scenarios, improving the model's generalization ability. Therefore, it solves the technical problems of poor generalization ability and low prediction accuracy in related technologies for traffic flow prediction models.

[0022] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0023] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 Here is a flowchart of the traffic flow prediction method provided according to the embodiments of this application; Figure 2 This is a diagram illustrating the architecture of the traffic flow prediction model provided according to an embodiment of this application. Figure 3 This is a schematic diagram illustrating the training of the objective loss function for the traffic flow prediction model provided in the embodiments of this application; Figure 4 This is a schematic diagram illustrating the migration and fine-tuning of the traffic flow prediction model provided in the embodiments of this application; Figure 5 This is an example diagram of a traffic flow prediction device provided according to an embodiment of this application; Figure 6This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation

[0024] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0025] Currently, solutions to cross-regional data adaptation problems often suffer from an over-reliance on massive amounts of labeled data. Furthermore, model fine-tuning schemes in related technologies typically require a certain scale of historical data accumulation in the target region, which can easily disrupt the general spatiotemporal paradigm learned by the model during training. Therefore, the main problems with these technologies are insufficient cross-regional generalization ability and excessive dependence on data distribution.

[0026] To address this, this application proposes a traffic flow prediction method. By introducing encoder-decoder parameter freezing and deep knowledge distillation mechanisms, the robustness and adaptability of the model under conditions of incomplete data are enhanced. This method can achieve relatively accurate short-term traffic flow prediction in complex traffic scenarios where historical data is scarce in the target area, demonstrating good adaptability and robustness, and enabling more accurate and reliable cross-regional traffic flow prediction. Simultaneously, through an effective transfer learning mechanism, the reliance on data from areas with incomplete data is effectively reduced, providing reliable technical support for cross-regional intelligent traffic management and planning.

[0027] Specifically, Figure 1 This is a flowchart illustrating a traffic flow prediction method provided in an embodiment of this application.

[0028] like Figure 1 As shown, the traffic flow prediction method includes the following steps: In step S101, road connection data and sensor data of the first region and the second region are acquired respectively, and based on the road connection data and sensor data of the first region and the second region, a first road network map of the first region and a second road network map of the second region are constructed respectively.

[0029] The first region can be a region with abundant data, and the second region can be a region with incomplete data; the road connection data is the connection relationship between actual roads; the sensor data includes the location and number of sensors, and the sensors can be roadside detectors.

[0030] It is understood that the embodiments of this application can obtain road connection data and sensor data of the first region and the second region respectively, and construct a first road network map of the first region and a second road network map of the second region based on the corresponding road connection data and sensor data of the first region and the second region respectively, so as to be used for subsequent model training and practical application.

[0031] In one embodiment of this application, a first road network map of the first region and a second road network map of the second region are constructed based on road connection data and sensor data corresponding to the first and second regions, respectively. The method includes: identifying the position coordinates of multiple sensors in the sensor data corresponding to each region, and abstracting each sensor as a node; constructing edges between nodes based on the road connection data of each region; calculating the Euclidean distance between every two nodes based on the position coordinates of the sensors, calculating the weight between every two nodes based on the Euclidean distance, and constructing a weighted adjacency matrix based on the weights; and constructing a road network map of the corresponding region based on the multiple nodes, the edges between nodes, and the weighted adjacency matrix.

[0032] Specifically, to facilitate computer understanding of the spatial structure of roads, this application first collects geographic coordinate data from sensor data in the first and second regions. Each roadside detector is abstracted as a node in a graph structure, and edges between nodes are defined based on actual road connectivity. To accurately quantify the spatial dependence strength between nodes, this application uses a distance-based Gaussian kernel function to calculate the weights of the adjacency matrix. The calculation logic involves calculating the Euclidean distance between two sensor nodes, normalizing it by dividing it by a preset distance standard deviation, and finally obtaining the weight values ​​through an exponential function. Ultimately, the road network is abstracted as a graph structure G=(V,E,W), where V represents the set of detector nodes, E represents the set of edges, and W represents the weighted adjacency matrix constructed based on the geographic geodesic distance between nodes.

[0033] In step S102, the first dataset of the first region and the second dataset of the second region are obtained; the traffic flow prediction model corresponding to the first region is trained using the first dataset and the first road network map to obtain the first traffic flow prediction model.

[0034] The dataset includes historical traffic flow sequences and corresponding real traffic flow data, including speed, flow rate, and time occupancy.

[0035] It is understood that, in the embodiments of this application, a traffic flow prediction model corresponding to a first region can be trained using a first dataset and a first road network map to obtain a trained first traffic flow prediction model.

[0036] It should be noted that the data in the dataset of this application embodiment has undergone preprocessing. Specifically, linear interpolation is used to fill in data missing due to equipment failure during the acquisition process, and smoothing filtering algorithms are used to remove abrupt noise. Subsequently, all data are Z-score standardized to eliminate the influence of different units on the model convergence speed.

[0037] In one embodiment of this application, the traffic flow prediction model includes a network layer and an output layer. The network layer includes a first sub-network and a second sub-network in parallel. The first and second sub-networks have the same structure, including an encoder and a decoder. The encoder processes the road network map and historical traffic flow sequences to obtain a first feature vector. The decoder processes the road network map and the first feature vector to obtain a second feature vector. The output layer performs a linear mapping on the second feature vector output by the first and second sub-networks to obtain predicted traffic flow data for the future target time period.

[0038] like Figure 2 As shown, the traffic flow prediction model in this embodiment includes a network layer and an output layer. The network layer contains two parallel sub-networks with identical structures: a first sub-network (network 1) and a second sub-network (network 2). Each sub-network is designed as a sequence-to-sequence encoder-decoder construction. The encoder processes the road network map and historical traffic flow sequences to obtain a first feature vector. The decoder processes the road network map and the first feature vector to obtain a second feature vector. The output layer performs a linear mapping on the second feature vectors output by the first and second sub-networks to obtain predicted traffic flow data for the future target time period.

[0039] In one embodiment of this application, the encoder and decoder have the same structure, including a diffusion graph convolutional layer and a gated recurrent unit layer. The diffusion graph convolutional layer in the encoder is used to extract spatial features of the road network map to obtain a spatial feature matrix. The gated recurrent unit layer in the encoder encodes historical traffic flow sequences to obtain a first temporal feature matrix. The spatial feature matrix and the first temporal feature matrix are fused to generate a first feature vector. The gated recurrent unit layer in the decoder performs temporal reconstruction on the first feature vector to obtain a second temporal feature matrix. The diffusion graph convolutional layer in the decoder performs spatial constraint processing on the road network map to obtain a spatial constraint matrix. The spatial constraint matrix and the second temporal feature matrix are fused to generate a second feature vector.

[0040] It is understood that the decoder in this application embodiment has a structure corresponding to the encoder, both including a diffusion graph convolutional layer and a gated recurrent unit layer. The encoder, by integrating the diffusion graph convolutional layer, uses a bidirectional random walk strategy on the directed graph to simulate the diffusion process of traffic flow in the road network, thereby capturing complex spatial dependencies. At the same time, combined with the time gating mechanism of the gated recurrent unit layer, it effectively extracts the dynamic evolution pattern in the time series and maps the input historical traffic flow sequence into a high-dimensional hidden layer state vector containing rich spatiotemporal semantics. The decoder is responsible for receiving the context vector output by the encoder and gradually reconstructing and generating the future traffic flow prediction sequence through autoregression.

[0041] Specifically, such as Figure 2 As shown, the traffic flow prediction model in this application embodiment is a deep learning prediction model, which uses a diffuse convolutional recurrent neural network that can simultaneously capture spatiotemporal dynamic characteristics as its core skeleton.

[0042] In one embodiment of this application, a knowledge distillation module is provided between the first sub-network and the second sub-network. The knowledge distillation module is used to achieve collaborative optimization of the first sub-network and the second sub-network based on mutual learning mechanism and self-distillation mechanism during the training process of the traffic flow prediction model corresponding to the first region.

[0043] To enhance the feature extraction capability and generalization robustness of the traffic flow prediction model, this embodiment embeds a knowledge distillation module between the two sub-networks. This module establishes a cross-network feature interaction channel, enabling the model to achieve collaborative optimization of the two channels through mutual learning and self-distillation mechanisms during subsequent training, thereby allowing the model to learn general traffic flow spatiotemporal evolution patterns.

[0044] In one embodiment of this application, during the training of the traffic flow prediction model corresponding to the first region and the traffic flow prediction model corresponding to the second region, the model parameters of the traffic flow prediction model are optimized by backpropagation based on the objective loss function. The objective loss function includes a first sub-loss function, a second sub-loss function, and a third sub-loss function. The first sub-loss function is used to measure the deviation between the predicted traffic flow data and the true traffic flow data. The second sub-loss function is used to measure the relative entropy divergence between the output probability distributions of the first sub-network and the second sub-network. The third sub-loss function is used to calculate the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network, as well as the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network.

[0045] To achieve efficient knowledge distillation and collaborative optimization, this application constructs a composite loss function with three constraints: the target loss function is updated via backpropagation, and the model training target loss function is as follows. Figure 3 As shown, the three-part loss function includes: 1. Cross-entropy loss function for task prediction (first sub-loss function): Cross-entropy or mean squared error is used to measure the deviation between the predicted value and the actual traffic flow data to ensure the accuracy of the basic prediction; 2. Mutual learning loss function (second sub-loss function): By calculating the KL (Kullback-Leibler, relative entropy) divergence between the output probability distributions of the first sub-network and the second sub-network, the two networks are encouraged to act as "teachers" for each other to transfer and imitate knowledge, thereby avoiding the single model from getting trapped in local optima; 3. Self-distillation loss function (third sub-loss function): This loss calculates the distribution difference between encoder output features and decoder hidden layer features within the same network or across networks, forcing consistency in feature representation within the model.

[0046] In one embodiment of this application, the method further includes: obtaining a training convergence state index of the traffic flow prediction model during the training process; and adjusting the weights of the first sub-loss function, the second sub-loss function, and the third sub-loss function according to the training convergence state index.

[0047] Among them, training convergence status indicators include the number of training iterations or the difference in model convergence.

[0048] It is understood that the embodiments of this application can obtain the training convergence state index of the traffic flow prediction model during the training process, and adjust the weights of the first sub-loss function, the second sub-loss function and the third sub-loss function according to the training convergence state index, thereby obtaining a pre-trained model with powerful general spatiotemporal feature extraction capabilities.

[0049] In other words, the embodiments of this application can also determine the balance coefficient by the number of training iterations and the convergence state of the model, and then dynamically weigh the weights of each loss term by adjusting the balance coefficient.

[0050] In step S103, the model parameters of the first traffic flow model are transferred to the traffic flow prediction model corresponding to the second region. The traffic flow prediction model corresponding to the second region is trained using the second dataset and the second road network map to obtain the second traffic flow prediction model. During the model training process, the model parameters of other layers of the model are kept unchanged, and the model parameters of the output layer of the model are adjusted.

[0051] The model parameters include the encoder, decoder, and weights of the output layer.

[0052] It is understood that, in this embodiment, the model parameters of the first traffic flow model can be transferred to the traffic flow prediction model corresponding to the second region. The second traffic flow prediction model is trained using the second dataset and the second road network map to obtain the second traffic flow prediction model. During model training, the model parameters of other layers remain unchanged, while the model parameters of the output layer are adjusted. Specifically, although the distribution of traffic flow data varies across different cities, the underlying spatiotemporal diffusion patterns (such as the waveform trends of morning and evening rush hours and the spatiotemporal propagation characteristics of congestion) are highly universal. Freezing these layers can effectively preserve the general knowledge learned from the source domain and prevent overfitting on small sample data. Through this strategy of "freezing the backbone and fine-tuning the ends," the model can quickly map general high-dimensional spatiotemporal features to the specific numerical space of the target domain. That is, in this embodiment, all model parameters trained on the dataset of the first region can be completely copied as the initial state and loaded into the traffic flow prediction model of the second region. A key layer freezing operation is performed, that is, all weight parameters of the encoder and decoder in the model are forcibly locked, so that they remain in a gradient-unupdated state during the training process in the second region. Only the last fully connected output layer is unlocked. Using the limited historical traffic data in the second region, the parameters of this output layer are fine-tuned with a small learning rate, achieving adaptation to new scenarios with low training cost. The model transfer and fine-tuning process is as follows: Figure 4 As shown.

[0053] In step S104, the traffic flow data for the future target time period of the second area is predicted using the second traffic flow prediction model.

[0054] This application embodiment can utilize a second traffic flow prediction model that has undergone migration fine-tuning to perform actual traffic flow prediction tasks. It receives time-series data (such as traffic flow or speed readings from the past hour) collected by sensors in the target domain in real time. First, it processes the data through an encoder block with the aforementioned parameters frozen, converting the raw data into a high-dimensional feature vector rich in spatiotemporal information. Subsequently, the feature vector is reconstructed temporally through a decoder. Finally, the fine-tuned output layer is linearly mapped to convert the hidden layer state into specific traffic state values. The traffic flow prediction model outputs traffic flow prediction results for multiple consecutive time steps in the future, providing traffic management departments with accurate short-term traffic state prediction information.

[0055] In summary, the traffic flow prediction method of this application mainly includes two stages: the first stage is to perform complete model pre-training on the first dataset in the first region with abundant data, and the second stage is to transfer the model to the target domain with incomplete data. By freezing the encoder and decoder parameters and only fine-tuning the output layer, efficient knowledge transfer and rapid adaptation are achieved, thereby significantly reducing the dependence on the data of the first region while maintaining prediction accuracy.

[0056] Specifically, the traffic flow prediction method of this application embodiment can achieve the following: 1. Improved prediction accuracy in areas with incomplete data: By introducing deep knowledge distillation and through mutual learning and self-distillation of dual networks, deeper spatiotemporal latent features were mined. Compared with a single model, it has stronger noise resistance and generalization performance, significantly improving the accuracy and reliability of traffic flow prediction in the target area.

[0057] 2. Enhanced cross-domain adaptability of the model: By transferring general knowledge from the source domain, this method only requires a small amount of target domain data to complete model adaptation, effectively solving the problem of difficulty in modeling newly built urban areas or areas with missing data. It maintains stable prediction performance in complex traffic scenarios with incomplete data and changing distribution, and has good generalization and robustness.

[0058] 3. Improved model training efficiency: The strategy of "freezing the backbone and fine-tuning the ends" avoids full parameter retraining of the massive graph neural network in the target domain, which greatly shortens the convergence time and saves computing resources.

[0059] According to the traffic flow prediction method proposed in this application, a first road network map of a data-rich first region and a second road network map of a data-incomplete second region can be constructed respectively. A traffic flow prediction model is trained based on the first dataset and the first road network map of the first region. The trained traffic flow model is then transferred to the second region while keeping the other layer parameters of the model unchanged. Based on the second dataset and the second road network map of the second region, only the output layer of the model is adjusted, which reduces the model convergence time and improves training efficiency. Finally, the traffic flow prediction model adjusted in the second region is used to predict the traffic flow in the second region. Thus, by transferring learning, model adaptation can be completed with only a small amount of data from the second region, solving the problem of difficulty in modeling newly built urban areas or areas with missing data. It maintains stable prediction performance even in scenarios with incomplete data and improves the generalization ability of the model.

[0060] Next, the traffic flow prediction device proposed according to the embodiments of this application is described with reference to the accompanying drawings.

[0061] Figure 5 This is a block diagram of a traffic flow prediction device according to an embodiment of this application.

[0062] like Figure 5 As shown, the traffic flow prediction device 10 includes: a construction module 100, an acquisition module 200, a training module 300, a transfer module 400, and a prediction module 500.

[0063] The system comprises the following modules: a construction module 100, which acquires road connection data and sensor data for the first and second regions respectively, and constructs a first road network map for the first region and a second road network map for the second region based on the corresponding road connection data and sensor data; an acquisition module 200, which acquires a first dataset for the first region and a second dataset for the second region; a training module 300, which trains a traffic flow prediction model for the first region using the first dataset and the first road network map to obtain a first traffic flow prediction model; a transfer module 400, which transfers the model parameters of the first traffic flow model to the traffic flow prediction model for the second region, trains the traffic flow prediction model for the second region using the second dataset and the second road network map to obtain a second traffic flow prediction model, and keeps the model parameters of other layers of the model unchanged during model training while adjusting the model parameters of the output layer; and a prediction module 500, which uses the second traffic flow prediction model to predict traffic flow data for the second region during the future target time period.

[0064] In one embodiment of this application, the dataset includes historical traffic flow sequences and corresponding real traffic flow data. The traffic flow prediction model includes a network layer and an output layer. The network layer includes a first sub-network and a second sub-network in parallel. The first and second sub-networks have the same structure, including an encoder and a decoder. The encoder processes the road network map and the historical traffic flow sequences to obtain a first feature vector. The decoder processes the road network map and the first feature vector to obtain a second feature vector. The output layer performs a linear mapping on the second feature vector output by the first and second sub-networks to obtain predicted traffic flow data for the future target time period.

[0065] In one embodiment of this application, the encoder and decoder have the same structure, including a diffusion graph convolutional layer and a gated recurrent unit layer. The diffusion graph convolutional layer in the encoder is used to extract spatial features of the road network map to obtain a spatial feature matrix. The gated recurrent unit layer in the encoder encodes historical traffic flow sequences to obtain a first temporal feature matrix. The spatial feature matrix and the first temporal feature matrix are fused to generate a first feature vector. The gated recurrent unit layer in the decoder performs temporal reconstruction on the first feature vector to obtain a second temporal feature matrix. The diffusion graph convolutional layer in the decoder performs spatial constraint processing on the road network map to obtain a spatial constraint matrix. The spatial constraint matrix and the second temporal feature matrix are fused to generate a second feature vector.

[0066] In one embodiment of this application, a knowledge distillation module is provided between the first sub-network and the second sub-network. The knowledge distillation module is used to achieve collaborative optimization of the first sub-network and the second sub-network based on mutual learning mechanism and self-distillation mechanism during the training process of the traffic flow prediction model corresponding to the first region.

[0067] In one embodiment of this application, during the training of the traffic flow prediction model corresponding to the first region and the traffic flow prediction model corresponding to the second region, the model parameters of the traffic flow prediction model are optimized by backpropagation based on the objective loss function. The objective loss function includes a first sub-loss function, a second sub-loss function, and a third sub-loss function. The first sub-loss function is used to measure the deviation between the predicted traffic flow data and the true traffic flow data. The second sub-loss function is used to measure the relative entropy divergence between the output probability distributions of the first sub-network and the second sub-network. The third sub-loss function is used to calculate the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network, as well as the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network.

[0068] In one embodiment of this application, the traffic flow prediction device 10 of this application embodiment further includes: an adjustment module.

[0069] The adjustment module is used to obtain the training convergence state index of the traffic flow prediction model during the training process; and adjust the weights of the first sub-loss function, the second sub-loss function, and the third sub-loss function according to the training convergence state index.

[0070] In one embodiment of this application, the construction module 100 is further configured to: identify the location coordinates of multiple sensors in the sensor data corresponding to each region, and abstract each sensor as a node; construct the edges between nodes based on the road connection data of each region; calculate the Euclidean distance between every two nodes based on the location coordinates of the sensors, calculate the weight between every two nodes based on the Euclidean distance, construct a weighted adjacency matrix based on the weights; and construct the road network map of the corresponding region based on the multiple nodes, the edges between nodes, and the weighted adjacency matrix.

[0071] It should be noted that the foregoing explanation of the traffic flow prediction method embodiment also applies to the traffic flow prediction device of this embodiment, and will not be repeated here.

[0072] According to the traffic flow prediction device proposed in the embodiments of this application, a first road network map of a data-rich first region and a second road network map of a data-incomplete second region can be constructed respectively. A traffic flow prediction model is trained based on the first dataset and the first road network map of the first region. The trained traffic flow model is then transferred to the second region while keeping the other layer parameters of the model unchanged. Based on the second dataset and the second road network map of the second region, only the output layer of the model is adjusted, which reduces the model convergence time and improves training efficiency. Finally, the traffic flow prediction model adjusted in the second region is used to predict the traffic flow in the second region. Thus, by transferring learning, model adaptation can be completed with only a small amount of data from the second region, solving the problem of difficulty in modeling newly built urban areas or areas with missing data. It maintains stable prediction performance even in scenarios with incomplete data and improves the generalization ability of the model.

[0073] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 601, the processor 602, and the computer program stored on the memory 601 and capable of running on the processor 602.

[0074] When the processor 602 executes the program, it implements the traffic flow prediction method provided in the above embodiments.

[0075] Furthermore, electronic devices also include: Communication interface 603 is used for communication between memory 601 and processor 602.

[0076] The memory 601 is used to store computer programs that can run on the processor 602.

[0077] The memory 601 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0078] If the memory 601, processor 602, and communication interface 603 are implemented independently, then the communication interface 603, memory 601, and processor 602 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0079] Optionally, in a specific implementation, if the memory 601, processor 602, and communication interface 603 are integrated on a single chip, then the memory 601, processor 602, and communication interface 603 can communicate with each other through an internal interface.

[0080] The processor 602 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0081] This application also provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed by a processor, implements the traffic flow prediction method described above.

[0082] This application also provides a computer program product, including a computer program or instructions, which, when executed, implement the traffic flow prediction method described above.

[0083] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0084] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0085] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0086] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or more of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.

[0087] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

Claims

1. A traffic flow prediction method, characterized in that, Includes the following steps: Road connection data and sensor data of the first region and the second region are acquired respectively. Based on the road connection data and sensor data of the first region and the second region, a first road network map of the first region and a second road network map of the second region are constructed respectively. Obtain the first dataset of the first region and the second dataset of the second region; The first traffic flow prediction model is obtained by training the traffic flow prediction model corresponding to the first region using the first dataset and the first road network map. The model parameters of the first traffic flow model are transferred to the traffic flow prediction model corresponding to the second region. The traffic flow prediction model corresponding to the second region is trained using the second dataset and the second road network map to obtain the second traffic flow prediction model. During the model training process, the model parameters of other layers of the model are kept unchanged, and the model parameters of the output layer of the model are adjusted. The second traffic flow prediction model is used to predict traffic flow data for the second region in the future target time period.

2. The traffic flow prediction method according to claim 1, characterized in that, The dataset includes historical traffic flow sequences and corresponding real traffic flow data. The traffic flow prediction model includes a network layer and an output layer. The network layer includes a first sub-network and a second sub-network in parallel. The first sub-network and the second sub-network have the same structure, including an encoder and a decoder. The encoder is used to process the road network map and the historical traffic flow sequence to obtain a first feature vector; The decoder is used to process the road network map and the first feature vector to obtain a second feature vector; The output layer is used to linearly map the second feature vectors output by the first sub-network and the second sub-network to obtain predicted traffic flow data for the future target time period.

3. The traffic flow prediction method according to claim 2, characterized in that, The encoder and the decoder have the same structure, including a spread graph convolutional layer and a gated recurrent unit layer, wherein, The diffusion map convolutional layer in the encoder is used to extract the spatial features of the road network map to obtain a spatial feature matrix. The gated loop unit layer in the encoder encodes the historical traffic flow sequence to obtain a first temporal feature matrix. The spatial feature matrix and the first temporal feature matrix are fused to generate the first feature vector. The gated recurrent unit layer in the decoder performs temporal reconstruction on the first feature vector to obtain a second temporal feature matrix. The diffusion graph convolutional layer in the decoder performs spatial constraint processing on the road network map to obtain a spatial constraint matrix. The spatial constraint matrix and the second temporal feature matrix are fused to generate the second feature vector.

4. The traffic flow prediction method according to claim 2, characterized in that, A knowledge distillation module is provided between the first sub-network and the second sub-network. The knowledge distillation module is used to achieve collaborative optimization of the first sub-network and the second sub-network based on mutual learning mechanism and self-distillation mechanism during the training process of the traffic flow prediction model corresponding to the first region.

5. The traffic flow prediction method according to claim 4, characterized in that, During the training of the traffic flow prediction model corresponding to the first region and the traffic flow prediction model corresponding to the second region, the model parameters of the traffic flow prediction model are optimized by backpropagation based on the objective loss function. The objective loss function includes a first sub-loss function, a second sub-loss function, and a third sub-loss function. The first sub-loss function is used to measure the deviation between the predicted traffic flow data and the true traffic flow data. The second sub-loss function is used to measure the relative entropy divergence between the output probability distributions of the first sub-network and the second sub-network. The third sub-loss function is used to calculate the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network, as well as the feature distribution difference between the first feature vector and the second feature vector of the first sub-network and the second sub-network.

6. The traffic flow prediction method according to claim 5, characterized in that, Also includes: Obtain the training convergence state index of the traffic flow prediction model during the training process; The weights of the first sub-loss function, the second sub-loss function, and the third sub-loss function are adjusted according to the training convergence state index.

7. The traffic flow prediction method according to claim 1, characterized in that, The step of constructing a first road network map for the first region and a second road network map for the second region based on road connection data and sensor data corresponding to the first region and the second region, respectively, includes: Identify the location coordinates of multiple sensors in the sensor data corresponding to each region, and abstract each sensor as a node; Edges between nodes are constructed based on the road connection data of each region; The Euclidean distance between each pair of nodes is calculated based on the position coordinates of the sensor, the weight between each pair of nodes is calculated based on the Euclidean distance, and a weighted adjacency matrix is ​​constructed based on the weight. A road network map of the corresponding region is constructed based on multiple nodes, the edges between the nodes, and the weighted adjacency matrix.

8. A traffic flow prediction device, characterized in that, include: The construction module is used to acquire road connection data and sensor data of the first region and the second region respectively, and construct a first road network map of the first region and a second road network map of the second region based on the road connection data and sensor data corresponding to the first region and the second region respectively. The acquisition module is used to acquire the first dataset of the first region and the second dataset of the second region; The training module is used to train the traffic flow prediction model corresponding to the first area using the first dataset and the first road network map to obtain the first traffic flow prediction model. The migration module is used to migrate the model parameters of the first traffic flow model to the traffic flow prediction model corresponding to the second region. The second traffic flow prediction model is trained using the second dataset and the second road network map to obtain the second traffic flow prediction model. During the model training process, the model parameters of other layers of the model are kept unchanged, while the model parameters of the output layer of the model are adjusted. The prediction module is used to predict traffic flow data for the second area in the future target time period using the second traffic flow prediction model.

9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the traffic flow prediction method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, The computer program or instructions are executed by a processor to implement the traffic flow prediction method as described in any one of claims 1-7.