AI State of the Art
Domains/Séries temporelles/28 min
Section 234

Deep Learning for Time Series: DeepAR, TCN, N-BEATS

Listen as a podcast →

The problem: what can a neural network add to a curve?

The previous lesson ended on a lesson in humility: simple statistical methods are hard to beat. So why did the field switch to deep learning anyway? This page presents three architectures that marked the switch, each carrying a different idea:

  • DeepAR changes the output: a probability-weighted range instead of a number;
  • the TCN changes the reading: convolutions instead of recurrence;
  • N-BEATS changes the structure: a learned decomposition, with no specialized component at all.

It then draws out the deeper change of nature all three share, the one that actually explains the switch.

The first reflex: recurrent networks

A time series is a sequence, and a family of networks built for sequences already existed: recurrent neural networks (RNNs) and their gated variants LSTM and GRU, presented in the lessons on RNNs and on LSTM and GRU. Their principle, read the sequence point by point while maintaining an internal memory, fits the shape of a curve naturally. The first deep successes in forecasting were therefore, unsurprisingly, recurrent networks. The most influential of them deserves a close look, less for its architecture than for how it changed the question being asked.

DeepAR: predict a distribution, not a number

DeepAR, published by Amazon in 2017, is a recurrent network trained for forecasting. Its most durable contribution is not technical but conceptual: instead of answering "next week's sales will be 1,000", it answers "they will probably land between 800 and 1,300, centered around 1,000". This is probabilistic forecasting: the model outputs a distribution over possible futures, not a single number.

Concretely, the network does not learn to emit a value but the parameters of a probability law (a center and a width of uncertainty) for each future time step. From that you can draw as many scenarios as you like and read off ranges: "9 times out of 10, demand will stay below 1,300".

Why it matters: a forecast without uncertainty is unusable for decision-making. The inventory manager does not want to know that average demand will be 1,000; she wants to know how much to stock so as to run out only one time in twenty, a question about the top of the range, not the middle. The same distribution answers opposite questions depending on the job:

  • the inventory manager reads the top of the range ("how much might be needed at worst?");
  • the electricity producer reads the bottom ("how much can I sell for sure?");
  • the risk auditor reads the width ("how deep in the fog are we?").

Two forecasts of "1,000", one near-certain and one wildly uncertain, thus call for opposite decisions, something a single number cannot express. The paper's abstract claims accuracy improvements of around 15% over the then state of the art, but its real legacy is having made the range, not the point, the standard deliverable.

DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks (Amazon)
DeepAR's second ingredient, quiet but decisive

DeepAR is not trained on one series but on a large set of related series, every product in a catalog, for instance. A recent product with almost no history benefits from the patterns learned on thousands of similar products. Hold on to this idea: as the end of this page shows, it is what truly separates this generation from the classical methods.

TCNs: convolutions instead of recurrence

Recurrent networks have a structural flaw: they read the sequence point by point, hence slowly, and their memory of distant events fades (see why the Transformer replaced RNNs). Temporal Convolutional Networks (TCN) attack that flaw with the tool of image processing: the convolution (the small sliding filter presented in the lesson on CNNs) applied here along the time axis. Two adjustments make the recipe both correct and powerful.

Causal: when forecasting, looking at the future is forbidden. The filter is therefore shifted to cover only the present and the past, the output at time t depends only on points up to t, never after.

Dilated: a short filter only sees a few points. The trick is to space out the points each layer looks at, more and more as you go up: the first layer looks at neighboring points, the second at points 2 apart, the next at 4, then 8, 16… The field of vision doubles with every layer, like a cartographer stacking maps at wider and wider scales: the street, the neighborhood, the city, the country. The arithmetic can be done in your head: 1 layer sees about 2 points, 2 layers see 4, and 10 layers see 210=1,0242^{10} = 1{,}024 points, three weeks of hourly history taken in by a ten-story network. And every position is computed in parallel, where a recurrent network had to march step by step.

The recipe was not born with time series: it is the one behind the success of WaveNet, DeepMind's model that generated speech sample by sample, sound being, precisely, a very high-frequency time series.

