Skip to main content
QUICK REVIEW

[Paper Review] Improving Position Encoding of Transformers for Multivariate Time Series Classification

Navid Mohammadi Foumani, Chang Wei Tan|arXiv (Cornell University)|May 26, 2023
Time Series Analysis and ForecastingComputer Science34 references6 citations
TL;DR

This paper proposes a novel transformer-based model, ConvTran, for multivariate time series classification by introducing two new position encoding methods: time Absolute Position Encoding (tAPE), which adapts absolute position encoding to time series by incorporating sequence length and embedding dimension, and efficient Relative Position Encoding (eRPE), which improves generalization. ConvTran achieves state-of-the-art performance across 32 multivariate time series datasets, outperforming existing CNN and transformer models.

ABSTRACT

Transformers have demonstrated outstanding performance in many applications of deep learning. When applied to time series data, transformers require effective position encoding to capture the ordering of the time series data. The efficacy of position encoding in time series analysis is not well-studied and remains controversial, e.g., whether it is better to inject absolute position encoding or relative position encoding, or a combination of them. In order to clarify this, we first review existing absolute and relative position encoding methods when applied in time series classification. We then proposed a new absolute position encoding method dedicated to time series data called time Absolute Position Encoding (tAPE). Our new method incorporates the series length and input embedding dimension in absolute position encoding. Additionally, we propose computationally Efficient implementation of Relative Position Encoding (eRPE) to improve generalisability for time series. We then propose a novel multivariate time series classification (MTSC) model combining tAPE/eRPE and convolution-based input encoding named ConvTran to improve the position and data embedding of time series data. The proposed absolute and relative position encoding methods are simple and efficient. They can be easily integrated into transformer blocks and used for downstream tasks such as forecasting, extrinsic regression, and anomaly detection. Extensive experiments on 32 multivariate time-series datasets show that our model is significantly more accurate than state-of-the-art convolution and transformer-based models. Code and models are open-sourced at \url{https://github.com/Navidfoumani/ConvTran}.

Motivation & Objective

  • To investigate the effectiveness and efficiency of existing absolute and relative position encodings in multivariate time series classification.
  • To address the limitations of standard position encodings in time series, where low embedding dimensions and variable sequence lengths reduce performance.
  • To design a time series-specific absolute position encoding method that accounts for sequence length and embedding dimension.
  • To develop a computationally efficient relative position encoding method that enhances model generalization.
  • To integrate the proposed encodings into a hybrid CNN-transformer architecture (ConvTran) for improved multivariate time series classification.

Proposed method

  • Proposes time Absolute Position Encoding (tAPE), a novel absolute position encoding that explicitly incorporates the sequence length and input embedding dimension to better represent positional information in time series.
  • Introduces efficient Relative Position Encoding (eRPE), a computationally lightweight relative position encoding method designed to improve generalization in time series tasks.
  • Combines tAPE and eRPE within a transformer block, integrating them with a convolutional layer for input feature extraction to form the ConvTran model.
  • Uses a hybrid architecture where convolutional layers extract local temporal patterns, and the transformer with enhanced position encoding captures long-range dependencies.
  • Employs learnable position embeddings that are jointly optimized during training, allowing the model to adapt to the structure of multivariate time series.
  • Applies standard self-attention mechanisms with modified query-key scoring using the proposed position encodings to preserve sequence order and context.

Experimental results

Research questions

  • RQ1How effective are standard absolute and relative position encodings in multivariate time series classification, particularly given low embedding dimensions and variable sequence lengths?
  • RQ2Can a time series-specific absolute position encoding that incorporates sequence length and embedding dimension improve model performance?
  • RQ3Can a more efficient relative position encoding method enhance generalization in time series classification tasks?
  • RQ4Does combining improved position encodings with a convolutional front-end lead to better performance in multivariate time series classification?
  • RQ5How does the proposed ConvTran model compare in accuracy and efficiency to state-of-the-art models across diverse multivariate time series datasets?

Key findings

  • ConvTran achieves state-of-the-art performance on 32 multivariate time series datasets, significantly outperforming existing CNN and transformer-based models.
  • On datasets with 100 or more training samples per class, ConvTran outperforms HC2, ROCKET, CIF, and Inception-Time, with the majority of wins marked in red on performance comparison figures.
  • On small-data datasets like EigenWorms (26 training samples per class), ConvTran still performs competitively among CNN-based models, though it is outperformed by some SOTA models due to data scarcity.
  • On the large InsectWingBeat dataset (25,000 training samples), ConvTran achieves higher test accuracy than ROCKET across all subset sizes, despite ROCKET being faster on small datasets.
  • ConvTran demonstrates faster training times than ROCKET as dataset size increases, and consistently faster inference times, even though ROCKET runs on CPU while ConvTran uses GPUs.
  • The ablation study confirms that both tAPE and eRPE contribute significantly to performance, with the full ConvTran model showing the best results across all evaluated metrics.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.