Method and device for predicting traffic flow, electronic equipment and storage medium

By extracting and enhancing historical traffic flow data of the road network to be predicted, utilizing the backbone network to obtain spatiotemporal dependency features, determining the target time scale, compressing and extracting scale-time series features, the problem of low traffic flow prediction accuracy in existing technologies is solved, and high-precision prediction across multiple time scales is achieved.

CN122024489APending Publication Date: 2026-05-12UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610371292.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-25
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, traffic flow prediction models struggle to capture the evolution patterns across different time scales simultaneously, resulting in low prediction accuracy.

Method used

By acquiring historical traffic flow data of the road network to be predicted, multi-source initial features are extracted using a pre-set traffic flow prediction model, and spatiotemporal dependency features are enhanced using a backbone network to determine the target time scale. The scale time series features are then compressed and extracted to finally obtain the predicted traffic flow sequence.

Benefits of technology

It enables traffic flow prediction at multiple time scales, improving the accuracy of predictions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122024489A_ABST
    Figure CN122024489A_ABST
Patent Text Reader

Abstract

The invention is applied to the technical field of intelligent traffic, and discloses a method and device for predicting traffic flow, electronic equipment and a storage medium. The method comprises the following steps: acquiring historical traffic flow data corresponding to a road network to be predicted; inputting the historical traffic flow data into a preset traffic flow prediction model to obtain a predicted flow sequence corresponding to the to-be-predicted road network; the traffic flow prediction model is used for extracting multi-source initial features of historical traffic flow data; enhancing the multi-source initial features by using a backbone network, obtaining space-time dependent features, and further determining a plurality of target time scales; based on each target time scale, compressing the space-time dependence feature and the scale compression feature corresponding to each target time scale; based on each scale compression feature, extracting a scale time sequence feature corresponding to each target time scale; and obtaining a predicted flow sequence corresponding to the road network to be predicted based on the scale time sequence characteristics corresponding to the target time scales. In this way, multi-time-scale flow prediction is realized, so that the prediction accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent transportation technology, and more specifically to a method, apparatus, electronic device, and storage medium for predicting traffic flow. Background Technology

[0002] Currently, with the continuous expansion of global cities and the increasing demand for individual travel, transportation systems are facing increasing pressure, making traffic flow prediction a core issue in modern intelligent transportation management. Traffic flow is a key indicator for measuring the operational status of the road network to be predicted; its dynamic changes directly affect road capacity and have a profound impact on the stability and reliability of urban transportation systems. Accurate traffic flow prediction can provide crucial information for management decisions such as traffic signal control, route guidance, and road network scheduling, thereby optimizing the efficiency of traffic resource allocation in both spatiotemporal dimensions. Furthermore, accurate flow forecasting helps identify potential bottleneck sections and peak periods, providing forward-looking support for congestion prevention and improving the efficiency of the road network to be predicted. Therefore, constructing high-precision, highly adaptable traffic flow prediction models has become an important research direction in the interdisciplinary field of traffic engineering and intelligent science. In recent years, deep learning models have made significant progress in traffic congestion prediction, especially Graph Convolutional Neural Networks (GCNs). By modeling the traffic network as a graph structure, GCNs can effectively capture the spatial dependencies between nodes (such as intersections and road segments) in the road network to be predicted, greatly promoting the development of traffic prediction models.

[0003] Current technologies typically use fixed time windows for traffic flow forecasting. However, traffic flow has significant spatiotemporal coupling characteristics and multi-scale time patterns. Fixed time windows often fail to capture the evolution patterns at different time scales simultaneously, resulting in low forecast accuracy.

[0004] Therefore, in order to overcome the above-mentioned technical problems, the present invention provides a method, apparatus, electronic device, and storage medium for predicting traffic flow. Summary of the Invention

[0005] The technical problem to be solved by the present invention is how to improve the accuracy of traffic flow prediction. The purpose is to provide a method, device, electronic device and storage medium for predicting traffic flow, so as to improve the accuracy of traffic flow prediction.

[0006] This invention is achieved through the following technical solution:

[0007] In a first aspect, a method for predicting traffic flow includes: acquiring historical traffic flow data corresponding to a road network to be predicted; the historical traffic flow data includes traffic state data corresponding to each traffic node and timestamp information corresponding to the traffic state data; inputting the historical traffic flow data into a preset traffic flow prediction model to obtain a predicted flow sequence corresponding to the road network to be predicted; the traffic flow prediction model is used to extract multi-source initial features of the historical traffic flow data based on node dimension, time dimension, and state dimension; enhancing the multi-source initial features using a preset backbone network to obtain the spatiotemporal dependency features; determining several target time scales based on the spatiotemporal dependency features; then compressing the spatiotemporal dependency features and scale compression features corresponding to each target time scale based on each target time scale; extracting scale time series features corresponding to each target time scale based on each scale compression feature; and then obtaining the predicted flow sequence corresponding to the road network to be predicted based on the scale time series features corresponding to each target time scale.

[0008] In some embodiments, the traffic flow prediction model extracts and enhances feature data from the historical traffic flow data based on node, time, and state dimensions to obtain spatiotemporal dependent features, including: extracting node index vectors, timestamp information, and traffic state data corresponding to each traffic node from the historical traffic flow data; obtaining time indexes and date one-hot encodings based on the timestamp information; obtaining node embedding vectors based on the node index vectors; obtaining time embedding vectors based on the time indexes; obtaining date embedding vectors based on the date one-hot encodings; obtaining traffic state embedding vectors based on the traffic state data; and determining the sum of the node embedding vectors, time embedding vectors, date embedding vectors, and traffic state embedding vectors as multi-source initial features.

[0009] In some embodiments, the backbone network includes a first graph neural network and a second graph neural network in parallel; the traffic flow prediction model utilizes the preset backbone network to enhance the multi-source initial features and obtain the spatiotemporal dependency features in the following manner: constructing a first unweighted undirected graph and a second unweighted undirected graph corresponding to the road network to be predicted; the nodes of the first unweighted undirected graph and the second unweighted undirected graph are the traffic nodes; the edges of the first unweighted undirected graph and the second unweighted undirected graph represent the roads of the road network to be predicted; the first adjacency matrix of the first unweighted undirected graph represents the connection relationship of each traffic node; the second adjacency matrix of the second unweighted undirected graph represents the data similarity of each traffic node; and so on. The multi-source initial features, the first adjacency matrix, and the second adjacency matrix are input into the backbone network; a number of spatiotemporal feature blocks are extracted from the multi-source initial features using a preset first sliding time window; each spatiotemporal feature block includes feature data from three consecutive time points; each spatiotemporal feature block is reshaped into a two-dimensional form to obtain spatiotemporal two-dimensional features; the spatiotemporal two-dimensional features are convolved with the first adjacency matrix using the first graph neural network to obtain a first feature tensor; the spatiotemporal two-dimensional features are convolved with the second adjacency matrix using the second graph neural network to obtain a second feature tensor; the first feature tensor and the second feature tensor are fused to obtain the spatiotemporal dependent features.

[0010] In some embodiments, the traffic flow prediction model determines several target time scales based on the spatiotemporal dependency features in the following manner: performing global average pooling and flattening on the spatiotemporal dependency features to obtain a global context feature vector; inputting the global context features into a preset scale attention selector to obtain a selection weight vector; and determining each of the target time scales in a preset scale candidate set based on the selection weight vector.

[0011] In some embodiments, the traffic flow prediction model extracts scale-time features corresponding to each target time scale based on each scale compression feature in the following manner: inputting each scale compression feature into a preset interactive graph convolutional network and a preset hypergraph convolutional network respectively to obtain interactive features and hypergraph features corresponding to each target time scale; fusing each interactive feature and each hypergraph feature based on the target time scale to obtain scale-time features corresponding to each target time scale.

[0012] In some embodiments, the traffic flow prediction model obtains the predicted traffic flow sequence corresponding to the road network to be predicted based on the scale-time series features corresponding to each of the target time scales in the following manner: performing feature fusion on the scale-time series features corresponding to each of the target time scales to obtain a joint spatiotemporal feature representation; and obtaining the predicted traffic flow sequence within a preset target time range based on the joint spatiotemporal feature representation.

[0013] In some embodiments, the traffic flow prediction model is obtained by: acquiring historical traffic flow data to be trained and subsequent real traffic flow sequences corresponding to the historical traffic flow data to be trained; inputting the historical traffic flow data to be trained into a preset initial traffic flow prediction model to obtain a predicted traffic flow sequence to be trained; calculating the mean absolute error corresponding to the initial traffic flow prediction model based on the subsequent real traffic flow sequence and the predicted traffic flow sequence to be trained; and using the mean absolute error as a loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model.

