Md. Asif Uddin
    Problem I.12.B02

    The minimum of a linear autoencoder, step by step

    symbolic▲▲▲

    Exact values where possible; six decimal places otherwise.

    STATEMENT

    Prove that the smallest loss of a linear autoencoder is the sum of the discarded eigenvalues, find every pair of matrices that attains it, and evaluate the result on four points.

    GIVEN

    Centred data with covariance S=∑i=1dλiuiuiT\mat S=\sum_{i=1}^d\lambda_i\vec u_i\vec u_i^{\mathsf T}, where λ1≥⋯≥λd>0\lambda_1\geq\cdots\geq\lambda_d>0 and the ui\vec u_i are orthonormal. The loss is the first line of (I.12.2), with E∈Rk×d\mat E\in\R^{k\times d}, D∈Rd×k\mat D\in\R^{d\times k} and k<dk<d. Assume λk>λk+1\lambda_k>\lambda_{k+1}. For the numbers, use the four points of I.12.B01 with k=1k=1.

    FIND

    (a) The best encoder for a fixed decoder, and the end-to-end map it gives. (b) The loss of that map in terms of an orthonormal basis. (c) The lower bound and the condition for equality. (d) All minimising pairs. (e) The eigenvalues, the optimal map, its loss and two different factorisations for the four points. (f) The other stationary projection and a path that leaves it downhill.

    STRATEGY

    Reduce pairs of matrices to subspaces by solving for the encoder. Then write the retained variance as a weighted sum of eigenvalues and bound the weights.

    SOLUTION

    (a) Fix D\mat D with independent columns. For one input, the derivative of ∥x−Dz∥2\|\vec x-\mat D\vec z\|^2 with respect to z\vec z is −2DT(x−Dz)-2\mat D^{\mathsf T}(\vec x-\mat D\vec z). It vanishes at

    z=(DTD)−1DTx,\vec z=(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T}\vec x,

    which is the unique minimum because DTD\mat D^{\mathsf T}\mat D is positive definite. The same matrix serves every input, so E=(DTD)−1DT\mat E=(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T} and

    DE=D(DTD)−1DT=P.\mat D\mat E=\mat D(\mat D^{\mathsf T}\mat D)^{-1}\mat D^{\mathsf T}=\mat P.

    Direct multiplication gives P2=P\mat P^2=\mat P and PT=P\mat P^{\mathsf T}=\mat P: the orthogonal projection onto the columns of D\mat D. No other encoder gives any input a better code, so no encoder has a smaller loss than P\mat P. Because λd>0\lambda_d>0 the data span every direction, and a different encoder gives some of them a strictly worse one.

    (b) Choose Q∈Rd×k\mat Q\in\R^{d\times k} with orthonormal columns spanning the same subspace. Then P=QQT\mat P=\mat Q\mat Q^{\mathsf T}, and I−P\mat I-\mat P is symmetric with (I−P)2=I−P(\mat I-\mat P)^2=\mat I-\mat P. Moving one factor around the trace,

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

    This is (I.12.4).

    (c) Substitute the eigendecomposition:

    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}

    Since QQT\mat Q\mat Q^{\mathsf T} is a projection and ui\vec u_i a unit vector, 0≤ci≤10\leq c_i\leq1. Since the ui\vec u_i are an orthonormal basis, ∑ici=tr⁡(QTQ)=k\sum_ic_i=\operatorname{tr}(\mat Q^{\mathsf T}\mat Q)=k. Therefore ∑i≤k(1−ci)=∑i>kci\sum_{i\leq k}(1-c_i)=\sum_{i>k}c_i, and

    ∑i≤kλi−∑i=1dλici  =∑i≤kλi(1−ci)−∑i>kλici  ≥λk∑i≤k(1−ci)  −λk+1∑i>kci  =(λk−λk+1)∑i>kci  ≥0.\begin{aligned} &\sum_{i\leq k}\lambda_i-\sum_{i=1}^d\lambda_ic_i\\ &\;=\sum_{i\leq k}\lambda_i(1-c_i) -\sum_{i>k}\lambda_ic_i\\ &\;\geq\lambda_k\sum_{i\leq k}(1-c_i)\\ &\;\quad-\lambda_{k+1}\sum_{i>k}c_i\\ &\;=(\lambda_k-\lambda_{k+1})\sum_{i>k}c_i\\ &\;\geq0. \end{aligned}

    So the retained variance is at most λ1+⋯+λk\lambda_1+\cdots+\lambda_k, and

    L≥∑i>kλi.\mathcal L\geq\sum_{i>k}\lambda_i.

    Because λk>λk+1\lambda_k>\lambda_{k+1}, equality requires ci=0c_i=0 for every i>ki>k, hence ci=1c_i=1 for every i≤ki\leq k. A unit vector whose projection has length one lies in the subspace. The subspace is therefore the span of u1,…,uk\vec u_1,\ldots,\vec u_k, and P=UkUkT\mat P=\mat U_k\mat U_k^{\mathsf T}.

    (d) A decoder attains the bound exactly when its columns span that subspace, that is, D=UkG\mat D=\mat U_k\mat G with G=UkTD\mat G=\mat U_k^{\mathsf T}\mat D invertible. By (a) the encoder must then be

    E=(GTG)−1GTUkT=G−1UkT.\begin{aligned} \mat E&=(\mat G^{\mathsf T}\mat G)^{-1}\mat G^{\mathsf T}\mat U_k^{\mathsf T}\\ &=\mat G^{-1}\mat U_k^{\mathsf T}. \end{aligned}

    Every invertible G\mat G gives a minimiser, and these are all of them. This is (I.12.5).

    A decoder of rank below kk spans fewer than kk dimensions. Its retained variance is at most λ1+⋯+λk−1\lambda_1+\cdots+\lambda_{k-1}, which is strictly less because λk>0\lambda_k>0.

    (e) For the four points, S\mat S has trace 55 and determinant 2.92⋅2.08−1.442=42.92\cdot2.08-1.44^2=4, so its eigenvalues solve λ2−5λ+4=0\lambda^2-5\lambda+4=0: they are 44 and 11. Solving (S−4I)u=0(\mat S-4\mat I)\vec u=\vec 0 gives u1=(0.8,0.6)\vec u_1=(0.8,0.6), and then u2=(−0.6,0.8)\vec u_2=(-0.6,0.8). With k=1k=1,

    DE=u1u1T=[0.640.480.480.36],L=λ2=1.\begin{aligned} \mat D\mat E&=\vec u_1\vec u_1^{\mathsf T} =\begin{bmatrix}0.64&0.48\\0.48&0.36\end{bmatrix},\\ \mathcal L&=\lambda_2=1. \end{aligned}

    For the point (1,2)(1,2) the code under G=1\mat G=1 is 0.8+1.2=20.8+1.2=2, the reconstruction is (1.6,1.2)(1.6,1.2) and the residual is (−0.6,0.8)(-0.6,0.8), of squared length 11. The same holds at every corner.

    Two factorisations of the same map: G=1\mat G=1 gives D=(0.8,0.6)T\mat D=(0.8,0.6)^{\mathsf T} and E=(0.8, 0.6)\mat E=(0.8,\,0.6). G=1/5\mat G=1/5 gives D=(0.16,0.12)T\mat D=(0.16,0.12)^{\mathsf T} and E=(4, 3)\mat E=(4,\,3).

    (f) Setting D=u2\mat D=\vec u_2 and E=u2T\mat E=\vec u_2^{\mathsf T} makes both gradients of (I.12.2) vanish, with loss λ1=4\lambda_1=4. Rotate the direction to cos⁡θ u2+sin⁡θ u1\cos\theta\,\vec u_2+\sin\theta\,\vec u_1. By (b) the loss is 5−(cos⁡2θ+4sin⁡2θ)=4−3sin⁡2θ5-(\cos^2\theta+4\sin^2\theta)=4-3\sin^2\theta. At θ=0.1\theta=0.1 it is 3.9701003.970100. The point is stationary and is not a minimum.

    Answer

    The minimum is ∑i>kλi\sum_{i>k}\lambda_i, attained exactly by D=UkG\mat D=\mat U_k\mat G, E=G−1UkT\mat E=\mat G^{-1}\mat U_k^{\mathsf T} for invertible G\mat G. For the four points the eigenvalues are 44 and 11, the optimal map is [0.640.480.480.36]\begin{bmatrix}0.64&0.48\\0.48&0.36\end{bmatrix} and the loss is 11. The projection onto u2\vec u_2 is a saddle with loss 44.

    Check — sanity

    The optimal map has trace 11, the dimension of the subspace, and squares to itself: its first entry is 0.642+0.482=0.640.64^2+0.48^2=0.64. The retained variance 44 and the loss 11 add to the total 55.

    Where this breaks

    With λk=λk+1\lambda_k=\lambda_{k+1} the last step fails: weight can move between the tied directions without changing the sum, and the optimal subspace is not unique (I.12.X05). With a zero eigenvalue the encoder is determined only on the directions in which the data vary. With uncentred data S\mat S is not a covariance and the subspace found is a different one (I.12.X03).

    Variation

    The script scans 36003600 directions and confirms that the loss of the projection onto each lies between 11 and 44, the two eigenvalues. For k=dk=d the bound is an empty sum: the loss is 00 and the map is the identity (I.12.X04).

    Draws on