FormerTime: Hierarchical Multi-Scale Representations for Multivariate Time Series Classification

Mingyue Cheng, Qi Liu, Zhiding Liu, Zhi Li, Yucong Luo, Enhong Chen

Abstract

Multivariate Time Series Classification (MTSC) requires models to capture both local patterns and long-range dependencies across multiple variables. While Convolutional Neural Networks (CNNs) excel at extracting multi-scale features, they often lack the global context provided by Transformers. Conversely, standard Transformers struggle with the low information density of individual time points and the high computational cost of long sequences. This paper introduces FormerTime, a hierarchical Transformer architecture that bridges this gap. By utilizing a multi-stage approach with temporal slicing and efficient attention mechanisms, FormerTime achieves state-of-the-art accuracy on the UEA archive while remaining computationally lean.

Introduction

Multivariate Time Series Classification is a cornerstone of modern data analysis, with applications ranging from medical diagnostics (e.g., ECG monitoring) to industrial sensor analysis. Historically, CNNs have dominated this field because they are "temporal-invariant" and can easily handle multi-scale features. However, their local receptive fields limit their ability to capture dependencies over long time horizons.

Transformers offer a promising alternative with global attention, but their application to time series is hindered by three main challenges:

  1. Information Density: Unlike words in a sentence, individual time points are often noisy; meaning is derived from sequences at various scales.
  2. Temporal Invariance: Transformers are naturally permutation-variant, which can weaken their ability to find consistent patterns regardless of when they occur.
  3. Efficiency: The $O(L^2)$ complexity of self-attention makes processing long sensor data prohibitively expensive.

Methodology: The FormerTime Architecture

FormerTime addresses these challenges through a hierarchical design that mimics the multi-scale feature extraction of CNNs within a Transformer framework.

The hierarchical architecture of FormerTime, featuring Temporal Slicing and the Transformer Encoder Network with Temporal Reduction Attention.

Hierarchical Multi-Scale Representation

Instead of a flat structure, FormerTime processes sequences through multiple stages. At each stage, a Temporal Slice strategy groups successive data points into "tokens." As the data progresses through the network, these slices are aggregated, allowing the model to learn representations ranging from fine-grained local shapes to high-level global patterns. This bridges the semantic gap between raw sensor pings and meaningful events.

Temporal Reduction Attention (TRA)

To mitigate the quadratic complexity of standard self-attention, FormerTime introduces TRA. This mechanism sub-samples the "Key" and "Value" matrices, reducing the temporal resolution before the attention calculation. This allows the model to maintain a global receptive field while significantly lowering memory and compute requirements.

Contextual Positional Encoding (CPE)

To preserve temporal order without sacrificing invariance, FormerTime replaces fixed or learnable embeddings with CPE. By using a 1D-convolutional layer with zero-padding, the model becomes "context-aware," enhancing its ability to recognize patterns regardless of their specific temporal location.

Experimental Results

The model was evaluated on 10 diverse datasets from the UEA multivariate time series classification archive, covering a wide range of lengths, dimensions, and classes.

Performance Comparison

FormerTime achieved an average accuracy of 0.7861, outperforming established baselines such as InceptionTime (0.7628) and ResNet (0.7373). It showed particularly strong performance on datasets with long sequences, where its global attention and efficient scaling provided a competitive advantage.

Critical Difference (CD) diagram showing the relative ranking of FormerTime against other state-of-the-art MTSC models.

Computational Efficiency

Despite its hierarchical complexity, FormerTime is highly efficient. It requires only 98M MACs (Multiply-Accumulate operations), which is significantly lower than other Transformer-based models like the Gated Transformer Network (1,565M MACs) and Informer (141M MACs).

Conclusion

FormerTime successfully integrates the strengths of CNNs—multi-scale representation and temporal invariance—into a Transformer backbone. By treating temporal slices as tokens and employing efficient attention mechanisms, it sets a new benchmark for multivariate time series classification. Future work will explore the transferability of these hierarchical representations to pre-training tasks on large-scale unlabeled time series data.

Summary updated

BibTeX
@inproceedings{cheng2023formertime,
  author = {Mingyue Cheng and Qi Liu and Zhiding Liu and Zhi Li and Yucong Luo and Enhong Chen},
  title = {{FormerTime: Hierarchical Multi-Scale Representations for Multivariate Time Series Classification}},
  booktitle = {The Web Conference},
  year = {2023},
}
Figure