[0014] In a second aspect, an apparatus for predicting traffic flow includes: an acquisition module configured to acquire historical traffic flow data corresponding to a road network to be predicted; the historical traffic flow data includes traffic state data corresponding to each traffic node and timestamp information corresponding to the traffic state data; and a prediction module configured to input the historical traffic flow data into a preset traffic flow prediction model to obtain a predicted flow sequence corresponding to the road network to be predicted; the traffic flow prediction model is used to extract multi-source initial features of the historical traffic flow data based on node dimension, time dimension, and state dimension; enhance the multi-source initial features using a preset backbone network to obtain the spatiotemporal dependency features; determine several target time scales based on the spatiotemporal dependency features; then compress the spatiotemporal dependency features and scale compression features corresponding to each target time scale based on each target time scale; extract scale time series features corresponding to each target time scale based on each scale compression feature; and then obtain the predicted flow sequence corresponding to the road network to be predicted based on the scale time series features corresponding to each target time scale.

[0015] Thirdly, an electronic device includes a processor and a memory storing program instructions, the processor being configured to execute the above-described method for predicting traffic flow when the program instructions are executed.

[0016] Fourthly, a storage medium stores program instructions that, when executed, perform the aforementioned method for predicting traffic flow.

[0017] Compared with existing technologies, this invention acquires historical traffic flow data corresponding to the road network to be predicted, then uses a preset traffic flow prediction model to extract multi-source initial features from the historical traffic flow data, and uses a preset backbone network to enhance the multi-source initial features to obtain spatiotemporal dependency features. Then, based on several target time scales obtained through the spatiotemporal dependency features, the spatiotemporal dependency features are compressed respectively. Next, scale-time series features corresponding to each target time scale are extracted using the scale-compression features corresponding to each target time scale. Finally, the predicted traffic flow sequence corresponding to the road network to be predicted is obtained based on the scale-time series features corresponding to each target time scale. In this way, this scheme obtains several target time scales by extracting and enhancing the spatiotemporal dependency features obtained from the historical traffic flow data corresponding to the road network to be predicted, compresses the spatiotemporal dependency features based on each target time scale, and extracts the scale-time series features corresponding to each target time scale. Traffic flow prediction is then performed based on the scale-time series features corresponding to each target time scale. Compared with existing technologies that use fixed time windows for traffic flow prediction, this achieves multi-time-scale traffic flow prediction, thereby improving the prediction accuracy. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:

[0019] Figure 1 This is a flowchart illustrating a method for predicting traffic flow provided in an embodiment of this disclosure;

[0020] Figure 2 This is a schematic diagram illustrating the training of an initial traffic flow prediction model provided in an embodiment of this disclosure;

[0021] Figure 3 This is a schematic diagram of a backbone network provided in an embodiment of this disclosure;

[0022] Figure 4 This is a schematic diagram of a device for predicting traffic flow provided in an embodiment of this disclosure;

[0023] Figure 5 This is a schematic diagram of another device for predicting traffic flow provided in an embodiment of this disclosure. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.

[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0026] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0027] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0028] In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0029] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating a method for predicting traffic flow, as shown in an exemplary embodiment of this application.

[0030] like Figure 1 As shown, this disclosure provides a method for predicting traffic flow, the method comprising:

[0031] Step S101: Obtain historical traffic flow data corresponding to the road network to be predicted; historical traffic flow data includes traffic status data corresponding to each traffic node and timestamp information corresponding to the traffic status data.

[0032] Step S102: Input historical traffic flow data into a preset traffic flow prediction model to obtain the predicted traffic flow sequence corresponding to the road network to be predicted; the traffic flow prediction model is used to extract multi-source initial features of historical traffic flow data based on node dimension, time dimension and state dimension; enhance the multi-source initial features using a preset backbone network to obtain spatiotemporal dependency features; determine several target time scales based on the spatiotemporal dependency features; then compress the spatiotemporal dependency features based on each target time scale, and the scale compression features corresponding to each target time scale; extract the scale time series features corresponding to each target time scale based on the scale compression features; and then obtain the predicted traffic flow sequence corresponding to the road network to be predicted based on the scale time series features corresponding to each target time scale.

[0033] This approach involves acquiring historical traffic flow data corresponding to the road network to be predicted, then using a pre-defined traffic flow prediction model to extract multi-source initial features from the historical traffic flow data. These initial features are then enhanced using a pre-defined backbone network to obtain spatiotemporal dependency features. These spatiotemporal dependency features are then compressed for several target time scales obtained through the spatiotemporal dependency features. Finally, scale-based time-series features corresponding to each target time scale are extracted using the scale-based time-series features corresponding to each target time scale. Based on these scale-based time-series features, the predicted traffic flow sequence for the road network to be predicted is obtained. This method, by extracting and enhancing the spatiotemporal dependency features obtained from historical traffic flow data corresponding to the road network to be predicted, adaptively acquires several target time scales. It then compresses the spatiotemporal dependency features based on each target time scale and extracts the scale-based time-series features corresponding to each target time scale. Traffic flow prediction is then performed based on these scale-based time-series features, achieving multi-time-scale traffic flow prediction compared to existing technologies that use fixed time windows. This improves the accuracy of the prediction.

[0034] It should be noted that a sensor module is installed at each traffic node in the road network to be predicted; this sensor module is used to collect traffic status data corresponding to the traffic node.

[0035] Furthermore, the traffic flow prediction model extracts and enhances the feature data of historical traffic flow data based on the node, time, and state dimensions to obtain spatiotemporal dependent features, including: extracting the node index vector, timestamp information, and traffic state data corresponding to each traffic node from the historical traffic flow data; obtaining the time index and date one-hot encoding based on the timestamp information; obtaining the node embedding vector based on the node index vector; obtaining the time embedding vector based on the time index; obtaining the date embedding vector based on the date one-hot encoding; obtaining the traffic state embedding vector based on the traffic state data; and determining the sum of the node embedding vector, time embedding vector, date embedding vector, and traffic state embedding vector as the multi-source initial feature. In this way, historical traffic flow data can be transformed into a unified dense vector representation based on the node, time, and state dimensions. That is, the multi-source initial feature achieves feature embedding, thereby facilitating the effective capture of spatial heterogeneity, temporal periodicity, and real-time dynamics from the multi-source initial feature, improving prediction accuracy.

[0036] It should be noted that the traffic flow prediction model includes an embedding layer. Both node embedding vectors and time-based embedding vectors can improve the acquisition of the embedding layer.

[0037] Furthermore, obtaining the node embedding vector based on the node index vector includes: inputting the node index vector into the embedding layer to obtain the node embedding vector.

[0038] Specifically, node embedding vectors .in, Embed vectors for nodes; Characterization embedding layer; This is the node index vector corresponding to the node index vector; . This represents the total number of traffic nodes. Each element in the node index vector represents a traffic node. The node index vector is input into the embedding layer to obtain the node embedding vector. In this way, the node embedding vector can reflect the unique characteristics of each traffic node.

[0039] Furthermore, obtaining the time embedding vector based on the time index vector includes: inputting the node index vector into the embedding layer to obtain the time embedding vector.

[0040] Specifically, the embedding vector at each time step ;in, The embedding vector at time step; The time index vector; It is the set of real numbers; Let B be a real tensor with T columns and D eigenvalues ​​in each column; each element of this real tensor is a real number. The batch size is represented by the number of samples in the historical traffic flow data. is the time step, which is the length of the time index vector; The preset feature dimensions.

[0041] Time index vector ; The original input features are historical traffic flow data; To Perform the slicing operation. The first three colons represent retrieving all batches, all time steps, and all nodes, respectively. This represents the 0th feature dimension. This represents the first feature dimension, which represents time information, such as "time of day".

[0042] It should be noted that the traffic flow prediction model also includes a linear layer. The linear layer is used to perform high-dimensional mapping between date one-hot encoding and traffic state data.

[0043] Furthermore, obtaining the date embedding vector based on one-hot date encoding includes: inputting the one-hot date encoding into a linear layer for high-dimensional mapping to obtain the date embedding vector.

[0044] Furthermore, date embedding vector ;in, Embedded as a date vector; For the preset one-hot encoded tensor of date, ; This is a preset bias vector. ; Embed weights for preset dates. .

[0045] It should be noted that traffic status data includes data such as flow rate, speed, and occupancy rate, which characterize the traffic conditions at each traffic node.

