I was part of a research lab as during the summer after my freshman year in college. I was apparently going to be studying time series techniques, and so the PI assigned me my first task: read and understand N-BEATS. I remember spending 2 entire days trying to figure it out until I realized this may be temporarily out of my league and gave up.
Here’s an explanation I wish I’d seen.
The problem N-BEATS is solving
Classical time series forecasting (ARIMA, exponential smoothing) relies on hand-built structure: you decompose a series into trend, seasonality, and residual, and fit each piece with a statistical model. This works well but requires domain-specific setup per series.
N-BEATS (Oreshkin et al., 2020) asks whether a pure deep learning model, with no time-series-specific feature engineering, can beat these methods. The architecture is just stacked fully-connected networks with a specific residual structure. It won the M4 forecasting competition and beat hybrid statistical/ML approaches on M3 and tourism datasets.
Setup
Given a lookback window $x \in \mathbb{R}^L$ of past values, predict the next $H$ values $y \in \mathbb{R}^H$. The network is a stack of $K$ blocks, $\ell = 1, \dots, K$. Each block takes an input $x_\ell \in \mathbb{R}^L$ and produces:
$$\hat{x}_\ell \in \mathbb{R}^L \quad \text{(backcast: reconstruction of the block's input)}$$ $$\hat{y}_\ell \in \mathbb{R}^H \quad \text{(forecast: this block's contribution to the prediction)}$$
Inside a block
Each block is a 4-layer fully-connected ReLU network that maps its input to two sets of expansion coefficients, $\theta_\ell^b$ (for backcast) and $\theta_\ell^f$ (for forecast). These coefficients are then projected through basis matrices:
$$\hat{x}_\ell = V^b \theta_\ell^b, \qquad \hat{y}_\ell = V^f \theta_\ell^f$$
The network never outputs the backcast/forecast directly. It outputs coefficients over a basis, the same idea as learning Fourier or polynomial coefficients instead of regressing straight to raw values. This is the “basis expansion” in the name.
Two choices for what $V^b, V^f$ look like:
- Generic: $V^b, V^f$ are learned freely (just a linear layer). Maximum flexibility, no interpretability.
- Interpretable: $V^f$ is fixed to a specific functional form.
- Trend stack: polynomial basis, $V^f_{i,\tau} = \tau^i$ for small polynomial degree $i$. Forces low-order polynomial forecasts, i.e., smooth trend curves.
- Seasonality stack: Fourier basis, $\cos(2\pi i \tau)$ and $\sin(2\pi i \tau)$ terms. Forces periodic forecasts.
The interpretable variant restricts each stack to only be able to express certain shapes, which is what later makes the stack-level outputs decomposable and readable.
Doubly residual stacking
This is the mechanism that makes the stack of blocks behave coherently instead of every block redundantly trying to predict the same thing. Two separate pathways run through the stack.
Backcast pathway (subtractive). Block 1 receives the raw input, $x_1 = x$. Every subsequent block receives what the previous block failed to reconstruct:
$$x_{\ell+1} = x_\ell - \hat{x}_\ell$$
Block 2 never sees the original series. It only sees the leftover after block 1’s reconstruction. This is the same logic as gradient boosting: each unit fits the residual of what came before, so units specialize instead of duplicating effort.
Forecast pathway (additive). Every block also emits a forecast contribution, and these sum directly into the final prediction:
$$y = \sum_{\ell=1}^{K} \hat{y}_\ell$$
No subtraction here, just accumulation. The reason it’s additive and not also residual is that backcast and forecast serve different purposes. The backcast residual is a diagnostic signal telling the next block what’s left to explain. The forecast is the actual output, and outputs from different components (trend forecast, seasonal forecast) compose rather than cancel, so summing them mirrors classical decomposition, $y = \text{trend} + \text{seasonal} + \text{residual}$, except each term is learned end-to-end instead of fit separately.
There’s a second level of the same idea: the residual leaving the last block of stack $s$ becomes the input to stack $s+1$. So the subtractive logic operates block-to-block within a stack and stack-to-stack across the whole network.
Why this forces decomposition (interpretable variant)
Say the trend stack is blocks 1-3 (polynomial basis) and the seasonality stack is blocks 4-6 (Fourier basis).
- Block 1 fits a polynomial to the raw input, producing a backcast that looks like a trend curve and a forecast that’s that curve extrapolated.
- $x_2 = x_1 - \hat{x}_1$ is now the detrended input.
- Blocks 2-3 refine the trend fit on what’s left.
- By block 4, the input has had the trend subtracted out of it. Block 4’s Fourier basis now fits what’s essentially seasonal signal, because the trend component is no longer present in what it sees.
The final forecast is $y \approx \sum(\text{trend blocks' forecasts}) + \sum(\text{seasonal blocks' forecasts})$, and each stack’s summed contribution can be plotted separately. The decomposition isn’t a post-hoc explanation technique, it’s forced during training by the subtractive backcast pathway. Nothing explicitly penalizes overlap between what different blocks forecast; the specialization is entirely a side effect of one block’s backcast removing that pattern from what the next block can see.
Practical details
- Inputs are typically normalized per-window (divide by the last value or a local statistic) since the model has no explicit trend/level state carried between series.
- Ensembling mattered a lot for the M4 competition results: multiple lookback window lengths, both generic and interpretable configurations, and multiple random seeds, averaged together. A meaningful fraction of the reported performance gain comes from this ensembling, not a single model instance.
- Pure feedforward, no recurrence or attention, which makes it fast to train and avoids the optimization issues that come with RNN-based forecasters.
Follow-up: N-HiTS
N-HiTS extends this with multi-rate sampling (different blocks operate at different temporal resolutions), which helps with long-horizon forecasting where a single-resolution MLP stack starts to struggle.