Diffusion model-based few-sample traffic flow prediction method, system and terminal

By introducing a diffusion generation model before the target domain prediction and generating adaptive aptive model parameters, the problem of low accuracy of transfer learning method when predicting the target domain is solved, and the accuracy of traffic flow prediction is improved.

CN119917907APending Publication Date: 2025-05-02GUANGDONG LAB OF ARTIFICIAL INTELLIGENCE & DIGITAL ECONOMY (SZ)
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411827737.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

When the existing transfer learning method directly applies the model trained by source domain data to the target domain, due to the large differences in the target domain's characteristics, the traffic flow prediction accuracy is low.

Method used

A diffusion model-based traffic flow prediction method is adopted to introduce a diffusion generation model before the target domain prediction, and an adaptive model parameter that is more in line with the target domain characteristics is generated, and a prediction is made based on the traffic flow characteristics of the target domain.

Benefits of technology

By generating model parameters that are more suitable for the feature of the target domain, the accuracy of traffic flow prediction is improved, and the problem of low accuracy of transfer learning methods when predicting the target domain is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917907A_ABST
    Figure CN119917907A_ABST
Patent Text Reader

Abstract

The invention discloses a few-sample traffic flow prediction method and system based on a diffusion model, and a terminal, and the method comprises the steps: obtaining the traffic flow data of a city, and enabling the city to comprise a source city and a target city; constructing a space-time prediction model, and training the space-time prediction model according to the traffic flow data to obtain a high-dimensional vector; acquiring spatial-temporal characteristic data of a city, and processing the spatial-temporal characteristic data to obtain a spatial-temporal characteristic embedded vector; constructing a diffusion model, and training the diffusion model according to the high-dimensional vector and the spatio-temporal feature embedded vector to obtain a trained diffusion model; and based on the trained diffusion model, performing traffic flow prediction on the target city according to the traffic flow data to obtain a traffic flow prediction result. According to the method, the diffusion generation model is introduced before target domain prediction to generate the adaptive model parameters more conforming to the target domain characteristics, so that the future traffic flow is predicted in combination with the traffic flow characteristics of the target domain, and the traffic flow prediction accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of traffic flow prediction, and in particular to a method, system and terminal for predicting a small number of traffic flows based on a diffusion model. Background Art

[0002] The key technologies for few-shot traffic flow prediction include data augmentation, time series prediction, and transfer learning. Transfer learning technology utilizes the features extracted from the data-rich source city and effectively transfers them to the data-scarce target city to improve the prediction performance of the model in the few-shot scenario. The typical spatiotemporal prediction model DCRNN (Diffusion Convolutional Recurrent Neural Network) constructs the spatial dependency relationship between nodes through a bidirectional graph random walk mechanism, and uses a recurrent neural network (RNN) to capture the dynamic characteristics of the time series, thereby learning the traffic flow pattern at a specific location. Based on this, the transfer learning diffusion convolutional recurrent neural network TL-DCRNN (Transfer Learning DCRNN) further introduces a graph partitioning method to divide the traffic network into multiple subgraphs and marginalize the information at specific locations. When applied to the prediction of a new graph, this method first partitions the target graph, and then uses the model trained on the source graph to predict the partitioned subgraphs to improve the generalization performance of the model. In addition, the transfer learning framework Ada-STGCN (AdaptiveSpatial-Temporal Graph Convolutional Network) uses an adaptive method of adversarial learning to achieve traffic flow migration prediction from the source domain to the target domain. By adaptively adjusting the features of the target area, the model can maintain high prediction accuracy when the data distribution is greatly different.

[0003] In the existing transfer learning algorithms, most methods train the model through the rich data in the source domain, and then directly apply the trained model to the prediction task in the target domain. In this process, the model parameters of the source domain are usually directly used for the prediction of the target domain. However, due to the large differences in the characteristics of different target domains in terms of spatial structure, traffic mode, etc., directly transferring model parameters often leads to prediction bias, affecting the generalization performance and prediction accuracy of the model.

