Building the Assumption into the Structure — Convolution and Recurrence
Chapter 2 listed "lower the capacity" among the remedies for overfitting — with the catch that lowering it too far leaves you short. Squeezed from both sides, it was a poor bargain.
This chapter is the third way: not reducing capacity but reducing it only in the right directions, by building what you know about the data into the structure itself. This is what Chapter 1 meant by "from Chapter 5, which assumption to build into the structure depends on the shape of the data."
1. A fully connected layer pays for assuming nothing
A fully connected layer mapping a image to 128 features has weights (plus 128 biases).
That layer knows nothing about how the pixels are arranged. Shuffle the pixels into a fixed random order before training and it reaches the same accuracy, because nothing in the structure says the arrangement means anything.
It pays twice for that.
- Parameter count. At input it becomes (still to 128).
- A shifted image is a different object. Move the cat one pixel right and every incoming number is different. The only way to cope is to have seen shifted examples.
2. Convolution — three assumptions at once
Slide one small window of shared weights across every position. In one dimension:
Three assumptions are built in:
- Locality — distant pixels are not directly related (nothing outside the window is seen)
- Weight sharing — the same feature is detected with the same weights wherever it appears
- Translation equivariance — shift the input and the output shifts with it
The parameter counts change:
| layer | weights + biases |
|---|---|
| fully connected | 100,480 |
| convolution ch | 320 |
| convolution ch | 832 |
About 314 times fewer — and a convolution's count does not depend on the input size. At or it is still 320, while the fully connected layer goes to and .
Small windows still reach far once stacked. With over layers, one output sees pixels (its receptive field):
| layers | 1 | 2 | 4 | 8 |
|---|---|---|---|---|
| receptive field (per side) | 3 | 5 | 9 | 17 |
One pixel further each way per layer. Depth is also the mechanism for covering a wide area with small windows.
3. How true is "shifted gives the same answer"?
Test equation (2) by computing it two ways. A: shift, then apply. B: apply, then shift.
Measured (length 32, kernel ):
| shift | bump at | conv (wrap) | conv (zero-pad) | fully connected |
|---|---|---|---|---|
| 1 | 11– | 0 | 0 | 0.8583 |
| 7 | 17– | 0 | 0 | 0.6100 |
| 18 | 28– | 0 | 0.1500 | — |
| 22 | 0– | 0 | 0.0750 | — |
| 25 | 3– | 0 | 0 | — |
(The output's own scale is 0.5155, so the fully connected gap of 0.86 means "a different thing entirely.")
Wrap-around is always exactly zero; zero-padding breaks precisely on the shifts where the bump straddles the edge. Equivariance is not something convolution has by itself — it holds only once the edge handling is specified. Real image models use zero-padding, so equivariance is broken near the borders — a fact textbook diagrams tend to hide.
4. Sequences — sharing weights along time
Sequences of varying length need a different assumption: the same rule applies at every time step. Written as weight sharing,
is one single matrix, independent of , which is what lets any length be processed.
In exchange, the product from Chapter 3 reappears along time:
Same shape as stacking layers, except the same is applied times. Equation (6) of Chapter 0-1 () applies directly, and eigenvalues come out raised to the .
Dropping the activation to isolate it, appears cleanly ( = largest absolute eigenvalue of ):
| 10 | 0.761 | 4.71 | |
| 50 | 0.345 | ||
| 100 | 0.354 |
matching in order of magnitude. Below 1 it vanishes, above 1 it explodes — in the linear case.
Put back and it changes:
| gradient at | mean | |
|---|---|---|
| 0.8 | 0.966 | |
| 1.0 | 0.927 | |
| 1.2 | 0.834 | |
| 2.0 | 0.488 |
At it does not explode. Raising enlarges , which drops and cancels it. Chapter 3's conclusion — what matters is the product of (weight size) × (activation slope) — holds here in exactly the same form.
5. Gates — multiplying by a learned "how much gets through"
If the trouble is a product repeated times, then make the factors something you can push toward 1. Learn how much passes:
(forget gate) and (input gate) lie in , and is the Hadamard product — the second of the two places Chapter 0-1 named as where it takes the leading role.
The gradient along this path is
does not appear at all. Not a product of weight matrices but a product of gate values, and if stays near 1 the signal survives any .
| 0.90 | 0.122 | |
| 0.95 | 0.358 | |
| 0.99 | 0.818 | 0.366 |
| 1.00 | 1.000 | 1.000 |
The plain RNN gave at even with . At it is 0.366 — more than three thousand times more.
A common misreading: "convolution is for images, recurrence is for sequences"
Look at which assumption got built in rather than at the tool's name:
| structure | assumption built in | axis shared |
|---|---|---|
| fully connected | none | (nothing shared) |
| convolution | only nearby things relate / the rule is the same at every position | space |
| recurrence | the rule is the same at every time step | time |
| attention | where to look is decided per input | (weights shared, connections variable) |
Convolution in one dimension serves audio and text (and is used there); recurrence can scan an image. The criterion is not the kind of data but whether the assumption holds.
Build in an assumption that does not hold and the capacity you gave up is simply lost. Tabular data is the classic case — where column order means nothing, a convolution gives a different answer when you reorder the columns, precisely the opposite of the property it was supposed to encode.
Exercises
The answers are folded away. Work them first.
Exercise 1. Input images of . (a) Parameters for a fully connected map to 256 features. (b) For a ch convolution. (c) What happens to each at input?
Show the answer
(a) .
(b) — about 410 times fewer.
(c) Fully connected: (16× more). Convolution: still 2,560. A convolution's count depends only on the window size and channel count, not on the input size — the direct consequence of reusing the same weights everywhere.
Exercise 2. Stacking convolutions. (a) How many layers for a 31-pixel receptive field? (b) With ? (c) For a given receptive field, which uses fewer parameters: one large window or several small ones (single channel)?
Show the answer
(a) 15. From .
(b) The field is , so → 8 layers (reaching ).
(c) Several small ones. For a 9-pixel field: one costs 81, four cost . And with activations between the layers, the stack expresses more shapes at the same receptive field. That is why dominates — at the price of more layers, which worsens the product problem of Chapter 3.
Exercise 3. A length-200 sequence through a plain RNN whose has largest absolute eigenvalue 0.9. (a) Roughly what factor does the gradient pick up (treating it as linear)? (b) With a gate holding ? (c) Why is (b) possible at all?
Show the answer
(a) — effectively zero. The start of the sequence cannot influence the loss at the end.
(b) — over a third survives.
(c) Because what gets multiplied changed. In the plain RNN the factor is , and is a single matrix for the whole sequence, forcing the same contraction at every step. The gated path multiplies only , which is computed from the input, per step and per component, so it can say "keep this ()" here and "forget it ()" there. Being able to push toward 1 only where it matters is the difference.
What this chapter does not say
- The full LSTM/GRU equations are not written out. Equation (5) isolates the cell-state path; the real thing adds an output gate and the construction of . Those are left to the article.
- Pooling, stride and dilation are not covered; the receptive-field arithmetic assumes stride 1. Pooling adds translation invariance (not equivariance), which is a different story.
- Attention gets one row in a table. Deciding where to look per input is the subject from Chapter 6 onward.
- The RNN measurements are single runs at width 64 with one fixed initialisation. The form — multiplied by the slope — is what holds; the values move with the setup.
- Every number was computed and checked (parameter counts, receptive fields, the two-order gap for wrap/zero-pad/fully-connected, the linear RNN's against , the gradients and mean with the activation in place, and the gate's ).
Comments
Sign in to comment