A width-one code that memorises
counterexample▲▲△Exact values where possible; six decimal places otherwise.
STATEMENT
Show that a narrow code does not, by itself, stop an autoencoder from memorising its training set.
GIVEN
The training set is the four points , , and , the corners of a rectangle. The encoder keeps the first coordinate, . The decoder returns . Its second output is piecewise linear, with :
For comparison, the principal-axis autoencoder of I.12.B02 projects onto . The held-out set is the midpoints of the rectangle’s four sides: , , and .
FIND
The training loss of both autoencoders, their mean error on the held-out points, the decoding of the code , and what went wrong.
STRATEGY
Write the decoder’s second coordinate on each of its three linear pieces. Then evaluate both models point by point.
SOLUTION
The decoder, piece by piece. The two ReLU terms switch on at and , so the second output is
Training points. The codes are , , and , and returns , , and . Every training point is reconstructed exactly, so the training loss is . The principal axis gives each corner an error of , so its training loss is .
Held-out points. At the code is and the decoder returns : squared error . At it returns : error again. At and it is exact. The mean is .
The principal axis gives the first two points the code and the reconstruction , with error each. The other two lie on the axis, with error . The mean is .
| training loss | held-out mean | |
|---|---|---|
| width-one code, two ReLU kinks | ||
| principal axis |
Away from the data. The code decodes to . The training codes lie between and ; nothing constrained the decoder beyond them.
What went wrong. The reconstruction surface is a zigzag through the corners in order of their first coordinate: . Its middle piece crosses the rectangle from one corner to the opposite one. The code is one number, as narrow as a code can be, and the surface is one-dimensional as it must be. But a curve with two kinks has three straight pieces, enough to meet four points. The bottleneck bounded the dimension of the surface and left its shape free.
Answer
Training loss against . Held-out mean error against , with against at . The code decodes to . The decoder had enough freedom to pass through every training point.
Check — sanity
The decoder is continuous: at both neighbouring pieces give , and at both give . Its first output is the code itself, so only the second coordinate can be wrong.
Where this breaks
The construction needs the training points to have distinct codes. Two inputs that share a code share a reconstruction, whatever the decoder, so they cannot both be memorised. A curve with kinks passes through points with distinct codes; with more training points than that, the same decoder can no longer fit them all.
Variation
Add the four midpoints to the training set. The zigzag now has a loss of on the eight points, since it errs by on two of them, while the principal axis has . More data repaired what a narrower code could not.