Part IV: Deep Learning for Sensor Time Series
Chapter 13: Neural Representations for Sensor Streams

Learned vs fixed filterbanks

"They gave me a hundred filters and let me choose the passbands. I chose badly for the first ten thousand steps, then I chose exactly what the textbook already knew."

A Chastened AI Agent

Why this choice sits at the front of every sensor network

The very first layer of a convolutional network for sensor streams is a filterbank: a set of short filters that each respond to a band of frequencies and slide along the signal. You can hand that filterbank to the network as a fixed, hand-designed object (a mel bank, a wavelet family, a Gabor set) or you can let gradient descent invent the filters from data. This is not a cosmetic decision. It sets how much data you need, whether a regulator can read the front end, how robust the model is when the hardware drifts, and how many multiply-accumulates the first layer costs on a microcontroller. This section makes the tradeoff precise and hands you a decision rule, plus the middle ground almost everyone actually ships.

Section 13.2 established that a 1D convolution is a bank of learned FIR filters, and Section 13.3 stacked them across scales. This section asks the question those two deferred: should the first bank be learned at all, or inherited from classical time-frequency analysis, the machinery of Chapter 7? Prerequisites: the short-time Fourier transform and wavelets from Chapter 7, the convolution-as-filter view from Section 13.2, and hand-crafted spectral features from Chapter 8.

What a filterbank is, and the two ways to get one

A filterbank is a collection of \(K\) filters \(\{g_k[n]\}\), each tuned to a different frequency band, applied to the same input so the signal is decomposed into \(K\) subband streams. In a fixed bank the coefficients come from a formula: a mel filterbank spaces triangular windows on a perceptual frequency axis, a wavelet bank dilates one mother wavelet, a Gabor bank multiplies sinusoids by Gaussians. In a learned bank the coefficients are the weights of the first convolution layer, initialized at random and moved by backpropagation to minimize the task loss. Mechanically both produce the same object, a set of FIR kernels convolved with the signal; the only difference is where the numbers come from, a designer's equation or the gradient.

That single difference propagates into everything downstream. A fixed bank encodes a strong inductive bias: the model is told, before it sees any data, that frequency content organized into these particular bands is what matters. A learned bank encodes almost none: it must discover from labels alone which bands carry signal, which is powerful when the useful bands are unusual and wasteful when they are exactly the ones a physicist could have named. Put plainly: a fixed filterbank is prior knowledge you get for free, and a learned filterbank is the same knowledge, if it exists at all, bought one labeled example at a time.

The fixed filterbank: physics and interpretability for free

A fixed bank buys three things that are hard to get any other way. First, data efficiency: because the filters are already correct, no training samples are spent learning them, so the network can be small and converge on a few hundred labeled windows rather than a few hundred thousand. Second, interpretability: every channel has a known center frequency and bandwidth, so a clinician or a safety auditor can read "this feature is energy in the 8 to 12 Hz band" instead of squinting at an opaque kernel. Third, robustness to leakage and drift: a data-independent front end cannot overfit an idiosyncrasy of one recording session, a real hazard treated in Chapter 5, and it ages gracefully because its bands never depended on any one sensor's quirks.

The cost is rigidity. If the discriminative information lives between the bands the designer chose, or in a phase relationship a magnitude filterbank discards, a fixed bank simply cannot represent it, and no amount of downstream capacity fully recovers what the front end threw away. Fixed banks also carry human priors that may be wrong for a machine: the mel scale was tuned to human hearing, which has nothing to say about the resonance of a failing gearbox.

Fixed banks trade capacity for prior knowledge

A fixed filterbank is a claim about where the information is, made before training. When the claim is right, you get accuracy for almost no data. When it is wrong, you have hard-coded a bottleneck the rest of the network cannot undo. The learned bank makes the opposite bet: no prior, but the capacity to be right about bands no human would have guessed, paid for in labeled data.

The learned filterbank: the first conv layer as an adaptive analyzer

Letting the first layer learn its filters means the network can discover task-specific bands that no standard bank contains: the exact sideband a specific bearing defect excites, the narrow rhythm a particular gesture produces, a cross-channel pattern that a per-channel spectral transform never sees. With enough labeled data this consistently matches or beats a fixed bank, and it removes the guesswork of picking a wavelet family. The price is everything the fixed bank gave away: more data, more compute, weaker interpretability, and a front end that can quietly overfit the calibration of the sensors in your training set.