Diagram of a stack of dilated causal convolutions: four layers with dilations of 1, 2, 4 and 8; arrows only flow from the past towards the present, and the spacing between the points each layer looks at doubles at every layer.
Dilated causal convolutions, as drawn in the WaveNet paper. Each layer looks at points twice as far apart as the previous one (dilation 1, 2, 4, 8): the field of vision doubles at every storey. And every arrow flows from past to present, never the other way, causality is guaranteed by construction.Source : WaveNet paper (figure 3)
WaveNet: A Generative Model for Raw Audio (DeepMind), the origin of dilated causal convolutions

The TCN reference paper (Bai, Kolter and Koltun, 2018) then systematically compared this scheme against recurrent networks on the standard sequence-modeling tasks: its abstract concludes that a simple convolutional architecture outperforms canonical recurrent networks such as the LSTM across a diverse range of tasks, with longer effective memory.

Causality by construction

Note the nature of the guarantee: the TCN cannot cheat by peeking at the future, not because it was trained not to, but because the architecture physically forbids it: the connections toward the future do not exist. That is a property you prove by looking at the network's diagram, not by hoping the training went well. The distinction between "guaranteed by construction" and "learned and therefore fallible" comes up constantly when analyzing these systems.

An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling (the TCN paper)

N-BEATS: no recurrence, no convolution, dense layers that decompose

