Traffic flow prediction method, medium and equipment based on multi-scale graph attention network

Through a multi-scale graph attention network, combined with Fourier transform and attention mechanism, the seasonal and periodic characteristics of traffic flow data are extracted, and the traffic road network characteristics are extracted through the depth full residual graph attention network, which solves the existing The problems of insufficient spatial information capture capabilities and poor nonlinear feature processing in the technology achieve more accurate and stable traffic flow prediction.

CN118711384BActive Publication Date: 2024-11-19ZHUZHOU CSR TIMES ELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411171487.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-11-19
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

The existing traffic flow prediction methods are insufficient in capturing spatial information correlation and generalization capabilities, and are not effective enough to process the nonlinear and periodic characteristics of traffic flow data, resulting in a degradation of prediction performance.

Method used

Using a multi-scale graph attention network, the seasonal and periodic trends of time series are extracted through Fourier transform and multi-core average pooling, and the long-term dependence and global correlation of time series are learned in combination with internal and cross-scale attention mechanisms, and The spatial characteristics of the traffic road network are extracted and encoded by the deep full residual graph attention network to achieve more accurate traffic flow prediction.

Benefits of technology

It improves the accuracy and generalization ability of traffic flow prediction, avoids noise propagation and local feature disappearance, and can better capture time-dependent and spatial structure information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118711384B_ABST
    Figure CN118711384B_ABST
Patent Text Reader

Abstract

The present invention discloses a traffic flow prediction method, medium and device based on a multi-scale graph attention network. The method includes the following steps: obtaining historical traffic flow time series data and preprocessing to obtain a time series with seasonal trends and periodic trends; dividing the time series into different scales to obtain time series at different time resolutions; for time series at different time resolutions, applying an internal attention mechanism and a cross-scale attention mechanism to learn the long-term dependency and global correlation of the time series to obtain weighted time features; obtaining a historical traffic road network, extracting spatial features in the traffic road network, and then encoding the spatial features to obtain encoded spatial features; fusing the weighted time features and the encoded spatial features to obtain traffic flow prediction values ​​in a future time window. The present invention has the advantages of high prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the field of traffic flow technology, and specifically to a traffic flow prediction method, medium and equipment based on a multi-scale graph attention network. Background Art

[0002] With the rapid development of urban transportation, the burden on the road traffic system is increasing, and congestion often occurs. In recent years, all countries have been committed to the development of intelligent transportation systems (ITS). Accurate traffic flow prediction is an important foundation of intelligent transportation systems. It not only helps to improve traffic efficiency, but also alleviates traffic congestion, reduces traffic accidents, reduces energy consumption, and alleviates environmental pollution. Traffic flow data is a time series of nodes in a fixed time interval in a traffic network continuously recorded by sensors deployed on the road, which can very intuitively reflect the actual situation of the traffic network. Since the traffic conditions on urban roads are affected by a variety of external factors, traffic flow presents more complex uncertainty in the time dimension. This uncertainty brings huge challenges to the task of traffic flow prediction.

[0003] Generally speaking, traffic flow prediction methods can be roughly divided into three categories: statistics, machine learning, and deep learning. The first type of method is to learn the temporal characteristics of traffic flow through the theoretical basis of statistical analysis. Models include historical average model, autoregressive moving average model, vector autoregressive model, etc.

[0004] Patent application CN116504060A discloses a Transformer-based diffusion graph attention network traffic flow prediction method. The traffic flow combined prediction method adopts a Transformer encoder-decoder architecture, wherein the encoder and decoder contain multiple spatiotemporal convolutional network modules (ST-Conv Block) and diffusion graph attention modules (DGA-Block); ST-Conv Block captures the temporal dependency and spatial correlation of traffic flow through a time-gated convolutional network and a spatial convolutional network respectively, and DGA-Block uses a query key value self-attention mechanism to adaptively learn the diffusion parameters of each diffusion step and dynamically update the adjacency transfer matrix to capture the dynamic spatiotemporal correlation of traffic flow; the decoder adds an information auxiliary module to aggregate traffic flow information between the encoder and the decoder. The diffusion graph attention method used in the invention models the dynamic spatial correlation of traffic flow. The method uses a query key value self-attention mechanism to adaptively learn the diffusion parameters of each diffusion step and dynamically update the adjacency transfer matrix, which cannot well reflect the spatial dynamic change characteristics of traffic flow. The decoder adds an information auxiliary module on the basis of the encoder to aggregate the traffic flow information between the encoder and the decoder, and the computational efficiency is relatively low.