A useful habit is to inspect what the learned bank became, rather than trust it blindly. Because each first-layer kernel is an FIR filter, its magnitude response is just the magnitude of its discrete Fourier transform. The snippet below builds a small learnable-style bank and reads off its passbands, the same lens we sharpen for debugging in Section 13.7.

import numpy as np

fs, K, L = 200.0, 4, 65          # 200 Hz signal, K filters, length-L kernels

def bandpass_sinc(f_lo, f_hi, L, fs):
    n = np.arange(L) - (L - 1) / 2
    def sinc_lp(fc):             # ideal low-pass, cutoff fc (Hz)
        return 2 * fc / fs * np.sinc(2 * fc / fs * n)
    h = sinc_lp(f_hi) - sinc_lp(f_lo)          # band-pass = difference of low-passes
    return h * np.hamming(L)                    # window to tame ripple

# a constrained, "learnable" bank: 2 numbers per filter (its two cutoffs)
cutoffs = [(4, 8), (8, 12), (12, 20), (20, 40)]
bank = np.stack([bandpass_sinc(lo, hi, L, fs) for lo, hi in cutoffs])

freqs = np.fft.rfftfreq(256, d=1/fs)
resp  = np.abs(np.fft.rfft(bank, n=256, axis=1))
peak_hz = freqs[resp.argmax(axis=1)]
print("free-bank params :", K * L)             # every tap is a weight
print("sinc-bank params :", K * 2)             # only two cutoffs per filter
print("peak response Hz :", np.round(peak_hz, 1))
Constructing a four-channel bandpass filterbank from sinc kernels and reading each filter's peak frequency off its FFT magnitude. The two print lines contrast a free learned bank (every one of the \(K\times L\) taps is a trainable weight) against a constrained sinc bank (only two cutoff numbers per filter), the parameter gap that motivates the next section.

Running it confirms the four channels peak near 6, 10, 16, and 30 Hz, and that the free bank carries \(4\times65=260\) parameters against the sinc bank's \(4\times2=8\). That 30-fold gap is the whole argument for constraining the learning.

A learned filter does not automatically look like a filter

It is tempting to assume that once backpropagation chooses the first-layer weights, each kernel settles into a clean, single-peaked bandpass shape the way the sinc filters above do by construction. A free, unconstrained kernel has no such obligation: with limited data, a poor initialization, or more channels \(K\) than the task's true bandwidth needs, several kernels often converge to near-duplicates, noisy multi-lobed responses, or nearly flat, low-energy filters that contribute little. The FFT-magnitude inspection above is not a formality; it is the only reliable way to confirm a "learned filterbank" is actually behaving like one. Duplicated or degenerate filters found this way are a signal to add a diversity penalty, shrink \(K\), or fall back to a constrained bank.

The middle ground: constrained learnable filterbanks

The dichotomy is false in practice. The dominant modern pattern is a parameterized filterbank: still learned by gradient descent, but constrained to a shape that guarantees it stays a sensible filter. SincNet (Ravanelli and Bengio, 2018) learns only the two cutoff frequencies of each bandpass sinc filter, so a 65-tap filter has 2 trainable numbers instead of 65. LEAF (Zeghidour et al., 2021) learns Gabor filter centers and bandwidths plus a learnable pooling and normalization. Both keep the interpretability of a fixed bank, you can still print a center frequency, while letting the data nudge the bands, and both need far less data than a free bank because the hypothesis space is tiny.

A second, even cheaper middle ground is initialization: replace the free conv layer's random weights with the coefficients of a mel, gammatone, or wavelet bank, then let ordinary backpropagation fine-tune every tap. Gradient descent from a bad random start spends its first many steps merely rediscovering that band-limited, roughly sinusoidal filters beat noise, a fact classical signal processing already proved decades ago; starting from that answer skips the rediscovery and places the optimizer directly in a loss basin near a sensible solution. This buys much of the fixed bank's data efficiency while keeping the full expressive ceiling of the learned one, since nothing stops the weights from drifting further once training is underway. Reach for it whenever a known frequency structure exists in the domain (vibration, audio, biosignals) and the labeled set is modest but not tiny, the middle case where neither a fully fixed bank nor a cold random start is clearly the better bet.

