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

Inductive biases for time series

"Give me enough data and I will learn anything. Give me a good prior and I will need far less data, provided you were right about the world."

A Well-Regularized AI Agent

Prerequisites

This section assumes you have met the convolutional machinery of Section 13.2 and the dilation idea of Section 13.3, and that you are comfortable with the bias-variance framing from Chapter 4. It leans on the sampling and stationarity language of Chapter 3. No new mathematics is introduced; this is a synthesis section about what assumptions your architecture is quietly making on your behalf.

The Big Picture

An inductive bias is the set of assumptions a model uses to generalize from the finite data it saw to the infinite data it did not. Every architecture has one, whether you chose it deliberately or inherited it by accident. A 1D convolution is not a neutral function approximator; it is a bet that useful patterns are local in time and look the same wherever they occur. On sensor streams those bets are often exactly right, which is why a small CNN can beat a much larger unstructured network on the same activity-recognition data. This section names the biases that matter for time series, shows how each one maps to a physical property of the signal, and teaches you to match the bias to the sensor rather than reaching for the biggest model and hoping.

What an inductive bias is, and why sensor time series need a strong one

A model that could represent every possible function fits your training set perfectly and predicts nothing useful, because infinitely many functions agree on the points you saw and disagree everywhere else. Learning is only possible because we constrain the hypothesis space: we tell the model, before it sees any data, which functions are a priori plausible. That constraint is the inductive bias. It is the reason a network trained on Monday's walking data recognizes Tuesday's walking data at all.

The why is a sample-efficiency argument. A strong, correct bias shrinks the effective number of parameters the data must pin down, so you need less labeled data to reach a given accuracy. This matters more for sensors than for almost any other domain, because sensor labels are expensive: a human activity dataset might have millions of accelerometer samples but only a few thousand labeled activity segments, and every label costs annotator time or a supervised protocol. A model with the right bias spends that scarce supervision learning what is genuinely uncertain instead of rediscovering that time flows left to right. The flip side, the when it hurts, is unforgiving: a strong bias that is wrong for your signal caps your accuracy no matter how much data you add, because the true function was excluded from the hypothesis space before training began.

Key Insight

Inductive bias trades data for assumptions at a fixed exchange rate. A correct bias is worth thousands of labels; a wrong one is a ceiling you cannot buy your way past. The engineering question is therefore never "how much bias" in the abstract, but "does this specific assumption hold for this specific sensor and task." That is a physics question, not a hyperparameter.

A catalog of temporal inductive biases

Deep models for sensor streams encode a small, recurring set of assumptions. Naming them lets you audit an architecture the way you would audit a set of modeling premises.

Shift equivariance and shift invariance. A convolution shares one filter across every time step, which means a pattern shifted in time produces the same response shifted in time (equivariance); add a global pooling layer and the final representation stops caring where the pattern occurred at all (invariance). The assumption is that the identity of an event does not depend on its absolute position in the window. A footstep is a footstep whether it lands at sample 10 or sample 90.

Locality. A finite kernel of width \(k\) asserts that what a sample means is determined by its immediate neighborhood, not by samples a thousand steps away. Formally the receptive field bounds the interactions the layer can model, so locality is the bet that the signal's short-range structure carries most of the information. Dilation and depth relax this bound gradually, which is precisely the multiresolution story of Section 13.3.

Causality. A causal model computes the output at time \(t\) from inputs at times \(\le t\) only, never peeking at the future. This is not a mathematical nicety; it is a hard requirement for any system that must act while the stream is still arriving, and it shapes every streaming deployment in Section 14.5. Offline analysis can drop the constraint and see the whole window at once.

Channel symmetry. How you wire the sensor axes encodes an assumption about their relationship. A channel-independent model applies the same transform to each axis and asserts the axes are exchangeable; a channel-mixing model lets them interact and asserts their joint pattern matters. For a tri-axial accelerometer the axes are emphatically not exchangeable once gravity picks out a direction, a subtlety we return to below.

Smoothness and periodicity. Many physical signals are band-limited and locally smooth, so architectures that favor low-frequency, continuous responses match reality; others, like gait or the cardiac cycle, are quasi-periodic, and encoding that repetition (through pooling over cycles or explicit periodic structure) is a powerful prior. These continuity assumptions connect directly to the filtering view in Chapter 6.

You can watch shift invariance appear or fail to appear just by changing how the time axis is collapsed. The snippet below feeds a three-axis window and a time-shifted copy of it through two encoders and measures how much the output moves.

import torch, torch.nn as nn

torch.manual_seed(0)
x = torch.randn(1, 3, 128)                      # (batch, channels, time): a 3-axis IMU window
shifted = torch.roll(x, shifts=16, dims=-1)     # slide the same window 16 samples in time

# Conv + global average pool: shift invariance is baked into the architecture
conv = nn.Sequential(
    nn.Conv1d(3, 8, kernel_size=9, padding=4), nn.ReLU(),
    nn.AdaptiveAvgPool1d(1), nn.Flatten())      # collapse the time axis to one vector

# Flatten + linear: every time position gets its own weights, so no shift bias
mlp = nn.Sequential(nn.Flatten(), nn.Linear(3 * 128, 8))

for name, net in [("conv+pool", conv), ("flatten+linear", mlp)]:
    delta = (net(x) - net(shifted)).abs().max().item()
    print(f"{name:15s} max output change after a 16-sample shift: {delta:.4f}")