[0005] Patent application CN116978222A discloses a short-term traffic flow prediction method based on spatiotemporal data. It adopts the grey correlation analysis method, selects the original traffic flow data of multiple road sections for research, and constructs a matrix sequence as the input of the model. At the same time, the particle swarm algorithm is used to optimize the background value coefficient to reduce the model error and improve the applicability of the model. The model proposed in this invention introduces the grey correlation analysis method to select multiple matrix sequences, and uses the particle swarm algorithm to optimize the background value coefficient of the model, which significantly increases the amount of calculation and has the risk of overfitting.

[0006] Therefore, although there are studies on traffic flow prediction, there are still the following shortcomings:

[0007] 1) The mainstream research on spatiotemporal traffic flow prediction methods extracts the spatial dependency of traffic networks through GCN. However, it assigns the same weight to different neighborhood nodes in the same order neighborhood, which limits the model's ability to capture the correlation of spatial information and the generalization ability of the model. In addition, GCN causes the noise to spread continuously in the process of deepening, and the prediction performance continues to decline.

[0008] 2) Traffic flow data has strong nonlinearity and periodicity. Periodicity is crucial to address the challenges of traffic flow prediction tasks brought by nonlinear features. However, few works consider weekly periodic data. Even if weekly data is considered, it may not be very effective. Since the forecast data has a strong similarity with the trend of periodic data and is different from the trend of recent historical data, these data need to apply different modules to learn their features and integrate them into the final forecast value. Summary of the invention

[0009] In view of the technical problems existing in the prior art, the present invention provides a traffic flow prediction method, medium and device based on a multi-scale graph attention network with accurate prediction.

[0010] In order to solve the above technical problems, the technical solution proposed by the present invention is:

[0011] A traffic flow prediction method based on a multi-scale graph attention network comprises the following steps:

[0012] Obtain historical traffic flow time series data and preprocess them to obtain time series with seasonal and cyclical trends;

[0013] Divide the time series with seasonal and cyclical trends into different scales to obtain time series with different time resolutions;

[0014] For time series at different time resolutions, the internal attention mechanism and the cross-scale attention mechanism are used to learn the long-term dependency and global correlation of the time series to obtain weighted time features.

[0015] Obtain a historical traffic road network, extract spatial features in the traffic road network, and then encode the spatial features to obtain encoded spatial features;

[0016] The weighted time features and the encoded spatial features are fused to obtain the traffic flow prediction value in the future time window.

[0017] Preferably, the preprocessing includes Fourier transform and multi-core average pooling, and the seasonal trend is obtained by Fourier transform; and the periodic trend is obtained by multi-core average pooling.

[0018] Preferably, the calculation formulas for Fourier transform and multi-core average pooling are:

[0019] (1)

[0020] (2)

[0021] (3)

[0022] in X represents the input time series, represents the seasonal trend of the time series, represents the difference between the input time series and the seasonal trend of the time series, Represents the periodic trend of the time series, represents the inverse Fourier transform, Φ and A Represent the phase and amplitude of each frequency respectively, represents the frequency with the largest magnitude; is the pooling function of the ith kernel, N corresponds to the number of cores, Controls the weighting of results from different kernels.

[0023] Preferably, the calculation formula of the internal attention mechanism is as follows:

[0024] (4)

[0025] (5)

[0026] in represents the attention value within the i-th time scale, represents the global internal attention value obtained by concatenating the internal attention values ​​of each scale, Q, K, VThey are the query vector, key vector, and value vector generated after linear transformation of the input time series; Indicates the size of the attention dimension, Used to normalize the attention weights. represents the vector concatenation operation of the internal attention weights of each scale; the superscript i represents the i-th time scale; the subscript intra The same time scale; subscript inter for different time scales; p Represents the number of subsequences into which the original time series is divided.

