FEDformer: Frequency Enhanced Decomposed Transformer

Machine Learning
Introduced by
Tian Zhou et al.
Year
2022
Type
Frequency-domain decomposed Transformer for time-series forecasting
Family
Time-series forecasting

What does it do?

FEDformer is a Transformer-based architecture for long-term multivariate time-series forecasting, introduced by Tian Zhou and co-authors at ICML 2022.

It combines seasonal-trend decomposition with attention computed in the frequency domain: queries, keys and values are transformed by a Fourier or wavelet transform, and only a selected subset of frequency components is retained. This is the source of the linear complexity reported for the method, while the representation remains organised around global periodic structure.

The intuition behind the method

Standard Transformers treat each time step as a separate token, which makes it harder to capture the periodic, structured behaviour common in real sequences. FEDformer first splits the input into a smooth trend and an oscillating seasonal component, then models dependencies between parts of the series in the frequency domain. Working on a limited set of frequency components is similar to describing a melody by its dominant notes rather than by every sampled point of the waveform: the description is shorter, but it keeps the main periodic patterns.

History

FEDformer was proposed by Tian Zhou and co-authors and presented at ICML 2022. It belongs to the Autoformer lineage of efficient Transformers for time-series forecasting, which also includes Informer (2021) and Autoformer (2021). Its distinguishing feature relative to these models is that the attention mechanism itself is moved into the frequency domain and combined with progressive seasonal-trend decomposition.

When to use it

Choose FEDformer for multivariate forecasting with a long look-back window and a long forecast horizon, particularly when the series has recurring periodic or seasonal structure, and when a Transformer-type model is being considered for its ability to use long contexts. Energy load, weather and traffic series are typical cases. The efficiency gain comes from long look-back windows, so it matters little when the window and horizon are short; for short horizons, accuracy should be compared with a simple baseline under the same protocol rather than assumed to favour FEDformer. Also avoid it for series without a dominant periodic component or for irregular, regime-switching data, where a few retained frequency modes cannot represent the signal. A simple linear model is a reasonable first baseline. For less periodic data, Temporal Fusion Transformer or N-BEATS are alternatives within this library.

Limitations and considerations

  • The retained frequency modes are drawn at random, so runs with different random seeds can keep different modes and produce different results. Seed variation should be measured before comparing two models.
  • The architecture is relatively complex: it stacks decomposition blocks in every layer, frequency-domain attention and frequency-domain cross-attention, which raises implementation effort and makes it harder to attribute accuracy to any one component.
  • The method assumes that a limited set of frequency components carries most of the signal. This assumption is weak for non-stationary series whose spectral content shifts over time, because a fixed budget of modes cannot follow those shifts.
  • Reported gains over other models come from the original experiments and depend on their datasets and settings. Before drawing a conclusion, rerun a simple baseline under identical conditions and compare the results.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The sparse selection of M frequency modes, with M much smaller than L, is what produces the linear complexity in sequence length; the cost therefore depends on how many modes are retained as well as on the window length.
  • The explicit trend and seasonal split is part of the architecture, so the seasonal pathway and the additive trend term can be discussed separately when analysing a forecast.
  • Frequency-domain mixing lets each output depend on the retained modes in a single step, so periodic structure spanning the whole look-back window is accessible without stacking many local time-domain operations.
  • The Fourier and wavelet variants share the same encoder-decoder design, so the choice of transform can be compared with the rest of the architecture held fixed.

Applications

  • Long-term electricity consumption forecasting, where daily and seasonal load cycles are the main structure
  • Multi-day or multi-week weather variable prediction, where periodic climate patterns are present
  • Traffic flow and speed forecasting, where recurring daily and weekly patterns are common
  • Multivariate sensor forecasting in industrial settings with periodic operating cycles

How it works

How it works

1

Each encoder and decoder layer applies this decomposition to its input. Average pooling over a padded window gives the trend, and subtracting the trend leaves the seasonal residual. Because the split is repeated inside the network, each sublayer can refine the trend and seasonal parts separately instead of mixing them in one representation.

Formula
\mathbf{x} = \mathbf{x}_{\text{trend}} + \mathbf{x}_{\text{seasonal}}, \quad \mathbf{x}_{\text{trend}} = \text{AvgPool}(\text{Padding}(\mathbf{x})),\quad \mathbf{x}_{\text{seasonal}} = \mathbf{x} - \mathbf{x}_{\text{trend}}
2

