Foundations to Frontier
Tests
E. Deep Learning › E7 CNN Building Blocks

1-D, 2-D and 3-D Convolutions

The same sliding-window idea works in any number of dimensions: 1-D convolutions slide along time (audio, sensor streams, text), 2-D along height and width (images, spectrograms), and 3-D along time and space (video, volumetric scans, lidar voxels). The choice decides which patterns a layer can see, and each extra dimension multiplies cost by the kernel size. This page covers the three cases, their shapes and costs, channels versus dimensions, and factorised (2+1)-D designs. In the exercises you build one routine for all three and show a spectrogram's full-height 2-D kernel equals a 1-D convolution with frequency bins as channels, then classify motion direction in tiny videos: per-frame 2-D filters were at chance, frames-as-channels reached 91% and 3-D filters 98%.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Sliding windows in time, space or both

A convolution slides a small window along the data. For a sound or a sensor stream the window slides along time (1-D). For an image it slides across height and width (2-D). For a video or a CT scan it slides across time or depth as well (3-D). What the network can detect depends on where the window can slide: to see motion, a filter must look at several frames at once.

CNN building blocks
input 9 × 9
→
output 7 × 7
output size = ⌊(n + 2p − d(k − 1) − 1)/s⌋ + 1 = ⌊(9 + 0 − 2 − 1)/1⌋ + 1 = 7
Deep-learning "convolution" slides a small learned kernel over the input (no flip). Stride shrinks the output, padding preserves borders, dilation spreads the kernel to see further without more weights. Pooling summarises windows. Stacking layers grows the receptive field. Depthwise-separable and grouped convolutions cut cost by not connecting every input channel to every output channel. Transposed convolution upsamples, but uneven kernel overlap leaves checkerboard patterns. Squeeze-and-excitation rescales whole channels by gates computed from their global averages; CBAM adds a per-pixel spatial gate. (Here the gates are fixed functions of the averages so you can see their effect; in a network the excitation is learned.)
Why engineers care

Engineering data come in all these shapes: vibration and telemetry (1-D), camera and radar images (2-D), video, lidar voxels and volumetric inspection scans (3-D). Choosing the right convolution, or a factorised mix, decides accuracy and whether the model fits on the hardware.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Audio is usually processed with…
  2. 2. To detect motion a filter must…
  3. 3. Each extra dimension multiplies the cost by…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Shapes (channels first):
    • 1-D: (C, T), kernel (C_out, C_in, k);
    • 2-D: (C, H, W), kernel (C_out, C_in, k, k);
    • 3-D: (C, D, H, W), kernel (C_out, C_in, k, k, k).
  • Weights for 64 → 64, k = 3: 12 288 (1-D), 36 864 (2-D), 110 592 (3-D).
  • Valid output shape: each dimension shrinks by k − 1: (16, 112, 112) with k = 3 → (14, 110, 110).
  • Channels versus dimensions: a 2-D convolution over a spectrogram (frequency × time) whose kernel covers every frequency bin is a 1-D convolution over time with frequency bins as channels.
  • (2+1)-D factorisation: a 3 × 3 spatial convolution to M channels, then a 3-tap temporal one: C_in·M·9 + M·C_out·3 weights.
📝 Quick check (Level 1)
0/3 answered
  1. 1. 3-D weights for 64 → 64, k = 3:
  2. 2. Valid output of (16, 112, 112) with k = 3:
  3. 3. A full-height spectrogram kernel equals…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 20 minUndergraduate students and practising engineers.

Convolutions in code

Exercise 1.

  • One routine based on sliding windows computed 1-D and 3-D valid convolutions correctly.
  • A 2-D kernel spanning all 8 frequency bins of a spectrogram gave exactly the 1-D convolution over time with the bins as channels.

Practice.

  • nn.Conv1d, nn.Conv2d, nn.Conv3d.
  • For video, consider early fusion (frames as channels), (2+1)-D factorisation (R(2+1)D) or 3-D convolutions on short clips.
  • For long 1-D signals, use dilated or strided 1-D convolutions to cover long contexts cheaply.
  • For sparse 3-D data such as lidar voxels, use sparse convolutions that skip empty space.
