Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Looking back through a widening window
A convolution slides a small pattern detector along a series. For forecasting it must be causal: it may look only at the past, never at the future. If each layer looks twice as far back as the one below, a few layers can see a long history: 1, 2, 4, 8, 16 steps back. Unlike a recurrent network, all time steps can be computed at once, which makes training fast.
WaveNet (2016) used dilated causal convolutions to generate audio sample by sample; the same idea became a strong forecasting architecture.
- 1. A causal convolution looks at…
- 2. Doubling the dilation at each layer makes the history seen grow…
- 3. Compared with RNNs, TCNs can process time steps…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Causal convolution: y_t = Σ_j w_j x_(t−j). Padding is added only at the start, so no output depends on the future.
- Dilation d: the kernel taps are spaced d apart, y_t = Σ_j w_j x_(t−jd).
- Receptive field: for kernel size k and dilations d₁, …, d_L it is 1 + (k − 1)Σd_l. With d = 1, 2, 4, … it doubles with each layer.
- Residual blocks: two dilated convolutions with normalisation, ReLU and dropout, plus a skip connection x + f(x) (Bai et al., 2018).
- Strengths: parallel training, stable gradients, a fixed and inspectable memory length.
- Weaknesses: a fixed memory window that must be designed to cover the relevant lags, such as daily and weekly cycles.
- 1. Receptive field of kernel 2 with dilations 1, 2, 4, 8, 16:
- 2. Causality is ensured by padding…
- 3. A residual block computes…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.A dilated causal TCN in NumPy
Exercise 1.
- Kernel-2 causal convolutions out_t = A·h_(t−d) + B·h_t + b with ReLU, and a linear head on the last time step.
- A gradient check on a 3-layer, 4-channel network.
- A receptive-field test: put a 1 at each input position in turn and see which ones change the output.
Practice.
- Choose dilations so the receptive field covers the longest seasonal lag (24 for daily cycles in hourly data, 168 for weekly).
- Use residual blocks with weight or layer normalisation for deeper stacks.
- Normalise each input window (or use RevIN) so level shifts do not break the model.
- Benchmark against linear models on the same window, such as DLinear and seasonal naive.
- Tools: PyTorch Conv1d with padding and slicing, Darts TCNModel, NeuralForecast TCN.
import numpy as np
def causal_conv(x, w, d=1):
y = np.zeros_like(x)
for j, wj in enumerate(w):
y[j * d:] += wj * x[:len(x) - j * d]
return y- 1. For hourly data with a daily cycle, the receptive field should be at least…
- 2. A Darts model for TCNs:
- 3. A strong simple baseline for long windows:
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Exponential reach. Each layer with dilation d connects time t to time t − d. A path from the output back to the input picks either the delayed or the current tap at each layer, so it can reach back any sum of a subset of the dilations. With dilations 1, 2, 4 that is every lag from 0 to 7. In Exercise 1 poking each input confirmed that exactly the last 8 inputs reach the output. Six layers with dilations 1…32 see 64 steps; six undilated layers see only 7.
What the receptive field means for learning. If the target depends on y_(t−24) and the network cannot see it, no amount of training helps: the best it can do is predict from what it sees. A larger field is necessary but not sufficient. The model must also represent the right function, and a linear autoregression sees everything in its window but can only combine it linearly.
Cost. A layer with C channels and kernel k has C²k + C weights. The 5-layer, 8-channel network of Exercise 2 has 577 weights, about half of a 16-unit LSTM, and computes all time steps in one pass.
- 1. Dilations 1, 2, 4 let the output see lags…
- 2. If the receptive field misses the key lag, more training…
- 3. A linear AR model with a long window can still fail when…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.When the next value depends nonlinearly on the value one period (24 steps) earlier, how do TCNs with receptive fields of 7, 16 and 32 compare with a linear autoregression that sees 48 steps?
History.
- A. van den Oord et al. (2016) introduced dilated causal convolutions in WaveNet.
- S. Bai, J. Kolter and V. Koltun (2018) showed that a generic TCN matches or beats LSTMs on many sequence tasks.
- A. Borovykh et al. (2017) applied WaveNet-style networks to financial forecasting.
- Later work combined convolutions with seasonality-aware designs, for example SCINet (2022) and TimesNet (2023).
Exercise 2.
- 1200 points of y_t = 1.5 cos(1.5 y_(t−24)) + e_t with noise sd 0.4. The noise sd is the best possible RMSE, and the series sd is about 1.
- Windows of 48 values; the first two thirds train and the rest test.
- TCNs with 8 channels and dilations (1,1,1,1,1,1), (1,2,4,8) and (1,2,4,8,16), giving receptive fields 7, 16 and 32; 30 epochs of Adam.
- A linear AR(48) by least squares, and persistence.
Seed 0, one-step test RMSE:
| model | RMSE |
|---|---|
| persistence | 1.5 |
| linear AR(48) | 1.1 |
| TCN, receptive field 7 | 1.1 |
| TCN, receptive field 16 | 1.1 |
| TCN, receptive field 32 | 0.51 |
- Only the TCN that could see lag 24 learned the dynamics and came close to the 0.4 noise floor. With fields of 7 and 16 the TCNs were no better than predicting the mean.
- The linear AR(48) saw lag 24 but could not use it: a straight-line fit to a cosine relation explains almost nothing.
- Seeds 1 and 2: field 32 gave 0.47 and 0.46; fields 7 and 16 gave 1.1 in every case; the linear AR gave 1.0 in both.
TCNs in practice
- Energy and traffic: TCNs forecast load and flows with receptive fields chosen to cover daily and weekly cycles.
- Hybrids: convolution front-ends feed transformers or RNNs; TimesNet reshapes a series into 2-D by period and applies 2-D convolutions.
- Anomaly detection: TCN autoencoders and forecasters flag deviations in sensor streams.
- Speed: convolutional models train and infer quickly on GPUs because all time steps are computed at once.
References
- A. van den Oord et al. (2016). “WaveNet: a generative model for raw audio.” arXiv:1609.03499.
- S. Bai, J. Z. Kolter and V. Koltun (2018). “An empirical evaluation of generic convolutional and recurrent networks for sequence modeling.” arXiv:1803.01271.
- A. Borovykh, S. Bohte and C. W. Oosterlee (2017). “Conditional time series forecasting with convolutional neural networks.” arXiv:1703.04691.
- M. Liu et al. (2022). “SCINet: time series modeling and forecasting with sample convolution and interaction.” NeurIPS.
- H. Wu et al. (2023). “TimesNet: temporal 2D-variation modeling for general time series analysis.” ICLR.