Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Memory by looking back, not carrying forward
A recurrent network carries a memory forward one step at a time. A temporal convolutional network instead looks back directly. Each layer combines a few past values, and each higher layer looks twice as far apart as the one below: 1, 2, 4, 8 steps back. A few layers can see a long way into the past, every time step can be computed in parallel, and the network can never peek at the future. The demo shows how far back the stack can see.
TCNs are fast to train, stable and easy to deploy on streaming sensor data. Their fixed receptive field is a clear, verifiable statement of how much history a model uses.
- 1. A causal convolution uses…
- 2. Doubling dilations makes the receptive field grow…
- 3. TCNs train over time steps…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Causal dilated convolution: y[t] = Σᵢ wᵢ x[t − i·d] with zeros before the start. Kernel size k and dilation d span (k − 1)d + 1 inputs.
- Receptive field of a stack:
- 1 + (k − 1) Σ dₗ;
- with k = 2 and dilations 1, 2, 4, 8, 16 it is 32; adding 32 gives 64;
- to reach a lag of 50 (field ≥ 51) needs 6 levels, and a lag of 31 needs 5.
- Bai et al.’s block:
- two dilated causal convolutions (kernel k) with weight normalisation, ReLU and dropout;
- a residual connection, with a 1 × 1 convolution if the channel count changes;
- dilation 2ⁱ at level i, so the field is 1 + 2(k − 1)(2ᴸ − 1); 8 levels with k = 3 give 1021.
- Parameters: a convolution with c_in inputs, c_out outputs and kernel k has c_in·c_out·k + c_out. For 8 → 8 channels and k = 2: 136.
- Parallelism: an RNN needs T sequential steps per layer. A TCN needs one per layer, since all time steps of a layer are computed at once.
- Streaming memory: to emit one new output, each layer caches its last (k − 1)·d inputs. Dilations 1, 2, 4 with 8 channels need 1 + 16 + 32 = 49 values.
- 1. Receptive field for k = 2 and dilations 1–16 (doubling):
- 2. Levels needed to cover a lag of 50 (k = 2):
- 3. Sequential steps for a 10-level TCN over 1000 steps:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.TCNs in code
Exercise 1.
- A dilated causal convolution of an impulse at t = 3 with kernel [1, 2] and dilation 4 put 1 at t = 3 and 2 at t = 7, and nothing before t = 3.
- The receptive-field formulas gave 32, 64 and 1021.
Practice.
- Implement causal convolution with
nn.Conv1d(c, c, k, dilation=d, padding=(k − 1)·d), then cut the extra (k − 1)·d outputs at the end. Or pad only on the left withF.pad(x, ((k − 1)·d, 0)). - Choose depth from the longest dependency: field ≥ lag + 1.
- Bai et al. used weight normalisation and dropout. Residual connections matter beyond a few levels.
- At inference on streams, cache each layer’s recent inputs (a ring buffer) so each new sample costs one step per layer, as in fast WaveNet generation.
class CausalConv(nn.Module):
def __init__(self, cin, cout, k, d):
super().__init__(); self.pad = (k - 1) * d; self.conv = nn.Conv1d(cin, cout, k, dilation=d)
def forward(self, x): # x: (B, C, T)
return self.conv(F.pad(x, (self.pad, 0)))
tcn = nn.Sequential(*[nn.Sequential(CausalConv(1 if i == 0 else 8, 8, 2, 2 ** i), nn.ReLU()) for i in range(6)])- 1. Causal padding goes…
- 2. Bai et al.'s TCN used…
- 3. Streaming TCN inference caches…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Fixed memory, short paths.
- A TCN’s output depends on exactly the inputs in its receptive field: it cannot use anything older, and needs nothing cleverer than the field to reach it.
- The gradient path from an input to the output has length equal to the number of layers, not the time lag. So there is no vanishing over time: a 50-step dependency is 6 layers away.
- By contrast an RNN’s path grows with the lag (E11-1).
Trade-offs.
- TCNs need the field chosen in advance, and memory for a long history at inference.
- They do not naturally handle unbounded context: a state of fixed size cannot be carried forever.
- RNNs and state-space models (E17) carry a compact state of fixed size, cheap for streaming but hard to train for long lags.
- Bai et al. found TCNs had longer effective memory than LSTMs of similar size in practice, despite LSTMs’ theoretically infinite memory.
Relation to other models. Time-delay neural networks (Waibel et al., 1989) were early 1-D convolutional networks for speech. WaveNet (E11-13) introduced dilated causal stacks for audio. Transformers replace the fixed field with attention over the whole context.
- 1. Gradient path length in a TCN depends on…
- 2. A TCN cannot use inputs…
- 3. An early 1-D convolutional speech model:
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Does a convolution remember what an RNN forgets?
History.
- A. Waibel et al. introduced time-delay neural networks (1989).
- A. van den Oord et al.’s WaveNet (2016) used dilated causal convolutions.
- S. Bai, J. Z. Kolter and V. Koltun’s “An empirical evaluation of generic convolutional and recurrent networks for sequence modeling” (2018) named and benchmarked the TCN.
Exercise 2. The same memory task as E11-1: remember a ±1 bit through 20 or 50 steps of unit noise. In E11-1 a vanilla RNN learned lag 50 on only 1 of 12 seeds.
- Models: TCNs with kernel 2, ReLU and 8 channels; dilations 1–16 (field 32) or 1–32 (field 64).
- Training: 150 Adam steps, 2 seeds.
| TCN | lag 20 | lag 50 |
|---|---|---|
| dilations 1–16 (field 32) | 1.0, 1.0 | 0.492, 0.468 |
| dilations 1–32 (field 64) | 1.0, 1.0 | 1.0, 1.0 |
- Inside its field a TCN learns quickly and reliably. Lag 50 is solved on every seed within 150 steps, a task the vanilla RNN almost never learned with twice the training.
- Outside its field it cannot learn at all. With field 32 the bit at lag 50 is simply invisible, so accuracy is chance, as the arithmetic predicts.
- The difference is the path length. The input bit reaches the output through 6 layers in the TCN, not through 50 recurrent steps.
TCNs in AI, robotics and aerospace
- Sensor streams: TCNs are popular for IMU-based activity recognition, vibration monitoring and fault detection, with fixed, auditable history windows.
- Control: causal convolutions give low-latency, parallel-trainable models of system dynamics.
- Forecasting: TCN-based forecasters handle long histories of power, traffic or telemetry efficiently.
References
- S. Bai, J. Z. Kolter, V. Koltun (2018). “An empirical evaluation of generic convolutional and recurrent networks for sequence modeling.” arXiv:1803.01271.
- A. Waibel, T. Hanazawa, G. Hinton, K. Shikano, K. Lang (1989). “Phoneme recognition using time-delay neural networks.” IEEE Trans. ASSP 37(3).
- A. van den Oord et al. (2016). “WaveNet: a generative model for raw audio.” arXiv:1609.03499.