[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention

[0005] The main purpose of this application is to provide a few-sample traffic flow prediction method, system and terminal based on a diffusion model, aiming to solve the problem that the transfer learning method in the prior art directly applies the model trained with source domain data to the prediction task in the target domain, but due to the large differences in features of different target domains, directly migrating model parameters leads to low traffic flow prediction accuracy.

[0006] A first aspect of an embodiment of the present application provides a few-sample traffic flow prediction method based on a diffusion model, the few-sample traffic flow prediction method based on a diffusion model comprising: obtaining traffic flow data of a city, wherein the city comprises a source city and a target city; constructing a spatiotemporal prediction model, and training the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector; obtaining spatiotemporal feature data of the city, processing the spatiotemporal feature data to obtain a spatiotemporal feature embedding vector; constructing a diffusion model, training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model; based on the trained diffusion model, performing traffic flow prediction on the target city according to the traffic flow data to obtain a traffic flow prediction result.

[0007] Optionally, in one embodiment of the present application, the training of the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector specifically includes: training the spatiotemporal prediction model according to the traffic flow data to obtain a trained spatiotemporal prediction model, and extracting parameters from the trained spatiotemporal prediction model to obtain a high-dimensional vector.

[0008] Optionally, in one embodiment of the present application, the spatiotemporal feature data includes time feature data, global feature data and local environment feature data of the source city and the target city, and the spatiotemporal feature embedding vector includes a spatial knowledge embedding vector and a temporal knowledge embedding vector; the processing of the spatiotemporal feature data to obtain the spatiotemporal feature embedding vector specifically includes: processing the global feature data and the local environment feature data to obtain spatial feature data; encoding the spatial feature data to obtain spatial feature coding, and performing graph convolution processing on the spatial splicing feature coding to obtain a spatial knowledge embedding vector; encoding the temporal feature data to obtain temporal feature coding, and processing the temporal feature coding to obtain a temporal knowledge embedding vector.

[0009] Optionally, in one embodiment of the present application, the spatiotemporal feature data includes time feature data, global feature data and local environment feature data of the source city and the target city, and the spatiotemporal feature embedding vector includes a spatial knowledge embedding vector and a temporal knowledge embedding vector; the processing of the spatiotemporal feature data to obtain the spatiotemporal feature embedding vector specifically includes: encoding the global feature data and the local environment feature data respectively to obtain a global feature code and a local environment feature code; fusing the global feature code and the local environment feature code to obtain a spatial feature vector, and performing graph convolution processing on the spatial feature vector to obtain a spatial knowledge embedding vector; encoding the temporal feature data to obtain a temporal feature code, and processing the temporal feature code to obtain a temporal knowledge embedding vector.

[0010] Optionally, in one embodiment of the present application, the diffusion model includes a normalization module and an attention module; the diffusion model is trained according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model, specifically including: performing noise processing on the high-dimensional vector to obtain a parameter matrix; inputting the parameter matrix into the normalization module for processing to obtain a normalized parameter matrix; embedding the spatiotemporal feature embedding vector into a channel through an encoder to obtain an embedded spatiotemporal feature embedding vector; inputting the normalized parameter matrix and the embedded spatiotemporal feature embedding vector into the attention module to obtain predicted noise; obtaining real noise, and optimizing the diffusion model according to the predicted noise and the real noise to obtain a trained diffusion model.

[0011] Optionally, in one embodiment of the present application, the diffusion model is trained according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model, and the steps include: acquiring time series data of the city; encoding the time series data to obtain a time step vector to train the diffusion model as an input of the diffusion model.

[0012] Optionally, in one embodiment of the present application, based on the trained diffusion model, traffic flow prediction is performed on the target city according to the traffic flow data to obtain a traffic flow prediction result, which specifically includes: sampling from the trained diffusion model according to the spatiotemporal feature data corresponding to the target city to obtain the neural network parameters of the target city; inputting the traffic flow data and the neural network parameters into the trained diffusion model to obtain the traffic flow prediction result of the target city.

[0013] The second aspect of the embodiment of the present application further provides a small sample traffic flow prediction system based on a diffusion model, wherein the small sample traffic flow prediction system based on a diffusion model includes:

[0014] A data acquisition module, used to acquire traffic flow data of a city, wherein the city includes a source city and a target city;

[0015] A prediction model training module, used for constructing a spatiotemporal prediction model and training the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector;

[0016] A spatiotemporal knowledge acquisition module, used to acquire the spatiotemporal feature data of the city, process the spatiotemporal feature data, and obtain a spatiotemporal feature embedding vector;

[0017] A diffusion model training module, used for constructing a diffusion model, training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector, to obtain a trained diffusion model;

[0018] The traffic flow prediction module is used to perform traffic flow prediction on the target city based on the trained diffusion model and the traffic flow data to obtain a traffic flow prediction result.

[0019] The third aspect of an embodiment of the present application also provides a terminal, wherein the terminal includes: a memory, a processor, and a few-sample traffic flow prediction program based on a diffusion model stored in the memory and executable on the processor, wherein the few-sample traffic flow prediction program based on a diffusion model implements the steps of the few-sample traffic flow prediction method based on a diffusion model as described above when executed by the processor.

[0020] The fourth aspect of an embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a few-sample traffic flow prediction program based on a diffusion model, and when the few-sample traffic flow prediction program based on a diffusion model is executed by a processor, the steps of the few-sample traffic flow prediction method based on a diffusion model as described above are implemented.

[0021] Beneficial effects: The present application provides a method, system and terminal for predicting small-sample traffic flow based on a diffusion model. The method introduces a diffusion generation model before the target domain prediction to generate adaptive model parameters that are more in line with the characteristics of the target domain, thereby combining the traffic flow characteristics of the target domain to complete the prediction of future traffic flow, thereby improving the accuracy of traffic flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in 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 described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 It is a flow chart of a preferred embodiment of the method for predicting traffic flow with a small number of samples based on a diffusion model of the present application;

[0024] Figure 2 It is a schematic diagram of the algorithm framework in a preferred embodiment of the method for predicting traffic flow with a small number of samples based on a diffusion model of the present application;

[0025] Figure 3 It is a structural diagram of a preferred embodiment of the small sample traffic flow prediction system based on the diffusion model of the present application;

[0026] Figure 4 This is a structural diagram of a preferred embodiment of the terminal of this application.

[0027] Description of reference numerals:

[0028] 100. Data acquisition module; 200. Prediction model training module; 300. Spatiotemporal knowledge acquisition module; 400. Diffusion model training module; 500. Traffic flow prediction module. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical scheme and effect of the present application clearer and more specific, the technical scheme in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. The described embodiments are only possible technical implementations of the present application, not all possible implementations. Based on the embodiments in the present application, those skilled in the art can completely combine the embodiments of the present application to obtain other embodiments without creative work, and these embodiments are also within the scope of protection of the present application.

[0030] In the related art, in the TL-DCRNN model, in order to solve the prediction error caused by the difference in target domain characteristics, a partitioning method is proposed. Through this partitioning process, the differences between regions can be captured and modeled, so that the model parameters can be adaptively adjusted according to the characteristics of different regions. However, the partitioning strategy of TL-DCRNN has limitations to a certain extent: the number of partitions is limited, and it is difficult to achieve comprehensive coverage of all spatial regions in the target domain. This limitation shows that transfer learning still faces significant challenges in complex target domain prediction, and it is necessary to further develop more sophisticated matching mechanisms to support wider regional coverage and more flexible parameter adjustment in order to maintain high prediction accuracy in diverse target domains.

[0031] First, the nouns involved in the embodiments of the present application are introduced:

[0032] The GraphWaveNet (GWN) framework, which means graph wave network (or graph wave neural network) in Chinese, is a deep spatiotemporal graph prediction model that captures spatial and temporal dependencies by combining WaveNet with an adaptive adjacency matrix and graph convolution. The model performs well on traffic datasets, especially in long time series prediction, outperforming traditional methods. The trainable adaptive adjacency matrix can maintain good performance without explicit graph structure.

[0033] Transformer network, which means converter network in Chinese, is a deep learning model based on the self-attention mechanism in the field of artificial intelligence and natural language processing (NLP).

[0034] STGCN (Spatio-Temporal Graph Convolutional Networks), spatio-temporal graph convolutional network; GWN (GraphWaveNet) is a graph wave network; STG (Spatio-Temporal Graph) is a spatio-temporal graph; LSTM (Long Short-Term Memory

[0035] ) is long and short-term memory.

[0036] The following describes the few-sample traffic flow prediction method, system and terminal based on the diffusion model of the embodiment of the present application with reference to the accompanying drawings. In view of the problem that the transfer learning method in the above-mentioned related technology directly applies the model trained with source domain data to the prediction task of the target domain, but due to the large difference in characteristics of different target domains, the direct migration of model parameters leads to low traffic flow prediction accuracy, the present application provides a few-sample traffic flow prediction method based on the diffusion model. In this method, in the few-sample traffic flow prediction scenario, by introducing a diffusion generation model before the target domain prediction, adaptive model parameters that are more in line with the characteristics of the target domain are generated, thereby combining the traffic flow characteristics of the target domain to complete the prediction of future traffic flow, thereby improving the accuracy of traffic flow prediction. As a result, the technical problem that the transfer learning method in the related technology directly applies the model trained with source domain data to the prediction task of the target domain, but due to the large difference in characteristics of different target domains, the direct migration of model parameters leads to low traffic flow prediction accuracy is solved.

[0037] This application uses the Graph WaveNet (GWN) framework to pre-train traffic flow data in a certain area, extract the trained network parameters, and combine the spatiotemporal feature information in the area to train the diffusion generation model. In the construction of the diffusion model, the Transformer network is used to predict the noise interference at each step, thereby improving the generalization ability of the model. Furthermore, by sampling according to the spatiotemporal feature information of the target area, adaptive network parameters that match the characteristics of the target domain are obtained. Finally, based on the small sample data of the target area and the generated adaptive network parameters, the future traffic flow of the target area is accurately predicted.

[0038] The diffusion model of the embodiment of the present application provides an innovative solution to the problems of uneven data distribution among cities and the applicability of algorithm migration. The algorithm framework does not migrate through simple model parameter matching, but deeply explores the spatiotemporal characteristics of different regions, and generates exclusive adaptive parameters according to the unique spatiotemporal characteristics of the target domain. Specifically, the diffusion model uses the spatiotemporal characteristics of the target domain (target city) to generate parameters that conform to its structure, and then fine-tunes the parameters in combination with a small amount of traffic flow sample data in the target domain to better adapt to the traffic flow pattern of the target domain. The present application has achieved a breakthrough in the generation of adaptive parameters in the target domain. Through the introduction of the diffusion generation model, the prediction accuracy under the condition of few samples has been effectively improved, providing new ideas and technical support for transfer learning in traffic flow prediction.

[0039] The embodiment of the present application introduces the diffusion generation model into the neural network framework of traffic flow prediction. Different from the traditional direct migration method of model parameters, the present application deeply mines the correlation between the pre-trained model parameters and the regional spatiotemporal knowledge, and performs generative prediction on the pre-trained model parameters, thereby generating adaptive parameters that are more in line with the characteristics of the target area. Finally, the generated parameters are fine-tuned in combination with a small amount of data from the target area to improve the accuracy and applicability of the prediction.

[0040] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0041] The few-sample traffic flow prediction method based on the diffusion model described in the preferred embodiment of the present application is as follows: Figure 1 As shown, the small sample traffic flow prediction method based on the diffusion model includes the following steps:

