HUTFormer: Hierarchical U-Net Transformer for Long-Term Traffic Forecasting

Zezhi Shao, Fei Wang, Tao Sun, Chengqing Yu, Yuchen Fang, Guangyin Jin, Zhulin An, Yang Liu, Xiaobo Qu, Yongjun Xu · DOI

TL;DR

HUTFormer introduces the first dedicated framework for long-term traffic forecasting (e.g., one day ahead) by combining a hierarchical U-Net structure with a Transformer architecture. By extracting and integrating multi-scale representations, it successfully captures both global daily periodicities and sudden local traffic changes while bypassing the high computational complexity of traditional spatial-temporal graph neural networks.

What Problem Does This Paper Address?

Traffic forecasting is a cornerstone of intelligent transportation systems, but existing state-of-the-art models—primarily Spatial-Temporal Graph Neural Networks (STGNNs)—focus almost exclusively on short-term predictions (like 1 hour ahead). When scaled to long-term forecasting (e.g., 1 day ahead), STGNNs suffer from prohibitive computational complexity ($O(N^2)$ or worse) due to continuous graph convolutions across long time series.

Conversely, standard long-sequence time series Transformers ignore the vital spatial correlations between sensors and fail to explicitly model multi-scale features. Long-term traffic data requires capturing both global patterns (like daily periodicity) and fine-grained local details (like sudden traffic congestion).

Examples of long-term traffic forecasting and multi-scale features

Methods

The authors propose HUTFormer (Hierarchical U-Net Transformer), which adopts an inverted U-shaped encoder-decoder structure:

  • Segment Embedding & ST-PE: Instead of point-wise inputs, data is split into non-overlapping segments to reduce sequence length and noise. Spatial-Temporal Positional Encoding (ST-PE) replaces expensive Graph Convolutional Networks (GCNs) with learnable spatial embeddings to capture sensor correlations efficiently.
  • Hierarchical Encoder: Uses Window Multi-head Self-Attention (W-MSA) to restrict the receptive field, paired with Segment Merging (a pooling layer that halves the token count and doubles the feature dimension at each step). This allows lower layers to focus on fine-grained local features and higher layers to capture coarse global trends. An intermediate prediction is made at the top layer.
  • Hierarchical Decoder: Solves the sequence misalignment problem (since history and future sequences don't align point-by-point) using a Cross-Scale Attention mechanism. It uses the decoder's representations as queries to retrieve multi-scale features from the encoder, fine-tuning the intermediate prediction with localized details.
  • Two-Stage Training: The encoder is trained first to extract robust multi-scale features, and its parameters are then frozen while training the decoder, preventing optimization conflicts.

Datasets

The model was evaluated on four commonly used real-world traffic benchmarks:

  • Traffic Speed: METR-LA (207 sensors, 4 months) and PEMS-BAY (325 sensors, 6 months).
  • Traffic Flow: PEMS04 (307 sensors, 2 months) and PEMS08 (170 sensors, 2 months).
  • Generalization Benchmarks: ETTh1, ETTm1, and Weather (standard non-spatial long-term time series datasets) to verify the model's versatility outside of traffic data.

Key Insights and Ideas

  • The Multi-Scale Dilemma: Global features are semantically strong but coarse-grained (good for daily cycles), while local features are fine-grained but semantically weak (good for sudden congestion). A robust long-term model must explicitly separate and then recombine them.
  • Rethinking GCNs for Traffic: Graph convolutions are notoriously heavy. The authors show that replacing explicit graph message-passing with learnable spatial positional embeddings (ST-PE) achieves comparable or better performance at a fraction of the computational cost.
  • Why End-to-End Fails Here: In computer vision, U-Nets use pre-trained backbones (like ResNet). Since no universal pre-trained backbone exists for traffic time series, training the encoder and decoder end-to-end leads to suboptimal feature extraction. A two-stage training approach yields significantly better results.

Key Results

HUTFormer consistently outperformed 12 state-of-the-art baselines (including DCRNN, Graph WaveNet, STID, D2STGNN, Informer, Autoformer, and PatchTST) across all four traffic datasets.

  • METR-LA (Traffic Speed): For 24-hour ahead prediction (Horizon 288), HUTFormer achieved a Mean Absolute Error (MAE) of 3.84 and MAPE of 12.28%, outperforming the best STGNN baseline (D2STGNN at 4.09 MAE) and long-sequence baseline (PatchTST at 5.25 MAE).
  • PEMS08 (Traffic Flow): At Horizon 288, HUTFormer hit an MAE of 18.44, outperforming STID (20.23) and PatchTST (23.73).
  • Efficiency: Efficiency testing showed that HUTFormer requires significantly less GPU memory and training time per epoch compared to models using standard self-attention or full GCNs.

Limitations and Future Work

  • Lack of Inductive Generalization: HUTFormer relies on fixed spatial positional encodings, meaning it cannot easily generalize to new, unseen sensors without retraining the embedding layer.
  • Training Complexity: The two-stage training strategy, while effective, is less convenient than a streamlined end-to-end pipeline.
  • Uncertainty Quantification: Very long-term forecasting inherently introduces massive uncertainty; incorporating external event data (like weather or accidents) and explicit uncertainty quantification remains an open area for future work.

Summary updated

Abstract

Traffic forecasting, which aims to predict traffic conditions based on historical observations, has been an enduring research topic and is widely recognized as an essential component of intelligent transportation. Recent proposals on Spatial-Temporal Graph Neural Networks~(STGNNs) have made significant progress by combining sequential models with graph convolution networks. However, due to high complexity issues, STGNNs only focus on short-term traffic forecasting (e.g., 1-h ahead), while ignoring more practical long-term forecasting. In this paper, we make the first attempt to explore long-term traffic forecasting (e.g., 1-day ahead). To this end, we first reveal its unique challenges in exploiting multi-scale representations. Then, we propose a novel Hierarchical U-Net TransFormer~(HUTFormer) to address the issues of long-term traffic forecasting. HUTFormer consists of a hierarchical encoder and decoder to jointly generate and utilize multi-scale representations of traffic data. Specifically, for the encoder, we {\color{black}propose} window self-attention and segment merging to extract multi-scale representations from long-term traffic data. For the decoder, we design a cross-scale attention mechanism to effectively incorporate multi-scale representations. In addition, HUTFormer employs an efficient input embedding strategy to address the complexity issues. Extensive experiments on four traffic datasets show that the proposed HUTFormer significantly outperforms state-of-the-art traffic forecasting and long time series forecasting baselines.
BibTeX
@misc{shao2023hutformer,
  author = {Zezhi Shao and Fei Wang and Tao Sun and Chengqing Yu and Yuchen Fang and Guangyin Jin and Zhulin An and Yang Liu and Xiaobo Qu and Yongjun Xu},
  title = {{HUTFormer: Hierarchical U-Net Transformer for Long-Term Traffic Forecasting}},
  year = {2023},
  eprint = {2307.14596},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.14596},
}
Figure