Wiki
Advanced14 min read

Deep learning for signals

Learning the filters instead of designing them: 1-D convolutions, dilated stacks, spectrograms and the evaluation pitfalls of time-series models.

For decades, reading a biosignal meant hand-designing features: detect the R peak, measure the intervals, compute band powers, feed those to a classifier. Deep learning asks why we should design the filters at all. A one-dimensional convolutional network slides learnable kernels along the waveform and discovers the features itself — the same operation as the hand-designed FIR filter, but with weights found by backpropagation rather than chosen by an engineer.

The widget shows the forward pass concretely: a signal convolved with class templates, rectified, globally max-pooled and passed through a softmax.

A conv layer is a bank of learned filters

Each 1-D kernel is a small pattern matcher. Convolving it over the signal produces a feature map that is large wherever the pattern occurs. ReLU keeps positive matches, global max-pooling keeps "did it occur anywhere", and the classifier decides from those presence scores. Stacking layers lets later kernels compose earlier ones into complex morphology.

A tiny 1-D CNN: convolution → ReLU → global max-pool → softmax. Choose the signal class and noise level; invert the kernels to watch it fail.

signal class
true: 11 Hz sine

3 Hz sine

template → feature map

pooled score 0.497

11 Hz sine

template → feature map

pooled score 0.964

3 Hz square

template → feature map

pooled score 0.474

3 Hz sine
5%
11 Hz sine
90%
3 Hz square
5%

predicted 11 Hz sine — correct

Real convolution, ReLU, max-pooling and softmax on a synthetic signal. Matched-filter templates are fixed; a trained 1-D CNN learns its kernels by backpropagation, but the forward pass you are watching is the same computation.

The 1-D convolution, layer by layer

A 1-D convolution of signal xx with kernel ww of length KK produces

y[t]=ReLU⁡ ⁣(∑k=0K−1w[k] x[t+k]),y[t] = \operatorname{ReLU}\!\left( \sum_{k=0}^{K-1} w[k]\, x[t + k] \right),

and a downsampling layer halves or thirds the length to build invariance. With CC output channels the layer learns CC distinct filters, each looking for a different local pattern. A global max-pool collapses the time axis to one number per channel — a learned "did this pattern appear" feature — and a final linear layer maps those features to class scores.

The receptive field and dilation

A single layer of length KK sees only KK samples. Stacking layers grows the receptive field linearly with depth, so capturing a full heartbeat (hundreds of samples) would need a deep stack. Dilated convolutions insert gaps in the kernel, so layer ℓ\ell with dilation 2ℓ2^\ell reaches exponentially far with linear depth — the trick from WaveNet that made raw-audio modelling practical. Causal padding restricts each output to past inputs, which matters for real-time streaming.

Spectrograms and 2-D CNNs

An alternative to convolutions on raw time is to convert the signal to a spectrogram (a short-time Fourier transform whose columns are spectra) and treat it as an image. Image architectures then apply directly, and time–frequency structure becomes spatial texture. The trade-off is resolution: the window size that gives good frequency resolution gives poor time resolution, and vice versa. Raw-waveform 1-D CNNs avoid that choice but must learn the time–frequency transform themselves.

Evaluating a time-series model

  • Split by time, not at random. Neighbouring windows are highly correlated; random splits leak information and inflate accuracy.
  • Resample to a fixed rate. Devices and studies differ, and aliasing after naive resampling is a silent bug.
  • Report per-class sensitivity at a clinical threshold, not just AUC, when the downstream action is an alert.
  • Test on other devices and populations — domain shift is the norm in physiological data.

Leakage is the classic time-series mistake

If overlapping windows from the same recording appear in both train and test, the model can memorise the patient rather than the pathology and post spectacular, meaningless numbers. Group splits by subject and split along time before you believe any accuracy figure.

Illustrative vs real

The widget uses fixed matched-filter templates and a three-class synthetic signal; a trained 1-D CNN would learn its kernels by backpropagation and stack many channels and layers. Hannun et al. classify twelve ECG rhythms from a single lead with a deep 1-D CNN; WaveNet models raw audio with dilated causal convolutions. The convolution, ReLU, pooling and softmax shown here are the same forward operations those networks use.

Check yourself

Eduspheria wiki · Applied AI, Signals and images

0 / 5 answered

  1. 1A 1-D conv layer has kernel length 5 and no dilation. How many samples does its immediate output depend on, per element?
    Numeric answer
  2. 2What does a global max-pooling layer over the time axis produce for each channel?
    Multiple choice
  3. 3Dilated convolutions let the receptive field grow exponentially with depth.
    True / false
  4. 4Should train and test sets for a physiological classifier be split at random or grouped by subject/time?
    Short answer
  5. 5What is the main advantage of a spectrogram + 2-D CNN over a raw-waveform 1-D CNN?
    Multiple choice

From the assignment paper

Modeled on NITJ AI-607, Assignment/Quiz

0 / 6 answered

  1. 1A CUDA kernel is launched with a grid of 2 blocks and 128 threads per block. How many threads are created in total?
    Numeric answer
  2. 2In CUDA, what is a warp?
    Multiple choice
  3. 3What causes thread divergence in CUDA?
    Multiple choice
  4. 4What does occupancy measure in CUDA?
    Multiple choice
  5. 5A stack of dilated 1-D convolutions doubles its dilation each layer, starting at 1. After 4 such layers, what is the receptive field in samples?
    Numeric answer
  6. 6Which memory space is most useful for variables shared and reused by threads within a block?
    Multiple choice

Where next: this chapter closes the Applied AI domain. From here, the same convolution and attention primitives recur in the Deep Learning and LLM domains — the applied problems change, the machinery does not.