[0046] Furthermore, obtaining traffic state embedding vectors based on traffic state data includes: inputting traffic state data into a linear layer for high-dimensional mapping to obtain traffic state embedding vectors.

[0047] Specifically, traffic state embedding vector ;in, This is a traffic weight matrix; It is a paranoia vector; Characterization This is a nonlinear transformation function used to introduce nonlinearity, enabling the model to learn more complex patterns. In some embodiments, .

[0048] It should be noted that the sum of the node embedding vector, time embedding vector, date embedding vector, and traffic state embedding vector is used to determine the initial multi-source features, i.e., by calculating... To obtain multi-source initial features; among them, These are initial features from multiple sources.

[0049] Furthermore, the backbone network includes a parallel first graph neural network and a second graph neural network; the traffic flow prediction model utilizes the pre-defined backbone network to enhance multi-source initial features and obtain spatiotemporal dependent features in the following manner: constructing a first unweighted undirected graph and a second unweighted undirected graph corresponding to the road network to be predicted; the nodes of the first unweighted undirected graph and the second unweighted undirected graph are traffic nodes; the edges of the first unweighted undirected graph and the second unweighted undirected graph represent roads in the road network to be predicted; the first adjacency matrix of the first unweighted undirected graph represents the connection relationship of each traffic node; the second adjacency matrix of the second unweighted undirected graph represents the data similarity of each traffic node; and multi-source... Initial features, a first adjacency matrix, and a second adjacency matrix are input into the backbone network. A preset first sliding time window is used to extract several spatiotemporal feature blocks from the multi-source initial features. Each spatiotemporal feature block includes feature data from three consecutive time points. Each spatiotemporal feature block is reshaped into a two-dimensional form to obtain spatiotemporal two-dimensional features. A first graph neural network is used to perform graph convolution operations between the spatiotemporal two-dimensional features and the first adjacency matrix to obtain a first feature tensor. A second graph neural network is used to perform graph convolution operations between the spatiotemporal two-dimensional features and the second adjacency matrix to obtain a second feature tensor. The first and second feature tensors are then fused to obtain spatiotemporally dependent features. In this way, by using the first graph neural network to convolve multiple spatiotemporal feature blocks and the first adjacency matrix from the multi-source initial features, and using the second graph neural network to convolve multiple spatiotemporal feature blocks and the second adjacency matrix from the multi-source initial features, the spatiotemporally dependent features are obtained. This allows for the integration of features extracted from two different perspectives: physical topology and data similarity. This allows the final spatiotemporal dependency features to include both the physical structure information of the road network and the data similarity information between nodes, enabling a more comprehensive and accurate characterization of the spatiotemporal dependencies in traffic flow data. This provides a richer feature base for subsequent traffic flow prediction, thereby improving the accuracy and reliability of the prediction.

[0050] It should be noted that the process of extracting several spatiotemporal feature blocks from the multi-source initial features using a preset first sliding time window is as follows: For the t-th time step in the multi-source initial features, taking this time step as the current processing time, the feature data of the two previous time steps and the current time step are extracted to form a spatiotemporal feature block containing three consecutive time steps. .

[0051] It should be noted that the specific process of reshaping each spatiotemporal feature block into a two-dimensional form to obtain spatiotemporal two-dimensional features is as follows: the spatiotemporal feature block is reshaped to merge the time and node dimensions and convert it into a three-dimensional tensor; this three-dimensional tensor is determined as the spatiotemporal two-dimensional feature.

[0052] Furthermore, before constructing the first and second unweighted undirected graphs corresponding to the road network to be predicted, an initial unweighted undirected graph can be constructed first.

[0053] It should be noted that the initial unweighted and undirected graph ;in, and These correspond to the node set and edge set of the initial unweighted undirected graph, respectively. If the nodes of the initial unweighted undirected graph are traffic nodes, then the node set is the set of traffic nodes. If the edges of the initial unweighted undirected graph are roads in the road network to be predicted, then the edge set is the set of roads, which is used to reflect the road connection relationships of the road network to be predicted.

[0054] This is the initial adjacency matrix of the initial unweighted undirected graph. This initial adjacency matrix is ​​used to represent the proximity relationship between two nodes, and is represented by 0 and 1.

[0055] Specifically, This formula represents the condition when the node... and nodes When there are connections between nodes, the initial adjacency matrix represents the nodes. and nodes Elements with proximity relationships =1, otherwise =0.

[0056] It should be noted that the nodes and edges of the first and second unweighted undirected graphs are the same as those of the initial unweighted undirected graph, and will not be repeated here.

[0057] Furthermore, the first adjacency matrix of the first unweighted undirected graph is obtained as follows: A first diagonal matrix is ​​constructed using a time window of size 3: ,in The initial adjacency matrix is ​​used. The first diagonal matrix is ​​expanded using a pre-defined first self-connection matrix; the expanded first diagonal matrix is ​​then normalized to obtain the first adjacency matrix.

[0058] Specifically, the first diagonal matrix is ​​expanded using a preset first self-connected matrix, including: by calculating... This yields the first diagonal matrix after expansion; where, This is the first diagonal matrix after expansion; This is the first diagonal matrix; This is the first self-connected matrix. Specifically, It is an identity matrix with dimensions 3N×3N. For example: .in, It is an identity matrix with dimensions N×N.

[0059] Furthermore, the expanded first diagonal matrix is ​​normalized to obtain the first adjacency matrix, including: obtaining the degree matrix of the expanded first diagonal matrix; and calculating... Thus, the first adjacency matrix is ​​obtained. This is the first adjacency matrix; Let be the degree matrix of the first diagonal matrix.

[0060] Furthermore, the second adjacency matrix of the second unweighted undirected graph is obtained as follows: A second diagonal matrix is ​​constructed using a time window of size 3: ,in The initial adjacency matrix is ​​used. The second diagonal matrix is ​​expanded using a pre-defined second self-connection matrix; the expanded second diagonal matrix is ​​then normalized to obtain the second adjacency matrix.

[0061] Furthermore, the second diagonal matrix is ​​expanded using a pre-defined second self-connected matrix, including: by calculating... This yields the expanded second diagonal matrix; where, This is the expanded second diagonal matrix; This is the second diagonal matrix; This is the second self-connected matrix.

[0062] Furthermore, the expanded second diagonal matrix is ​​normalized to obtain the second adjacency matrix, including: obtaining the row degree matrix of the expanded second diagonal matrix; and calculating... The second adjacency matrix is ​​obtained; where, This is the second adjacency matrix; This is the row degree matrix of the expanded second diagonal matrix.

[0063] It should be noted that the element in the i-th row and i-th column of the row degree matrix of the expanded second diagonal matrix is ​​obtained as follows: .

[0064] It should be noted that the spatiotemporal feature block includes feature data at three consecutive time points. That is, for the t1th time point, the spatiotemporal feature block includes: feature data at the t1-1th time point, feature data at the t1th time point, and feature data at the t1+1th time point.

[0065] It should be noted that the backbone network consists of two parallel processing paths, with each path corresponding to a graph neural network. Specifically, the first path uses the first graph neural network to perform graph convolution operations between the spatiotemporal two-dimensional features and the first adjacency matrix to obtain the first feature tensor; the second path uses the second graph neural network to perform graph convolution operations between the spatiotemporal two-dimensional features and the second adjacency matrix to obtain the second feature tensor.

[0066] In both the first and second graph neural networks, the essence of graph convolution is to mix the features of each node with the features of its spatiotemporal neighbors according to the weights defined by the adjacency matrix, thereby capturing the dependencies between nodes. The convolved features undergo a nonlinear transformation through a feedforward neural network, are then added to the original input features as residuals, and finally have their numerical distribution stabilized through layer normalization.

[0067] Both the first and second graph neural networks include L layers of the same GNN (Graph Neural Network) processing units. The first and second graph neural networks use the same processing method but have independent parameters.

[0068] The mathematical operations of a single-layer GNN processing unit are shown in the following formula: ;in, For the nth path of the graph neural network, the nth path is the nth path. Layer input; For the nth path of the graph neural network, the nth path is the nth path. Layer output; This is the adjacency matrix corresponding to the nth path; The graph neural network representing the nth path Layered GNN processing unit.

[0069] Specific, complete The operation can be expanded as follows: In this context, FNN represents a feedforward neural network; The graph convolution steps are as follows: ;in, Represents the reshaping of features into two dimensions. This is a learnable weight matrix. This process stacks multiple layers within each path, deepening feature extraction layer by layer.