[0042] In step S101, traffic flow data of a city is obtained, wherein the city includes a source city and a target city.

[0043] It is worth noting that if Figure 2As shown, the algorithm framework of this application is generally divided into two stages. The first stage is the pre-training stage ( Figure 2 ), based on the collected traffic flow data, the study area is divided into source cities with rich data and target cities with relatively scarce data. First, the GraphWaveNet (GWN) network framework is trained on the source city dataset, and the neural network parameters generated by the training are extracted and stored, laying the foundation for subsequent prediction tasks. The second stage is the prediction stage of the target area ( Figure 2 ), a Transformer-based diffusion model is used to adaptively predict the target domain. In this stage, the input of the Transformer consists of three parts: the first part is the network parameters after k-step noise perturbation; the second part is the forward diffusion step length k; and the third part is the spatiotemporal feature embedding vector processed by the graph convolutional network. The Transformer network is used to gradually predict the noise of each diffusion step, and update the parameters of the diffusion model by comparing with the real noise, thereby optimizing the generation process. Finally, sampling is performed based on the spatiotemporal characteristics of the target city to generate adaptive neural network parameters that adapt to the target city, thereby further realizing the prediction of traffic flow data for the target city in the next 15 minutes, 30 minutes, and 45 minutes.

[0044] In the generative training process of the diffusion model, the generative model G is introduced γ To learn the process of generating target model parameters in a single time. Specifically, the generated model G γ Prediction parameter distribution P G (θ i ∣p i ), where p i Represents the feature vector of region i, which is used to guide the generation of model parameters that conform to the characteristics of the region, θ i represents the model parameters of region i. The diffusion model trains the generation process by gradually removing Gaussian noise. According to the feature vector p of the target region i , the diffusion model gradually samples the generated parameters, simulating the parameter optimization process from random initialization to regional characteristics. This generation process not only captures the mapping relationship between regional characteristics and parameters, but also ensures the adaptability of the generated parameters between different regions. The corresponding loss function is as follows:

[0045]

[0046] Where L represents the loss function; Represents the initial parameter θ 0 ,∈ and k, used to calculate the average value of the loss function; θ 0represents the initialized model parameters; ∈ represents Gaussian noise, whose distribution is N(0,1), that is, a normal distribution with a mean of 0 and a variance of 1; ∈ γ (θ k ,p,k) represents the generated model G γ Next, according to the current parameter θ k , feature vector p, and the noise predicted by a certain step k (referring to the number of iterations or time steps); θ k Represents the model parameters generated at the kth step in the iteration or training process.

[0047] Furthermore, in the data preprocessing process of the pre-training stage, the purpose is to prepare and preprocess the traffic flow data to provide input for the pre-training stage. In this embodiment, a traffic flow dataset LargeST (large-scale traffic flow prediction benchmark dataset) of a certain region and a certain time period is obtained, and the entire region dataset is divided into multiple datasets by year, and a dataset of a certain time period is further extracted for experimental analysis. At the same time, in order to conduct regionalization and migration research, the region dataset is subdivided into multiple (such as 22) county-level regions according to administrative divisions to form multiple independent sub-datasets.

[0048] In step S102, a spatiotemporal prediction model is constructed, and the spatiotemporal prediction model is trained according to the traffic flow data to obtain a high-dimensional vector.

[0049] In a possible implementation, the spatiotemporal prediction model is trained according to the traffic flow data to obtain a trained spatiotemporal prediction model, and parameters are extracted from the trained spatiotemporal prediction model to obtain a high-dimensional vector.

[0050] In this application, the spatio-temporal graph (STG) is defined as GST = (V, E, A, X), where V represents a node set, E represents an edge set, A represents an adjacency matrix, and X represents a feature matrix of a node. In this application, the node feature is traffic flow data. In the traffic speed data set, nodes represent sensors deployed along the road network, and edges represent the connection relationship between these sensors. The construction of the spatio-temporal graph is adaptively adjusted according to the needs of the specific prediction task to fully reflect the spatial correlation and temporal dependency between nodes.

[0051] In the spatiotemporal prediction task, given a spatiotemporal graph GST, each node contains M historical signals [X t-M+1 ,X t-M+2 ,…,X t ], the goal is to predict the data of the next n time steps [X t+1 ,…,X t+n ]. That is, under the condition of known space-time graph GST, a parameterized model F is constructed θ, so that the model can satisfy the following relationship:

[0052] [X t+1 ,…,X t+n ]=F θ ([X t-M+1 ,X t-M+2 ,…,X t ]; GST);

[0053] By learning the parameter θ, the model F can capture the dynamic changes of node features in the space-time graph, thereby achieving accurate prediction of future multi-step traffic flow. The prediction model will consider the spatial and temporal dependencies between nodes to build a more accurate spatiotemporal prediction of traffic flow.

[0054] Specifically, input data, taking the traffic flow data of the county-level area and its corresponding adjacency matrix as input; initial convolution operation, performing initial convolution operation on the input data to extract basic features; WaveNet block processing, iterative processing through multiple WaveNet blocks, each WaveNet block contains multiple convolution layers, and uses dilated convolution to capture longer time dependencies; feature map generation, generating two feature maps through filtered convolution and gated convolution, respectively processed by tanh (hyperbolic tangent function) and sigmoid (S-type function or logical function) activation functions, and performing element-by-element multiplication operations to realize jump connections; spatial feature extraction, the processed feature data is further extracted from the spatial features through the graph convolutional network (GCN), and the adjacent node information is integrated; feature integration, feature integration is performed through two convolutional layers to merge and output multi-scale spatiotemporal features. Parameter collection: During the pre-training process, the weight matrices and bias items of the filter convolution layer, gated convolution layer, graph convolution layer, and fully connected layer are collected; parameter flattening: The weight matrices and bias items in the spatiotemporal prediction model are flattened and formed into a high-dimensional vector through splicing operations; parameter transfer: The high-dimensional vector is passed as input to the training phase of the diffusion model.

[0055] Furthermore, in the process of traffic flow pre-training in the preprocessing stage, the purpose is to train the GraphWaveNet (GWN) network framework on the source city (data-rich county-level area) and extract neural network parameters. This application uses the traffic flow data of the county-level area and its corresponding adjacency matrix as the input of the pre-training stage, and the node data enters the loop processing flow at intervals of 15 minutes. First, an initial convolution operation is performed on the input data to extract the basic features, and then it is iteratively processed through multiple WaveNet blocks. Each WaveNet block contains multiple convolutional layers, each of which uses dilated convolution to expand the receptive field to capture longer time dependencies. During the convolution process, two feature maps are generated by filter convolution and gated convolution, which are processed by tanh and sigmoid activation functions respectively, and then element-by-element multiplication operations are performed to achieve skip connections, thereby retaining effective timing information. On this basis, the processed feature data is further extracted through the graph convolutional network (GCN) to further extract spatial features, fuse adjacent node information, and finally integrate features through two convolutional layers to merge and output multi-scale spatiotemporal features. It is understandable that the pre-training part uses the GWN framework. Although good predictions have been achieved, attention modules and long short-term memory (LSTM) modules can be appropriately added according to the characteristics of different regions. A hybrid model can be constructed to combine GWN with attention mechanisms and LSTM modules.

[0056] Furthermore, in the process of extracting parameters in the preprocessing stage, the purpose is to extract neural network parameters from the pretrained model for the subsequent training of the diffusion model. In the pretraining process, the parameters involved include the weight matrix and bias term of the filter convolution layer, gated convolution layer, graph convolution layer, and fully connected layer. For the sensor nodes in the county-level area, pretraining is first performed to obtain the parameters of each layer. After the pretraining is completed, the weight matrix and bias term in the spatiotemporal prediction model are flattened and formed into a high-dimensional vector through a splicing operation, which is passed as input to the training stage of the diffusion model.

[0057] In step S103, the spatiotemporal feature data of the city is obtained, and the spatiotemporal feature data is processed to obtain a spatiotemporal feature embedding vector.

[0058] The spatiotemporal feature data include time feature data, global feature data and local environment feature data of the source city and the target city, and the spatiotemporal feature embedding vector includes a spatial knowledge embedding vector and a temporal knowledge embedding vector.

[0059] In one possible implementation, the global feature data and the local environment feature data are processed to obtain spatial feature data; the spatial feature data are encoded to obtain spatial feature coding, and graph convolution is performed on the spatial splicing feature coding to obtain a spatial knowledge embedding vector; the temporal feature data is encoded to obtain temporal feature coding, and the temporal feature coding is processed to obtain a temporal knowledge embedding vector.

[0060] In another possible implementation, the global feature data and the local environment feature data are encoded respectively to obtain a global feature code and a local environment feature code; the global feature code and the local environment feature code are feature fused to obtain a spatial feature vector, and the spatial feature vector is graph convolution processed to obtain a spatial knowledge embedding vector; the time feature data is encoded to obtain a time feature code, and the time feature code is processed to obtain a time knowledge embedding vector.

[0061] Furthermore, in the node feature preprocessing process of the target area prediction stage, the purpose is to preprocess the node features of the target city and extract the spatiotemporal knowledge embedding vector (i.e., the spatiotemporal feature embedding vector). In this application, feature splicing, for nodes in the same county, first shares the county-level global feature information and splices it with the node-level feature information of each node; graph convolution operation, combined with the adjacency matrix, applies graph convolution operation to extract the embedding vector of the regional spatial features, thereby obtaining the spatial knowledge embedding of the region.

