Proposition 3I.12.P0342 of 100 in the corpus
Noise, contraction and sparsity do a bottleneck's work without narrowing the code.
Each makes copying suboptimal in its own way. For a linear map every one of them is a gain on each principal direction, and the best possible denoiser moves a corrupted point towards higher density.
Three ways to refuse the copy
With the identity is available, and by proposition 1 it is optimal. Three classical changes to the objective each make it suboptimal without narrowing the code.
- Corrupt the input and keep the clean target. This is the denoising autoencoder of Vincent, Larochelle, Bengio and Manzagol (2008).
- Penalise how sharply the code responds to its input. This is the contractive autoencoder of Rifai and colleagues (2011).
- Penalise the size of the code. This is sparse coding in the form Olshausen and Field (1996) gave it.
Each is a regulariser in the sense of I.8: among many maps that reconstruct well, it decides which one is chosen. For a linear autoencoder the choice has an exact description. Every one of these methods multiplies each principal direction of the data by a gain between zero and one. The figure shows the gains for the four points of this chapter, whose eigenvalues are and . A bottleneck cuts. The others shrink.
Noise turns reconstruction into shrinkage
Corrupt each input as , where is independent of with mean zero and covariance . Train a linear map to return the clean input. Expanding the square, the cross term between and has mean zero, and :
Input noise is a ridge penalty on the end-to-end map.
The first identity is the clean reconstruction loss plus weight decay of strength on the end-to-end map. Only the mean and covariance of the noise were used. The second sets the gradient to zero.
No bottleneck appears in (I.12.7), and the optimum is still not the identity. A direction with passes almost unchanged. A direction with is nearly removed, because there the corrupted input is mostly noise. Principal components make a hard cut at position ; noise makes a soft one at the scale . With a bottleneck as well, the optimum keeps the top directions and shrinks them by the same gains. I.12.B03 works both cases and the two limits: as the map returns to the identity, and as it outputs the mean.
The best denoiser points uphill in density
Drop linearity. Among all functions , the expected squared error is minimised by a conditional mean, , by the result of I.4 for squared error.
For Gaussian noise that mean has a second form. Write for the density of the noise, a Gaussian with mean zero and covariance . The corrupted data have density . Differentiating with respect to multiplies it by , so
Dividing by gives
The best denoiser moves a corrupted point up the noised density.
This is I.12.T3. Statisticians know it as Tweedie’s formula (Efron 2011). Vincent (2011) and Alain and Bengio (2014) read it for autoencoders: the displacement of the best denoiser is times the score of the noised density. A denoising autoencoder trained to its optimum has therefore estimated a vector field that points from every corrupted input towards higher density. It has learned something about the distribution without writing a density down. Models that generate by denoising repeatedly start from this identity.
For Gaussian data, (I.12.8) is (I.12.7) again. The noised density is , its score is , and
The identity also explains a familiar defect. If the clean input is or with equal probability, the best denoiser is (I.12.X08). At it returns , which is not a possible input. A conditional mean of two sharp alternatives lies between them. Squared-error reconstructions of ambiguous inputs are blurred for this reason, and no amount of training removes it.
The corruption need not be additive. Vincent and colleagues (2008) set a random subset of the input’s coordinates to zero. The best reconstruction is still a conditional mean, of the hidden coordinates given the visible ones, but (I.12.8) no longer applies. Predicting the hidden part of an input from the rest is the same objective with deletion as the corruption.
A penalty on the Jacobian says it directly
The contractive autoencoder adds at every training point, where is the encoder’s Jacobian. For a sigmoid code the Jacobian is , so the penalty is with the -th row of . It costs one pass over the weights.
Noise imposes nearly the same thing on the whole reconstruction map . Expand to first order as . As in (I.12.7),
near the optimum, where the second-order term of the expansion is multiplied by the small residual and drops out at this order (Bishop 1995; Alain and Bengio 2014). For a linear map the relation is exact and is the first identity of (I.12.7).
So the two methods differ in what they flatten. Denoising penalises the Jacobian of the reconstruction; the contractive penalty acts on the code. Both pull against the reconstruction term, which needs the map to vary along the data in order to tell examples apart. The compromise is a map that responds to movement along the data and ignores movement away from it.
Sparsity needs a fixed decoder scale
A sparse autoencoder adds to the loss, usually with more code units than inputs, so that each input is rebuilt from a few active units out of many. Its effect is visible in one coordinate. For a target , minimise . For the derivative vanishes at , which is positive only if . The negative side is symmetric, and otherwise is best:
An L1 penalty zeroes small codes and shortens the rest.
Two things follow from (I.12.9). Codes below the threshold are exactly zero, which is the sparsity. Every surviving code is shortened by , which is a bias in its amplitude.
The penalty is only meaningful if the decoder cannot undo it. Divide the encoder by a constant and multiply the decoder by . Every reconstruction is unchanged and the penalty falls by the factor . As grows the objective approaches the unpenalised loss without reaching it, and the penalty has bought nothing but large weights. The remedy is to hold every decoder column at unit norm, or to weight each by the norm of its column. I.12.X07 computes both sides. The same scaling defeats a contractive penalty when the decoder is free. Rifai and colleagues tie the weights, noting that this rules out a contracting encoder paired with an expanding decoder.
Makhzani and Frey (2013) replace the penalty by a hard rule: keep a fixed number of the largest code coordinates and zero the rest. That gives sparsity without the shortening of (I.12.9).
Width is not capacity
All of these control the map and not only the code. One more quantity needs control, and it is the oldest in the book.
A decoder with enough freedom can pass its reconstruction surface through every training point, however narrow the code. In I.12.B04 a width-one code and a decoder with two ReLU kinks reconstruct all four training points exactly: training loss , against for the principal axis. On a held-out point from the same rectangle the order reverses, with a squared error of against .
A bottleneck bounds the dimension of the surface. The size of the encoder and decoder, and the amount of data, bound how it bends. Reconstruction error is a training loss like any other, and by I.1 it must be read on held-out data.
Reproduce the gains
lam = (4.0, 1.0) # eigenvalues of the four-point covariance
noise, decay = 1.0, 0.5
rows = {
"bottleneck k=1": [1.0, 0.0],
"noise": [l/(l + noise) for l in lam],
"weight decay": [1 - decay/l for l in lam],
}
for name, gains in rows.items():
error = sum((1 - g)**2*l for g, l in zip(gains, lam))
print(f"{name}: gains {gains}, clean error {error:.4f}")
It prints gains , and , with clean reconstruction errors , and . The noise row is (I.12.7) and the weight-decay row is (I.12.6). A map with gains leaves the error on clean inputs. The two shrinking methods reconstruct the training data better than the bottleneck does, and neither has learned to copy.
Sources
- Extracting and Composing Robust Features with Denoising Autoencoders
- A Connection Between Score Matching and Denoising Autoencoders
- What Regularized Auto-Encoders Learn from the Data-Generating Distribution
- Training with Noise is Equivalent to Tikhonov Regularization
- Tweedie's Formula and Selection Bias
- Contractive Auto-Encoders: Explicit Invariance During Feature Extraction
- Emergence of simple-cell receptive field properties by learning a sparse code for natural images
- k-Sparse Autoencoders
Depends on
- I.12.P01 — An autoencoder is supervised learning whose target is its own input.
- I.12.P02 — A linear autoencoder finds the principal subspace, and not its axes.
- I.8.P01 — Regularisation does not improve the fit; it decides which fit you get.
- I.4.P02 — Every loss is the negative log-likelihood of some noise model, said or not.
Used by
Problems using this
- I.12.B03 — How much noise, how much shrinkagelimit▲▲△
- I.12.B04 — A width-one code that memorisescounterexample▲▲△
- I.12.X07 — A penalty on the code can be scaled awaycounterexample▲▲△
- I.12.X08 — The best denoiser returns a conditional meanprobability▲▲△