This block replaces softmax attention. Queries and keys are transformed to the frequency domain and combined by element-wise multiplication of the query spectrum with the conjugate key spectrum. Only a selected set of M frequency modes is kept, the result is applied to the value spectrum, and the output is inverted to the time domain. Keeping M modes instead of all L is what gives the linear complexity stated for the method.

Formula
\text{FEA}(\mathbf{Q}, \mathbf{K}, \mathbf{V}) = \mathcal{F}^{-1}\!\left(\text{Select}\!\left(\mathcal{F}(\mathbf{Q}) \odot \overline{\mathcal{F}(\mathbf{K})}\right) \cdot \mathcal{F}(\mathbf{V})\right)
3

The feed-forward sublayer is replaced by a Frequency Enhanced Block. The input is Fourier-transformed, a learnable weight matrix is applied to a sparse subset S of frequency indices with |S| = M much smaller than L, and the result is inverse-transformed to the time domain. Restricting the learnable weights to the retained modes keeps the computation sparse and avoids dense time-domain convolutions or full attention matrices.

Formula
\mathbf{y} = \mathcal{F}^{-1}\!\left(\mathbf{W}_{\text{freq}} \odot \mathcal{F}(\mathbf{x})_{S}\right), \quad S \subset \{0,1,\dots,L-1\},\; |S| = M \ll L
4

The encoder processes the look-back window. The decoder is initialised from the seasonal component together with a placeholder for the forecast horizon, and it attends to the encoder output. The forecast is a linear projection of the final decoder hidden states, plus the mean of the trend term from the decomposition. The trend therefore enters the prediction through this additive term rather than through the frequency blocks.

Formula
\hat{\mathbf{x}}_{\text{out}} = \mathbf{W}_{\text{proj}}\, \mathbf{h}_{\text{dec}}^{(N)} + \mathbf{x}_{\text{trend}}^{\text{mean}}, \quad \mathbf{h}_{\text{dec}}^{(N)} = \text{FEDformerDecoder}\!\left(\mathbf{x}_{\text{seasonal}},\, \mathbf{h}_{\text{enc}}^{(N)}\right)

Common pitfalls

  • The efficiency gain of frequency-domain attention applies mainly to long look-back windows. With short windows and horizons the cost difference is small, so accuracy should be checked against simpler baselines under the same protocol before FEDformer is chosen.
  • Input normalisation is part of the experimental protocol. The scheme should be stated and held fixed across comparisons, since a change of preprocessing alone can change the reported error.
  • Choosing M too small can underfit complex seasonal patterns, while choosing M too large removes the efficiency advantage and can increase overfitting. M should be tuned on validation data rather than fixed by default.
  • Published benchmark numbers are not directly comparable when dataset splits, normalisation, look-back length or metrics differ. Baselines should be rerun under the same protocol before concluding that one model is better.

Frequently asked questions

How does FEDformer differ from Autoformer?

Both models use seasonal-trend decomposition and aim for efficient long-sequence forecasting. Autoformer computes auto-correlation between time-domain series, using the FFT as a computational shortcut. FEDformer moves the attention mechanism itself into the frequency domain and learns on a sparse subset of frequency modes, so frequency-domain processing is a central architectural choice rather than a shortcut.

Why is random frequency mode selection used instead of always keeping the top-K modes?

Random selection is the design choice described for FEDformer. It is intended to give the model access to a wider part of the spectrum than the strongest modes alone. The original experiments give the evidence for this choice; comparing it with top-K selection on the target data is the practical way to judge whether it helps in a given application.

Can FEDformer handle univariate forecasting, or is it designed only for multivariate data?

The model is described as applicable to both settings. In the univariate case a single series is processed. In the multivariate case the encoder and decoder process all channels together, so inter-variable dependencies can be learned through the shared representations and cross-attention. Confirm the channel-handling details in the authors' implementation before adapting the model.

What does FEDformer take as input and return as output?

The input is a window of past observations of one or more variables, of length L (the look-back window). The output is a forecast over the next H time steps (the horizon) for each variable. The trend and seasonal parts are computed inside the model from the input. Normalisation is not described as part of the architecture, so the scheme used should be reported with every result.

Related methods

Sources

  1. Zhou, T., Ma, Z., Wen, Q., Wang, X., Sun, L., & Jin, R. (2022). FEDformer: Frequency enhanced decomposed transformer for long-term series forecasting. ICML.

    Open publication reference