[0062] In a possible implementation, time series data of the city is obtained; the time series data is encoded to obtain a time step vector to serve as an input of the diffusion model to train the diffusion model.

[0063] Furthermore, for temporal knowledge modeling, 75% of the time points are randomly selected for masking, and a self-supervised learning model is designed to capture temporal dynamic characteristics; for time series encoding, the trained model is used to encode the time series data of the last three days to generate an embedding vector of regional-level temporal knowledge.

[0064] In step S104, a diffusion model is constructed, and the diffusion model is trained according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model.

[0065] In a possible implementation, the diffusion model includes a normalization module and an attention module. The high-dimensional vector is subjected to noise processing to obtain a parameter matrix; the parameter matrix is ​​input into the normalization module for processing to obtain a normalized parameter matrix; the spatiotemporal feature embedding vector is embedded into a channel through an encoder to obtain an embedded spatiotemporal feature embedding vector; the normalized parameter matrix and the embedded spatiotemporal feature embedding vector are input into the attention module to obtain predicted noise; the real noise is obtained, and the diffusion model is optimized according to the predicted noise and the real noise to obtain a trained diffusion model.

[0066] Specifically, the initial parameter matrix and the noise addition process, the parameter matrix extracted from the pre-training is the starting point of the training. Through the k-step noise addition process, noise is gradually introduced, which helps the model learn the distribution of the data and enhances its robustness to noise. Input construction, the parameter matrix after noise addition, the generated spatiotemporal knowledge vector, and the time step vector of the encoding embedding together constitute the input of the Transformer network. The spatiotemporal knowledge vector is embedded in two channels through the encoder, capturing different dimensions of temporal and spatial features respectively, which helps the model understand the spatiotemporal characteristics of the data. In the processing of the Transformer network, the input first passes through the layer normalization module to ensure the scale consistency of the features of each dimension, which helps the stability of subsequent processing. Then, the input is sent to the multi-head attention module, in which the query matrix (Q), key matrix (K) and value matrix (V) are calculated. The query matrix acts as an intermediary in the calculation process, and measures the similarity with the key matrix, thereby adjusting the weight of the value matrix. This process realizes the weighted fusion of features. The spatiotemporal knowledge vector also participates in the calculation of the attention mechanism, and works together with the query matrix to enable the model to understand the spatiotemporal characteristics of the data more accurately. Prediction and loss calculation, after the nonlinear transformation of the point-by-point feedforward network, the model outputs the predicted noise, and continuously optimizes the model parameters by calculating the loss (such as mean square error, cross entropy, etc.) with the real noise. Training results, after multiple iterations of training, the model gradually learns the distribution characteristics of the data and can generate high-quality prediction results. The trained diffusion model can be used for various tasks, such as image generation, time series prediction, etc.

[0067] In other words, the process of training the diffusion model can be summarized as follows: based on the high-dimensional vector (parameter matrix after adding noise) and the spatiotemporal feature embedding vector (the spatiotemporal knowledge vector embedded by the encoder), feature extraction and weighted fusion are performed through the Transformer network, and finally the predicted noise is obtained and the loss is calculated with the real noise to optimize the model parameters, thereby obtaining a trained diffusion model. This model can capture the spatiotemporal characteristics of the data and generate high-quality prediction results.

[0068] Furthermore, in the process of training diffusion model in the target area prediction stage, a Transformer-based diffusion model is trained to generate adaptive neural network parameters for the target area. Parameter denoising: The parameter matrix extracted from pre-training undergoes a k-step denoising process to introduce noise and enhance the robustness of the model. Input processing: The noisy parameter matrix, the generated spatiotemporal knowledge vector, and the time step vector of the encoded embedding are passed to the Transformer network as input. The specific calculation is as follows: First, normalization processing: The parameter matrix is ​​input to the layer normalization module for normalization processing to ensure the scale consistency of the features in each dimension; multi-head attention calculation: The normalized parameter matrix is ​​sent to the multi-head attention module to calculate the query matrix (Query, Q), key matrix (Key, K) and value matrix (Value, V). The query matrix serves as an important intermediary in the calculation process for subsequent attention mechanism calculation. Spatiotemporal knowledge embedding: At the same time, the spatiotemporal knowledge vector is embedded into two channels through the encoder. This process aims to capture different dimensions of temporal and spatial features respectively. Attention mechanism calculation, the embedded spatiotemporal knowledge vector is further input into the attention module, and participates in the calculation of the attention mechanism together with the query matrix in the parameter matrix. This module realizes weighted fusion of features by adaptively defining the importance of features. Specifically, the query matrix adjusts the weight of the value matrix by measuring the similarity with the key matrix, and finally obtains the predicted noise through nonlinear transformation through the point-by-point feedforward network. By calculating the loss with the real noise, the parameters are continuously optimized to fully train the diffusion model.

[0069] In step S105, based on the trained diffusion model, traffic flow prediction is performed on the target city according to the traffic flow data to obtain a traffic flow prediction result.