[0070] After processing both paths, two feature tensors with identical shapes are obtained: the first feature tensor and the second feature tensor. They represent feature representations learned based on different spatial relationships, respectively.

[0071] Furthermore, by fusing the first feature tensor and the second feature tensor, spatiotemporal dependent features are obtained, including: through computation To obtain spatiotemporal dependency features; among them, It is a spatiotemporal dependent feature; Let it be the first feature tensor; This is the second characteristic tensor.

[0072] The dimensions of the first feature tensor, the second feature tensor, and the spatiotemporal dependency feature are all: .

[0073] In this way, the output feature tensors of the two paths are stacked along a new dimension using max pooling, and then the maximum value is taken for each corresponding feature value along this dimension. This means that for each specific position in the feature tensor, the model compares the feature values ​​of the two paths at that position and only retains the one with the larger value. This fusion method is equivalent to making the two paths competitively contribute features—in each feature dimension, only the features of the path that is more active and significant are retained.

[0074] Furthermore, the traffic flow prediction model determines several target time scales based on spatiotemporal dependency features as follows: global average pooling and flattening are performed on the spatiotemporal dependency features to obtain a global context feature vector; the global context features are input into a pre-defined scale attention selector to obtain a selection weight vector; and each target time scale is determined from a pre-defined scale candidate set based on the selection weight vector. This allows the model to adaptively determine an appropriate time window size from the data features, enabling it to select the corresponding analysis range according to the characteristics of the traffic scenario. This helps the model analyze and predict traffic flow at different time granularities, capturing the patterns of traffic flow changes at different time scales.

[0075] Furthermore, global average pooling and flattening are performed on the spatiotemporal dependent features to obtain a global context feature vector. This includes performing global average pooling on both the time and node dimensions and flattening the vector to obtain a single global context feature vector. This global context feature vector is a compact vector. This vector comprehensively represents the overall state and spatiotemporal distribution pattern of the current batch of data across the entire range.

[0076] It should be noted that the preset candidate scale set includes M different time scale factors. Specifically, the candidate scale set... ;in, Each of these is a positive integer or a specific real number, representing the step size or ratio when performing adaptive pooling on the input time series. The M timescale factors in the candidate scale set can cover different time analysis windows ranging from minutes to hours.

[0077] The preset scale attention selector takes the global context feature vector as input and obtains the selection weight vector.

[0078] Specifically, select the weight vector , it is A weight vector of dimension; Each element is selected from the weight vector. Each element corresponds one-to-one with an element in the scale candidate set.

[0079] Furthermore, the scale attention selector obtains the selection weight vector in the following way: ;in, The preset first learning weight; The second learning weight is preset. The preset first learning bias parameter, This is the preset second learning bias parameter; , , , All of these are learnable parameters. The preset sigmoid activation function is used to ensure that each element in the selection weight vector... Weight It reflects the correlation score of the corresponding time scale factor in the current traffic scenario.

[0080] Furthermore, based on the selection of weight vectors, each target time scale is determined from a pre-defined set of candidate scales, including: by calculating... The activation scale subset is determined from the candidate scale set; the elements in the activation scale subset are then identified as the target time scale. To activate the scale subset; This is the preset selection threshold.

[0081] Furthermore, the spatiotemporal dependency features are compressed based on each target time scale, and the scale compression features corresponding to each target time scale are compressed. That is, a time pooling operation is performed based on each target time scale to compress the spatiotemporal dependency features to the length corresponding to that target time scale.

[0082] Furthermore, the traffic flow prediction model extracts scale-time series features corresponding to each target time scale based on compressed features at each scale in the following manner: The compressed features at each scale are input into a pre-defined interactive graph convolutional network and a pre-defined hypergraph convolutional network to obtain the interactive features and hypergraph features corresponding to each target time scale; based on the target time scale, the interactive features and hypergraph features are fused to obtain the scale-time series features corresponding to each target time scale. In this way, the interactive graph convolutional network can capture the interaction relationships between nodes, the hypergraph convolutional network can extract hypergraph features and mine higher-order relationships, and the scale-time series features corresponding to each target time scale can be obtained by fusing the interactive features and hypergraph features based on the target time scale. This allows the fused scale-time series features to more comprehensively describe the characteristics and changing patterns of traffic flow at the target time scale, better capture subtle changes and potential patterns in the data, and thus improve the accuracy of traffic flow prediction.

[0083] It should be noted that for interactive graph convolutional networks, after receiving compressed features at each scale, a spatiotemporal adjacency matrix is ​​constructed based on the initial adjacency matrix. Then, the spatiotemporal adjacency matrix is ​​symmetrically normalized. For each target time scale, a pre-defined second sliding window is used to extract features of the current time step and its previous few time steps from the scale compressed features, obtaining the time window features corresponding to each time step. For each time step, the time window features are reshaped into a two-dimensional form to obtain two-dimensional time features. The two-dimensional time features are then subjected to multi-branch projection and aggregation based on the symmetrically normalized spatiotemporal adjacency matrix to obtain multiple aggregated time features. Candidate interactive features are obtained based on each aggregated time feature. Finally, the candidate interactive features corresponding to each time step are aggregated to obtain the interactive features.

[0084] It should be noted that the spatiotemporal adjacency matrix ;in, ; The preset number of blocks. The spatiotemporal adjacency matrix is ​​formed by... Composed of blocks, front All blocks are identity matrices The last block is the initial adjacency matrix. Specifically, each of the preceding blocks is an identity matrix, representing the correspondence between a node and itself at a past time step; the last block is the initial adjacency matrix, representing the spatial connections between nodes at the current time step. This design allows each node to simultaneously receive information from its spatial neighbors and its own historical state.

[0085] Thus, starting from the initial adjacency matrix that encodes the spatial connections between nodes in the transportation network, a time dimension is introduced to expand this initial adjacency matrix into a larger spatiotemporal adjacency matrix. This spatiotemporal adjacency matrix not only includes the initial adjacency matrix, but also adds the self-connection relationships between nodes at different time steps in the form of an identity matrix.

[0086] Furthermore, the spatiotemporal adjacency matrix is ​​symmetrically normalized, including by calculating... The symmetric normalized spatiotemporal adjacency matrix is ​​obtained in the th... Okay, number The values ​​of the elements in the column. Among them, The symmetric normalized spatiotemporal adjacency matrix In the Okay, number The values ​​of the elements in the column; Spatiotemporal adjacency matrix In the Okay, number The values ​​of the elements in the column; Spatiotemporal adjacency matrix No. The sum of all elements in a row; Spatiotemporal adjacency matrix No. The sum of all elements in the list; ϵ is a preset minimum positive number used to avoid a denominator of 0.

[0087] Furthermore, a preset second sliding window is used to extract features of the current time step and the previous few time steps from the scale compression features, obtaining the time window features corresponding to each time step, including: padding before the scale compression features. The zero value at each time step; using a preset second sliding window to calculate The time window features corresponding to each time step are obtained; among them It involves slicing on a four-dimensional tensor. The first colon indicates that all batches are taken, meaning that all batch dimensions are retained. Representation from the time dimension Starting from 2 positions, take consecutive positions. The third colon (:) indicates that all nodes are selected, meaning all node dimensions are preserved; the fourth colon (:) indicates that all features are selected, meaning all feature dimensions are preserved. The scale-compressed feature tensor after padding; Features of a time window; This represents the filled time index, i.e., the filled time step.

[0088] Furthermore, the time window features are reshaped into a two-dimensional form to obtain two-dimensional time features, including: through calculation Two-dimensional time features are obtained. It is a two-dimensional time feature; Representation reshaping operations do not change the total number of elements in a tensor, but only rearrange the dimensions of the elements.

[0089] pass Merging the two dimensions, number of blocks W and number of nodes N, into a single dimension, the resulting new dimension has the following size: This makes the feature tensor more suitable for subsequent matrix operations such as graph convolution.

[0090] Furthermore, the two-dimensional time features are subjected to multi-branch projection and aggregation based on the symmetrically normalized spatiotemporal adjacency matrix to obtain multiple aggregated time features, including: projecting the two-dimensional time features using multiple projection weight matrices to generate a first projection feature representation, a second projection feature representation, and a third projection feature representation; and aggregating the first projection feature representation, the second projection feature representation, and the third projection feature representation using the symmetrically normalized spatiotemporal adjacency matrix to obtain each aggregated time feature.