[0027] Preferably, the calculation formula of the cross-scale attention mechanism is as follows:

[0028] (6)

[0029] Represents cross-scale attention between different scales.

[0030] Preferably, the formula for extracting spatial features in the traffic network is:

[0031] (7)

[0032] in represents a deep full residual graph attention network, G Represents the characteristics of the traffic network. Represents time characteristics, represents the dimension transformation matrix, Represents the activation function.

[0033] Preferably, the formula for encoding the spatial features is:

[0034] (8)

[0035] in express network, Indicates the hidden state at the last moment. Indicates the current hidden state.

[0036] The embodiment of the present invention further discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method described above are executed.

[0037] An embodiment of the present invention further discloses a computer device, including a memory and a processor connected to each other, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the steps of the above method are executed.

[0038] Compared with the prior art, the advantages of the present invention are:

[0039] The present invention obtains the seasonal and cyclical trends of traffic flow data by performing Fourier transform and multi-core average pooling on the input time series data, thereby dividing the time series into different time resolutions and performing adaptive multi-scale division, which can better learn the long-term dependency and global correlation of the input data and achieve more accurate prediction; the dual attention mechanism of the present invention performs internal attention on the data of the same scale for each scale of division, and performs cross-scale attention on the data of different scales, which can capture the global correlation and local details of time dependency. The deep full residual graph attention block (DFRGAT) of the present invention accurately captures the spatial structure information of the road network through dynamic aggregation, which can avoid the disappearance of local features and the propagation of noise during the propagation process caused by the deepening of the GAT layer. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 The flowchart of the traffic flow prediction method in an embodiment of the present invention.

[0041] Figure 2 This is a diagram of the multi-scale graph attention network architecture of the present invention. DETAILED DESCRIPTION

[0042] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.

[0043] The traffic flow prediction method of the embodiment of the present invention is implemented based on a multi-scale graph attention network. Figure 2 As shown in the figure, the Multi-Scale Graph Attention Network (Multi-Scale GAT) is a fusion of two different components, including the AMS Block (Adaptive Multi-Scale Selection Block) for multi-scale partitioning of time series, the DFRGAT (Deep Full Residual Graph Attention Block) for feature extraction of spatial features, and the DFRGAT-GRU (Deep Full Residual Graph Attention-Gated Recurrent Unit) for feature encoding.

[0044] like Figure 1 As shown, the traffic flow prediction method based on the multi-scale graph attention network of the embodiment of the present invention specifically includes the steps of:

[0045] Perform Fourier transform and multi-core average pooling on historical traffic flow time series data to obtain the seasonal trend of the time series and cyclical trends , and its calculation formula is:

[0046] (1)

[0047] (2)

[0048] (3)

[0049] in X represents the input time series, represents the difference between the input time series and the seasonal trend of the time series, represents the inverse Fourier transform, Φ and A Respectively DFT(X) The phase and amplitude of each frequency, Indicates the one with the largest magnitude Frequency; is the pooling function of the ith kernel, N corresponds to the number of cores, Controls the weighting of results from different kernels.

[0050] In the application scenario of traffic flow prediction, time series data usually contains seasonal and cyclical trends, such as daily, weekly, and monthly traffic patterns. In order to improve the accuracy of prediction, the data is adaptively divided into different scales according to the characteristics of these time series, so as to obtain time series data at different time resolutions. Specifically, by identifying the seasonal trend of traffic flow, the original data is divided into the following three different scales:

[0051] 1. Daily pattern: Traffic flow usually varies significantly at different times of the day. For example, traffic flow during the morning and evening peaks is usually higher than at night or during non-peak hours.

[0052] 2. Weekly patterns: Certain days of the week may have different traffic patterns. For example, weekdays and weekends usually have different traffic distributions.

[0053] 3. Monthly or yearly patterns: Certain months or seasons (such as holidays, peak travel seasons) may have different traffic flow trends.

[0054] In view of the above characteristics of the input data, the seasonal trend in the data can be captured through Fourier transform and inverse transform, and the original time series can be divided according to the three different scales mentioned above based on the data characteristics.

