Crossformer is a long-horizon forecasting model that embeds a multivariate time series into a 2D array of "short per-variable intervals (segments)" and captures both the relations between time steps and the relations between variables with a two-stage attention split into a time direction and a variable direction. It was introduced in 2023 by Zhang and Yan of Shanghai Jiao Tong University in "Crossformer: Transformer Utilizing Cross-Dimension Dependency for Multivariate Time Series Forecasting" and published at ICLR 2023.
In image recognition there is a different model with a very similar name, CrossFormer, introduced by Wang et al. in 2021 ("CrossFormer: A Versatile Vision Transformer Hinging on Cross-scale Attention", arXiv:2108.00154). It is a vision Transformer that embeds image patches at multiple sizes and has nothing to do with the time series forecasting Crossformer covered in this article. When you see the name in a paper or library, check which one is meant.
Earlier Transformer-based time series forecasting models (Informer, Autoformer, FEDformer, and others) focused mainly on capturing relations between time steps efficiently. The values of all variables at a time step were simply embedded into one vector, and relations between variables (for example, electricity usage rising when the temperature rises) were not handled explicitly.
To use these "relations between variables" explicitly, Crossformer combines three components.
- Dimension-segment-wise embedding (DSW embedding): cuts the series of each variable into intervals of length and turns each interval into one vector.
- Two-stage attention layer (TSA layer): applies attention first along the time direction and then along the variable direction. The variable direction goes through a small number of "routers" to keep the cost down.
- Hierarchical encoder-decoder (HED): merges adjacent segments to build coarser time scales, predicts at each scale, and sums the predictions.
In this article, the past interval used as input for the forecast is called the lookback window, and the interval to be predicted is called the forecast window. In the paper's notation, the lookback window length is , the forecast window length is , and the number of variables is (note that these symbols differ from and in other articles).