[0091] Furthermore, multiple projection weight matrices are used to project the two-dimensional time features respectively, generating a first projected feature representation, a second projected feature representation, and a third projected feature representation, including: calculating... The first projected feature representation is obtained; where, This represents the first projection feature. The first projection weight matrix is ​​preset; by calculation The second projection feature representation is obtained; where, This is a representation of the second projection feature; The second projection weight matrix is ​​preset; by calculation The third projection feature representation is obtained; where, This is represented by the third projection feature; This is the preset third projection weight matrix.

[0092] Furthermore, the first, second, and third projective feature representations are aggregated using the symmetrically normalized spatiotemporal adjacency matrix to obtain each aggregated temporal feature, including: by calculating Obtain the aggregation time features corresponding to the first projection feature representation; through calculation The aggregation time features corresponding to the second projection feature representation are obtained; by calculating... The second projection feature representation is obtained, which corresponds to the aggregated time feature.

[0093] Furthermore, candidate interaction features are obtained based on each aggregated time feature, including: fusing each aggregated time feature to obtain a fused time feature; and introducing a residual connection mechanism to add the fused time feature to the original input feature to obtain candidate interaction features.

[0094] Furthermore, the aggregated time features are fused to obtain fused time features, including: through calculation The fusion time characteristics were obtained; among them, To integrate temporal characteristics; The first projection feature represents the corresponding aggregation time feature, and the second projection feature represents the corresponding interaction branch result of the aggregation time feature. The third projection feature represents the linear branch result corresponding to the aggregation time feature; .

[0095] It should be noted that the results of the interactive branch are obtained in the following way: through calculation. , obtain interactive branches; among them, It is the ReLU activation function. This indicates element-wise multiplication.

[0096] Furthermore, the candidate interaction features corresponding to each time step are aggregated to obtain interaction features, including: through calculation To obtain interaction features; among them, For interactive features; For the candidate interaction features corresponding to the 0th time step, These are the candidate interaction features corresponding to the first time step; For the first Each time step corresponds to a candidate interaction feature; The stacking operation is characterized by combining the alternative interaction features along a new dimension.

[0097] It should be noted that for hypergraph convolutional networks, after receiving compressed features at various scales, for each target time scale, a learnable hyperedge classifier matrix is ​​used to calculate the probability distribution of each node's features belonging to each hyperedge, thus obtaining a hyperedge assignment matrix. Based on the hyperedge assignment matrix, feature representations at the hyperedge level are extracted to obtain hyperedge features. The hyperedge features are then subjected to a nonlinear transformation according to a preset hyperedge mapping matrix to obtain hyperedge transformed features. The hyperedge transformed features are updated based on a residual connection algorithm. The updated hyperedge transformed features are propagated back to the node space in the hypergraph convolutional network to update the representation of each node. Finally, the hypergraph features are obtained based on the updated representations of each node.

[0098] Furthermore, a learnable hyperedge classifier matrix is ​​used to calculate the probability distribution of each node's features belonging to each hyperedge, thus obtaining the hyperedge assignment matrix. This includes: calculating... Obtain the input features after feature reshaping; through calculation Obtain the hyperedge assignment matrix; where, This is a scale-compression feature; Input features after feature reshaping; Assign matrices to the hyperedges; Let be the hyperedge classifier matrix. ; The reshaped node-time joint dimension; This represents the probability of each node-time unit being assigned to each hyperedge.

[0099] Specifically, this formula represents the multiplication of a learnable hyperedge classifier matrix and a feature matrix, followed by normalization along the hyperedge dimension using a predefined softmax function to obtain a hyperedge assignment matrix. It's important to note that each element in this hyperedge assignment matrix represents the probability weight of a corresponding node belonging to a certain hyperedge. Unlike traditional hard assignment, where a node belongs to only one hyperedge, this soft assignment allows a node to belong to multiple hyperedges simultaneously with different weights.

[0100] It should be noted that extracting hyperedge-level feature representations based on the hyperedge allocation matrix to obtain hyperedge features involves multiplying the transpose of the hyperedge allocation matrix with the scale-compressed features. Specifically, the hyperedge features... Thus, in the hyperedge features, the feature representation at each hyperedge level is a weighted average of the features of all member nodes.

[0101] It should be noted that the hyperedge transformation features are obtained by performing a nonlinear transformation on the hyperedge features based on a preset hyperedge mapping matrix, i.e., by calculating... This yields the hyperedge transformation features. This is a hyperedge transformation feature; , Let be the hyperedge mapping matrix, which is a learnable matrix; The ReLU activation function is used to characterize nonlinearity. Thus, a learnable hyperedge mapping matrix is ​​used to obtain hyperedge transformation features, which encode the correlation strength between different hyperedges, enabling information exchange between them.

[0102] It should be noted that the hyperedge transformation features are updated based on the residual connection algorithm, that is, by calculating... , thereby obtaining the updated hyperedge transformation features; where, This represents the updated hyperedge transformation features. Thus, residual connections maintain training stability and prevent information loss.

[0103] It should be noted that the updated hyperedge features need to be propagated back to the node space to update the representation of each node. Here, "node" refers to a traffic node in the traffic network after dimensionality reshaping. The hyperedge assignment matrix is ​​multiplied by the updated hyperedge feature matrix to obtain the new feature representation for each node. In this process, each node receives feature information from all its hyperedges, with the receiving weight determined by the initial hyperedge assignment probability.

[0104] Specifically, the updated hyperedge transformation features are propagated back to the node space in the hypergraph convolutional network to update the representation of each node, i.e., by calculating... This allows us to obtain the updated representations of each node.

[0105] Furthermore, the hypergraph features are obtained based on the updated representations of each node, including: using residual connections to obtain the features after residual connections based on the updated representations of each node; and performing layer normalization on the features after residual connections to obtain the hypergraph features.

[0106] Specifically, the residual join is used to obtain the features after the residual join based on the updated representations of each node, that is, by calculating... right Perform feature reshaping operations. The reshaped features are a four-dimensional spacetime structure; through calculation To obtain the features after residual connection; among them, These are the features after residual connection. The features input to the hypergraph convolutional network are scale-compressed features.

[0107] Layer normalization is performed on the features after residual connection to obtain hypergraph features, i.e., by calculating... To obtain hypergraph features; among them, Hypergraph features; Normalization of the representation layer.

[0108] It should be noted that, based on the target time scale, each interaction feature and each hypergraph feature are fused to obtain the scale-time series feature corresponding to each target time scale. That is, for each target time scale, the sum of the interaction feature and the hypergraph feature is determined as the scale-time series feature corresponding to the target time scale.

[0109] Specifically, it can be calculated Integrating various interaction features and hypergraph features, among which, This represents the scale-time series feature corresponding to the k-th target time scale. The interaction features corresponding to the kth target time scale; This represents the hypergraph feature corresponding to the k-th target time scale.

[0110] It should be noted that two key temporal features can be extracted from the fused features. The first is the local feature, which is the feature representation of the last time step corresponding to each target time scale, expressed as: Secondly, there are global features, which are obtained by average pooling the entire time series, and are represented as follows: Global features characterize the overall trends and statistical regularities of the traffic network within the target time scale, including long-term stable patterns, periodic changes, and summarized information on historical behavior. Therefore, the output results can be obtained. ,in, For local features, This is a global feature.

[0111] Furthermore, the traffic flow prediction model obtains the predicted traffic flow sequence for the road network to be predicted based on the scale-time series features corresponding to each target time scale in the following manner: feature fusion is performed on the scale-time series features corresponding to each target time scale to obtain a joint spatiotemporal feature representation; based on the joint spatiotemporal feature representation, the predicted traffic flow sequence within a preset target time range is obtained. In this way, by fusing the scale-time series features corresponding to each target time scale, traffic flow features reflecting the changing patterns of traffic flow at different time granularities extracted at different target time scales can be integrated together, complementing and correcting each other, reducing the impact of noise interference on single-scale features, and enhancing the robustness of the joint spatiotemporal feature representation. This enables the model to extract effective information more stably when facing complex and variable traffic flow data, thereby obtaining a more accurate predicted traffic flow sequence and improving the reliability of the prediction.

[0112] It should be noted that after the integration of features at different scales is completed, the multi-scale fusion stage begins. A learnable scale weight mechanism can be used, which can assign appropriate fusion weights to features at different scales based on the characteristics of the input data and the predicted scale value, and perform fusion based on these fusion weights.