[0070] In a possible implementation, sampling is performed from the trained diffusion model according to the spatiotemporal feature data corresponding to the target city to obtain the neural network parameters of the target city; the traffic flow data and the neural network parameters are input into the trained diffusion model to obtain the traffic flow prediction result of the target city.

[0071] Specifically, the parameters of the pre-trained neural network are sampled from the trained diffusion model according to the spatiotemporal knowledge of the target area (such as geographical location, traffic network structure, historical traffic data, etc.); the sampled parameters can be regarded as customized neural network parameters for the target area, which already contain universal spatiotemporal patterns learned from a large amount of data. Combined with the few sample data of the target area, although the sampled parameters have a certain generalization ability, in order to better adapt to the specific characteristics of the target area (such as traffic habits, road conditions, special events, etc.), it is necessary to fine-tune the parameters in combination with the few sample data of the target area. These few sample data can be the recent traffic flow data of the target area, special event records, etc. Input into the original pre-trained network, the traffic flow data of the target city and the sampled neural network parameters are input into the original pre-trained network together. It should be noted here that the original pre-trained network may be a large and complex model, such as Transformer, LSTM, etc., which has been pre-trained on a large amount of data and has powerful feature extraction and pattern recognition capabilities. The prediction output is carried out by combining the traffic flow data of the target area and the neural network parameters in the original pre-trained network, performing forward propagation calculations, and finally outputting the traffic flow prediction results of the target city. These results include both the universal spatiotemporal patterns learned from a large amount of data and the specific characteristics of the target area.

[0072] Furthermore, in the sampling and prediction process of the target area prediction stage, adaptive neural network parameters are sampled from the trained diffusion model based on the spatiotemporal knowledge of the target area, and traffic flow prediction is performed. Sampling parameters: the pre-trained neural network parameters of the target area are sampled from the trained diffusion model based on the spatiotemporal knowledge of the target area; combining data: combining the few sample data of the target area, the target city traffic flow data and neural network parameters are input into the original pre-trained network, and the traffic flow data of the target city is predicted and output. Prediction output: in this way, the traffic flow data of the target area can not only make full use of the universal spatiotemporal patterns learned in the pre-trained network, but also effectively adjust the network parameters through the few sample learning mechanism to adapt to the specific characteristics of the target area.

[0073] Next, a small sample traffic flow prediction system based on a diffusion model proposed in accordance with an embodiment of the present application will be described with reference to the accompanying drawings.

[0074] Figure 3 It is a structural diagram of a small sample traffic flow prediction system based on a diffusion model in an embodiment of the present application.

[0075] like Figure 3As shown, the small sample traffic flow prediction system based on the diffusion model includes: a data acquisition module 100, a prediction model training module 200, a spatiotemporal knowledge acquisition module 300, a diffusion model training module 400 and a traffic flow prediction module 500.

[0076] Specifically, the data acquisition module 100 is used to acquire traffic flow data of a city, wherein the city includes a source city and a target city;

[0077] A prediction model training module 200, for constructing a spatiotemporal prediction model and training the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector;

[0078] The spatiotemporal knowledge acquisition module 300 is used to acquire the spatiotemporal feature data of the city, process the spatiotemporal feature data, and obtain a spatiotemporal feature embedding vector;

[0079] A diffusion model training module 400 is used to construct a diffusion model, and train the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model;

[0080] The traffic flow prediction module 500 is used to perform traffic flow prediction on the target city based on the trained diffusion model and the traffic flow data to obtain a traffic flow prediction result.

[0081] Figure 4 This is a structural diagram of a terminal provided in an embodiment of the present application. The terminal may include:

[0082] A memory 501 , a processor 502 , and a computer program stored in the memory 501 and executable on the processor 502 .

[0083] When the processor 502 executes the program, the few-sample traffic flow prediction method based on the diffusion model provided in the above embodiment is implemented.

[0084] Furthermore, the terminal further includes:

[0085] The communication interface 503 is used for communication between the memory 501 and the processor 502 .

[0086] The memory 501 is used to store computer programs that can be executed on the processor 502 .

[0087] The memory 501 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0088] If the memory 501, the processor 502 and the communication interface 503 are implemented independently, the communication interface 503, the memory 501 and the processor 502 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus or an Extended Industry Standard Architecture (EIS) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0089] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.

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

[0091] This embodiment also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned small-sample traffic flow prediction method based on the diffusion model is implemented.

[0092] One embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the present application Figure 1 Any of the corresponding embodiments provides a small sample traffic flow prediction method based on a diffusion model.

[0093] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

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

[0095] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0096] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable storage medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, a "computer-readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable storage media include the following: an electrical connection with one or N wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable storage medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.

[0097] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0098] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0099] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0100] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

