A frequency-aware traffic flow prediction method and system
By employing a frequency-aware traffic flow prediction method, wavelet decomposition and self-attention mechanism are used to adaptively model the multi-scale spatiotemporal dependencies of traffic flow data, thus solving the problem of insufficient model generalization ability in existing methods and achieving higher-precision traffic flow prediction.
Patent Information
- Application Number
- CN202611274988.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-21
- Publication Date
- 2026-11-27
AI Technical Summary
Existing traffic flow prediction methods rely on predefined or manually constructed road network graph structures, making it difficult to fully explore the multi-scale spatiotemporal dependencies in traffic flow data. Furthermore, they fail to design time series models for both overall stable changes and local abrupt changes, resulting in insufficient model generalization ability.
A frequency-aware approach is adopted to obtain trend and detail components through discrete wavelet decomposition, and feature embedding is performed on each component. Temporal modeling is then performed using global self-attention and local window temporal convolution. Combined with a cross-frequency adjustment module and self-attention mechanism, the dependency between time and spatial dimensions is adaptively modeled to fully explore multi-scale spatiotemporal patterns.
It improves the accuracy of traffic flow prediction and the generalization ability of the model, adapts to different road network scenarios, avoids information loss, and improves the accuracy of prediction.
Smart Images

Figure CN123182407A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of traffic flow prediction technology, and in particular to a frequency-aware traffic flow prediction method, system, storage medium, and electronic device. Background Technology
[0002] Rapid urbanization worldwide has led to a surge in motor vehicle ownership, making traffic congestion one of the major problems plaguing modern cities, resulting in enormous waste of time, economic losses, and environmental pollution. Effective traffic management (such as traffic light timing optimization, traffic guidance, and congestion pricing) and improving public travel efficiency (such as intelligent navigation and travel planning) both heavily rely on accurate predictions of future traffic conditions.
[0003] Traffic prediction technology has evolved from early statistical models and machine learning methods to the current era of deep learning, centered on graph neural networks and attention mechanisms. Most existing methods rely on predefined or manually constructed road network graph structures to model the spatial dependencies between nodes. The quality of the graph structure and prior assumptions directly affect the model's predictive performance and generalization ability. Meanwhile, traffic conditions often contain both overall stable trend patterns and locally abrupt detailed patterns. Most existing methods fail to design appropriate temporal modeling methods for the different characteristics of these two patterns, and rarely consider the interrelationships and complementarities between trend and detailed patterns, making it difficult for models to fully exploit the multi-scale spatiotemporal dependencies inherent in traffic flow data. Summary of the Invention
[0004] This invention provides a frequency-aware traffic flow prediction method, system, storage medium, and electronic device. It can adaptively model the temporal and spatial dependencies entirely based on a self-attention mechanism without relying on a predefined or manually constructed road network graph structure. At the same time, it fully explores the multi-scale spatiotemporal patterns in traffic flow data through frequency decomposition and cross-frequency adjustment mechanisms, thereby improving the accuracy of traffic flow prediction and the generalization ability of the model.
[0005] This invention provides a frequency-aware traffic flow prediction method, comprising: Historical traffic flow data is acquired, and discrete wavelet decomposition is performed on the historical traffic flow data to obtain trend components and detail components. Feature embedding is performed on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend embedding representation input is a trend temporal encoding module composed of multiple stacked global self-attention modules, which is used for temporal modeling to obtain trend temporal features; the detail embedding representation input is a detail temporal encoding module composed of multiple stacked local window temporal convolution modules, which is used for temporal modeling to obtain detail temporal features. The trend time series features and the detailed time series features are input into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The adjusted trend features and the adjusted detail features are concatenated along the feature dimension and then passed through a feature fusion layer to obtain fused temporal features. The fused temporal features are then input into a spatial encoding module composed of multiple stacked global self-attention modules to obtain spatially encoded spatiotemporal features. The spatially encoded spatiotemporal features are then passed through a projection layer to obtain traffic flow prediction results.
[0006] Furthermore, according to the above-mentioned frequency-aware traffic flow prediction method, the historical traffic flow data includes multiple flow features, including road traffic flow, intraday time information at the corresponding time, and weekday information. Feature embedding is performed on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation, including: Based on the index of each time step of the historical traffic flow data, calculate the daily periodic feature index and the weekly periodic feature index; The time feature slices corresponding to the daily cycle feature index and the time slices corresponding to the weekly cycle feature index are embedded using an embedding function to obtain the daily cycle embedding and the weekly cycle embedding. The trend component is mapped through a fully connected layer to obtain the traffic embedding. The learnable node embedding matrix, the daily periodic embedding, the weekly periodic embedding, and the traffic embedding are concatenated to obtain the trend embedding representation. The detailed components are mapped through a fully connected layer to obtain detailed embeddings. The learnable node embedding matrix, the daily periodic embedding, and the detailed embeddings are concatenated to obtain a trend embedding representation.
[0007] Furthermore, according to the frequency-aware traffic flow prediction method described above, the processing procedure of the global self-attention module includes: The input feature sequence is subjected to three linear transformations to obtain a query matrix, a key matrix, and a value matrix. The query matrix, the key matrix, and the value matrix are then divided into multiple attention heads along the feature dimension. The outputs of each attention head are concatenated and mapped through a linear layer to obtain the self-attention output; The self-attention output is added to the input feature sequence, and then passed through a feedforward network and layer normalization to obtain the output features of the global self-attention module.
[0008] Furthermore, according to the frequency-aware traffic flow prediction method described above, the processing procedure of the local window temporal convolution module includes: After transposing the time dimension and feature dimension of the input feature sequence, it is sequentially passed through one-dimensional convolution, activation function, random deactivation and pointwise one-dimensional convolution to obtain temporal convolution output. Then the temporal convolution output is transposed back to the original dimensional arrangement. The transposed temporal convolution output is added to the input feature sequence, and then passed through a feedforward network and layer normalization to obtain the output features of the local window temporal convolution module.
[0009] Furthermore, according to the frequency-aware traffic flow prediction method described above, the processing procedure of the cross-frequency adjustment module includes: Based on the cross-frequency attention mechanism, complementary trend information and complementary detail information are extracted from the trend time-series features and the detail time-series features, respectively. Based on the complementary trend information, the trend time series features are gated and updated to obtain the adjusted trend features. Based on the complementary information of the details, the temporal features of the details are gated and updated to obtain the adjusted details features.
[0010] Furthermore, according to the frequency-aware traffic flow prediction method described above, based on the cross-frequency attention mechanism, complementary trend information and complementary detail information are extracted from the trend time-series features and the detail time-series features, respectively, as expressed by the following formula:
[0011]
[0012] in, For complementary trend information, For complementary information on details, For trend time series features, For detailed timing features, Indicates cross-frequency adjustment module, , For each attention head, the feature dimensions, For activation function, These represent the query, key, and value, respectively. The gating update process is represented by the following formula:
[0013]
[0014] in, The adjusted trend characteristics, For the adjusted detailed features, This indicates a splicing operation. , It is a gated weight matrix. It is the sigmoid activation function, where ⊙ represents element-wise multiplication. Presentation layer normalization operation.
[0015] Furthermore, according to the frequency-aware traffic flow prediction method described above, the daily periodic feature index and the weekly periodic feature index are calculated using the following formula:
[0016]
[0017] in, This represents the index of each time step L in the historical traffic flow data, where S represents the number of time steps in a day. The floor function represents the rounding down operation, while mod represents the modulo operation. The time feature slices corresponding to the daily cycle feature index and the time slices corresponding to the weekly cycle feature index are embedded using an embedding function to obtain the daily cycle embedding and the weekly cycle embedding, which are expressed by the following formula:
[0018]
[0019] in, , These are time feature slices at indices 1 and 2, respectively. 、 , , , and It is an embedded function.
[0020] The present invention also provides a frequency-aware traffic flow prediction system, comprising: The data acquisition and decomposition module is used to acquire historical traffic flow data and perform discrete wavelet decomposition on the historical traffic flow data to obtain trend components and detail components. The feature embedding module is used to perform feature embedding on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend time series encoding module is composed of multiple stacked global self-attention modules, which is used to perform time series modeling on the trend embedding to obtain trend time series features; The detail temporal coding module is composed of multiple stacked local window temporal convolutional modules, which is used to perform temporal modeling on the detail embedding to obtain detail temporal features; A cross-frequency domain adjustment module is used to input the trend time series features and the detailed time series features into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The feature fusion module is used to concatenate the adjusted trend features and the adjusted detail features along the feature dimension, and obtain the fused temporal features through the feature fusion layer; The spatial encoding module, composed of multiple stacked global self-attention modules, is used to obtain spatially encoded spatiotemporal features based on the fused temporal features. The output projection module is used to obtain traffic flow prediction results by passing the spatially encoded spatiotemporal features through the projection layer.
[0021] The present invention also provides a computer-readable storage medium storing a plurality of instructions adapted to be loaded by a processor to execute any of the frequency-aware traffic flow prediction methods described above.
[0022] The present invention also provides an electronic device, including a processor and a memory, wherein the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used in the steps of the frequency-aware traffic flow prediction method described in any of the preceding claims.
[0023] This invention provides a frequency-aware traffic flow prediction method, system, storage medium, and electronic device. First, it decouples the original traffic flow data by frequency dimension through discrete wavelet decomposition. Then, based on the different statistical characteristics of trend and detail components, it designs a global self-attention-based temporal coding module and a local temporal convolution-based temporal coding module, respectively, which can fully capture the global periodic pattern and local instantaneous fluctuation pattern of traffic flow. Second, it designs a cross-frequency adjustment module, which uses bidirectional cross-attention and gating mechanisms to mutually adjust trend and detail features, fully mining the complementary information between the two frequency patterns and avoiding information loss caused by isolated modeling. Furthermore, this invention models the spatial relationships between road nodes entirely based on a self-attention mechanism, without the need for pre-construction or manual specification of the road network graph structure, improving the model's adaptability and generalization ability in different road network scenarios. Attached Figure Description
[0024] The technical solution and other beneficial effects of the present invention will become apparent from the following detailed description of specific embodiments of the invention, in conjunction with the accompanying drawings.
[0025] Figure 1 A flowchart of a frequency-aware traffic flow prediction method provided in an embodiment of the present invention.
[0026] Figure 2 This is a schematic diagram of the structure of a frequency-aware traffic flow prediction system provided in an embodiment of the present invention.
[0027] Figure 3This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] This invention provides a frequency-aware traffic flow prediction method, system, storage medium, and electronic device. The frequency-aware traffic flow prediction system provided in this invention can be integrated into an electronic device, which may be a terminal, server, or other device. The terminal may include a tablet computer, laptop computer, personal computer (PC), microprocessor box, or other devices.
[0030] Please see Figure 1 , Figure 1 The flowchart illustrates a frequency-aware traffic flow prediction method provided in an embodiment of the present invention, which is applied in an electronic device. The frequency-aware traffic flow prediction method includes the following steps: S1: Obtain historical traffic flow data, perform discrete wavelet decomposition on the historical traffic flow data, and obtain trend components and detail components.
[0031] Obtain historical traffic flow data ,in To input the historical time step, The number of road nodes. The historical traffic flow data includes multiple flow characteristics, such as road traffic flow, intraday time information, and weekday information.
[0032] Representing historical traffic flow data as ,in To input the historical time step, This represents the number of road nodes. After dimensional rearrangement along the time dimension, a specified orthogonal wavelet basis is used. Perform time series analysis on each node Discrete wavelet transform of order 1:
[0033] in, for The approximate coefficients after decomposition represent the low-frequency components of the signal; (j=1,…, J) is the j-th The detail coefficients of the layer characterize the high-frequency components of the signal. To obtain the trend components that are of the same length as the original data and aligned with the time domain, only approximate coefficients are retained. After setting all detail coefficients to zero, perform an inverse discrete wavelet transform:
[0034] in, For trend components.
[0035] To obtain the detail components, only all detail coefficients are retained, and the approximate coefficients are set to zero before inverse wavelet transform reconstruction is performed.
[0036] in, For detailed components.
[0037] Among them, the trend component High-frequency abrupt changes were filtered out, preserving the overall smooth pattern of traffic flow, which can be considered a stable traffic pattern; detailed components Low-frequency stationary components were filtered out, while local abrupt changes and instantaneous fluctuations in traffic flow were retained, which can be considered as local traffic patterns. After decomposition, and Rearrange the dimensions back to the same order as the original data.
[0038] S2, feature embedding is performed on the trend component and detail component respectively to obtain the trend embedding representation and detail embedding representation.
[0039] In one embodiment, step S2 includes the following steps: S21, based on the index of each time step of historical traffic flow data, calculate the daily periodic feature index and the weekly periodic feature index.
[0040] For each time step index in all time steps L of historical traffic data The daily cycle feature index is calculated using the following formula. and periodic feature index :
[0041]
[0042] in, This represents the index of each time step L in the historical traffic flow data, and S represents the number of time steps in a day (5 minutes per time step, for a total of 288 steps). The floor function represents the rounding down operation, while mod represents the modulo operation. Secondly, the time feature is extended to all N nodes:
[0043]
[0044] in, The Repeat operation is used to extend temporal features to the spatial dimension.
[0045] S22, the time feature slices corresponding to the daily cycle feature index and the time slices corresponding to the weekly cycle feature index are embedded using the embedding function to obtain the daily cycle embedding and the weekly cycle embedding.
[0046] For historical traffic data X The last two feature dimensions (daily and weekly feature indices) are taken and embedded using an embedding function to obtain the daily and weekly embeddings, which are expressed by the following formula:
[0047]
[0048] in, , These are time feature slices at indices 1 and 2, respectively. 、 , , , and It is an embedded function.
[0049] S23, the trend component is mapped through a fully connected layer to obtain the traffic embedding, and the learnable node embedding matrix, daily periodic embedding, weekly periodic embedding and traffic embedding are concatenated to obtain the trend embedding representation.
[0050] For the trend component, its flow value is passed through a fully connected layer. The mapping yields the traffic embedding, and simultaneously, a learnable node embedding matrix that is randomly initialized and updated during network training is introduced. Broadcasting is performed in both batch and time dimensions. The above embeddings are then concatenated along the feature dimension to obtain the trend embedding representation. :
[0051] in, This is for splicing operations.
[0052] S24. The detail components are mapped through a fully connected layer to obtain the detail embedding. The learnable node embedding matrix, daily periodic embedding, and detail embedding are concatenated to obtain the trend embedding representation.
[0053] For the detail components, feature embedding is performed in a similar manner to that for the trend components to obtain the detail embedding representation. :
[0054] In a preferred embodiment of the present invention, the feature embedding of the detail components does not include the weekday embedding because the detail components mainly represent short-term local fluctuations and have a weak correlation with the long-span weekday periodicity, thereby reducing redundant parameters and noise and improving model efficiency. In other embodiments, the weekday embedding or other auxiliary time feature embeddings can be introduced into the feature embedding of the detail components according to the needs of the actual scenario.
[0055] S3, the trend embedding representation input is a trend temporal encoding module composed of multiple layers of global self-attention modules stacked together, and the trend temporal features are obtained by temporal modeling; the detail embedding representation input is a detail temporal encoding module composed of multiple layers of local window temporal convolution modules stacked together, and the detail temporal features are obtained by temporal modeling.
[0056] The trend time series encoding module is composed of multiple layers of global self-attention modules stacked together. The output of the previous layer of global self-attention module serves as the input of the next layer of global self-attention module, and finally the trend time series features are output by the last layer of global self-attention module.
[0057] In one embodiment, the processing procedure of the global self-attention module includes: S31, perform three linear transformations on the input feature sequence to obtain the query matrix, key matrix and value matrix, and divide the query matrix, key matrix and value matrix into multiple attention heads along the feature dimension.
[0058] Specifically, for the input feature sequence (The input to the first-layer global self-attention module is the trend embedding representation, and the input to the remaining layers of global self-attention modules is the output feature of the previous layer's global self-attention module.) The query matrix is obtained through three independent linear transformations. Key matrix Sum matrix The three are then divided into multiple attention heads along the feature dimension:
[0059]
[0060] in These are the query matrix, key matrix, and value matrix, respectively. , , These are learnable parameters. The feature dimensions for each attention head.
[0061] S32 concatenates the outputs of each attention head and maps them through a linear layer to obtain the self-attention output.
[0062] S33, after adding the self-attention output to the input feature sequence, passes it through a feedforward network and layer normalization to obtain the output features of the global self-attention module.
[0063] The self-attention output is added to the residual of the input feature sequence and then normalized by a layer. This is followed by a feedforward network module (consisting of two linear transformations and a GELU activation function), residual connections, and another layer normalization step to obtain the output feature of that layer. Finally, the last layer of global self-attention module outputs the trend time-series features. .
[0064] In one embodiment, the processing procedure of the local window temporal convolution module includes: S34. After transposing the time dimension and feature dimension of the input feature sequence, it is sequentially passed through one-dimensional convolution, activation function, random deactivation and pointwise one-dimensional convolution to obtain temporal convolution output, and then the temporal convolution output is transposed back to the original dimensional arrangement.
[0065] S35, the transposed temporal convolution output is added to the input feature sequence and then passed through a feedforward network and layer normalization to obtain the output features of the local window temporal convolution module.
[0066] Specifically, the temporal and feature dimensions of the input feature sequence (the input to the first-layer local window temporal convolutional module is the detail embedding representation, and the input to the remaining layers of the local window temporal convolutional module is the output feature of the previous layer's local window temporal convolutional module) are transposed, and then sequentially processed through a kernel of size [missing information]. One-dimensional convolution, GELU activation function, random deactivation, and pointwise one-dimensional convolution with kernel size 1 are used to obtain the temporal convolution output, which is then transposed back to the original dimensional arrangement, as expressed by the following formula:
[0067] in, , The local window radius, This is a discard operation.
[0068] The transposed temporal convolution output is added to the residual of the input feature sequence and then normalized layer by layer. This is then passed through a feedforward network module with the same structure as the trend temporal coding module, along with residual connections and layer normalization, to obtain the output feature of that layer. Finally, the detailed temporal features are output by the last layer of local window temporal convolution. Because one-dimensional convolution operations inherently possess the characteristic of local receptive fields, this module can efficiently capture the high-frequency fluctuation features of detail components within their local neighborhoods.
[0069] S4 inputs the trend time series features and detailed time series features into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features.
[0070] In one embodiment, the processing procedure of the cross-frequency adjustment module includes: S41, based on the cross-frequency attention mechanism, extracts complementary trend information and complementary detail information from the trend time series features and the detail time series features, respectively.
[0071] To fully exploit the complementary information between trend features and detail features, this invention designs a cross-frequency regulator, the specific process of which is as follows: A cross-frequency attention mechanism is employed, enabling each branch to extract complementary information from the other's time representation:
[0072]
[0073] in, For complementary trend information, For complementary information on details, For trend time series features, For detailed timing features, Indicates cross-frequency adjustment module, , For each attention head, the feature dimensions, For activation function, These represent the query, key, and value, respectively.
[0074] S42, based on complementary trend information, performs gating update on the trend time series features to obtain the adjusted trend features.
[0075] S43, based on complementary detail information, performs gated updates on the temporal features of the details to obtain the adjusted detail features.
[0076] The gating update process is represented by the following formula:
[0077]
[0078] in, The adjusted trend characteristics, For the adjusted detailed features, This indicates a splicing operation. , It is a gated weight matrix. It is the sigmoid activation function, where ⊙ represents element-wise multiplication. Presentation layer normalization operation.
[0079] S5 concatenates the adjusted trend features and adjusted detail features along the feature dimension, and obtains the fused temporal features through the feature fusion layer; the fused temporal features are then input into the spatial encoding module composed of multiple layers of global self-attention modules to obtain the spatially encoded spatiotemporal features.
[0080] Representing the adjusted trend characteristics and detailed feature representation By concatenating along the feature dimension and applying linear mapping and normalization layers, a unified spatiotemporal representation is obtained:
[0081] in, To integrate temporal features.
[0082] To model the spatial relationships between road nodes, this invention will The node dimension serves as the sequence length. The input is a spatial encoding module composed of multiple layers of global spatial self-attention modules (with the same structure as the global self-attention module in step S3), which adaptively models the correlation between any two road nodes without relying on a pre-constructed road network graph structure. After spatial encoding, the features are restored to their original dimensional arrangement of time and nodes, resulting in the spatially encoded spatiotemporal features.
[0083] S6, the spatially encoded spatiotemporal features are passed through a projection layer to obtain traffic flow prediction results.
[0084] The node and time dimensions of the spatially encoded spatiotemporal features are transposed, and the time and feature dimensions are flattened into a one-dimensional vector. This vector is then mapped through an output projection linear layer to the product dimension of the number of future time steps and the number of output feature channels. Finally, the vector is reshaped and transposed back to the dimensional arrangement of (future time steps, nodes, and number of output feature channels) to obtain the final predicted traffic flow data. .
[0085] The above steps S1-S6 can be applied to traffic flow prediction models. The training process of this model is similar to the application process. First, historical traffic flow data for each road node is collected. The historical traffic flow data is divided into traffic flow samples and actual traffic flow data. The traffic flow samples are input into the traffic flow prediction model to execute steps S1-S6 to obtain predicted traffic flow data. A loss function is constructed based on the actual traffic flow data and the predicted traffic flow data, defined as follows:
[0086] in, Represents the actual observed value. This represents the model's predicted value. The set of observation samples used for training is used. The Adam optimization algorithm is used to jointly iteratively optimize all learnable parameters in the model, including the feature embedding parameters after discrete wavelet decomposition, the trend and detail temporal coding module parameters, the cross-frequency adjustment module parameters, the feature fusion layer parameters, the spatial coding module parameters, and the output projection layer parameters, until the loss function converges, resulting in a trained traffic flow prediction model.
[0087] The datasets used in the embodiments of this invention are from the following sources: Experiments were conducted using four public datasets, PEMS03, PEMS04, PEMS07, and PEMS08. All datasets were divided into training, validation, and test sets in a 6:2:2 ratio based on the total number of time steps.
[0088] PeMS03: Contains 358 sensors, covering a period of 90 days from September 1, 2018 to November 30, 2018.
[0089] PeMS04: Contains 307 sensors, covering a period of 59 days from January 1, 2018 to February 28, 2018.
[0090] PeMS07: Contains 883 sensors, covering a period of 122 days from May 1, 2017 to August 31, 2017.
[0091] PeMS08: Contains 170 sensors, covering a period of 61 days from July 1, 2016 to August 31, 2016.
[0092] This invention employs three commonly used metrics for evaluating model performance in traffic prediction tasks: mean absolute error. Mean absolute percentage error and root mean square error The details are as follows:
[0093]
[0094]
[0095] in, Represents the actual observed value. This represents the model's predicted value. This is the observed sample set. The time threshold for the experiment in this invention is set to 12, using traffic flow from the past hour to predict traffic flow for the next hour. The Adam optimizer is used, with a learning rate of 0.001 and 200 training epochs. Batch sizes are all set to 16. To prevent overfitting, an early stopping technique is implemented; if no reduction in loss is observed after 20 epochs, the training process is stopped.
[0096] Based on the method described in the above embodiments, this embodiment will further describe it from the perspective of a frequency-aware traffic flow prediction system. The frequency-aware traffic flow prediction system can be implemented as an independent entity or integrated into an electronic device. The electronic device can be a terminal, server, or other device. The terminal can include a tablet computer, a laptop computer, a personal computer (PC), a microprocessor box, or other devices.
[0097] Please see Figure 2 , Figure 2 This invention specifically describes a frequency-aware traffic flow prediction system provided in an embodiment of the invention, which is applied in an electronic device. The frequency-aware traffic flow prediction system may include: The data acquisition and decomposition module is used to acquire historical traffic flow data and perform discrete wavelet decomposition on the historical traffic flow data to obtain trend components and detail components. The feature embedding module is used to perform feature embedding on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend time series encoding module is composed of multiple stacked global self-attention modules, which is used to perform time series modeling on the trend embedding to obtain trend time series features; The detail temporal coding module is composed of multiple stacked local window temporal convolutional modules, which is used to perform temporal modeling on the detail embedding to obtain detail temporal features; A cross-frequency domain adjustment module is used to input the trend time series features and the detailed time series features into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The feature fusion module is used to concatenate the adjusted trend features and the adjusted detail features along the feature dimension, and obtain the fused temporal features through the feature fusion layer; The spatial encoding module, composed of multiple stacked global self-attention modules, is used to obtain spatially encoded spatiotemporal features based on the fused temporal features. The output projection module is used to obtain traffic flow prediction results by passing the spatially encoded spatiotemporal features through the projection layer.
[0098] In specific implementation, the above modules and / or units can be implemented as independent entities, or they can be arbitrarily combined and implemented as the same or several entities. For the specific implementation of the above modules and / or units, please refer to the previous method embodiments. For the specific beneficial effects that can be achieved, please also refer to the beneficial effects in the previous method embodiments, which will not be repeated here.
[0099] In addition, this embodiment of the invention also provides an electronic device, which may be a computer, tablet computer, or other similar device. This electronic device can implement the steps of any embodiment of the frequency-aware traffic flow prediction method provided in this embodiment of the invention. Therefore, it can achieve the beneficial effects that any frequency-aware traffic flow prediction method provided in this embodiment of the invention can achieve, as detailed in the preceding embodiments, and will not be repeated here.
[0100] Figure 3 A specific structural block diagram of an electronic device provided in an embodiment of the present invention is shown. This electronic device can be used to implement the frequency-aware traffic flow prediction method provided in the above embodiments. The electronic device 500 can be a terminal, server, or other device. The terminal can include a tablet computer, laptop computer, personal computer (PC), microprocessor box, or other devices.
[0101] The memory 520 can be used to store software programs and modules, such as the program instructions / modules corresponding to those in the above embodiments. The processor 580 executes various functional applications and data processing by running the software programs and modules stored in the memory 520. The memory 520 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 520 may further include memory remotely located relative to the processor 580, and these remote memories can be connected to the electronic device 500 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0102] The input unit 530 can be used to receive input numeric or character information, and to generate a keyboard and mouse related to user settings and function control.
[0103] Display unit 540 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces, which can be composed of graphics, text, icons, video, and any combination thereof. Display unit 540 may include display panel 541, which may optionally be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), or other similar forms.
[0104] Electronic device 500, through transmission module 570 (e.g., Wi-Fi module), can help users receive requests, send information, etc., providing users with wireless broadband internet access. Although transmission module 570 is shown in the figure, it is understood that it is not an essential component of electronic device 500 and can be omitted as needed without changing the essence of the invention.
[0105] The processor 580 is the control center of the electronic device 500. It connects to various parts of the phone via various interfaces and lines, and performs various functions and processes data of the electronic device 500 by running or executing software programs and / or modules stored in the memory 520, and by calling data stored in the memory 520, thereby providing overall monitoring of the electronic device. Optionally, the processor 580 may include one or more processing cores; in some embodiments, the processor 580 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 580.
[0106] Electronic device 500 also includes a power supply 590 (such as a battery) that supplies power to various components. In some embodiments, the power supply may be logically connected to processor 580 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 590 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0107] Although not shown, the electronic device 500 also includes cameras (such as front-facing cameras and rear-facing cameras), Bluetooth modules, etc., which will not be described in detail here. Specifically, in this embodiment, the display unit of the electronic device is a touch screen display, and the mobile terminal also includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors. One or more programs contain instructions for performing the following operations: Historical traffic flow data is acquired, and discrete wavelet decomposition is performed on the historical traffic flow data to obtain trend components and detail components. Feature embedding is performed on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend embedding representation input is a trend temporal encoding module composed of multiple stacked global self-attention modules, which is used for temporal modeling to obtain trend temporal features; the detail embedding representation input is a detail temporal encoding module composed of multiple stacked local window temporal convolution modules, which is used for temporal modeling to obtain detail temporal features. The trend time series features and the detailed time series features are input into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The adjusted trend features and the adjusted detail features are concatenated along the feature dimension and then passed through a feature fusion layer to obtain fused temporal features. The fused temporal features are then input into a spatial encoding module composed of multiple stacked global self-attention modules to obtain spatially encoded spatiotemporal features. The spatially encoded spatiotemporal features are then passed through a projection layer to obtain traffic flow prediction results.
[0108] In practice, the above modules can be implemented as independent entities or combined in any way to be implemented as the same or several entities. For the specific implementation of the above modules, please refer to the previous method implementation examples, which will not be repeated here.
[0109] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. Therefore, embodiments of the present invention provide a storage medium storing multiple instructions that can be loaded by a processor to execute the steps of any embodiment of the frequency-aware traffic flow prediction method provided by the present invention.
[0110] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0111] Since the instructions stored in the storage medium can execute the steps in any embodiment of the frequency-aware traffic flow prediction method provided in the embodiments of the present invention, the beneficial effects that any frequency-aware traffic flow prediction method provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0112] The foregoing has provided a detailed description of a frequency-aware traffic flow prediction method, system, storage medium, and electronic device provided by embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A traffic flow prediction method based on frequency sensing, characterized in that, The method includes: Historical traffic flow data is acquired, and discrete wavelet decomposition is performed on the historical traffic flow data to obtain trend components and detail components. Feature embedding is performed on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend embedding representation input is a trend temporal encoding module composed of multiple stacked global self-attention modules, which is used for temporal modeling to obtain trend temporal features; the detail embedding representation input is a detail temporal encoding module composed of multiple stacked local window temporal convolution modules, which is used for temporal modeling to obtain detail temporal features. The trend time series features and the detailed time series features are input into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The adjusted trend features and the adjusted detail features are concatenated along the feature dimension and then passed through a feature fusion layer to obtain fused temporal features. The fused temporal features are then input into a spatial encoding module composed of multiple stacked global self-attention modules to obtain spatially encoded spatiotemporal features. The spatially encoded spatiotemporal features are then passed through a projection layer to obtain traffic flow prediction results.
2. The traffic flow prediction method based on frequency sensing according to claim 1, characterized in that, Historical traffic flow data includes multiple flow characteristics, including road traffic flow, intraday time information, and weekday information. Feature embedding is performed on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation, including: Based on the index of each time step of the historical traffic flow data, calculate the daily periodic feature index and the weekly periodic feature index; The time feature slices corresponding to the daily cycle feature index and the time slices corresponding to the weekly cycle feature index are embedded using an embedding function to obtain the daily cycle embedding and the weekly cycle embedding. The trend component is mapped through a fully connected layer to obtain the traffic embedding. The learnable node embedding matrix, the daily periodic embedding, the weekly periodic embedding, and the traffic embedding are concatenated to obtain the trend embedding representation. The detailed components are mapped through a fully connected layer to obtain detailed embeddings. The learnable node embedding matrix, the daily periodic embedding, and the detailed embeddings are concatenated to obtain a trend embedding representation.
3. The traffic flow prediction method based on frequency sensing according to claim 1, characterized in that, The processing procedure of the global self-attention module includes: The input feature sequence is subjected to three linear transformations to obtain a query matrix, a key matrix, and a value matrix. The query matrix, the key matrix, and the value matrix are then divided into multiple attention heads along the feature dimension. The outputs of each attention head are concatenated and mapped through a linear layer to obtain the self-attention output; The self-attention output is added to the input feature sequence, and then passed through a feedforward network and layer normalization to obtain the output features of the global self-attention module.
4. The traffic flow prediction method based on frequency sensing according to claim 1, characterized in that, The processing procedure of the local window temporal convolution module includes: After transposing the time dimension and feature dimension of the input feature sequence, it is sequentially passed through one-dimensional convolution, activation function, random deactivation and pointwise one-dimensional convolution to obtain temporal convolution output. Then the temporal convolution output is transposed back to the original dimensional arrangement. The transposed temporal convolution output is added to the input feature sequence, and then passed through a feedforward network and layer normalization to obtain the output features of the local window temporal convolution module.
5. The traffic flow prediction method based on frequency sensing according to claim 1, characterized in that, The processing procedure of the cross-frequency adjustment module includes: Based on the cross-frequency attention mechanism, complementary trend information and complementary detail information are extracted from the trend time-series features and the detail time-series features, respectively. Based on the complementary trend information, the trend time series features are gated and updated to obtain the adjusted trend features. Based on the complementary information of the details, the temporal features of the details are gated and updated to obtain the adjusted details features.
6. The traffic flow prediction method based on frequency sensing according to claim 5, characterized in that, Based on the cross-frequency attention mechanism, complementary trend information and complementary detail information are extracted from the trend time-series features and the detail time-series features, respectively, as expressed by the following formula: in, For complementary trend information, For complementary information on details, For trend time series features, For detailed timing features, Indicates cross-frequency adjustment module, , For each attention head, the feature dimensions, For activation function, These represent the query, key, and value, respectively. The gating update process is represented by the following formula: in, The adjusted trend characteristics, For the adjusted detailed features, This indicates a splicing operation. , It is a gated weight matrix. It is the sigmoid activation function, where ⊙ represents element-wise multiplication. Presentation layer normalization operation.
7. The traffic flow prediction method based on frequency sensing according to claim 2, characterized in that, The daily cycle feature index and the weekly cycle feature index are calculated using the following formula: in, This represents the index of each time step L in the historical traffic flow data, where S represents the number of time steps in a day. The floor function represents the rounding down operation, while mod represents the modulo operation. The time feature slices corresponding to the daily cycle feature index and the time slices corresponding to the weekly cycle feature index are embedded using an embedding function to obtain the daily cycle embedding and the weekly cycle embedding, which are expressed by the following formula: in, , These are time feature slices at indices 1 and 2, respectively. 、 , , , and It is an embedded function.
8. A frequency-aware traffic flow prediction system, characterized in that, include: The data acquisition and decomposition module is used to acquire historical traffic flow data and perform discrete wavelet decomposition on the historical traffic flow data to obtain trend components and detail components. The feature embedding module is used to perform feature embedding on the trend component and the detail component respectively to obtain trend embedding representation and detail embedding representation; The trend time series encoding module is composed of multiple stacked global self-attention modules, which is used to perform time series modeling on the trend embedding to obtain trend time series features; The detail temporal coding module is composed of multiple stacked local window temporal convolutional modules, which is used to perform temporal modeling on the detail embedding to obtain detail temporal features; A cross-frequency domain adjustment module is used to input the trend time series features and the detailed time series features into the cross-frequency adjustment module to obtain the adjusted trend features and adjusted detailed features; The feature fusion module is used to concatenate the adjusted trend features and the adjusted detail features along the feature dimension, and obtain the fused temporal features through the feature fusion layer; The spatial encoding module, composed of multiple stacked global self-attention modules, is used to obtain spatially encoded spatiotemporal features based on the fused temporal features. The output projection module is used to obtain traffic flow prediction results by passing the spatially encoded spatiotemporal features through the projection layer.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to execute the frequency-aware traffic flow prediction method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, The method includes a processor and a memory, the processor being electrically connected to the memory, the memory being used to store instructions and data, and the processor being used to execute the steps of the frequency-aware traffic flow prediction method according to any one of claims 1 to 7.
