SegRNN: Segment Recurrent Neural Network for Long-Term Time Series Forecasting

Machine Learning
Introduced by
Shengsheng Lin et al.
Year
2023
Type
Segment-based recurrent forecasting model
Family
Time-series forecasting

What does it do?

SegRNN is a recurrent neural network for long-term time series forecasting, proposed by Shengsheng Lin et al. in 2023.

Rather than feeding every time step to the recurrent cell, it partitions the input into fixed-length segments and passes each segment, as one embedded vector, through a GRU. This reduces the number of recurrent updates by roughly the segment length, which targets the difficulty recurrent models have when long sequences are processed one step at a time.

The intuition behind the method

Compare reading a text word by word with reading it sentence by sentence. SegRNN groups consecutive time steps into segments and gives each segment a single representation for the recurrent pass, so the GRU runs over far fewer steps. A shorter recurrent path may make long-range context easier to carry forward, although this is a design rationale rather than a guarantee of better training. A decoding stage then produces forecasts for the target horizon from the recurrent state.

History

SegRNN was introduced in a 2023 arXiv preprint by Shengsheng Lin and colleagues. Its central change is to apply the recurrent network to segments of time steps rather than to individual steps, for long-term forecasting.

When to use it

Consider SegRNN for long-horizon forecasting of univariate or multivariate series when a recurrent model is preferred to a Transformer-based forecaster. It is a weaker fit when the target depends on fine, step-level dynamics that a segment embedding may blur, such as detecting anomalies at individual time steps. With very small datasets, the model may be harder to fit reliably than simpler baselines, so comparison against a simple baseline is advisable. Patch-based Transformers such as PatchTST, listed among related methods, are reasonable alternatives to benchmark against for high-dimensional multivariate problems.

Limitations and considerations

  • Segment length s is a sensitive hyperparameter; an unsuitable choice can blur within-segment temporal structure or leave the recurrent component with many steps.
  • The linear segment projection may not capture complex nonlinear patterns within a segment as effectively as convolutional or attention-based encoders.
  • Forecast error can grow over long horizons, as it does for most multi-step forecasters.
  • Performance on tasks that need fine-grained temporal resolution, such as anomaly detection at individual time steps, is limited by the segmentation granularity.

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

Strengths

  • Operating on segments means the GRU runs over roughly s times fewer steps than a step-wise recurrent model on the same input, which shortens the recurrent path that gradients must traverse.
  • The architecture combines a linear segment projection with a GRU, which keeps the core design simple to follow.

Applications

  • Long-horizon forecasting of univariate or multivariate time series.
  • Domain suitability, for example for energy load, traffic or sensor data, should be established by testing on the user's own data before deployment.

How it works

How it works

1

The input series of length L is split into N = floor(L/s) non-overlapping segments of length s, as given in the formula. The segment length s is the main design choice: shorter segments keep more within-segment detail but leave more recurrent steps, while longer segments shorten the recurrence at the cost of resolution inside each segment.

Formula
\text{Given input sequence } \mathbf{x} \in \mathbb{R}^{L}, \text{ partition into } N = \lfloor L / s \rfloor \text{ non-overlapping segments } \{\mathbf{x}_i\}_{i=1}^{N}, \text{ each of length } s.
2

Each segment of s raw values is mapped by a learned linear projection to a d-dimensional embedding. The GRU then operates on these embeddings rather than on the raw values, so the input representation it sees is set by this projection.

Formula
\text{Each segment } \mathbf{x}_i \in \mathbb{R}^{s} \text{ is linearly projected to a hidden embedding: } \mathbf{e}_i = \mathbf{W}_e \mathbf{x}_i + \mathbf{b}_e, \quad \mathbf{e}_i \in \mathbb{R}^{d}.
3

A GRU reads the N segment embeddings in order and updates its hidden state once per segment. Because the recurrence runs over segments rather than individual time steps, the number of sequential recurrent updates is roughly s times smaller than for a step-wise GRU over the same input.

Formula
\text{A GRU processes the segment embeddings sequentially: } \mathbf{h}_i = \mathrm{GRU}(\mathbf{e}_i,\, \mathbf{h}_{i-1}), \text{ accumulating temporal context across segments rather than individual time steps.}
4

After the input segments have been encoded, a decoder produces forecast values for the target horizon. The exact design of the decoder, including how it generates the output for each part of the horizon, is specified in Lin et al. (2023) and should be taken from that paper.

Formula
\text{Forecasting uses Iterative Prediction Mode (IPM): the decoder unrolls } M \text{ steps with shared parameters, producing output segments } \hat{\mathbf{y}}_j = \mathbf{W}_d \mathbf{h}_j + \mathbf{b}_d \text{ until the horizon } H = M \cdot s \text{ is reached.}

Common pitfalls

  • When L is not a multiple of s, the floor operation in N = floor(L/s) leaves trailing points outside any complete segment. The formula as written does not pad, so the handling of these points (padding, truncation or other treatment) must be chosen and documented explicitly.
  • Very large segments reduce the number of recurrent steps but can remove short-term dynamics from the representation, which tends to hurt short-horizon accuracy.
  • Input scaling is not specified in the segment projection formulation. If series have large magnitudes or drift, the projection receives mismatched value ranges, so the normalisation strategy should be decided and reported explicitly.

Frequently asked questions

How does SegRNN differ from standard LSTM or GRU forecasters?

Standard LSTM and GRU forecasters update their state once per time step. SegRNN groups consecutive steps into segments of length s and runs the GRU once per segment, so the recurrent sequence is roughly s times shorter. Each segment is first mapped to an embedding by a linear projection, so the values within a segment are compressed rather than fed to the recurrent cell one step at a time.

How does SegRNN produce its multi-step forecast, and why does the segment structure matter?

The encoder summarises the input segments in a GRU hidden state, and a decoder then generates the forecast for the target horizon. Because the recurrence operates over segments, the number of sequential updates on the input side is roughly s times smaller than for a step-wise model. The decoder's exact design is specified in Lin et al. (2023).

How should the segment length s be chosen in practice?

The segment length is typically treated as a hyperparameter chosen by validation performance. Aligning s with a known cycle in the data, such as a daily cycle in hourly data, is one reasonable starting point, but the appropriate value depends on the dataset. Because the input length L is rarely an exact multiple of s, the handling of trailing points should also be decided.

Related methods

Sources

  1. Lin, S., Lin, W., Wu, W., Zhao, F., Mo, R., & Zhang, H. (2023). SegRNN: Segment recurrent neural network for long-term time series forecasting. arXiv preprint.

    Open publication reference