[0101] It should be understood that the application of the present application is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to this application.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A small sample traffic flow prediction method based on a diffusion model, characterized in that: The small sample traffic flow prediction method based on the diffusion model includes: Acquire traffic flow data of cities, wherein the cities include a source city and a target city; Constructing a spatiotemporal prediction model, and training the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector; Acquire the spatiotemporal feature data of the city, process the spatiotemporal feature data, and obtain a spatiotemporal feature embedding vector; Constructing a diffusion model, and training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model; Based on the trained diffusion model, traffic flow prediction is performed on the target city according to the traffic flow data to obtain a traffic flow prediction result.

2. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 1, characterized in that: The training of the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector specifically includes: Training the spatiotemporal prediction model according to the traffic flow data to obtain a trained spatiotemporal prediction model; Parameters are extracted from the trained spatiotemporal prediction model to obtain a high-dimensional vector.

3. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 1, characterized in that: The spatiotemporal feature data includes time feature data, global feature data and local environment feature data of the source city and the target city, and the spatiotemporal feature embedding vector includes a spatial knowledge embedding vector and a temporal knowledge embedding vector; The processing of the spatiotemporal feature data to obtain a spatiotemporal feature embedding vector specifically includes: Processing the global feature data and the local environment feature data to obtain spatial feature data; Encoding the spatial feature data to obtain spatial feature codes, and performing graph convolution processing on the spatial splicing feature codes to obtain spatial knowledge embedding vectors; The time feature data is encoded to obtain a time feature code, and the time feature code is processed to obtain a time knowledge embedding vector.

4. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 1, characterized in that: The spatiotemporal feature data includes time feature data, global feature data and local environment feature data of the source city and the target city, and the spatiotemporal feature embedding vector includes a spatial knowledge embedding vector and a temporal knowledge embedding vector; The processing of the spatiotemporal feature data to obtain a spatiotemporal feature embedding vector specifically includes: Encoding the global feature data and the local environment feature data respectively to obtain a global feature code and a local environment feature code; Performing feature fusion on the global feature code and the local environment feature code to obtain a spatial feature vector, and performing graph convolution processing on the spatial feature vector to obtain a spatial knowledge embedding vector; The time feature data is encoded to obtain a time feature code, and the time feature code is processed to obtain a time knowledge embedding vector.

5. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 1, characterized in that: The diffusion model includes a normalization module and an attention module; The step of training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model specifically includes: Performing noise processing on the high-dimensional vector to obtain a parameter matrix; Inputting the parameter matrix into the normalization module for processing to obtain a normalized parameter matrix; Embedding the spatiotemporal feature embedding vector into a channel through an encoder to obtain an embedded spatiotemporal feature embedding vector; Inputting the normalized parameter matrix and the embedded spatiotemporal feature embedding vector into the attention module to obtain prediction noise; The real noise is obtained, and the diffusion model is optimized according to the predicted noise and the real noise to obtain a trained diffusion model.

6. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 5, characterized in that: The step of training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector to obtain a trained diffusion model further includes: Obtaining time series data for the city; The time series data is encoded to obtain a time step vector to serve as an input of the diffusion model to train the diffusion model.

7. The method for predicting traffic flow with a small number of samples based on a diffusion model according to claim 1, characterized in that: The step of performing traffic flow prediction on the target city based on the trained diffusion model and the traffic flow data to obtain a traffic flow prediction result specifically includes: Sampling from the trained diffusion model according to the spatiotemporal feature data corresponding to the target city to obtain the neural network parameters of the target city; The traffic flow data and the neural network parameters are input into the trained diffusion model to obtain the traffic flow prediction result of the target city.

8. A small sample traffic flow prediction system based on a diffusion model, characterized in that: The small sample traffic flow prediction system based on the diffusion model includes: A data acquisition module, used to acquire traffic flow data of a city, wherein the city includes a source city and a target city; A prediction model training module, used for constructing a spatiotemporal prediction model and training the spatiotemporal prediction model according to the traffic flow data to obtain a high-dimensional vector; A spatiotemporal knowledge acquisition module, used to acquire the spatiotemporal feature data of the city, process the spatiotemporal feature data, and obtain a spatiotemporal feature embedding vector; A diffusion model training module, used for constructing a diffusion model, training the diffusion model according to the high-dimensional vector and the spatiotemporal feature embedding vector, to obtain a trained diffusion model; The traffic flow prediction module is used to perform traffic flow prediction on the target city based on the trained diffusion model and the traffic flow data to obtain a traffic flow prediction result.

9. A terminal, characterized in that: The terminal includes: a memory, a processor, and a few-sample traffic flow prediction program based on a diffusion model stored in the memory and executable on the processor. When the few-sample traffic flow prediction program based on a diffusion model is executed by the processor, the steps of the few-sample traffic flow prediction method based on a diffusion model as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a few-sample traffic flow prediction program based on a diffusion model, and when the few-sample traffic flow prediction program based on a diffusion model is executed by a processor, the steps of the few-sample traffic flow prediction method based on a diffusion model as described in any one of claims 1-7 are implemented.

Citation Information

Cited By

  • Urban activity prediction method and system based on Transform architecture and denoising diffusion probability model

    CN120471108A

  • Traffic flow prediction method, device, equipment, storage medium and program product

    CN120496324A