Source-linked AI summary
Structure-Guided Spatiotemporal Attention Graph Neural Network for Traffic Flow Prediction
Xuanmian He, Can Li, Wanjing Ma
TL;DR
Black-box traffic prediction models lack transparency, while existing approaches struggle to reconcile static structural knowledge with dynamic real-time flexibility. SGSAN learns a static dependency graph, softly anchors dynamic attention to it, and achieves state-of-the-art accuracy across four real-world datasets, with 88% physical-network alignment.
Problem
Deep traffic prediction models remain difficult to deploy in safety-critical urban systems because their black-box reasoning lacks transparency and existing methods struggle to balance structure with flexibility.
Method
SGSAN learns a time-invariant Directed Dependency Graph, softly couples dynamic spatiotemporal attention to it with InfoNCE, and separates structure discovery from representation learning.
Results
88% alignment with physical network structure was achieved, while experiments across four real-world datasets reported state-of-the-art predictive performance and efficient inference.
Takeaways & Limitations
SGSAN provides a traffic forecasting framework combining high predictive accuracy with built-in interpretability aligned with physical road-network structure.
Abstract
from arXiv · showhide
Deep spatiotemporal models integrating graph convolutions and attention mechanisms have demonstrated excellent performance in network-level traffic flow prediction, owing to their exceptional ability to capture complex spatiotemporal dependencies. Despite their predictive success, deployment of such models in safety-critical urban systems remains constrained by their inherent lack of transparency. Existing post-hoc diagnostic methods often struggle with spurious correlations and fail to unveil the intrinsic decision-making mechanisms governing traffic dynamics, resulting in suboptimal interpretability and limited operational trustworthiness. To address these challenges, this paper proposes the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN). Departing from traditional architectures that rely on unconstrained adaptive graphs, SGSAN explicitly learns a static Directed Dependency Graph (DDG) to identify the invariant macroscopic propagation paths of traffic states. We further introduce an InfoNCE-based soft-coupling mechanism that anchors the model's dynamic spatiotemporal attention to this structural prior, offering a mechanistic account of the model's decision-making process while ensuring robust forecasting by aligning attention-based reasoning with identified macroscopic dependencies and preventing over-reliance on ephemeral local noise. Furthermore, a decoupled two-stage optimization framework is developed to resolve the fundamental conflict between structural discovery and predictive error minimization. Extensive experiments on multiple real-world datasets demonstrate that SGSAN achieves state-of-the-art predictive accuracy while providing built-in interpretability that organically aligns with the physical logic of traffic networks.
I. Introduction · II. Related Works · A. Interpretable Prediction
The paper motivates structurally interpretable traffic prediction by identifying the limits of opaque, correlation-driven models and existing explanation methods. It proposes SGSAN, which combines a static dependency graph, dynamically adaptive attention, soft coupling, and decoupled training to improve trustworthy forecasting.
- I. Introduction: Accurate traffic flow prediction supports proactive traffic control, congestion mitigation, and route planning in Intelligent Transportation Systems.Deep learning models achieve high accuracy by capturing complex features across large-scale sensor-equipped networks.
- I. Introduction: Opaque architectures may fit ephemeral local noise and spurious relations instead of stable underlying network structure, limiting reliable traffic engineering.The paper argues that practical predictions require structural interpretability in addition to high accuracy.
- I. Introduction: Post-hoc diagnostics, gradient-based attribution, and attention mechanisms constitute major interpretability approaches, but post-hoc explanations externally approximate model behavior.The introduction identifies LIME and SHAP as examples of post-hoc diagnostics.
- I. Introduction: Structural guidance must balance stable macroscopic dependencies against volatile traffic patterns, gradient interference, and over-regularization of localized events.Joint structure-prediction optimization can destabilize topology, while rigid constraints may hinder responses to accidents.
- I. Introduction: SGSAN learns a static Directed Dependency Graph to guide attention along time-invariant macroscopic propagation paths while retaining dynamic local adaptability.A decoupled two-stage framework separates structure learning from spatiotemporal correlation extraction, reducing disruption from short-term noise.
- I. Introduction: The framework evaluates mechanistic alignment among learned dependency priors, attention maps, and physical road networks while targeting state-of-the-art accuracy and built-in interpretability.The paper introduces metrics for quantifying alignment between model reasoning and physical network topology.
- II. Related Works: Related interpretable prediction methods include inherently interpretable models and explainability techniques for black-box models.The latter category includes post-hoc diagnostics, physics-informed methods, attention-based methods, and causal analysis.
- A. Interpretable Prediction: Attention weights identify important contextual traffic features, model long-term sequence dependencies, and provide interpretive information about feature significance.The related-work discussion links attention-based weighting to improved prediction accuracy and understanding of traffic flow models.
B. From Causal Analysis to Structural Discovery · III. Problem Formulation
The paper motivates structural dependency discovery as a more interpretable alternative to correlation-based traffic modeling and distinguishes it from strict causal identification. It formulates traffic forecasting on a detector graph, where SGSAN learns a directed dependency graph to guide dynamic spatiotemporal attention.
- B. From Causal Analysis to Structural Discovery: Correlation-based neural models can capture traffic patterns but remain vulnerable to uninterpretable and spurious statistical associations.Causal or structural relationships are presented as more closely aligned with the mechanisms governing prediction.
- B. From Causal Analysis to Structural Discovery: Pure causal discovery studies use nonlinear Granger causality for feature selection and DAG-GNN for scalable continuous directed acyclic graph optimization.These approaches target directional temporal dependencies and implicit causal relationships without combinatorial structure search.
- B. From Causal Analysis to Structural Discovery: Causal-constrained spatiotemporal models introduce explicit structures to reduce spurious correlations in complex traffic networks.Examples include Spatial-Temporal Granger Causality graphs and structural causal models that separate causal representations from observational noise.
- B. From Causal Analysis to Structural Discovery: Existing methods either seek strict causal identification unavailable from observational traffic data alone or capture local causal features without global, time-invariant propagation topology.SGSAN therefore reframes the goal as structural dependency discovery rather than strict causal identification.
- B. From Causal Analysis to Structural Discovery: Existing causal integrations leave unresolved the tension between static global structural knowledge and dynamic flexibility for accurate short-term prediction.Rigid fusion strategies can hinder mechanistic clarity, motivating separate global dependency and dynamic attention mechanisms.
- B. From Causal Analysis to Structural Discovery: SGSAN softly couples a global dependency graph with spatiotemporal attention for local fluctuations, mitigating spurious correlations while preserving accuracy and structural interpretability.Structural discovery supplies global dependencies, whereas attention captures dynamic local changes.
- III. Problem Formulation: A physical traffic network is represented as G = (V, E), with detector nodes V, road-connection edges E, and physical adjacency matrix A ∈ R^V×V.The graph formalizes the network topology used in the forecasting problem.
- III. Problem Formulation: The forecasting task learns f(·) from T historical traffic-state steps and structural network information to predict the next H steps.Within SGSAN, f(·) explicitly learns a DDG G ∈ R^V×V that guides dynamic spatiotemporal attention.
IV. Methodology · A. Structural Discovery Module
SGSAN combines static structural discovery with dynamic spatiotemporal attention in a four-module architecture. Its structural discovery module learns a directed dependency graph and structural representation from temporally encoded node embeddings, using variational and graph-convolution components to capture global topology.
- IV. Methodology: SGSAN is a four-module architecture that fuses static structural knowledge with dynamic real-time flexibility for spatiotemporal traffic modeling.The framework is designed to bridge structural discovery and spatiotemporal modeling.
- IV. Methodology: A dynamic spatiotemporal attention module stacks two spatial attention layers and one temporal attention layer to generate h_att.The final spatial attention layer produces G_a, a weight map encoding data-driven local correlations.
- IV. Methodology: The model’s parallel structural and attention tracks reconcile global topology discovery with localized temporal variation for short-term prediction.The structural track filters short-term spurious correlations, whereas the attention track captures localized temporal variations.
- A. Structural Discovery Module: The structural discovery module constructs a directed dependency graph and hidden structural representation h_str to enable Structure-Guided attention.It primarily uses an encoder–decoder structure to extract topological information.
- A. Structural Discovery Module: The module encodes temporally attended node embeddings whose shapes remain independent of sequence length, providing stable information for dependency-graph learning.A graph convolution layer further captures spatial relationships within the network.
- A. Structural Discovery Module: Its encoder–decoder uses multilayer perceptrons, with the encoder processing node embedding h_n and the decoder generating intermediate output ĥ_str.The learned matrix G is the normalized dependency-graph adjacency matrix.
- A. Structural Discovery Module: A graph-convolution layer follows the VAE structure to produce h_str by aggregating spatial features from neighboring nodes.The formulation uses the normalized physical adjacency matrix with self-loops, its degree matrix, and learnable coefficient matrix W.
- A. Structural Discovery Module: The structural adjacency matrix starts from parameterized B_0, applies sinh(·) with temperature coefficient τ, and uses Softmax normalization to encode directed-dependency weights.This initialization is intended to improve nonlinear-feature expression and produce the final adjacency matrix G.
B. Spatiotemporal Attention Module
The spatiotemporal attention module models temporal dynamics with multihead self-attention and spatial dependencies with graph attention. Its final attention map captures dynamic node correlations and is aligned with the structural representation to produce the spatiotemporal representation.
- Temporal Attention: Temporal attention uses multihead self-attention, generating keys, queries, and values by linearly mapping the input h_t.The mechanism is designed to model temporal dynamics in sequential traffic flow states.
- Temporal Attention: Attention outputs from m heads are concatenated and linearly mapped into the temporal attention-based representation h_t.The module computes a weighted sum of value vectors using temporal attention weights before combining heads.
- Spatial Attention: Spatial attention applies a graph attention network to capture complex dependencies between nodes using their temporal attention representations.The spatial module computes attention scores between nodes and uses learnable parameter matrices with vector concatenation.
- Spatial Attention: Softmax-normalized scores form G_a, whose elements represent dynamic spatial correlations between node i and node j.The resulting matrix is the dynamic spatial attention weight matrix.
- Structural Alignment: The last spatial attention matrix serves as an attention map aligned with h_str to generate the final spatiotemporal representation h_att.This alignment connects dynamic attention patterns with the structural representation.
C. Loss Function
The loss function uses a two-stage framework with prediction, structural, sparsity, and InfoNCE soft-coupling terms. These components jointly enforce valid sparse dependencies while softly aligning dynamic attention with the learned dependency skeleton.
- Overall Objective: The two-stage objective combines prediction loss L_A, dependency structural loss L_D, sparsity regularizer L_S, and InfoNCE soft-coupling loss L_I.The framework addresses the optimization conflict between discovering stable structural dependencies and minimizing dynamic prediction errors.
- Dependency Structural Loss: The dependency structural loss uses a continuous NOTEARS trace-exponential penalty to enforce a valid directed acyclic dependency graph.For adjacency matrix G, tr(e^(G⊙G)) = V holds if and only if G is acyclic.
- Sparsity Regularizer: The sparsity regularizer applies L1 regularization to prevent over-smoothing, remove redundant edges, and identify the dominant dependency backbone.This structural sparsity also reduces the influence of spurious correlations.
- InfoNCE Soft-Coupling Loss: The InfoNCE soft-coupling loss replaces rigid KL-divergence alignment with contrastive learning for the spatiotemporal attention mechanism.It anchors attention to the dependency skeleton while preserving flexibility to capture real-time local dependencies.
D. Two-Stage Training Strategy
SGSAN separates structural dependency discovery from attention optimization to prevent conflicting objectives and degraded performance. The learned sparse DDG then guides flexible attention while reducing Stage II and online inference complexity.
- D. Two-Stage Training Strategy: The decoupled two-stage process prevents mutual interference between directed dependency structure learning and attention optimization, which otherwise pursue fundamentally different objectives concurrently.Algorithm 1 formalizes this separation.
- D. Two-Stage Training Strategy: Stage I excludes dynamic attention and optimizes structural discovery to learn a global dependency graph representing time-invariant macroscopic topology.This stage performs DDG generation before attention training.
- D. Two-Stage Training Strategy: Stage II freezes the learned dependency graph G* as a structural prior and optimizes spatiotemporal attention through soft coupling of multi-scale representations.Soft coupling mitigates spurious correlations while preserving adaptation to real-time inputs.
- D. Two-Stage Training Strategy: O(T·|E|·D) replaces standard spatial attention complexity O(T·N^2·D) in Stage II by masking attention with the learned sparse dependency graph.|E| denotes the number of retained edges.
- D. Two-Stage Training Strategy: O(T·|E|·D) bounds online inference complexity because structural discovery is bypassed and dynamic inputs use only the frozen, pre-computed sparse DDG mask.The O(N^3) continuous DAG optimization occurs only during offline Stage I pre-training.
V. Experiment and Results · A. Datasets and Experiment Setup
The experiments evaluate SGSAN on four real-world traffic datasets against baseline models, with ablations and efficiency comparisons. The setup uses a two-stage training procedure that first discovers and freezes a DDG, then guides spatiotemporal attention with the learned structural prior.
- V. Experiment and Results: Experiments compare SGSAN with baseline models, conduct ablations of structural discovery and two-stage learning, and assess training and inference efficiency.SGSAN denotes the proposed model trained with the two-stage framework.
- V. Experiment and Results: The two-stage framework first optimizes the temporal, structural discovery, and output modules to generate a DDG, then extracts and freezes the optimized graph G*.Stage I minimizes LStage-I until convergence before extracting G*.
- V. Experiment and Results: Stage II updates the temporal, spatial attention, and output modules using attention guided by the stable structural prior G*.The procedure minimizes LStage-II until convergence.
- A. Datasets and Experiment Setup: Evaluations use four open-source California PeMS traffic datasets: PeMS03, PeMS07, PeMS08, and PeMS-Bay.The datasets are provided by the Performance Measurement System of the California Department of Transportation.
- A. Datasets and Experiment Setup: The model uses 15-minute input sequences to predict traffic flow at 15-, 30-, and 60-minute horizons, with data split into training, validation, and test sets at 7:1:2.Training uses Adam with a learning rate of 4 × 10^-4, dropout rate 0.1, and 100 epochs on an NVIDIA Tesla A800 GPU.
- A. Datasets and Experiment Setup: Training allocates the first 50 epochs to Stage I and the remaining 50 epochs to Stage II to balance efficiency with dependency-structure learning.This schedule is part of the 100-epoch training configuration.
- A. Datasets and Experiment Setup: Hyperparameter tuning sets every SGSAN module’s hidden dimension to 16, each temporal attention module to 4 heads, and γ_D, γ_S, and γ_I to 0.1, 1 × 10^-6, and 1 × 10^-3.These values are specified for Equations (14) and (15).
- A. Datasets and Experiment Setup: Comparative experiments evaluate SGSAN alongside T-GCN, STGCN, GMAN, ASTGCN, STTN, DST2former, DCST, CCHMM, and PSTCGCN.The baselines cover graph-convolutional, attention-based, transformer, and causal-graph approaches described in the setup.
B. Comparative Analysis of Prediction Accuracy · C. Ablation Studies
SGSAN achieves state-of-the-art prediction accuracy across four datasets, outperforming Transformer-based models particularly at shorter horizons. Ablations attribute its performance and interpretability to the DDG, InfoNCE coupling, and decoupled two-stage training.
- B. Comparative Analysis of Prediction Accuracy: SGSAN achieves state-of-the-art predictive accuracy on all four datasets and outperforms Transformer-based models, especially at shorter horizons.The compared Transformer-structured models include STTN, DST2Former, and DCST.
- C. Ablation Studies: The ablation study evaluates the DDG and two-stage training framework against STA-GNN, relaxed-DAG, random-DDG, and joint-training variants.STA-GNN removes structural discovery; the other variants preserve the architecture while modifying structural priors or optimization.
- C. Ablation Studies: STA-GNN derives predictions solely from its attention module after structural discovery is removed, isolating the contribution of the DDG.The comparison is part of the prediction-accuracy ablation in Table IV.
- C. Ablation Studies: The comprehensive ablations validate the advantages of SGSAN and the contributions of its individual components and decoupled two-stage training.These results support the proposed framework beyond improvements attributable solely to sparsity penalties.
- C. Ablation Studies: SGSAN (Joint) reaches an MAE of 70.26 on PeMS07 at the 60-min horizon, indicating severe optimization conflict when macroscopic priors and local correlations are learned simultaneously.Compared with the two-stage framework, the joint model struggles to converge on complex networks.
- C. Ablation Studies: Random sparse priors can underperform unconstrained STA-GNN, while relaxing strict acyclicity introduces spurious cyclic noise.The random-DDG uses a sparse DAG with equivalent edge density, uniformly drawn and normalized non-zero entries; DAG-Relaxed uses 𝜖=0.1.
- C. Ablation Studies: InfoNCE outperforms MSE, cosine, and KL-divergence coupling in many cases while anchoring dynamic attention without forcing equality with the static DDG.This preserves flexibility to capture real-time, non-topological local fluctuations.
- C. Ablation Studies: Hard coupling restricts adaptation by forcing the dynamic attention matrix to replicate the static DDG, whereas InfoNCE permits dynamic local variance.Strict numerical regularization provides tighter bounds but reduces the attention mechanism’s numerical freedom.
D. Computational Efficiency … E. Interpretability Analysis
SGSAN improves computational efficiency through decoupled training and offline structural learning, reducing training cost and online graph-generation overhead. Its interpretability analysis evaluates whether attention remains structurally consistent, physically aligned, and adaptively balanced between global dependencies and local stochasticity.
- D. Computational Efficiency: The two-stage framework is evaluated for both training speed and online inference latency.These analyses cover the training and deployment phases.
- 1) Training Efficiency:: Approximately 31.7% lower average training time per epoch is achieved by SGSAN (Ours) than SGSAN (Joint) across all datasets.The reduction mitigates the bottleneck caused by simultaneously generating graphs and optimizing predictions.
- 2) Inference Efficiency:: Offline learning of the global dependency graph eliminates structural generation overhead during online inference.Online processing applies only the pre-learned sparse graph mask, with data flow comparable to standard GNNs.
- 2) Inference Efficiency:: 0.096 ms/sample is SGSAN (Ours)'s average inference latency on PeMS03.SGSAN (Ours) is faster than SGSAN (Joint) and PSTCGCN, while ASTGCN and CCHMM are marginally faster but offer a less favorable accuracy-efficiency trade-off.
- E. Interpretability Analysis: Interpretability is assessed through qualitative and quantitative analyses of internal consistency and external physical alignment.The analysis tests whether dynamic attention is anchored to the learned structural backbone and reflects real-world road-network topology.
- E. Interpretability Analysis: Dynamic flexibility examines whether SGSAN adaptively balances reliance on global structure with local stochasticity.Sensitivity analysis considers interpretability metrics across varying Top-K% sparsity levels.
1) Consistency Metrics for Structure-Guided Interpretability: · 2) Quantitative Analysis of Structural Consistency:
SGSAN evaluates interpretability by measuring alignment among its static dependency graph, dynamic attention, and physical road-network topology. Across sparsity levels and datasets, the results indicate strong structural alignment, faithful propagation to attention, and robust coupling through InfoNCE.
- 1) Consistency Metrics for Structure-Guided Interpretability:: SGSAN evaluates whether its learned structural prior and dynamic attention capture the road network’s physical macroscopic backbone rather than spurious statistical noise.This assumption underlies the quantitative interpretability analysis.
- 1) Consistency Metrics for Structure-Guided Interpretability:: Attention-Structural Consistency (ASC) measures internal alignment between the static DDG and dynamic spatiotemporal attention maps.Higher ASC indicates stronger guidance from the structural prior.
- 1) Consistency Metrics for Structure-Guided Interpretability:: A high ASC indicates that the InfoNCE contrastive-learning loss effectively anchors attention weights to the Stage I structural backbone.The dependency graph remains static while attention adapts to real-time inputs across batches.
- 1) Consistency Metrics for Structure-Guided Interpretability:: Structural-Physical Consistency (SPC) and Attention-Physical Consistency (APC) externally evaluate overlap between learned representations and the physical road-network adjacency.These metrics address the self-referential risk of evaluating attention against a graph explicitly integrated during Stage II.
- 2) Quantitative Analysis of Structural Consistency:: High SPC scores across all four datasets show that the learned dependency graph aligns with physical topology without geographic supervision.The result supports recovery of the traffic network’s macroscopic structure.
- 2) Quantitative Analysis of Structural Consistency:: ASC remains highly robust across varying network densities.The result is reported in the sensitivity analysis spanning Top-10% to Top-50% retained capacity.
- 2) Quantitative Analysis of Structural Consistency:: At Top-30% sparsity on PeMS-Bay, SPC reaches 0.88 while APC reaches 0.85, with both metrics following closely matched, parallel trajectories across sparsity levels.This indicates that dynamic attention inherits the structural prior’s physical alignment.
- 2) Quantitative Analysis of Structural Consistency:: InfoNCE coupling anchors attention to the core structural skeleton while preserving numerical freedom to capture real-time, non-topological dependencies.This combines structural interpretability with adaptive attention behavior.
3) Visualization of Graph Alignment: · VI. Conclusion
SGSAN’s visualizations show that dynamically varying attention largely follows a sparse, globally learned directed dependency structure and reflects asymmetric traffic influence. Across four real-world datasets, the model combines state-of-the-art forecasting with efficient inference, two-stage training, and built-in interpretability, including 88% alignment with physical network structure.
- 3) Visualization of Graph Alignment:: SGSAN constructs key subgraphs by filtering significant node pairs from sample-specific attention maps and the static dependency graph.The dependency graph is uniform across inputs, whereas attention varies dynamically.
- 3) Visualization of Graph Alignment:: Figure 3 shows strong consistency between directed dependencies and attention-based correlations across six typical nodes.Arrow width indicates relationship weight.
- 3) Visualization of Graph Alignment:: The sparse dependency graph’s dominant paths are mostly mirrored in attention, providing a global perspective on traffic-flow propagation.The dependency graph learns from the macroscopic structure of the entire dataset.
- 3) Visualization of Graph Alignment:: Unlike baseline STA-GNN attention, SGSAN adopts asymmetric relationships because its dependency graph is constrained to be directed and acyclic.Unconstrained attention tends to produce symmetric, bidirectional relationships that reflect statistical correlation rather than physical influence.
- VI. Conclusion: SGSAN addresses observational correlations, local noise, and spurious correlations by decoupling structural discovery from representation learning through two-stage training.This framework is presented as a bridge between high-accuracy deep learning and trustworthy traffic-flow prediction.
- VI. Conclusion: Four real-world datasets show that SGSAN achieves state-of-the-art predictive performance while outperforming most baselines in inference efficiency and improving training efficiency through two-stage optimization.The efficiency claims distinguish inference from training.
- VI. Conclusion: 88% alignment with real-network physical structure demonstrates built-in interpretability from the learned DDG without geographic constraints.The conclusion attributes this verification to newly introduced structural consistency metrics.