[0113] Furthermore, feature fusion is performed on the scale-time series features corresponding to each target time scale to obtain a joint spatiotemporal feature representation, including: extracting global statistical features based on the original input data; obtaining scale-aware vectors corresponding to each target time scale based on the global statistical features and the target time scale; concatenating the scale-aware vectors corresponding to each target time scale and capturing the dependencies of the concatenated scale-aware vectors to obtain enhanced scale features; generating fusion weights based on the enhanced scale features using a pre-defined multilayer perceptron; and performing feature fusion on the scale-time series features corresponding to each target time scale based on the fusion weights to obtain a joint spatiotemporal feature representation.

[0114] It should be noted that global statistical features are extracted based on the original input data, that is, through calculation. To obtain global statistical features; among them, For global statistical features; 3 represents the t3rd time step, where T is the number of time steps; Represents the nth traffic node; The original input data has the following dimensions: In this way, by performing average pooling operations on the time and space dimensions, a compact global feature vector is generated.

[0115] It should be noted that the scale-aware vectors corresponding to each target time scale are obtained based on global statistical features and the target time scale, i.e., by calculating... , to obtain the scale-aware vector corresponding to the k-th target time scale; where This is the scale-aware vector corresponding to the kth target time scale; Characterize a first multilayer perceptron for performing nonlinear transformations on the concatenated features. This multilayer perceptron consists of multiple fully connected layers and is able to learn the complex relationships between input features, mapping the concatenated features to a new feature space to better adapt to the needs of subsequent tasks. Characterizes the splicing operation; Let k be the target time scale. In this way, by combining the predicted scale value with global features, the specific value for each scale is extracted separately and concatenated with the global features to form a scale-aware input vector.

[0116] Furthermore, the scale-aware vectors corresponding to each target time scale are concatenated, and the dependencies of the concatenated scale-aware vectors are captured to obtain enhanced scale features, including: by calculating This yields the spliced ​​scale-aware vector; where... This is the spliced ​​scale-aware vector; This is the scale-aware vector corresponding to the first target time scale; This is the scale-aware vector corresponding to the second target time scale; Let K be the scale-aware vector corresponding to the Kth target time scale; K is the number of target time scales. This is calculated... To obtain enhanced scale features; among them, To enhance scale features; The scale dependencies between the concatenated scale-aware vectors are captured using Transformer blocks. The feature dimension of the scale-aware vector.

[0117] This enhances the representational power of features at each scale and models the dependencies between scales, enabling the network to consider the interactions between different scales.

[0118] Furthermore, a pre-defined multilayer perceptron is used to generate fusion weights based on the enhanced scale features, including: calculating... To obtain the k-th original weight; where This is the k-th original weight; The second multilayer perceptron is used to generate the original weights; Characterizes all feature values ​​at the k-th target time scale in the spliced ​​scale-aware vector; by calculating To obtain the fusion weights; among them, For weighting; For the first The original weights.

[0119] It should be noted that feature fusion is performed on the scale-time series features corresponding to each target time scale based on the fusion weights to obtain a joint spatiotemporal feature representation, that is, by calculating... This yields a joint spatiotemporal feature representation. Among them, For joint spatiotemporal feature representation; This is the projection operation function, which can be a linear transformation, such as a fully connected layer, or other suitable feature transformation operation, used to... Feature mapping is performed so that features at different scales can be fused on the same dimension.

[0120] Furthermore, based on the joint spatiotemporal feature representation, the predicted traffic sequence within a preset target time range is obtained, including: using a preset fusion layer to perform dimensionality reduction processing on the joint spatiotemporal feature representation to obtain joint spatiotemporal dimensionality reduction features; obtaining features for future time periods; splicing the joint spatiotemporal dimensionality reduction features and the features for future time periods to obtain spatiotemporal splicing features; and using a preset prediction head network to obtain the predicted traffic sequence based on the spatiotemporal splicing features.

[0121] It should be noted that the preset fusion layer is used to perform linear transformation, ReLU activation, and Dropout regularization on the joint spatiotemporal feature representation in order to compress the spliced ​​features to a fixed dimension, thereby integrating and refining information, removing redundant information, and retaining the core pattern of multi-scale analysis.

[0122] Future time period features are extracted from the future time slice portion of the input data. Specifically, the model input data contains historical time period features and auxiliary information for future time periods. Future time period features include time-coded information corresponding to the time period to be predicted, such as date, time, and other time-coded features.

[0123] It should be noted that spatiotemporal splicing features are obtained by splicing together joint spatiotemporal dimensionality reduction features and future time period features, i.e., by calculating... To obtain spatiotemporal splicing features; among them, It is a spatiotemporal splicing feature; For joint spatiotemporal dimensionality reduction features; This represents a characteristic of a future time period.

[0124] It should be noted that the prediction head network consists of two fully connected layers, which are used to perform nonlinear activation and regularization on the spatiotemporal splicing features.

[0125] It should be noted that the predicted flow sequence is obtained by using a pre-defined prediction head network based on spatiotemporal splicing features, i.e., by calculating... ;in, To predict flow sequences; This is the preset third learning weight; The fourth learning weight is preset. The third learning bias parameter is preset. This is the preset fourth learning bias parameter; , , , All of these are learnable parameters.

[0126] Furthermore, the traffic flow prediction model is obtained as follows: acquiring the historical traffic flow data to be trained and the subsequent real traffic flow sequence corresponding to the historical traffic flow data to be trained; inputting the historical traffic flow data to be trained into the preset initial traffic flow prediction model to obtain the predicted traffic flow sequence to be trained; calculating the mean absolute error corresponding to the initial traffic flow prediction model based on the subsequent real traffic flow sequence and the predicted traffic flow sequence to be trained; using the mean absolute error as the loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model.

[0127] In this way, by acquiring historical traffic flow data to be trained and the corresponding subsequent real traffic flow sequences, the historical traffic flow data to be trained is input into a pre-set initial traffic flow prediction model to obtain a predicted traffic flow sequence to be trained. The mean absolute error (MAE) of the initial traffic flow prediction model is calculated based on the subsequent real traffic flow sequence and the predicted traffic flow sequence to be trained. The MAE is then used as a loss function to iteratively train the initial traffic flow prediction model, resulting in a traffic flow prediction model. This allows the model to continuously adjust its parameters based on the feedback from the loss function, thereby reducing the MAE. Through multiple iterations, the model can gradually learn the potential patterns and regularities in historical traffic flow data, thus improving its ability to predict future traffic flow.

[0128] It should be noted that the method of inputting the historical traffic flow data to be trained into the preset initial traffic flow prediction model to obtain the predicted traffic flow sequence to be trained is the same as the method of inputting the historical traffic flow data into the preset traffic flow prediction model to obtain the predicted traffic flow sequence corresponding to the road network to be predicted, and will not be repeated here.

[0129] It should be noted that the mean absolute error of the initial traffic flow prediction model is calculated based on subsequent real traffic flow sequences and the predicted traffic flow sequences to be trained. The mean absolute error is obtained; among which, Mean absolute error; The total number of prediction elements in the predicted flow sequence to be trained; ,in, It is the time step length of the output sequence, that is, how many future time points are predicted; Let be the value of the i-th element in the predicted flow sequence to be trained; This represents the value of the i-th element in the subsequent actual traffic sequence.

[0130] It should be noted that the mean absolute error is used as the loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model. That is, the mean absolute error is minimized by the preset backpropagation algorithm, and the learnable parameters of the model are continuously updated by the gradient descent optimizer, thereby improving the prediction performance.

[0131] During training, an early stopping mechanism can be used to monitor model performance based on validation set performance. When the validation loss no longer decreases over multiple consecutive training cycles, the best-performing set of model parameters on the validation set is saved, and the model with these optimal parameters is used as the final version of the traffic flow prediction model for prediction output.

[0132] In some embodiments, please refer to Figure 2 , Figure 2 This is a schematic diagram illustrating the training of the initial traffic flow prediction model.

[0133] like Figure 2 As shown, the initial traffic flow prediction model 20 includes an initial feature embedding layer, an initial backbone network, an initial multi-scale selection layer, an initial graph convolutional network layer, and an initial scale weighting layer.

[0134] The initial feature embedding layer is used to extract the initial multi-source features of the historical traffic flow data to be trained based on the node dimension, time dimension, and state dimension.

[0135] The initial backbone network is used to enhance the initial features from multiple sources to be trained and to obtain the spatiotemporal dependent features to be trained.

[0136] The initial multi-scale selection layer is used to determine several training target time scales based on the spatiotemporal dependency features to be trained; then, the training spatiotemporal dependency features are compressed based on each training target time scale, and the training scale compression features are corresponding to each training target time scale.