[0055] Furthermore, multi-core average pooling can be used to identify and extract periodic trends, and periodic components can be identified by analyzing the periodic fluctuations of traffic flow.

[0056] The above-mentioned adaptive multi-scale segmentation of the input data can simultaneously capture the change patterns of different time scales in the traffic flow data, such as short-term traffic congestion, long-term trend changes, etc., learn the temporal correlation and high-dimensional spatial correlation of longer time series, and solve the long-term traffic prediction task of urban road networks.

[0057] Then, for time series at different time resolutions, the internal attention mechanism and cross-scale attention mechanism are applied to learn the long-term dependency and global correlation of time series. The cross-scale patch attention establishes the relationship between different scales to capture the global correlation; the internal attention is used to capture the local details of the time series at the same scale.

[0058] Specifically, the calculation formulas of the internal attention mechanism and the cross-scale attention mechanism are as follows:

[0059] (4)

[0060] (5)

[0061] (6)

[0062] in represents the attention value within the i-th time scale, represents the global internal attention value obtained by concatenating the internal attention values ​​of each time scale, Representing cross-scale attention between different time scales; Q , query), K(Key ,key), V(Value , value) are respectively the query vector, key vector and value vector generated after the linear transformation of the input sequence; Indicates the size of the attention dimension, Used to normalize the attention weights. represents the vector concatenation operation of the internal attention weights of each scale; the superscript i represents the i-th time scale; the subscript intra The same time scale; subscript inter for different time scales; p Represents the number of subsequences into which the original time series is divided;

[0063] For the spatial characteristics of the traffic network, DFRGAT(Deep Residual Graph Attention Network) extracts features from the input traffic network and then encodes the spatial features by applying the GRU (Gated Recurrent Network) based on the attention mechanism.

[0064] Specifically, the calculation formula for feature extraction is:

[0065] (7)

[0066] in represents a deep full residual graph attention network, G Represents the characteristics of the traffic network. Represents time characteristics, represents the dimension transformation matrix, Represents the activation function.

[0067] GRU The encoding module is shown in formula (8):

[0068] (8)

[0069] in express network, Indicates the hidden state at the last moment. Represents the hidden state at the current moment. Encoding spatial features through GRU can effectively learn the temporal correlation of the traffic network.

[0070] Finally, periodic feature fusion is used to fuse the weighted time features and the encoded spatial features, and then input into the decoder to obtain the nearest traffic flow prediction value in the future time window. Specifically, based on the results of seasonal trend decomposition and periodic trend decomposition, the time features are first weighted, and different weights are assigned according to the degree of influence of different time periods on traffic flow (for example, the weight of traffic flow during the morning rush hour can be higher than that of other time periods); then the features of different time periods are weighted and evaluated to obtain the fused weighted time features, and finally the fused weighted time features are fused with the encoded spatial features to obtain the fused feature vector. Among them, the periodic feature fusion can improve the accuracy of Multi-ScaleGAT long-term prediction.

[0071] Then the traffic flow prediction value The actual flow value For comparison, the error loss is calculated. The model uses the mean square error loss function. After obtaining the model loss, the model is trained through the back propagation algorithm to continuously update the model weights. At the same time, after the training is completed, the performance of the model on the test set needs to be evaluated to determine the accuracy and generalization ability of the model.

[0072] The present invention obtains the seasonal and cyclical trends of traffic flow data by performing Fourier transform and multi-core average pooling on the input time series data, thereby dividing the time series into different time resolutions and performing adaptive multi-scale division, which can better learn the long-term dependency and global correlation of the input data and achieve more accurate prediction; the dual attention mechanism of the present invention performs internal attention on the data of the same scale for each scale of division, and performs cross-scale attention on the data of different scales, which can capture the global correlation and local details of time dependency. The deep full residual graph attention block (DFRGAT) of the present invention accurately captures the spatial structure information of the road network through dynamic aggregation, which can avoid the disappearance of local features and the propagation of noise during the propagation process caused by the deepening of the GAT layer.

