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.
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 , which has rank at most :
Assume the data are centred, so that is their covariance (I.12.X03 shows what happens otherwise). Write its eigendecomposition (Rank, eigenvalues and the singular value decomposition 0.LA.04) as with and orthonormal . Let hold the first eigenvectors as columns. Which of rank at most 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 in (I.12.2) gives , which is solved by the first line below whenever the code covariance is invertible.
Fix the decoder, with independent columns. For one input, the code that minimises is the least-squares solution . It is linear in , so a linear encoder can produce the best code for every input at once.
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,
the orthogonal projection onto the column space of (Projections and orthogonality 0.LA.05): and . 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 -dimensional subspaces.
The loss of a projection is the variance it drops
Let the columns of be an orthonormal basis of the subspace, so . Since is also a symmetric projection, the cyclic property of the trace gives
A projection's loss is the variance it fails to keep.
Here is the total variance of the data and is the total variance of the codes . By (I.12.4), minimising reconstruction error and maximising retained variance are one problem.
Now expand in the eigenbasis:
Each is the squared length of the projection of a unit vector, so . They sum to , because the form an orthonormal basis. A weighted sum of the with weights between zero and one that total is largest when weight one sits on the largest. Hence the retained variance is at most . If , equality forces for , which places every one of inside the subspace.
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 and : the best width-one autoencoder projects onto that line and its loss is exactly .
The result has an older name. With the centred data matrix, its right singular vectors are the and for singular values . The reconstruction is the best approximation of of rank 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 of size , since cancels in the product. The loss cannot tell these factorisations apart, so the minimum is a family with 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, with computes the same reconstructions as with , 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, does not change: by (I.12.2), and 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 , form the matrix and diagonalise it. Or change the objective so that the freedom is not there.
Weight decay removes most of the freedom
Add the penalty of I.8. The stationarity conditions become and . Multiply the first on the left by and the second on the right by . The left-hand sides agree, so for , at every stationary point. Kunin, Bloom, Goeva and Seed (2019) prove more: every stationary point has , and for the minima are
Weight decay shrinks each direction and leaves only a rotation of the code.
with any orthogonal matrix. The family has shrunk from all invertible to rotations of the code. When the kept eigenvalues are distinct, so are the singular values of the decoder. Its left singular vectors are then 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 , 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 eigenvectors of , not necessarily the first, as the columns of , and set , . Then and , 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 is included, is not, and . Replace by . The subspace stays -dimensional and the loss changes by , which is negative for every small . 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 with distinct eigenvalues there are no other stationary points of rank beyond these and their -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 with a tilt of towards , at step size . The loss sits within of the saddle’s value from step to step , and reaches only at step . With a tilt of it has left by step . 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 . Every reconstruction lies in the flat , of dimension at most . 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 from that subspace, so it is at least . 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 ---- 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 per image, against 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
. The factors are
[1.0048, 0.7536] and [0.6369, 0.4777]: both
point along , and neither is that vector. The imbalance
began at and ends at , moved
only by the finite step size. The product is determined by the data. The
factors remember where they started.
Sources
- Neural networks and principal component analysis: Learning from examples without local minima
- The Approximation of One Matrix by Another of Lower Rank
- Auto-association by multilayer perceptrons and singular value decomposition
- Loss Landscapes of Regularized Linear Autoencoders
- Algorithmic Regularization in Learning Deep Homogeneous Models: Layers are Automatically Balanced
- Exact solutions to the nonlinear dynamics of learning in deep linear neural networks
- Reducing the Dimensionality of Data with Neural Networks
Depends on
Used by
- I.12.P03 — Noise, contraction and sparsity do a bottleneck's work without narrowing the code.
- I.12.P04 — Reconstruction error measures distance to a surface, and certifies nothing else.
- I.13.P01 — A latent-variable model explains each observation by a code it never sees, and its likelihood is an integral over every code.
Problems using this
- I.12.B01 — Keep one coordinate, then repair each halfnumeric▲△△
- I.12.B02 — The minimum of a linear autoencoder, step by stepsymbolic▲▲▲
- I.12.X01 — A code has no unitsnumeric▲△△
- I.12.X03 — Centre the data, or the code spends itself on the meannumeric▲▲△
- I.12.X05 — A flat spectrum cannot be compressedlimit▲▲△
- I.12.X06 — Weight decay fixes the axessymbolic▲▲▲
- I.BOOK.B08 — Depth adds nothing to a linear autoencoderproof▲▲▲