[0137] The initial graph convolutional network layer includes an initial interactive graph convolutional network and a hypergraph convolutional network. The initial graph convolutional network layer is used to input the compressed features of each training scale into the initial interactive graph convolutional network and the initial hypergraph convolutional network respectively to obtain the training interaction features and training hypergraph features corresponding to each training target time scale. Based on the training target time scale, the training interaction features and training hypergraph features are fused to obtain the training scale temporal features corresponding to each training target time scale.

[0138] The initial scale weighting layer is used to perform feature fusion on the time-series features of the target time scale corresponding to each target time scale to obtain the joint spatiotemporal feature representation to be trained; based on the joint spatiotemporal feature representation to be trained, the predicted flow sequence to be trained within the preset target time range is obtained.

[0139] Then, based on the historical traffic flow data to be trained and subsequent real traffic flow sequences, the mean absolute error (MAE) corresponding to the initial traffic flow prediction model is calculated. The MAE is then used as the loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model.

[0140] In some embodiments, please refer to Figure 3 , Figure 3 This is a schematic diagram of the backbone network.

[0141] like Figure 3 As shown, the backbone network 30 includes a first sliding time window, a parallel first graph neural network, and a second graph neural network.

[0142] First, construct the first unweighted undirected graph and the second unweighted undirected graph corresponding to the road network to be predicted; the nodes of the first unweighted undirected graph and the second unweighted undirected graph are traffic nodes; the edges of the first unweighted undirected graph and the second unweighted undirected graph represent the roads of the road network to be predicted; the first adjacency matrix of the first unweighted undirected graph represents the connection relationship of each traffic node; the second adjacency matrix of the second unweighted undirected graph represents the data similarity of each traffic node.

[0143] Then, the multi-source initial features, the first adjacency matrix, and the second adjacency matrix are input into the backbone network.

[0144] Several spatiotemporal feature blocks are extracted from the multi-source initial features through a first sliding time window; each spatiotemporal feature block includes feature data from three consecutive time points.

[0145] Then, each spatiotemporal feature block is reshaped to obtain spatiotemporal two-dimensional features;

[0146] Then, the first graph neural network is used to perform graph convolution operation between the spatiotemporal two-dimensional features and the first adjacency matrix to obtain the first feature tensor; the second graph neural network is used to perform graph convolution operation between the spatiotemporal two-dimensional features and the second adjacency matrix to obtain the second feature tensor.

[0147] Then, the first feature tensor and the second feature tensor are fused to obtain the spatiotemporal dependent features.

[0148] Combination Figure 4 As shown, this embodiment of the disclosure provides an apparatus 40 for predicting traffic flow, the apparatus including: an acquisition module 41 and a prediction module 42.

[0149] The acquisition module 31 is configured to acquire historical traffic flow data corresponding to the road network to be predicted; the historical traffic flow data includes traffic status data corresponding to each traffic node and timestamp information corresponding to the traffic status data.

[0150] The prediction module 42 is configured to input historical traffic flow data into a preset traffic flow prediction model to obtain the predicted traffic flow sequence corresponding to the road network to be predicted. The traffic flow prediction model is used to extract multi-source initial features of historical traffic flow data based on node dimension, time dimension, and state dimension; enhance the multi-source initial features using a preset backbone network to obtain spatiotemporal dependency features; determine several target time scales based on the spatiotemporal dependency features; then compress the spatiotemporal dependency features and scale compression features corresponding to each target time scale; extract scale time series features corresponding to each target time scale based on the scale compression features; and finally obtain the predicted traffic flow sequence corresponding to the road network to be predicted based on the scale time series features corresponding to each target time scale.

[0151] The device for predicting traffic flow provided in this disclosure acquires historical traffic flow data corresponding to the road network to be predicted. It then uses a preset traffic flow prediction model to extract multi-source initial features from the historical traffic flow data and enhances these initial features using a preset backbone network to obtain spatiotemporal dependent features. These features are then compressed based on several target time scales obtained through the spatiotemporal dependent features. Finally, scale-time series features corresponding to each target time scale are extracted using the scale-compression features corresponding to the compressed target time scales. The predicted traffic flow sequence corresponding to the road network to be predicted is then obtained based on these scale-time series features. In this way, this solution adaptively acquires several target time scales by extracting and enhancing the spatiotemporal dependent features obtained from historical traffic flow data corresponding to the road network to be predicted. It then compresses the spatiotemporal dependent features based on each target time scale and extracts the scale-time series features corresponding to each target time scale. Traffic flow prediction is then performed based on these scale-time series features, achieving multi-time-scale traffic flow prediction compared to the fixed time window used in existing technologies, thereby improving prediction accuracy.

[0152] Furthermore, the traffic flow prediction model extracts and enhances the feature data of historical traffic flow data based on the node dimension, time dimension, and state dimension to obtain spatiotemporal dependent features, including: extracting the node index vector, timestamp information, and traffic state data corresponding to each traffic node from the historical traffic flow data; obtaining the time index and date one-hot encoding based on the timestamp information; obtaining the node embedding vector based on the node index vector; obtaining the time embedding vector based on the time index; obtaining the date embedding vector based on the date one-hot encoding; obtaining the traffic state embedding vector based on the traffic state data; and determining the sum of the node embedding vector, time embedding vector, date embedding vector, and traffic state embedding vector as the multi-source initial features.

[0153] Furthermore, the backbone network includes a parallel first graph neural network and a second graph neural network; the traffic flow prediction model utilizes the pre-defined backbone network to enhance multi-source initial features and obtain spatiotemporal dependent features in the following manner: constructing a first unweighted undirected graph and a second unweighted undirected graph corresponding to the road network to be predicted; the nodes of the first unweighted undirected graph and the second unweighted undirected graph are traffic nodes; the edges of the first unweighted undirected graph and the second unweighted undirected graph represent roads in the road network to be predicted; the first adjacency matrix of the first unweighted undirected graph represents the connection relationship of each traffic node; the second adjacency matrix of the second unweighted undirected graph represents the data similarity of each traffic node; and multi-source... Initial features, a first adjacency matrix, and a second adjacency matrix are input into the backbone network. Several spatiotemporal feature blocks are extracted from the multi-source initial features using a preset first sliding time window. Each spatiotemporal feature block includes feature data from three consecutive time points. Each spatiotemporal feature block is reshaped into a two-dimensional form to obtain spatiotemporal two-dimensional features. A first graph neural network is used to perform graph convolution operations between the spatiotemporal two-dimensional features and the first adjacency matrix to obtain a first feature tensor. A second graph neural network is used to perform graph convolution operations between the spatiotemporal two-dimensional features and the second adjacency matrix to obtain a second feature tensor. The first and second feature tensors are fused to obtain spatiotemporally dependent features.

[0154] Furthermore, the traffic flow prediction model determines several target time scales based on spatiotemporal dependency features in the following manner: global average pooling and flattening of the spatiotemporal dependency features to obtain a global context feature vector; inputting the global context features into a preset scale attention selector to obtain a selection weight vector; and determining each target time scale from a preset scale candidate set based on the selection weight vector.

[0155] Furthermore, the traffic flow prediction model extracts scale-time series features corresponding to each target time scale based on the compressed features of each scale in the following way: the compressed features of each scale are input into a preset interactive graph convolutional network and a preset hypergraph convolutional network respectively to obtain the interactive features and hypergraph features corresponding to each target time scale; based on the target time scale, the interactive features and hypergraph features are fused to obtain the scale-time series features corresponding to each target time scale.

[0156] Furthermore, the traffic flow prediction model obtains the predicted traffic flow sequence corresponding to the road network to be predicted based on the scale time series features corresponding to each target time scale in the following way: feature fusion is performed on the scale time series features corresponding to each target time scale to obtain a joint spatiotemporal feature representation; based on the joint spatiotemporal feature representation, the predicted traffic flow sequence within the preset target time range is obtained.

[0157] Furthermore, the traffic flow prediction model is obtained as follows: acquiring the historical traffic flow data to be trained and the subsequent real traffic flow sequence corresponding to the historical traffic flow data to be trained; inputting the historical traffic flow data to be trained into the preset initial traffic flow prediction model to obtain the predicted traffic flow sequence to be trained; calculating the mean absolute error corresponding to the initial traffic flow prediction model based on the subsequent real traffic flow sequence and the predicted traffic flow sequence to be trained; using the mean absolute error as the loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model.

[0158] It should be noted that the device for predicting traffic flow provided in the above embodiments and the method for predicting traffic flow provided in the above embodiments belong to the same concept. The specific ways in which each module and unit performs its operation have been described in detail in the method embodiments, and will not be repeated here. In practical applications, the device for predicting traffic flow provided in the above embodiments can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not a limitation.