Listing 13.6.1. The same shift produces a near-zero change for the convolutional encoder with global pooling and a large change for the flatten-then-linear encoder. The difference is not learned; it is structural. The conv model was built to ignore absolute timing, the linear model was built to memorize it.

As Listing 13.6.1 makes concrete, "shift invariance" is a property of the wiring, not something the optimizer has to discover from data. Choosing the conv encoder is choosing the assumption before a single gradient step.

The Right Tool

Enforcing causality by hand means allocating asymmetric padding, slicing off the trailing samples the kernel would otherwise read from the future, and getting the off-by-one right at every dilation level, roughly fifteen lines that are easy to break silently. A modern time-series library ships it as a flag:

from pytorch_tcn import TCN
model = TCN(num_inputs=3, num_channels=[16, 16, 32], causal=True)  # causal=True does the masking
Listing 13.6.2. The causal=True flag handles left-padding, future-sample removal, and per-layer receptive-field bookkeeping, collapsing about fifteen error-prone lines into one. It guarantees the no-peeking property; it does not decide whether your task actually needs it.

Matching the bias to the physics

The catalog is useless without judgment about when each assumption holds. The discipline is to read the bias back as a claim about the sensor and ask whether the claim is true.

Shift invariance is the classic example of a bias that is right until it is not. For classifying a gesture inside a fixed window it is exactly right. But a tri-axial accelerometer also measures the gravity vector, and gravity encodes orientation: the same motion performed with the phone upside down produces a differently signed signal. A model that is invariant to absolute channel orientation will happily confuse the two. The fix is either to remove the assumption (let the axes mix and keep orientation) or to remove the nuisance first (rotate into a gravity-aligned frame), a design tension explored in depth in Chapter 23. Stationarity is another quiet premise: weight sharing across time assumes the signal's statistics do not change within the window, which holds for a two-second walking clip and fails for a startup transient or a fault that evolves over minutes.

In Practice: a bearing on a factory motor

An industrial team building a vibration classifier for rolling-element bearings started with an off-the-shelf image-style CNN whose global pooling made it fully shift invariant. It worked well in the lab and then failed on the line. The reason was a mismatched bias. Bearing faults announce themselves as periodic impacts whose rate relative to shaft speed is the diagnostic signature, and the running motor's speed drifted between the training rig and the plant. Absolute-time invariance was correct, but the model also needed the periodicity prior it did not have, so it latched onto amplitude cues that shifted with load. Re-expressing the input in a shaft-angle domain (resampling so one revolution always spans the same number of samples) baked the right periodic structure into the representation, and accuracy recovered. The lesson generalizes: when a strong general model underperforms a smaller one, suspect a missing or wrong inductive bias before you suspect the optimizer. This is the same condition-monitoring problem developed in Chapter 37.

The bias-strength spectrum: from hand-crafted priors to data-hungry generalists

Architectures for sensor streams sit on a spectrum of how much structure they impose. At the strong end are hand-crafted feature pipelines (Chapter 8): a spectral-band energy feature is a maximal prior, encoding exactly what to look at, and it can be trained on a few hundred examples. Convolutional and temporal-convolutional models sit in the middle, imposing locality, weight sharing, and (optionally) causality while learning the filters themselves. At the weak end, attention-based models (Chapter 15) drop locality entirely and let any time step attend to any other, buying flexibility at the cost of needing far more data or clever pretraining to avoid overfitting.

The trend toward foundation models is, in one sentence, the trade of inductive bias for data. When you cannot supply the right prior by hand, you can sometimes supply enough unlabeled data that the model learns an appropriate bias itself, which is exactly the promise of the time-series foundation models in Chapter 19. This is not a free win. Data at that scale is its own expense, and a learned bias is harder to audit than a stated one. For most sensor projects, with modest labeled data and a well-understood signal, a mid-spectrum model carrying the few biases you can justify remains the sample-efficient default. The classical-versus-foundation tradeoff is a recurring thread of this book, and inductive bias is the axis it turns on.

Exercise

Take a labeled human-activity dataset you can access (or the one from Lab 13). Train two encoders on a shrinking fraction of the labels: a small 1D CNN with global pooling, and a plain multilayer perceptron over the flattened window. Plot test accuracy against training-set size on a log scale. (1) At which data budget do the curves cross, if they do? (2) Explain the gap in the low-data regime in terms of the CNN's shift-invariance and locality biases. (3) Now corrupt the assumption: append the raw gravity component so orientation matters, and describe which model's bias becomes a liability.

Self-Check

1. Explain why a strong inductive bias reduces the amount of labeled data you need, and state the precise cost you pay when that bias is wrong for your signal.

2. Weight sharing across time gives you shift invariance and also encodes a stationarity assumption. Give one sensor scenario where shift invariance helps and stationarity simultaneously hurts.

3. A colleague replaces a working CNN with a much larger attention model and accuracy drops on the same data. Give two distinct inductive-bias explanations for why the "bigger" model did worse.

What's Next

In Section 13.7, we stop reasoning about biases in the abstract and open the model up: how to visualize and inspect the filters a network actually learned, so you can confirm that the assumptions you thought you baked in are the ones the trained weights are honoring, and catch the cases where the optimizer quietly built a shortcut instead.