Md. Asif Uddin
    Problem I.12.B04

    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 (1,2)(1,2), (2.2,0.4)(2.2,0.4), (−1,−2)(-1,-2) and (−2.2,−0.4)(-2.2,-0.4), the corners of a rectangle. The encoder keeps the first coordinate, z=x1z=x_1. The decoder returns g(z)=(z, g2(z))g(z)=(z,\,g_2(z)). Its second output is piecewise linear, with relu⁡(a)=max⁡(a,0)\operatorname{relu}(a)=\max(a,0):

    g2(z)=−43z−103+103relu⁡(z+1)−103relu⁡(z−1).\begin{aligned} g_2(z)=&-\tfrac43z-\tfrac{10}3\\ &+\tfrac{10}3\operatorname{relu}(z+1)\\ &-\tfrac{10}3\operatorname{relu}(z-1). \end{aligned}

    For comparison, the principal-axis autoencoder of I.12.B02 projects onto u1=(0.8,0.6)\vec u_1=(0.8,0.6). The held-out set is the midpoints of the rectangle’s four sides: (−0.6,0.8)(-0.6,0.8), (0.6,−0.8)(0.6,-0.8), (1.6,1.2)(1.6,1.2) and (−1.6,−1.2)(-1.6,-1.2).

    FIND

    The training loss of both autoencoders, their mean error on the held-out points, the decoding of the code z=5z=5, 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 z=−1z=-1 and z=1z=1, so the second output is

    z≤−1:g2=−43z−103,∣z∣≤1:g2=2z,z≥1:g2=−43z+103.\begin{aligned} z\leq-1&:\quad g_2=-\tfrac43z-\tfrac{10}3,\\[2pt] |z|\leq1&:\quad g_2=2z,\\[2pt] z\geq1&:\quad g_2=-\tfrac43z+\tfrac{10}3. \end{aligned}

    Training points. The codes are 11, 2.22.2, −1-1 and −2.2-2.2, and g2g_2 returns 22, 0.40.4, −2-2 and −0.4-0.4. Every training point is reconstructed exactly, so the training loss is 00. The principal axis gives each corner an error of 11, so its training loss is 11.

    Held-out points. At (−0.6,0.8)(-0.6,0.8) the code is −0.6-0.6 and the decoder returns (−0.6,−1.2)(-0.6,-1.2): squared error (0.8+1.2)2=4(0.8+1.2)^2=4. At (0.6,−0.8)(0.6,-0.8) it returns (0.6,1.2)(0.6,1.2): error 44 again. At (1.6,1.2)(1.6,1.2) and (−1.6,−1.2)(-1.6,-1.2) it is exact. The mean is 22.

    The principal axis gives the first two points the code 00 and the reconstruction (0,0)(0,0), with error 11 each. The other two lie on the axis, with error 00. The mean is 0.50.5.

    training lossheld-out mean
    width-one code, two ReLU kinks0022
    principal axis110.50.5

    Away from the data. The code 55 decodes to (5, −203+103)=(5, −3.333333)(5,\,-\tfrac{20}3+\tfrac{10}3)=(5,\,-3.333333). The training codes lie between −2.2-2.2 and 2.22.2; nothing constrained the decoder beyond them.

    What went wrong. The reconstruction surface is a zigzag through the corners in order of their first coordinate: (−2.2,−0.4)→(−1,−2)→(1,2)→(2.2,0.4)(-2.2,-0.4)\to(-1,-2)\to(1,2)\to(2.2,0.4). 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 00 against 11. Held-out mean error 22 against 0.50.5, with 44 against 11 at (−0.6,0.8)(-0.6,0.8). The code 55 decodes to (5,−3.333333)(5,-3.333333). The decoder had enough freedom to pass through every training point.

    Check — sanity

    The decoder is continuous: at z=−1z=-1 both neighbouring pieces give −2-2, and at z=1z=1 both give 22. 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 n−2n-2 kinks passes through nn 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 11 on the eight points, since it errs by 44 on two of them, while the principal axis has 0.750.75. More data repaired what a narrower code could not.

    Draws on