N-BEATS (2019) pushes the challenge one step further: no recurrence, no convolution, no attention, only dense layers (every neuron connected to all of the previous layer's outputs, the most elementary building block in the field) stacked in a cascade of blocks.

The mechanism has a very legible elegance: each block receives the window of past values, explains part of it (producing a piece of the forecast plus a reconstruction of what it understood of the past) then subtracts what it explained and hands the remainder to the next block. Each block peels one layer off the signal, and the final forecast is the sum of the contributions.

Picture a chain of experts in front of the same curve: the first says "I explain the underlying slope", removes it, and passes on the rest; the second says "I explain the weekly pattern", removes it, and passes on the rest; the last one receives nothing but noise. It is the old idea of decomposition (remove the trend, then the season, then look at what is left) but with every expert learned instead of prescribed. One variant of the model even constrains its blocks to explicitly output a trend and a seasonality, making the decomposition inspectable.

N-BEATS architecture: a block of dense layers producing a backcast and a forecast, blocks chained in cascade with residual subtraction, and stacks whose forecasts are summed into the global forecast.
The N-BEATS cascade, read left to right. A block (left): dense layers producing an explanation of the past (backcast) and a piece of the forecast. A stack (middle): each block subtracts what it explained and hands the remainder to the next. On the right, the stacks whose contributions are summed into the global forecast.Source : N-BEATS paper (figure 1)

The result that made history: on the M3, M4 and TOURISM competition datasets, the paper's abstract claims state-of-the-art performance, improving forecast accuracy by 11% over a statistical benchmark and by 3% over the M4 winner, the hand-crafted statistics + neural network hybrid met in the previous lesson. In other words: a "pure" neural network, with no time-series-specific component whatsoever, ended up beating the hand-built hybrid. The demonstration mattered as much as the score.

N-BEATS: Neural basis expansion analysis for interpretable time series forecasting

How these models are trained: the sliding window

One practical detail unites the three models and illuminates everything else: where do the training examples come from? From a sliding window. A template ("this many points of past → this many points of future") is slid along every history: points 1 to 100 must predict points 101 to 110; then points 2 to 101 must predict 102 to 111; and so on.

Every position of the template becomes a graded exercise, the "future" to be guessed is already known, since it is cut out of the past. A history of a few years thus yields thousands of exercises, and a catalog of thousands of series yields millions: enough to feed a neural network, where an ARIMA made do with the single series alone.

One precaution follows directly from the module's opening lesson: these windows overlap and resemble each other enormously. Evaluation must therefore use a period entirely later than all the training windows, on pain of large-scale data leakage, and laboratory scores with no bearing on reality.

One last practical detail: for series of incomparable scales (sales in units, power in megawatts) to feed the same network, each window is brought to a comparable scale before entering. That idea will become central, under the name of instance normalization, in the lesson on foundation models.

ModelCore mechanismWhat it outputsThe idea to remember
DeepARRecurrent network (LSTM)One distribution per time stepThe range rather than the number
TCNDilated causal convolutionsFuture values (or any sequence output)Field of vision doubling per layer, parallel computation
N-BEATSCascaded dense layersForecast = sum of the blocks' contributionsClassical decomposition, but learned

The real shift: learning across thousands of series

Step back from the three models. Their deepest common point is neither recurrence, nor convolution, nor the cascade of blocks. It is this:

  • A classical method (ARIMA, exponential smoothing) is fitted to one series at a time: its handful of parameters are recomputed for each curve, from that curve's history alone.
  • A deep model is trained once across thousands of series: its shared parameters encode patterns seen everywhere (weekly rhythms, year-end spikes, reversion to the mean) and are then applied to every series.

This is sometimes called cross-learning. It is what changes the economics of the problem: the short, signal-poor series that drives ARIMA to despair becomes predictable, because the model has seen a thousand series that resemble it. And it explains the verdict of the M competitions: deep learning wins precisely when there are many related series to learn from together, and remains beatable on an isolated series.

What this generation did not solve

Three limits remain intact, and set up the rest of the module:

  • You still have to train at home. DeepAR, TCN and N-BEATS are trained on your catalog of series. New company, new domain? New training run, with all the data, time and expertise that implies.
  • Non-stationarity does not go away. A model trained on three years of past remains blind to an unprecedented break, so the reflex of the naive baseline and of testing on the future stands, untouched.
  • What about attention? All three architectures avoid the Transformer, whose attention mechanism nonetheless seemed tailor-made for connecting "this Monday" to "every previous Monday". Its application to time series (expensive on long curves, but powerful) is precisely the next step of the story.
Where the invention lives, in these architectures

In this generation, the novelty is rarely "a neural network that forecasts", that idea is old and documented. It lives in the precise building blocks: the shape of the output (predicting a distribution, and which one), the dilation scheme of the convolutions, the block structure that subtracts its own contribution, the way training windows are built and balanced across very different series. The real differences play out at that level of detail.

The bridge to what comes next

Push cross-learning to its limit: train on every curve available (energy, traffic, finance, sensors) to obtain a model that forecasts a series it has never seen, with no re-fitting at all. That is exactly the program of Transformers applied to time series, then of foundation models like TimesFM and Chronos, covered in the lesson on time series foundation models.

Key takeaways

  1. Recurrent networks (RNN, LSTM) were the first reflex: a curve is a sequence, and they were the tool for sequences.
  2. DeepAR changed the question: predict a distribution (a probability-weighted range) rather than a number, because a forecast without uncertainty cannot support a decision. Its abstract claims around 15% better accuracy than the then state of the art.
  3. TCNs replace recurrence with causal convolutions (no peeking at the future) and dilated ones (the field of vision doubles at each layer): long memory and parallel computation.
  4. N-BEATS uses nothing but cascaded dense layers, each block explaining then subtracting its share of the signal, a learned decomposition; its abstract claims +11% over a statistical benchmark and +3% over the hybrid M4 winner.
  5. The change of nature: classical methods fit series by series, deep models learn patterns across thousands of series, that is cross-learning, and it is the bridge to foundation models.
  6. When examining a disclosure: the novelty lives in the precise building blocks (shape of the output, dilation scheme, subtractive blocks, construction of the training windows), never in the general idea of "a network that forecasts".
Check your understanding0 / 5

1. Why is DeepAR's most lasting contribution outputting a distribution rather than a number?

2. In a TCN, what is the increasing dilation of the convolutions for, and what order of magnitude does it produce?

3. The page stresses that a TCN cannot look at the future 'by construction'. Why does that phrasing matter?

4. N-BEATS uses only dense layers stacked into blocks. What does each block do exactly, and which older idea does that echo?

5. What, according to the page, is the deepest thing DeepAR, TCN and N-BEATS have in common, the one that explains the shift to deep learning?