Md. Asif Uddin

    Proposition 2I.12.P0241 of 100 in the corpus

    A linear autoencoder finds the principal subspace, and not its axes.

    The minimum of the reconstruction loss is the projection onto the directions of largest variance. The loss fixes that subspace and leaves the basis inside it free, so the code's coordinates are not principal components.

    Four points and their principal axisThe four corners of a rectangle four units long and two units wide, turned so that its long side points along the direction 0.8, 0.6. A solid line through the origin in that direction is the principal axis. Each corner drops a perpendicular of length one onto it, and the two corners at each end land on the same point. A dashed horizontal line marks the alternative of keeping the first coordinate alone, which costs 2.08 instead of 1.four points · one code numberx₁ axisloss 2.08u₁ = (0.8, 0.6)loss 1length 1Each corner lies 1 from the line, so the loss is 1 = λ₂.Two corners share each reconstruction. The codes are ±2.
    Fig. 2 — Type B · Construction — Four points and the best line through them, drawn to scale. Each corner lies at distance one from the principal axis, so the mean squared reconstruction error is one, the discarded eigenvalue. Keeping the first coordinate instead costs 2.08.

    The question, stated so it can be answered

    Proposition 1 left one thing open: a bottleneck forces a linear autoencoder to discard a subspace, and the loss chooses which. By (I.12.2) the loss depends on the two matrices only through their product M=DE\mat M=\mat D\mat E, which has rank at most kk:

    L(M)=tr⁡((I−M) S (I−M)T).\mathcal L(\mat M)=\operatorname{tr}\big( (\mat I-\mat M)\,\mat S\,(\mat I-\mat M)^{\mathsf T}\big).

    Assume the data are centred, so that S\mat S is their covariance (I.12.X03 shows what happens otherwise). Write its eigendecomposition (Rank, eigenvalues and the singular value decomposition 0.LA.04) as S=∑iλiuiuiT\mat S=\sum_i\lambda_i\vec u_i\vec u_i^{\mathsf T} with λ1≥⋯≥λd≥0\lambda_1\geq\cdots\geq\lambda_d\geq0 and orthonormal ui\vec u_i. Let Uk\mat U_k hold the first kk eigenvectors as columns. Which M\mat M of rank at most kk makes the loss smallest?

    Each half is a least-squares problem

    Hold one matrix fixed and the other has a closed form.

    Fix the encoder. The codes are then fixed, and the loss is a linear regression of each input on its code. Setting ∇DL=0\nabla_{\mat D}\mathcal L=\mat 0 in (I.12.2) gives (I−DE)SET=0(\mat I-\mat D\mat E)\mat S\mat E^{\mathsf T}=\mat 0, which is solved by the first line below whenever the code covariance ESET\mat E\mat S\mat E^{\mathsf T} is invertible.

    Fix the decoder, with independent columns. For one input, the code that minimises ∥x−Dz∥2\|\vec x-\mat D\vec z\|^2 is the least-squares solution z=(DTD)−1DTx\vec z=(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T}\vec x. It is linear in x\vec x, so a linear encoder can produce the best code for every input at once.

    fixed E:D=SET(ESET)−1,fixed D:E=(DTD)−1DT.\begin{aligned} \text{fixed }\mat E:\quad \mat D&=\mat S\mat E^{\mathsf T} (\mat E\mat S\mat E^{\mathsf T})^{-1},\\ \text{fixed }\mat D:\quad \mat E&=(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T}. \end{aligned}
    (I.12.3)

    Each half, taken alone, is a least-squares problem with a closed form.

    The second line settles the form of the answer. With that encoder,

    M=D(DTD)−1DT=P,\mat M=\mat D(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T}=\mat P,

    the orthogonal projection onto the column space of D\mat D (Projections and orthogonality 0.LA.05): P2=P\mat P^2=\mat P and PT=P\mat P^{\mathsf T}=\mat P. So for any decoder, no encoder does better than the one that makes the autoencoder a projection onto the decoder’s columns. A decoder of lower rank spans a smaller subspace, and enlarging a subspace never increases a distance to it. The search over pairs of matrices has become a search over kk-dimensional subspaces.

    The loss of a projection is the variance it drops

    Let the columns of Q∈Rd×k\mat Q\in\R^{d\times k} be an orthonormal basis of the subspace, so P=QQT\mat P=\mat Q\mat Q^{\mathsf T}. Since I−P\mat I-\mat P is also a symmetric projection, the cyclic property of the trace gives

    L(QQT)=tr⁡(S(I−QQT))=tr⁡S−tr⁡(QTSQ).\begin{aligned} \mathcal L(\mat Q\mat Q^{\mathsf T}) &=\operatorname{tr}\big(\mat S(\mat I-\mat Q\mat Q^{\mathsf T})\big)\\ &=\operatorname{tr}\mat S-\operatorname{tr}(\mat Q^{\mathsf T}\mat S\mat Q). \end{aligned}
    (I.12.4)

    A projection's loss is the variance it fails to keep.

    Here tr⁡S\operatorname{tr}\mat S is the total variance of the data and tr⁡(QTSQ)\operatorname{tr}(\mat Q^{\mathsf T}\mat S\mat Q) is the total variance of the codes QTx\mat Q^{\mathsf T}\vec x. By (I.12.4), minimising reconstruction error and maximising retained variance are one problem.

    Now expand in the eigenbasis:

    tr⁡(QTSQ)=∑i=1dλici,ci=∥QTui∥2.\begin{aligned} \operatorname{tr}(\mat Q^{\mathsf T}\mat S\mat Q) &=\sum_{i=1}^d\lambda_i c_i,\\ c_i&=\|\mat Q^{\mathsf T}\vec u_i\|^2. \end{aligned}

    Each cic_i is the squared length of the projection of a unit vector, so 0≤ci≤10\leq c_i\leq1. They sum to tr⁡(QTQ)=k\operatorname{tr}(\mat Q^{\mathsf T}\mat Q)=k, because the ui\vec u_i form an orthonormal basis. A weighted sum of the λi\lambda_i with weights between zero and one that total kk is largest when weight one sits on the kk largest. Hence the retained variance is at most λ1+⋯+λk\lambda_1+\cdots+\lambda_k. If λk>λk+1\lambda_k>\lambda_{k+1}, equality forces ci=1c_i=1 for i≤ki\leq k, which places every one of u1,…,uk\vec u_1,\ldots,\vec u_k inside the subspace.

    min⁡E,DL=∑i>kλi,attained atDE=UkUkT,that is,D=UkG,E=G−1UkT.\begin{aligned} \min_{\mat E,\mat D}\mathcal L&=\sum_{i>k}\lambda_i,\\ \text{attained at}\quad\mat D\mat E&=\mat U_k\mat U_k^{\mathsf T},\\ \text{that is,}\quad\mat D&=\mat U_k\mat G,\\ \mat E&=\mat G^{-1}\mat U_k^{\mathsf T}. \end{aligned}
    (I.12.5)

    The minimum fixes the subspace and leaves the basis free.

    That is I.12.T1. I.12.B02 writes out each step and evaluates it on the four points of the figure, where λ=(4,1)\lambda=(4,1) and u1=(0.8,0.6)\vec u_1=(0.8,0.6): the best width-one autoencoder projects onto that line and its loss is exactly 11.

    The result has an older name. With X\mat X the centred data matrix, its right singular vectors are the ui\vec u_i and λi=si2/n\lambda_i=s_i^2/n for singular values sis_i. The reconstruction XUkUkT\mat X\mat U_k\mat U_k^{\mathsf T} is the best approximation of X\mat X of rank kk in the Frobenius norm, which is the theorem of Eckart and Young (1936). Bourlard and Kamp (1988) and Baldi and Hornik (1989) recognised it in the autoencoder.

    The subspace, and not its axes

    The last two lines of (I.12.5) hold for every invertible G\mat G of size k×kk\times k, since G\mat G cancels in the product. The loss cannot tell these factorisations apart, so the minimum is a family with k2k^2 free numbers.

    Principal component analysis delivers more than this. Its directions are orthonormal and ordered by variance, and its scores are uncorrelated. A trained linear autoencoder delivers a basis of the right subspace and nothing else. The decoder’s columns need not be orthogonal or of unit length, the code’s coordinates may be correlated, and none comes first. On the four points, E=(4, 3)\mat E=(4,\,3) with D=(0.16,0.12)T\mat D=(0.16,0.12)^{\mathsf T} computes the same reconstructions as E=(0.8, 0.6)\mat E=(0.8,\,0.6) with D=(0.8,0.6)T\mat D=(0.8,0.6)^{\mathsf T}, and every one of its codes is five times larger (I.12.X01).

    Training does pick one member of the family, and the data do not decide which. Under gradient descent with a vanishing step size, EET−DTD\mat E\mat E^{\mathsf T}-\mat D^{\mathsf T}\mat D does not change: by (I.12.2), ddt(EET)\frac{d}{dt}(\mat E\mat E^{\mathsf T}) and ddt(DTD)\frac{d}{dt}(\mat D^{\mathsf T}\mat D) are the same matrix. Du, Hu and Lee (2018) prove invariances of this kind between adjacent layers of deep homogeneous networks. The factorisation reached is therefore fixed by the imbalance between the two matrices at initialisation.

    To read principal components off a trained linear autoencoder, orthonormalise the decoder’s columns into Q\mat Q, form the k×kk\times k matrix QTSQ\mat Q^{\mathsf T}\mat S\mat Q and diagonalise it. Or change the objective so that the freedom is not there.

    Weight decay removes most of the freedom

    Add the penalty γ(∥E∥F2+∥D∥F2)\gamma(\|\mat E\|_F^2+\|\mat D\|_F^2) of I.8. The stationarity conditions become (I−DE)SET=γD(\mat I-\mat D\mat E)\mat S\mat E^{\mathsf T}=\gamma\mat D and DT(I−DE)S=γE\mat D^{\mathsf T}(\mat I-\mat D\mat E)\mat S=\gamma\mat E. Multiply the first on the left by DT\mat D^{\mathsf T} and the second on the right by ET\mat E^{\mathsf T}. The left-hand sides agree, so for γ>0\gamma>0, DTD=EET\mat D^{\mathsf T}\mat D=\mat E\mat E^{\mathsf T} at every stationary point. Kunin, Bloom, Goeva and Seed (2019) prove more: every stationary point has E=DT\mat E=\mat D^{\mathsf T}, and for γ<λk\gamma<\lambda_k the minima are

    D=Ukdiag⁡ ⁣(1−γ/λi)OT,E=DT,DE=Ukdiag⁡(1−γ/λi) UkT,\begin{aligned} \mat D&=\mat U_k\operatorname{diag}\!\Big(\sqrt{1-\gamma/\lambda_i}\Big) \mat O^{\mathsf T},\\ \mat E&=\mat D^{\mathsf T},\\ \mat D\mat E&=\mat U_k\operatorname{diag}(1-\gamma/\lambda_i)\, \mat U_k^{\mathsf T}, \end{aligned}
    (I.12.6)

    Weight decay shrinks each direction and leaves only a rotation of the code.

    with O\mat O any orthogonal k×kk\times k matrix. The family has shrunk from all invertible G\mat G to rotations of the code. When the kept eigenvalues are distinct, so are the singular values 1−γ/λi\sqrt{1-\gamma/\lambda_i} of the decoder. Its left singular vectors are then u1,…,uk\vec u_1,\ldots,\vec u_k in order, and the axes can be read from the decoder alone.

    The price is in the last line of (I.12.6). The end-to-end map is no longer a projection: each kept direction is shrunk by 1−γ/λi1-\gamma/\lambda_i, a weak one more than a strong one. I.12.X06 verifies that (I.12.6) is stationary and evaluates it.

    Every other stationary point is a saddle

    Take any kk eigenvectors of S\mat S, not necessarily the first, as the columns of UI\mat U_I, and set D=UI\mat D=\mat U_I, E=UIT\mat E=\mat U_I^{\mathsf T}. Then (I−DE)SUI=0(\mat I-\mat D\mat E)\mat S\mat U_I=\mat 0 and UIT(I−DE)=0\mat U_I^{\mathsf T}(\mat I-\mat D\mat E)=\mat 0, so both gradients in (I.12.2) vanish. The loss there is the sum of the eigenvalues left out.

    Such a point is not a minimum unless it is the principal subspace. Suppose uj\vec u_j is included, um\vec u_m is not, and λm>λj\lambda_m>\lambda_j. Replace uj\vec u_j by cos⁡θ uj+sin⁡θ um\cos\theta\,\vec u_j+\sin\theta\,\vec u_m. The subspace stays kk-dimensional and the loss changes by −(λm−λj)sin⁡2θ-(\lambda_m-\lambda_j)\sin^2\theta, which is negative for every small θ≠0\theta\neq0. Scaling the decoder up instead raises the loss. A point with a way down and a way up is a saddle. Baldi and Hornik (1989) show that for full-rank S\mat S with distinct eigenvalues there are no other stationary points of rank kk beyond these and their G\mat G-families. This is I.12.T2: the loss surface of a linear autoencoder has no local minimum that is not global.

    It promises the destination and not the schedule. Near a saddle the gradient is small, and the escape is slower the closer the start. On the four points, begin half a unit along u2\vec u_2 with a tilt of 10−610^{-6} towards u1\vec u_1, at step size 0.010.01. The loss sits within 0.010.01 of the saddle’s value 44 from step 8282 to step 273273, and reaches 1.011.01 only at step 513513. With a tilt of 10−310^{-3} it has left by step 8585. Saxe, McClelland and Ganguli (2014) solve these dynamics exactly for deep linear networks: long plateaus, then rapid drops, with the stronger directions learned first.

    A linear decoder caps the autoencoder at this bound

    The projection step used nothing about the encoder except that it could produce the best code. So make the encoder anything at all, deep and nonlinear, and keep an affine decoder g(z)=Dz+cg(\vec z)=\mat D\vec z+\vec c. Every reconstruction lies in the flat c+col⁡(D)\vec c+\operatorname{col}(\mat D), of dimension at most kk. For centred data, the mean squared distance to that flat is the mean squared distance to the parallel subspace through the origin plus the squared distance of c\vec c from that subspace, so it is at least λk+1+⋯+λd\lambda_{k+1}+\cdots+\lambda_d. A nonlinear encoder in front of a linear decoder cannot beat principal components on the training loss.

    To bend the reconstruction surface, the decoder must be nonlinear. Hinton and Salakhutdinov (2006) trained a 784784-10001000-500500-250250-3030 autoencoder on images of handwritten digits, pretrained one layer at a time, with logistic units throughout except for a linear code. On test images they report an average squared error of 3.003.00 per image, against 13.8713.87 for principal components with the same thirty numbers. Proposition 3 takes up what else has to be controlled once the decoder has that freedom.

    Train one and watch the product

    This script runs gradient descent on (I.12.2) for the four points, from a deliberately unbalanced start:

    S = [[2.92, 1.44], [1.44, 2.08]]          # covariance of the four points
    e, d = [1.0, 0.0], [0.2, 0.0]             # encoder row, decoder column
    
    def loss_and_grads(e, d):
        r = [[(i == j) - d[i]*e[j] for j in range(2)] for i in range(2)]   # I - DE
        rs = [[r[i][0]*S[0][j] + r[i][1]*S[1][j] for j in range(2)] for i in range(2)]
        loss = sum(rs[i][j]*r[i][j] for i in range(2) for j in range(2))
        gd = [-2*(rs[i][0]*e[0] + rs[i][1]*e[1]) for i in range(2)]
        ge = [-2*(d[0]*rs[0][j] + d[1]*rs[1][j]) for j in range(2)]
        return loss, ge, gd
    
    for step in range(4000):
        loss, ge, gd = loss_and_grads(e, d)
        e = [a - 0.01*g for a, g in zip(e, ge)]
        d = [a - 0.01*g for a, g in zip(d, gd)]
    print(round(loss, 6), [round(d[i]*e[j], 4) for i in range(2) for j in range(2)])
    print([round(v, 4) for v in e], [round(v, 4) for v in d])

    It prints a loss of 1.0 and the product [0.64, 0.48, 0.48, 0.36], which is u1u1T\vec u_1\vec u_1^{\mathsf T}. The factors are [1.0048, 0.7536] and [0.6369, 0.4777]: both point along (0.8,0.6)(0.8,0.6), and neither is that vector. The imbalance ∥E∥2−∥D∥2\|\mat E\|^2-\|\mat D\|^2 began at 0.960.96 and ends at 0.94380.9438, moved only by the finite step size. The product is determined by the data. The factors remember where they started.

    Sources