[0159] Combination Figure 5 As shown, this disclosure provides another apparatus for predicting traffic flow, including a processor 51 and a memory 52. ​​Optionally, the apparatus may further include a communication interface 53 and a bus 54. The processor 51, communication interface 53, and memory 52 can communicate with each other via the bus 54. The communication interface 53 can be used for information transmission. The processor 51 can call logical instructions in the memory 52 to execute the traffic flow prediction method of the above embodiments.

[0160] Furthermore, the logic instructions in the aforementioned memory 52 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.

[0161] The memory 52, as a storage medium, can be used to store software programs, computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this disclosure. The processor 51 executes functional applications and data processing by running the program instructions / modules stored in the memory 52, that is, it implements the method for predicting traffic flow in the above embodiments.

[0162] The memory 52 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 52 may include high-speed random access memory and may also include non-volatile memory.

[0163] This disclosure provides a storage medium storing computer-executable instructions configured to perform the above-described method for predicting traffic flow.

[0164] The aforementioned storage media can be either transient computer-readable storage media or non-transitory computer-readable storage media. Non-transitory storage media include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, and can also be transient storage media.

[0165] The foregoing description and accompanying drawings fully illustrate embodiments of this disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the terminology used in this application is for describing embodiments only and is not intended to limit the claims. As used in the description of embodiments and claims, the singular forms “a,” “an,” and “the” are intended to equally include the plural forms unless the context clearly indicates otherwise. Similarly, the term “and / or” as used in this application means including one or more of the associated listed items and all possible combinations thereof. Additionally, when used in this application, the term "comprise" and its variations "comprises" and / or "comprising" refer to the presence of stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof. Without further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes said element. In this document, each embodiment may focus on the differences from other embodiments, and similar or identical parts between embodiments can be referred to mutually. For methods, products, etc., disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, the relevant parts can be referred to the description of the method section.

[0166] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0167] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in a different order than disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. Each block in a block diagram and / or flowchart, and combinations of blocks in a block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

Claims

1. A method for predicting traffic flow, characterized in that, include: Obtain historical traffic flow data corresponding to the road network to be predicted; the historical traffic flow data includes traffic status data corresponding to each traffic node and timestamp information corresponding to the traffic status data. The historical traffic flow data is input into a preset traffic flow prediction model to obtain the predicted traffic flow sequence corresponding to the road network to be predicted; the traffic flow prediction model is used to extract multi-source initial features of the historical traffic flow data based on node dimension, time dimension and state dimension. The multi-source initial features are enhanced using a preset backbone network to obtain the spatiotemporal dependency features; several target time scales are determined based on the spatiotemporal dependency features; then the spatiotemporal dependency features are compressed based on each target time scale, and the scale-compressed features corresponding to each target time scale are obtained. Based on the scale compression features of each of the aforementioned scales, scale-time series features corresponding to each of the target time scales are extracted; then, based on the scale-time series features corresponding to each of the aforementioned target time scales, the predicted traffic sequence corresponding to the road network to be predicted is obtained.

2. The method according to claim 1, characterized in that, The traffic flow prediction model extracts and enhances the feature data of the historical traffic flow data based on the node dimension, time dimension, and state dimension to obtain spatiotemporal dependent features, including: Extract the node index vector, timestamp information and traffic status data corresponding to each traffic node from the historical traffic flow data; Based on the timestamp information, obtain the time index and date one-hot encoding; Node embedding vectors are obtained based on the node index vectors; time embedding vectors are obtained based on the time index; date embedding vectors are obtained based on the one-hot date encoding; and traffic status embedding vectors are obtained based on the traffic status data. The sum of the node embedding vector, the time embedding vector, the date embedding vector, and the traffic state embedding vector is determined as the multi-source initial feature.

3. The method according to claim 2, characterized in that, The backbone network includes a parallel first graph neural network and a second graph neural network; the traffic flow prediction model utilizes the preset backbone network to enhance the multi-source initial features and obtain the spatiotemporal dependent features in the following manner: A first unweighted undirected graph and a second unweighted undirected graph are constructed corresponding to the road network to be predicted; the nodes of the first unweighted undirected graph and the second unweighted undirected graph are the traffic nodes; the edges of the first unweighted undirected graph and the second unweighted undirected graph represent the roads of the road network to be predicted; the first adjacency matrix of the first unweighted undirected graph represents the connection relationship of each traffic node; the second adjacency matrix of the second unweighted undirected graph represents the data similarity of each traffic node. The multi-source initial features, the first adjacency matrix, and the second adjacency matrix are input into the backbone network; A number of spatiotemporal feature blocks are extracted from the multi-source initial features using a preset first sliding time window; the spatiotemporal feature blocks include feature data from three consecutive time points; Each of the aforementioned spatiotemporal feature blocks is reshaped into a two-dimensional form to obtain spatiotemporal two-dimensional features; The first feature tensor is obtained by performing graph convolution operation between the spatiotemporal two-dimensional features and the first adjacency matrix using the first graph neural network. The second feature tensor is obtained by performing graph convolution operation between the spatiotemporal two-dimensional features and the second adjacency matrix using the second graph neural network. The spatiotemporal dependent features are obtained by fusing the first feature tensor and the second feature tensor.

4. The method according to claim 1, characterized in that, The traffic flow prediction model determines several target time scales based on the spatiotemporal dependence features in the following manner: The spatiotemporal dependent features are subjected to global average pooling and flattening to obtain a global context feature vector; The global context features are input into a preset scale attention selector to obtain a selection weight vector; Based on the selected weight vector, each target time scale is determined from a preset set of candidate scales.

5. The method according to claim 1, characterized in that, The traffic flow prediction model extracts scale-time series features corresponding to each target time scale based on the scale compression features in the following manner: The scale compression features of each of the above are respectively input into a preset interactive graph convolutional network and a preset hypergraph convolutional network to obtain the interactive features and hypergraph features corresponding to each of the target time scales. Based on the target time scale, the interaction features and the hypergraph features are fused respectively to obtain the scale-time series features corresponding to each target time scale.

6. The method according to claim 1, characterized in that, The traffic flow prediction model obtains the predicted traffic flow sequence corresponding to the road network to be predicted based on the scale-time features corresponding to each of the target time scales in the following manner: The scale-time series features corresponding to each of the target time scales are fused to obtain a joint spatiotemporal feature representation; Based on the joint spatiotemporal feature representation, a predicted flow sequence within a preset target time range is obtained.

7. The method according to claim 1, characterized in that, The traffic flow prediction model is obtained in the following way: Obtain the historical traffic flow data to be trained and the subsequent real traffic flow sequence corresponding to the historical traffic flow data to be trained; The historical traffic flow data to be trained is input into a preset initial traffic flow prediction model to obtain the predicted traffic flow sequence to be trained. The mean absolute error of the initial traffic flow prediction model is calculated based on the subsequent real traffic flow sequence and the predicted traffic flow sequence to be trained. The average absolute error is used as a loss function to iteratively train the initial traffic flow prediction model to obtain the traffic flow prediction model.

8. A device for predicting traffic flow, characterized in that, include: The acquisition module is configured to acquire historical traffic flow data corresponding to the road network to be predicted; the historical traffic flow data includes traffic status data corresponding to each traffic node and timestamp information corresponding to the traffic status data. The prediction module is configured to input the historical traffic flow data into a preset traffic flow prediction model to obtain the predicted traffic flow sequence corresponding to the road network to be predicted; the traffic flow prediction model is used to extract multi-source initial features of the historical traffic flow data based on node dimension, time dimension and state dimension. The multi-source initial features are enhanced using a preset backbone network to obtain the spatiotemporal dependency features; several target time scales are determined based on the spatiotemporal dependency features; then the spatiotemporal dependency features are compressed based on each target time scale, and the scale-compressed features corresponding to each target time scale are obtained. Based on the scale compression features of each of the aforementioned scales, scale-time series features corresponding to each of the target time scales are extracted; then, based on the scale-time series features corresponding to each of the aforementioned target time scales, the predicted traffic sequence corresponding to the road network to be predicted is obtained.

9. An electronic device comprising a processor and a memory storing program instructions, characterized in that, The processor is configured to, when running the program instructions, perform the method for predicting traffic flow as described in any one of claims 1 to 7.

10. A storage medium storing program instructions, characterized in that, When the program instructions are executed, they perform the method for predicting traffic flow as described in any one of claims 1 to 7.