Self-supervised traffic flow prediction method based on multi-scale space-time-frequency fusion
The self-supervised traffic flow prediction method based on multi-scale spatiotemporal frequency fusion solves the problems of insufficient spatiotemporal feature extraction and inadequate periodicity mining in existing technologies, and achieves higher accuracy and robustness in traffic flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-03-13
AI Technical Summary
Existing traffic flow prediction methods lack sufficient extraction of spatiotemporal features and fail to adequately explore periodic patterns, resulting in insufficient prediction accuracy and robustness.
A self-supervised traffic flow prediction method using multi-scale spatiotemporal-frequency fusion is adopted. Through an adaptive graph enhancement module, a multi-scale spatiotemporal-frequency encoder, and a frequency domain residual filter module, combined with a prediction head network and a joint loss function, end-to-end optimization training is performed to improve spatiotemporal feature extraction and frequency domain information utilization.
It significantly improves the accuracy and robustness of traffic flow prediction, better captures local fluctuation patterns and global long-range dependencies, enhances periodicity characteristics, suppresses noise interference, and improves prediction accuracy and generalization ability.
Smart Images

Figure CN121661846A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and in particular to a self-supervised traffic flow prediction method based on multi-scale spatiotemporal frequency fusion. Background Technology
[0002] With rapid economic development and rising living standards, the number of cars on the road has increased dramatically, leading to traffic congestion and other problems in cities. Intelligent Traffic Systems (ITS) have become a primary means of addressing these issues. Traffic flow prediction, a key technology in ITS, provides decision support for traffic management and resource allocation. Accurate traffic flow prediction can alleviate peak-hour congestion, thereby improving travel efficiency. However, traffic flow data possesses complex dynamic spatiotemporal characteristics, evolving not only over time but also being closely linked to spatial location. Effectively modeling and extracting these complex dynamic dependencies is a key challenge in traffic flow prediction.
[0003] Early traffic flow prediction research primarily focused on the correlation of time-series data, employing classical statistical models. However, these models, due to their linear assumptions and insufficient ability to model complex spatiotemporal relationships, are no longer sufficient to meet the accuracy requirements of current urban development. Therefore, researchers have used machine learning methods to overcome these shortcomings. Common machine learning algorithms for traffic flow prediction include decision trees, support vector machines, and hidden Markov models. Although traditional machine learning methods have a solid theoretical foundation and perform better than statistical models in handling nonlinear and high-dimensional data, they still have limitations when dealing with complex and highly nonlinear traffic flow data. These methods often rely on manual feature engineering, increasing the complexity of modeling and the cost of practical applications.
[0004] With the development of neural networks, deep learning-based methods are becoming increasingly prevalent. However, traffic flow data exhibits highly complex spatiotemporal dynamics. Existing prediction methods have significant shortcomings in addressing these complexities. On one hand, many deep learning-based methods employ fixed or single receptive fields, making it difficult to simultaneously capture the coexisting local fluctuation patterns and global long-range dependencies in traffic flow, resulting in insufficient extraction of spatiotemporal features. On the other hand, most models only process traffic data in the time domain, ignoring the periodic information in the frequency domain that reflects traffic patterns. This makes the models susceptible to random noise interference, resulting in less robust learned representations that affect prediction accuracy and generalization ability. Summary of the Invention
[0005] To address the shortcomings of existing traffic flow prediction methods, such as insufficient extraction of spatiotemporal features and inadequate mining of periodic patterns, this invention aims to propose a self-supervised traffic flow prediction method based on multi-scale spatiotemporal frequency fusion to improve the accuracy and robustness of predictions.
[0006] To achieve the above objectives, the technical solution of the present invention is as follows: A self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion is disclosed. This method utilizes a traffic flow prediction model based on multi-scale spatiotemporal-frequency fusion, which includes an adaptive graph enhancement module, a multi-scale spatiotemporal-frequency encoder, a frequency domain residual filter module, and a prediction head network. The traffic flow prediction method includes the following steps: A. Obtaining Enhanced Data The original traffic flow data and its corresponding original adjacency matrix are used as the original view. The adaptive graph enhancement module performs flow-level data enhancement and graph topology-level structure enhancement respectively to obtain the enhanced view. B. Perform multi-scale spatiotemporal feature encoding The original view and the enhanced view are fed in parallel into a weight-shared multi-scale spatiotemporal frequency encoder, namely the MSTFE encoder, to extract spatiotemporal features. The MSTFE encoder consists of two spatiotemporal blocks in series, each of which includes a hybrid temporal coding module and a multi-scale spatial coding module. C. Perform frequency domain residual filtering The spatiotemporal features are input into the frequency domain residual filtering module to denoise and periodically enhance the signal at the feature level, thus obtaining the final spatiotemporal features. D. Generating traffic flow prediction results Based on the final spatiotemporal characteristics, a traffic flow prediction result is generated through a prediction head network; E. Perform joint objective optimization Based on the traffic flow prediction results and the final spatiotemporal characteristics, end-to-end optimization training is performed using a joint loss function; the joint loss function includes supervised prediction loss, temporal contrast loss, spatial contrast loss, and frequency domain consistency loss.
[0007] Furthermore, the enhancement method of the adaptive graph enhancement module described in step A includes the following steps: A1. Perform traffic-level data augmentation; Global average pooling is used to aggregate the input traffic flow data along the time dimension, resulting in node embeddings that reflect the long-term average traffic patterns of each node. An attention mechanism is used to calculate the importance score of each time point to the entire input sequence, yielding a temporal attention weight. Based on these temporal attention weights, time points with lower importance are selected with higher probability for masking, i.e., their feature values are set to zero, resulting in enhanced traffic flow data.
[0008] A2. Perform graph topology-level data augmentation; Based on the node embeddings, a traffic pattern similarity matrix between nodes is obtained by calculating the cosine similarity between any two node embeddings. For each existing edge in the graph, if the similarity value of the two nodes it connects to in the similarity matrix is lower than a first preset threshold, the edge is probabilistically removed according to a probability distribution negatively correlated with similarity. For each pair of unconnected nodes in the graph, if the similarity value they connect to in the similarity matrix is higher than a second preset threshold, a new connecting edge is probabilistically added according to a probability distribution positively correlated with similarity, resulting in an adjacency matrix enhanced by graph topology.
[0009] A3. Obtain the enhanced view; The enhanced traffic flow data and the enhanced adjacency matrix are used as an enhanced view.
[0010] Furthermore, the encoding method of the multi-scale spatiotemporal feature encoding module in step B includes the following steps: B1. Temporal features are extracted using a hybrid temporal coding module. This module extracts local and global temporal features respectively through parallel multi-scale dilated convolutional branches and causal Transformer branches, and then uses an adaptive gating fusion mechanism to fuse the two types of features to output the temporal features. The specific steps are as follows: B11. Perform multi-scale dilated convolution branch calculations to obtain local temporal features; A set of one-dimensional temporal convolutions with different dilation rates d∈D={1, 2, 4} are used in parallel along the temporal dimension. Each temporal convolution with a different dilation rate focuses on the receptive field at a specific time. The standard convolution with d=1 captures transient changes in nearby localities, while larger d values capture patterns over a longer range through skip connections. For any dilation rate d, the convolution operation is formally expressed as follows: (1) Among them, X enc Here are the input features, N is the batch size, C' is the number of channels, L is the sequence length, and V is the number of nodes. Represents a time convolution with a dilation rate of d. The activation function is defined as follows. For each dilation rate d, a gated linear unit (GLU) is used as the activation function after the convolution operation. The calculation process of the GLU is as follows: (2) (3) First, the convolutional layer outputs twice the number of channels and is divided into two parts, A and B, along the channel dimension. Part A serves as the content part and is connected to the channel-aligned residuals via Align(X). enc The two parts are added together. Align(·) is a 1x1 convolution used to match the number of channels. Part B is passed through the Sigmoid function σ(·) to form a gate between 0 and 1. The information flow is dynamically controlled by element-wise multiplication ⊙ to obtain the output of the gated linear unit at this expansion rate. Finally, through simple averaging and fusion, the output of multi-scale dilated convolution is obtained. The branch, specifically the formula, is as follows: (4) |D| represents the number of elements in the set D to which different expansion rates d belong.
[0011] B12. Perform causal Transformer branch calculations to obtain global time features; First, a position encoding vector is generated by calculating sine and cosine functions, and then the position encoding vector is coupled with the input feature X. enc Element-wise summation yields the position-encoded features. These position-encoded features are then mapped using a linear transformation to a query matrix Q, a key matrix K, and a value matrix. It is divided into multiple attention heads to extract subspace features in parallel.
[0012] When calculating attention, first calculate the transpose product of the query matrix Q and the key matrix K and divide by the scaling factor. Then, a causal mask matrix M is added, where the elements on the main diagonal and below M are 0, and the elements above M are negative infinity, thus masking information from future time steps. The attention weight matrix is obtained by normalizing using the Softmax normalization function. This attention weight matrix is then compared with the value matrix... Multiply to obtain the attention output Y. head The calculation formula for the attention head output is as follows: (5) Finally, the outputs of all attention heads are concatenated and fused through a linear layer to obtain the output Y of the causal Transformer branch. Trans .
[0013] B13. Perform adaptive gating fusion of the two branches; First, the learnable gate vector β is transformed using the Sigmoid function to obtain the weight vector. Using weight vectors Output of multi-scale dilated convolution branches The output Y of the causal Transformer branchTrans We perform a weighted summation to obtain the fused feature Y. fused The formula is as follows: (6) The fused feature Y fused The time features are obtained by adding the residuals to the original input and then performing layer normalization.
[0014] B2. Input the temporal features into the multi-scale spatial coding module to extract spatial aggregation features; Following the hybrid temporal encoding module, a multi-scale spatial encoding module is connected. This module aims to capture the dependencies of traffic flow across different spatial scales through parallel processing. First, the adjacency matrix is normalized to obtain a normalized Laplacian matrix. Then, a set of Chebyshev graphical convolutional units of different orders k are used in parallel. For each unit, based on its order k, a set of k-order Chebyshev polynomial basis functions are generated by polynomial expansion of the Laplacian matrix. These basis functions are then used to perform graphical convolution on the input features. Finally, the spatial features obtained at all different orders k are summed element-wise and averaged to obtain the spatial aggregated feature Y. spatial The spatial aggregation feature output expression is: (7) Among them, X in The time characteristics output by the hybrid time encoding module. K represents the output of a graph convolution unit with an upper limit of Chebyshev order k. s It represents the total number of parallel scales.
[0015] B3. Input the spatial aggregation features into the hybrid temporal coding module to further extract and fuse local and global features in the temporal dimension to obtain spatiotemporal features X; the hybrid temporal coding module has the same structure as the hybrid temporal coding module in step B1. Furthermore, the steps of frequency domain residual filtering described in step C are as follows: C1. Perform a Fast Fourier Transform (FFT) along the time dimension on the spatiotemporal features input to the frequency domain residual filter module, transforming them from the time domain to the frequency domain, to obtain the complex form of the frequency domain spatiotemporal features X. f C2. Perform adaptive frequency domain filtering; using a frequency domain spatiotemporal feature X... f A learnable frequency domain mask N with the same frequency dimension size will represent the frequency domain spatiotemporal features X. fThe frequency component is element-wise multiplied with the frequency domain mask N, and each frequency component is adaptively weighted to enhance periodic features and suppress irrelevant noise frequency components. An independent weight is assigned to each feature channel and frequency point to obtain the filtered frequency domain spatiotemporal features. .
[0016] C3. Perform inverse time-domain transformation, convert the filtered frequency-domain spatiotemporal features to the time domain using inverse fast Fourier transform, and obtain the filtered time-domain features. C4. Perform weighted residual fusion; using a learnable scalar parameter. The filtered time-domain features and residual coefficients obtained in step C3 are compared. Multiply the result and add it element-wise to the spatiotemporal feature X obtained in step B to form a residual concatenation, thus obtaining the final output Y of the frequency domain residual filtering module. SRF The mathematical expression is formalized as follows: (8) This represents the inverse fast Fourier transform along the time dimension. The intensity of adding the filtered temporal features back to the original features is adaptively determined.
[0017] Furthermore, the steps in step D for generating traffic flow prediction results are as follows: D1. Perform feature dimension mapping: Input the final spatiotemporal feature Z1 obtained by stacking two spatiotemporal blocks of the original view into a multilayer perceptron prediction head network. The multilayer perceptron prediction head network performs a linear transformation on the input feature in the channel dimension, mapping the feature from the high-dimensional hidden layer dimension to the output dimension of the target traffic flow data, and obtains the full sequence prediction feature containing historical time steps. D2. Generate the final prediction result. Based on the preset future prediction time step, perform a truncation operation on the full sequence prediction features in the time dimension, and select the corresponding number of time step data at the end of the sequence as the final traffic flow prediction result.
[0018] Furthermore, the method for joint objective optimization described in step E is as follows: Based on the final prediction result, the final spatiotemporal feature Z1, and the final spatiotemporal feature Z2 obtained after stacking two spatiotemporal blocks of the enhanced view, the traffic flow prediction model is optimized end-to-end using a joint loss function: (9) This loss function supervises the model training process from three complementary dimensions: spatiotemporal and frequency, including supervised prediction loss. Time comparison loss Spatial contrast loss and frequency domain consistency loss They jointly guide the model's learning process. Among them, , , These represent the weights of supervised prediction loss, temporal contrastive loss, and spatial contrastive loss in the total loss at training epoch t, respectively. They are dynamically calculated using a dynamic weight averaging strategy based on the loss values of each task in the previous epoch. It is a fixed hyperparameter used to control the weight of frequency domain consistency loss.
[0019] E1. Calculate the supervised prediction loss; The supervised prediction loss is obtained by the mean absolute error (MAE) between the final traffic flow prediction result and the actual traffic flow data, as shown in the following formula: (10) in, and These represent the actual inflow and outflow values of node n, respectively. and These are the predicted inflow and outflow values for node n. For multidimensional flow prediction tasks, this is achieved through a hyperparameter. The errors of different channels are weighted and summed.
[0020] E2. Calculate spatial contrast loss; The final spatiotemporal features extracted from the original view and the enhanced view are subjected to average pooling in the time dimension to obtain the node-level features h of the original view. n and node-level features of the enhanced view ; First, define P learnable clustering prototype vectors {c1, c2, ..., c}. P} Calculate the node-level features of the enhanced view. With each cluster prototype vector c p The dot product similarity between nodes is used to optimize the assignment matrix of all nodes using the Sinkhorn-Knoop algorithm, resulting in a soft clustering assignment probability distribution. Calculate the node-level features h of the original view. n With each cluster prototype vector c p The dot product similarity between them is calculated using the following formula: (11) The spatial contrastive loss function is obtained by transforming it into a predicted probability distribution using a normalized exponential function and calculating the average value over all nodes, as shown in the following formula: (12) Where N is the total number of nodes, and P is the total number of cluster prototype vectors. It is a temperature parameter that controls the smoothness of the softmax output. This represents the target probability that node n belongs to the p-th cluster prototype.
[0021] E3. Calculate time-comparison loss; The final spatiotemporal features Z1 of the original view and Z2 of the enhanced view are weighted and fused to obtain the fused spatiotemporal feature U. Global average pooling is then applied to the fused spatiotemporal feature U along the spatial node dimension, and a global city feature vector s corresponding to each time step is generated using the Sigmoid activation function. t Regional features at the same time step With the city's global feature vector s t Defined as positive sample pairs, the fused features at different time steps With the city's global feature vector s t Defined as negative sample pairs, the time-contrast loss is calculated using a bilinear discriminant, as shown in the following formula: (13) Where T is the time series length, N is the total number of nodes, and W is the learnable discriminant matrix in the bilinear discriminator.
[0022] E4. Calculate the frequency domain consistency loss. The specific calculation process is as follows: E41. Perform a Fast Fourier Transform along the time dimension on the spatiotemporal features Z1 and Z2 extracted from the original view and the enhanced view respectively, and transform them to the frequency domain dimension to obtain their complex representations in the frequency domain. E42. Calculate the amplitude of the spectrum. , This describes the energy distribution of spatiotemporal features at various frequencies; E43. Normalize the first amplitude spectrum A1 and the second amplitude spectrum A2 respectively. The steps are as follows: Divide each element of the amplitude spectrum by the sum of its corresponding frequency dimension elements, and add a very small constant ε to prevent division by zero, to obtain the first normalized amplitude spectrum A. n1 Second normalized amplitude spectrum A n2 ; E44. Calculate the cosine similarity between two normalized amplitude spectra. Treat the spectrum of each sample as a high-dimensional vector and calculate the angle between them. The frequency domain consistency loss function is expressed as follows: (14) Compared with the prior art, the present invention has the following beneficial effects: 1. To address the problem that existing technologies struggle to simultaneously capture both local fluctuation patterns and global long-range dependencies in traffic flow, leading to insufficient spatiotemporal feature extraction, this invention designs a multi-scale spatiotemporal frequency encoder. In the time dimension, it simultaneously captures local and global temporal features through a hybrid time encoding module. In the spatial dimension, the multi-scale spatial encoding module aggregates spatial features at different distances, significantly improving prediction accuracy.
[0023] 2. To address the issue that most existing technologies model in the time domain, neglecting the periodic information contained in the frequency domain and resulting in insufficient mining of periodic patterns, this invention embeds a frequency domain residual filtering module in the encoder to adaptively purify frequency domain features in an end-to-end manner, enhance key periodic features, suppress irrelevant noise, and fuse back spatiotemporal features through residual connections, achieving collaborative modeling of the three dimensions of time, space, and frequency. At the same time, a frequency domain consistency loss is introduced in the optimization stage to constrain the original view and the enhanced view to maintain consistency in the frequency domain structure, making it more robust when facing real traffic data containing noise. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the overall architecture of the method of the present invention.
[0025] Figure 2 This is a schematic diagram of the hybrid time encoding module of the present invention.
[0026] Figure 3 This is a schematic diagram of the multi-scale spatial coding module of the method of the present invention. Detailed Implementation
[0027] The invention will now be further described with reference to the accompanying drawings. Figure 1 As shown, a traffic flow prediction method includes the following steps: A. Obtain the enhanced view The original traffic flow data and its corresponding original adjacency matrix are used as the original view. The adaptive graph enhancement module performs flow-level data enhancement and graph topology-level structure enhancement respectively to obtain the enhanced view. B. Perform multi-scale spatiotemporal feature encoding The original view and the enhanced view are fed in parallel into a weight-shared multi-scale spatiotemporal frequency encoder, namely the MSTFE encoder, to extract spatiotemporal features. The MSTFE encoder consists of two spatiotemporal blocks in series, each of which mainly includes a hybrid temporal coding module and a multi-scale spatial coding module. C. Perform frequency domain residual filtering The extracted spatiotemporal features are input into the frequency domain residual filtering module to denoise and periodically enhance the signal at the feature level, thus obtaining the final spatiotemporal features. D. Generating traffic flow prediction results Based on the final spatiotemporal features extracted from the original view, a traffic flow prediction result is generated through a prediction head network; E. Perform joint objective optimization Based on the prediction results and the final spatiotemporal features extracted from the original view and the enhanced view respectively, end-to-end optimization training is performed through a joint loss function; the joint loss function includes supervised prediction loss, temporal contrast loss, spatial contrast loss and frequency domain consistency loss.
[0028] Figure 2 The diagram shown is a schematic of the hybrid time coding module of the present invention. It uses two parallel dual-branch structures to extract time features. For details of the specific steps, please refer to steps B11-B13 in the invention description.
[0029] Figure 3 The multi-scale spatial coding module of the present invention is shown. For details of the specific steps, please refer to step B2 in the invention description.
[0030] The frequency domain residual filtering module is used to enhance key periodic features and suppress noise. For details, please refer to steps C1-C4 in the invention description.
[0031] The extracted final features are used to generate the final prediction result. For details, please refer to steps D1-D2 in the invention description.
[0032] The final traffic flow prediction model is jointly optimized through a multi-objective function, and the specific steps are detailed in steps E1-E4 of the invention description.
[0033] This invention is not limited to this embodiment. Any equivalent concept or modification within the technical scope disclosed in this invention shall be included within the protection scope of this invention.
Claims
1. A self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion, characterized in that: Traffic flow prediction is performed using a multi-scale spatiotemporal-frequency fusion-based traffic flow prediction model. This model includes an adaptive graph enhancement module, a multi-scale spatiotemporal-frequency encoder, a frequency domain residual filter module, and a prediction head network. The traffic flow prediction method includes the following steps: A. Obtaining Enhanced Data The original traffic flow data and its corresponding original adjacency matrix are used as the original view. The adaptive graph enhancement module performs flow-level data enhancement and graph topology-level structure enhancement respectively to obtain the enhanced view. B. Perform multi-scale spatiotemporal feature encoding The original view and the enhanced view are fed in parallel into a weight-shared multi-scale spatiotemporal frequency encoder, namely the MSTFE encoder, to extract spatiotemporal features. The MSTFE encoder consists of two spatiotemporal blocks in series, each of which includes a hybrid temporal coding module and a multi-scale spatial coding module. C. Perform frequency domain residual filtering The spatiotemporal features are input into the frequency domain residual filtering module to denoise and periodically enhance the signal at the feature level, thus obtaining the final spatiotemporal features. D. Generating traffic flow prediction results Based on the final spatiotemporal characteristics, a traffic flow prediction result is generated through a prediction head network; E. Perform joint objective optimization Based on the traffic flow prediction results and the final spatiotemporal characteristics, end-to-end optimization training is performed using a joint loss function; the joint loss function includes supervised prediction loss, temporal contrast loss, spatial contrast loss, and frequency domain consistency loss.
2. The self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion according to claim 1, characterized in that: The enhancement method for the adaptive graph enhancement module described in step A includes the following steps: A1. Perform traffic-level data augmentation; Global average pooling is used to aggregate the input traffic flow data in the time dimension to obtain node embeddings that reflect the long-term average traffic patterns of each node; an attention mechanism is used to calculate the importance score of each time point to the entire input sequence to obtain the time attention weight; based on the time attention weight, time points with lower importance are selected with higher probability for masking, that is, their feature values are set to zero to obtain enhanced traffic flow data. A2. Perform graph topology-level data augmentation; Based on the node embeddings, a traffic pattern similarity matrix between nodes is obtained by calculating the cosine similarity between any two node embeddings. For each existing edge in the graph, if the similarity value of the two nodes it connects to in the similarity matrix is lower than a first preset threshold, the edge is probabilistically removed according to a probability distribution negatively correlated with similarity. For each pair of nodes that are not connected in the graph, if the similarity value they connect to in the similarity matrix is higher than a second preset threshold, a new connecting edge is probabilistically added according to a probability distribution positively correlated with similarity, resulting in an adjacency matrix enhanced by graph topology. A3. Obtain the enhanced view; The enhanced traffic flow data and the enhanced adjacency matrix are used as an enhanced view.
3. The self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion according to claim 1, characterized in that: The encoding method of the multi-scale spatiotemporal feature encoding module in step B includes the following steps: B1. Temporal features are extracted using a hybrid temporal coding module. This module extracts local and global temporal features respectively through parallel multi-scale dilated convolutional branches and causal Transformer branches, and then uses an adaptive gating fusion mechanism to fuse the two types of features to output the temporal features. The specific steps are as follows: B11. Perform multi-scale dilated convolution branch calculations to obtain local temporal features; A set of one-dimensional temporal convolutions with different dilation rates d∈D={1, 2, 4} are used in parallel along the time dimension; each temporal convolution with a different dilation rate focuses on the receptive field at a specific time. The standard convolution with d=1 captures the transient changes in the nearby local area, while larger d values capture patterns over a longer range through skip connections. For any dilation rate d, the convolution operation is formally expressed as follows: (1) Among them, X enc Here are the input features, N is the batch size, C' is the number of channels, L is the sequence length, and V is the number of nodes. Represents a time convolution with a dilation rate of d. The activation function is d; for each dilation rate d, a gated linear unit is used as the activation function after the convolution operation; the calculation process of the gated linear unit is as follows: (2) (3) First, the convolutional layer outputs twice the number of channels and is divided into two parts, A and B, along the channel dimension. Part A, as the content part, is added to the channel-aligned residual connection Align(Xenc). Align(·) is a 1x1 convolution used to match the number of channels. Part B is passed through the Sigmoid function σ(·) to form a gate between 0 and 1. The information flow is dynamically controlled by element-wise multiplication ⊙ to obtain the output of the gated linear unit at this dilation rate. Finally, through simple averaging and fusion, the output of multi-scale dilated convolution is obtained. The branch, specifically the formula, is as follows: (4) |D| represents the number of elements in the set D to which different expansion rates d belong; B12. Perform causal Transformer branch calculations to obtain global time features; First, a position encoding vector is generated by calculating sine and cosine functions, and then the position encoding vector is coupled with the input feature X. enc Element-wise summation yields the position-encoded features; these features are then mapped through a linear transformation to a query matrix Q, a key matrix K, and a value matrix. It is divided into multiple attention heads to extract subspace features in parallel; When calculating attention, first calculate the transpose product of the query matrix Q and the key matrix K and divide by the scaling factor. Then, a causal mask matrix M is added, where the elements on the main diagonal and below M are 0, and the elements above M are negative infinity, thus masking information from future time steps. The attention weight matrix is then obtained by normalizing using the Softmax normalization function. This attention weight matrix is then compared with the value matrix... Multiply to obtain the attention output Y. head The calculation formula for the attention head output is as follows: (5) Finally, the outputs of all attention heads are concatenated and fused through a linear layer to obtain the output Y of the causal Transformer branch. Trans ; B13. Perform adaptive gating fusion of the two branches; First, the learnable gate vector β is transformed using the Sigmoid function to obtain the weight vector. Using weight vectors Output of multi-scale dilated convolution branches The output Y of the causal Transformer branch Trans We perform a weighted summation to obtain the fused feature Y. fused The formula is as follows: (6) The fused feature Y fused The time features are obtained by adding the residuals to the original input and then performing layer normalization. B2. Input the temporal features into the multi-scale spatial coding module to extract spatial aggregation features; Following the hybrid temporal encoding module, a multi-scale spatial encoding module is connected. This module aims to capture the dependencies of traffic flow across different spatial ranges through parallel processing. First, the adjacency matrix is normalized to obtain a normalized Laplacian matrix. Then, a set of Chebyshev graphical convolutional units of different orders k are used in parallel. For each unit, based on its order k, a set of k-order Chebyshev polynomial basis functions are generated by polynomial expansion of the Laplacian matrix. These basis functions are then used to perform graphical convolution on the input features. Finally, the spatial features obtained at all different orders k are summed element-wise and averaged to obtain the spatial aggregated feature Y. spatial The spatial aggregation feature output expression is: (7) Among them, X in The time characteristics output by the hybrid time encoding module. K represents the output of a graph convolution unit with an upper limit of Chebyshev order k. S It represents the total number of parallel scales; B3. Input the spatial aggregation features into the hybrid temporal coding module to further extract and fuse local and global features in the time dimension to obtain spatiotemporal features X; the hybrid temporal coding module has the same structure as the hybrid temporal coding module in step B1.
4. The self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion according to claim 1, characterized in that: The steps of frequency domain residual filtering described in step C are as follows: C1. Perform a Fast Fourier Transform (FFT) along the time dimension on the spatiotemporal features input to the frequency domain residual filter module, transforming them from the time domain to the frequency domain, to obtain the complex form of the frequency domain spatiotemporal features X. f C2. Perform adaptive frequency domain filtering; using a frequency domain spatiotemporal feature X... f A learnable frequency domain mask N with the same frequency dimension size will represent the frequency domain spatiotemporal features X. f The frequency component is element-wise multiplied with the frequency domain mask N, and each frequency component is adaptively weighted to enhance periodic features and suppress irrelevant noise frequency components. An independent weight is assigned to each feature channel and frequency point to obtain the filtered frequency domain spatiotemporal features. ; C3. Perform inverse time-domain transformation, convert the filtered frequency-domain spatiotemporal features to the time domain using inverse fast Fourier transform, and obtain the filtered time-domain features. C4. Perform weighted residual fusion; using a learnable scalar parameter. ; The filtered time-domain features and residual coefficients obtained in step C3 are compared. Multiply the result and add it element-wise to the spatiotemporal feature X obtained in step B to form a residual concatenation, thus obtaining the final output Y of the frequency domain residual filtering module. SRF The mathematical expression is formalized as follows: (8) This represents the inverse fast Fourier transform along the time dimension. The intensity of adding the filtered temporal features back to the original features is adaptively determined.
5. The self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion according to claim 1, characterized in that: The steps for generating traffic flow prediction results in step D are as follows: D1. Perform feature dimension mapping: Input the final spatiotemporal feature Z1 obtained by stacking two spatiotemporal blocks of the original view into a multilayer perceptron prediction head network. The multilayer perceptron prediction head network performs a linear transformation on the input feature in the channel dimension, mapping the feature from the high-dimensional hidden layer dimension to the output dimension of the target traffic flow data, and obtains the full sequence prediction feature containing historical time steps. D2. Generate the final prediction result. Based on the preset future prediction time step, perform a truncation operation on the full sequence prediction features in the time dimension, and select the corresponding number of time step data at the end of the sequence as the final traffic flow prediction result.
6. The self-supervised traffic flow prediction method based on multi-scale spatiotemporal-frequency fusion according to claim 1, characterized in that: The method for joint objective optimization described in step E is as follows: Based on the final prediction result, the final spatiotemporal feature Z1, and the final spatiotemporal feature Z2 obtained after stacking two spatiotemporal blocks of the enhanced view, the traffic flow prediction model is optimized end-to-end using a joint loss function: (9) This loss function supervises the model training process from three complementary dimensions: spatiotemporal and frequency, including supervised prediction loss. Time comparison loss Spatial contrast loss and frequency domain consistency loss They jointly guide the model's learning process; among which, , , These represent the weights of supervised prediction loss, temporal contrastive loss, and spatial contrastive loss in the total loss at the t-th training epoch; they are dynamically calculated by a dynamic weight averaging strategy based on the loss values of each task in the previous epoch. It is a fixed hyperparameter used to control the weight of frequency domain consistency loss; E1. Calculate the supervised prediction loss; The supervised prediction loss is obtained by the mean absolute error (MAE) between the final traffic flow prediction result and the actual traffic flow data, as shown in the following formula: (10) in, and These represent the actual inflow and outflow values of node n, respectively. and These are the predicted inflow and outflow values for node n. For multidimensional flow prediction tasks, this is achieved through a hyperparameter. Weighted summation of errors from different channels; E2. Calculate spatial contrast loss; The final spatiotemporal features extracted from the original view and the enhanced view are subjected to average pooling in the time dimension to obtain the node-level features h of the original view. n and node-level features of the enhanced view ; First, define P learnable clustering prototype vectors {c1, c2, ..., c}. P } Calculate the node-level features of the enhanced view. With each cluster prototype vector c p The dot product similarity between nodes is used to optimize the assignment matrix of all nodes using the Sinkhorn-Knoop algorithm, resulting in a soft clustering assignment probability distribution. ; Calculate the node-level features h of the original view n With each cluster prototype vector c p The dot product similarity between them is calculated using the following formula: (11) The spatial contrastive loss function is obtained by transforming it into a predicted probability distribution using a normalized exponential function and calculating the average value over all nodes, as shown in the following formula: (12) Where N is the total number of nodes, and P is the total number of cluster prototype vectors. It is a temperature parameter that controls the smoothness of the softmax output. This represents the target probability that node n belongs to the p-th cluster prototype; E3. Calculate time comparison loss; The final spatiotemporal features Z1 of the original view and Z2 of the enhanced view are weighted and fused to obtain the fused spatiotemporal feature U. Global average pooling is then applied to the fused spatiotemporal feature U along the spatial node dimension, and a global city feature vector s corresponding to each time step is generated using the Sigmoid activation function. t ; Regional features at the same time step With the city's global feature vector s t Defined as positive sample pairs, the fused features at different time steps With the city's global feature vector s t Defined as negative sample pairs, the time-contrast loss is calculated using a bilinear discriminant, as shown in the following formula: (13) Where T is the length of the time series, N is the total number of nodes, and W is the learnable discriminant matrix in the bilinear discriminator; E4. Calculate the frequency domain consistency loss. The specific calculation process is as follows: E41. Perform a Fast Fourier Transform along the time dimension on the spatiotemporal features Z1 and Z2 extracted from the original view and the enhanced view respectively, and transform them to the frequency domain dimension to obtain their complex representations in the frequency domain. E42. Calculate the amplitude of the spectrum. , This describes the energy distribution of spatiotemporal features at various frequencies; E43. Normalize the first amplitude spectrum A1 and the second amplitude spectrum A2 respectively. The steps are as follows: Divide each element of the amplitude spectrum by the sum of its corresponding frequency dimension elements, and add a very small constant ε to prevent division by zero, to obtain the first normalized amplitude spectrum A. n1 Second normalized amplitude spectrum A n2 ; E44. Calculate the cosine similarity between two normalized amplitude spectra. Treat the spectrum of each sample as a high-dimensional vector and calculate the angle between them. The frequency domain consistency loss function is expressed as follows: (14)。
Citation Information
Cited By
Fan foundation prediction method and system based on adaptive noise reduction and spatio-temporal graph fusion
CN122196930A
Fan foundation prediction method and system based on adaptive noise reduction and spatio-temporal graph fusion
CN122196930B