x = torch.randn(8, 3, 16, 112, 112)            # batch, channels, frames, height, width
y = torch.nn.Conv3d(3, 64, kernel_size=3, padding=1)(x)
🐍 Exercise 1: one routine for every dimension
Implement an n-D valid convolution with sliding windows, test it in 1-D and 3-D, and show a full-height spectrogram kernel is a 1-D convolution with bins as channels.
📝 Quick check (Level 2)
0/3 answered
  1. 1. R(2+1)D factorises a 3-D conv into…
  2. 2. Lidar voxels are best handled by…
  3. 3. Long 1-D contexts are covered cheaply by…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Same operation, different symmetry. A d-dimensional convolution is equivariant to shifts along its d sliding axes. Which axes slide is a modelling choice: frequency in a spectrogram is not translation-invariant in the way time is, so many audio models treat frequency as channels (1-D) or use 2-D convolutions with small frequency kernels.

Temporal information. A filter that sees only one frame produces features independent of frame order; pooling over time then makes the representation completely order-blind, so motion direction is invisible (exercise 2). Early fusion mixes all frames in the first layer; 3-D convolutions build spatio-temporal features gradually and are equivariant in time.

Cost. Parameters and multiply–adds grow as kᵈ. Factorisations such as (2+1)-D and depthwise convolutions (E7-6) reduce this; R(2+1)D also adds a nonlinearity between the spatial and temporal parts, which Tran et al. (2018) found helped.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Per-frame filters with pooling over time are…
  2. 2. Convolution cost grows with dimension as…
  3. 3. Frequency in spectrograms is often treated as…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Seeing motion

History.

  • A. Waibel et al. (1989) introduced time-delay neural networks (1-D convolutions for speech).
  • S. Ji et al. (2013) and D. Tran et al. (2015, C3D) used 3-D convolutions for action recognition.
  • J. Carreira and A. Zisserman (2017) inflated 2-D networks to 3-D (I3D); D. Tran et al. (2018) proposed R(2+1)D.

Exercise 2. Tiny videos (6 frames of 10 × 10) of a 2 × 2 blob moving one pixel per frame left or right, with noise. Features: 16 fixed random filters with ReLU and global max pooling; a linear readout trained on 200 videos. Three seeds:

features test accuracy
3 × 3 filters on each frame, max over frames 0.504
3 × 3 filters with the 6 frames as input channels 0.911
3 × 3 × 3 filters (3-D) 0.981
  • Per-frame filters were at chance: each frame shows a blob; only the order of frames reveals the direction, and pooling over time discards it.
  • Frames as channels (early fusion) captured motion, and 3-D filters, which see three consecutive frames at every position, did best.
🐍 Exercise 2 (research): seeing motion
Classify the direction of a moving blob with per-frame 2-D filters, frames-as-channels 2-D filters and 3-D filters.

Convolutions of every dimension in AI, robotics and aerospace

  • 1-D: vibration-based fault detection, telemetry anomaly detection, keyword spotting on microcontrollers.
  • 2-D: camera, thermal and radar images; spectrograms of acoustic or RF signals.
  • 3-D: action and gesture recognition from video, volumetric CT inspection of composite parts, sparse 3-D convolutions on lidar for autonomous driving.

References

  1. A. Waibel, T. Hanazawa, G. Hinton, K. Shikano, K. Lang (1989). “Phoneme recognition using time-delay neural networks.” IEEE Trans. ASSP 37(3).
  2. D. Tran, L. Bourdev, R. Fergus, L. Torresani, M. Paluri (2015). “Learning spatiotemporal features with 3D convolutional networks.” Proc. ICCV.
  3. J. Carreira, A. Zisserman (2017). “Quo vadis, action recognition? A new model and the Kinetics dataset.” Proc. CVPR.
  4. D. Tran et al. (2018). “A closer look at spatiotemporal convolutions for action recognition.” Proc. CVPR.