[0073] The embodiment of the present invention further discloses a computer program product, including a computer program, which executes the steps of the above method when executed by a processor. The embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored, which executes the steps of the above method when executed by a processor. The embodiment of the present invention further discloses a computer device, including a memory and a processor connected to each other, on which a computer program is stored, which executes the steps of the above method when executed by a processor. The product, medium and device of the present invention all correspond to the above method and also have the advantages described in the above method.

[0074] The present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable storage media include: any entity or device that can carry computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. The memory is used to store computer programs and / or modules. The processor implements various functions by running or executing computer programs and / or modules stored in the memory, and calling data stored in the memory. The memory may include a high-speed random access memory and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0075] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A traffic flow prediction method based on multi-scale graph attention network, characterized in that: Includes steps: Obtain historical traffic flow time series data and preprocess them to obtain time series with seasonal and cyclical trends; Divide the time series with seasonal and cyclical trends into different scales to obtain time series with different time resolutions; For time series at different time resolutions, the internal attention mechanism and the cross-scale attention mechanism are used to learn the long-term dependency and global correlation of the time series to obtain weighted time features. For each scale of the division, an internal attention mechanism is performed on the data of the same scale, and a cross-scale attention mechanism is performed on the data of different scales; Obtain a historical traffic network, extract spatial features in the traffic network, and then encode the spatial features to obtain encoded spatial features; for the spatial features in the traffic network, extract features of the input traffic network through a deep residual graph attention network, and then encode the spatial features by applying a gated recurrent network based on an attention mechanism; The weighted time features and the encoded spatial features are fused to obtain the traffic flow prediction value in the future time window.

2. The traffic flow prediction method based on multi-scale graph attention network according to claim 1 is characterized in that: The preprocessing includes Fourier transform and multi-core average pooling, and the seasonal trend is obtained by Fourier transform; and the periodic trend is obtained by multi-core average pooling.

3. The traffic flow prediction method based on multi-scale graph attention network according to claim 2 is characterized in that: The calculation formulas for Fourier transform and multi-core average pooling are: (1) (2) (3) in X represents the input time series, represents the seasonal trend of the time series, represents the difference between the input time series and the seasonal trend of the time series, Represents the periodic trend of the time series, represents the inverse Fourier transform, Φ and A Represent the phase and amplitude of each frequency respectively, represents the frequency with the largest magnitude; is the pooling function of the ith kernel, N corresponds to the number of cores, Controls the weighting of results from different kernels.

4. The traffic flow prediction method based on multi-scale graph attention network according to claim 1, 2 or 3, characterized in that: The calculation formula of the internal attention mechanism is as follows: (4) (5) in represents the attention value within the i-th time scale, represents the global internal attention value obtained by concatenating the internal attention values ​​of each scale, Q, K, V They are the query vector, key vector, and value vector generated after linear transformation of the input time series; Indicates the size of the attention dimension, Used to normalize the attention weights. Represents the vector concatenation operation of the internal attention weights at each scale; The superscript i represents the i-th time scale; the subscript intra The same time scale; Subscript inter for different time scales; p Represents the number of subsequences into which the original time series is divided.

5. The traffic flow prediction method based on multi-scale graph attention network according to claim 4 is characterized in that: The calculation formula of the cross-scale attention mechanism is as follows: (6) Represents cross-scale attention between different scales.

6. The traffic flow prediction method based on multi-scale graph attention network according to claim 1, 2 or 3, characterized in that: The formula for extracting spatial features from the traffic network is: (7) in represents a deep full residual graph attention network, G Represents the characteristics of the traffic network. Represents time characteristics, represents the dimension transformation matrix, Represents the activation function.

7. The traffic flow prediction method based on multi-scale graph attention network according to claim 6, characterized in that: The formula for encoding spatial features is: (8) in express network, Indicates the hidden state at the last moment. Indicates the current hidden state.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program performs the steps of the method according to any one of claims 1 to 7.

9. A computer device comprising a memory and a processor connected to each other, wherein a computer program is stored in the memory, characterized in that: When the computer program is executed by a processor, the computer program performs the steps of the method according to any one of claims 1 to 7.