A trainable filterbank in one layer, not forty

Hand-rolling a fixed mel bank, wiring it into a differentiable front end, and adding learnable cutoffs is easily 40+ lines of window math and buffer bookkeeping. Modern libraries expose it as a single module: a fixed differentiable mel front end is torchaudio.transforms.MelSpectrogram(sample_rate=fs, n_mels=K); a fully trainable STFT front end is one nnAudio.features.STFT(trainable=True); a SincNet bank is speechbrain.nnet.CNN.SincConv(out_channels=K, kernel_size=L, sample_rate=fs). Each replaces roughly 40 lines with 1, and the library handles windowing, framing, edge padding, and gradient flow through the transform.

Bearing faults: where a learned band beat the mel scale

A predictive-maintenance team monitoring rolling-element bearings on factory motors (the subject of Chapter 36) started with a mel filterbank on 20 kHz vibration, because it was the default in their audio toolkit. It plateaued: the mel scale packs resolution into low frequencies, but the diagnostic signature of an outer-race fault is a train of high-frequency resonant bursts modulated at a defect frequency the mel bands smeared together. Swapping to a SincNet front end, initialized from a linear-frequency bank, let the filters migrate to the resonance and sharpen there; accuracy rose several points, and because each learned filter still reported a center frequency, the engineers could see the network had rediscovered the bearing's known resonant band, turning a black box into something their reliability team would sign off on. A fully free bank reached similar accuracy but needed roughly ten times the labeled fault examples, which for a rarely-failing machine they simply did not have.

Does a foundation model still need a designed front end?

Time-series and sensor foundation models trained on very large, heterogeneous corpora (Chapter 19, Chapter 20) push the learned-bank argument to its limit: does a designed or constrained filterbank still earn its place once pretraining spans enough sensor types, or does raw-waveform tokenization discover a superset of every useful filterbank on its own? Evidence so far is mixed: some foundation models recover mel-like or wavelet-like structure in their first layers unprompted, while others learn front ends that resist any classical interpretation, reopening the interpretability cost this section raised, now at a scale where inspecting every filter by hand is no longer practical. Whether physically grounded front ends stay worthwhile once pretraining data is effectively unlimited remains open.

A decision rule you can apply today

Little labeled data, or a regulator who must read the front end, or a microcontroller counting every multiply (Chapter 59): use a fixed bank or a constrained learnable one (SincNet, LEAF). Abundant labeled data and a task whose useful bands are unusual or cross-channel: use a free learned bank, but initialize it from a fixed bank and inspect the result. When in doubt, the constrained learnable bank is the low-regret default: it rarely loses to either extreme by much and often wins.

Exercise: make the data-efficiency gap visible

Take a public accelerometer activity-recognition set (for example UCI HAR at 50 Hz). Train three identical small 1D CNNs differing only in the first layer: (a) a fixed mel/linear bandpass bank with frozen weights, (b) a SincNet-style bank learning only per-filter cutoffs, (c) a free conv layer from random init. Sweep the training-set size from 5 percent to 100 percent and plot validation accuracy against data budget for all three, using a subject-disjoint split so there is no leakage across people. Confirm that (a) and (b) dominate in the low-data regime while (c) catches up only once data is plentiful, and report the crossover point.

Self-check

  1. In what precise sense is the first convolution layer of a sensor CNN already a filterbank, and what is the only thing that distinguishes a "learned" bank from a "fixed" one?
  2. Name two concrete advantages a fixed mel bank has over a free learned bank, and one situation where each advantage becomes a liability.
  3. A SincNet filter of length 65 has how many trainable parameters, and why does that small number simultaneously improve data efficiency and preserve interpretability?

What's Next

In Section 13.5, we turn from the filters to the samples that flow through them: how to normalize sensor windows so a drifting baseline does not swamp the bands your filterbank just learned, and how to augment them so the network generalizes across mounting angles, users, and devices without ever seeing the future.