AI Wiki中文/EN

Denoising autoencoders: corrupt the input, keep the target clean

去噪自编码器

Derive and train the optimal linear denoiser under correlated signal and independent noise, with a closed-form numerical check.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Start with the problem

An ordinary autoencoder can copy its input. A denoising autoencoder receives a corrupted input but must reconstruct the original clean one. The corruption changes what a useful solution must do: it must exploit regularities that survive the damage.

Vincent and colleagues describe this clean-target training rule and stacked versions. Deep Learning Chapter 14 places it among regularized autoencoders. Our example removes architectural distractions: a trainable full-rank linear map learns to denoise correlated two-dimensional data without a compressed bottleneck.

Definitions and derivation

Let clean signal and additive noise be independent, centered random vectors. Their covariance assumptions and half-MSE objective are:

x~=x+ε,E[x]=E[ε]=0,Cov⁡(x)=C,Cov⁡(ε)=νI,x⊥ε,L(W)=12E∥Wx~−x∥2.\widetilde x=x+\varepsilon,\quad \mathbb E[x]=\mathbb E[\varepsilon]=0,\quad \operatorname{Cov}(x)=C,\quad \operatorname{Cov}(\varepsilon)=\nu I,\quad x\perp\varepsilon,\qquad L(W)=\tfrac12\mathbb E\|W\widetilde x-x\|^2.

The reconstruction target is x, not x̃. Changing the target to x̃ would reward copying noise too. Independence removes the cross term when expanding the expected quadratic loss:

L(W)=12tr⁡[(W−I)C(W−I)⊤+νWW⊤],∇WL=W(C+νI)−C,W∗=C(C+νI)−1.L(W)=\tfrac12\operatorname{tr}\big[(W-I)C(W-I)^\top+\nu WW^\top\big],\quad \nabla_WL=W(C+\nu I)-C,\quad W_*=C(C+\nu I)^{-1}.

Here ν is a variance, not a standard deviation. The inverse exists when C+νI is positive definite, as in our example; the zero-noise case also works because our C is nonsingular. Solving a linear system is preferable to explicitly forming an inverse in code. This solution is the best linear denoiser under the stated second moments. If signal and noise are jointly Gaussian, it is also the conditional mean and minimizes MSE over all measurable predictors; without that distributional assumption, the all-predictor claim does not follow from covariance alone.

Diagonalize the signal covariance to see what the denoiser retains:

C=Qdiag⁡(λi)Q⊤⟹W∗=Qdiag⁡ ⁣(λiλi+ν)Q⊤.C=Q\operatorname{diag}(\lambda_i)Q^\top\quad\Longrightarrow\quad W_*=Q\operatorname{diag}\!\left(\frac{\lambda_i}{\lambda_i+\nu}\right)Q^\top.

Directions with large signal variance relative to noise shrink less. The code uses C with diagonal one and off-diagonal 0.8, whose eigenvalues are 0.2 and 1.8. At noise variance 0.25, shrinkage factors are 0.444444444 and 0.878048780. The common-coordinate direction is more reliable than the difference direction. Consequently an observed point (1,0) reconstructs with a nonzero second coordinate: the learned correlation supplies information.

The expected objective is integrated analytically here, so there is no random noise sample or Monte Carlo error in training. A usual nonlinear DAE instead samples corruptions and trains encoder and decoder parameters with minibatches. Our four-parameter linear network can be factored into a two-dimensional identity encoder and learned decoder, but it is not the original stacked nonlinear architecture.

Closed-form optimal denoising scales computed from the article covariance. At equal noise variance, the weaker signal direction is shrunk more. ν denotes variance, not standard deviation; the curves are not measured image quality.
Closed-form optimal denoising scales computed from the article covariance. At equal noise variance, the weaker signal direction is shrunk more. ν denotes variance, not standard deviation; the curves are not measured image quality.

Run the calculation

Run Python 3.12 with NumPy 1.26.4:

import numpy as np

COV=np.array([[1.,.8],[.8,1.]])


def objective(weight,noise=.25):
    w=np.asarray(weight,dtype=float)
    if w.shape!=(2,2) or not np.isfinite(w).all() or not np.isfinite(noise) or noise<0:raise ValueError('Use a finite 2x2 map and nonnegative isotropic noise variance.')
    residual=w-np.eye(2);loss=.5*np.trace(residual@COV@residual.T+noise*w@w.T)
    return float(loss),w@(COV+noise*np.eye(2))-COV


def optimum(noise=.25):return np.linalg.solve(COV+noise*np.eye(2),COV).T


def train(noise=.25):
    w=np.eye(2)
    for _ in range(200):w-=.2*objective(w,noise)[1]
    return w


if __name__ == '__main__':
    w=train();ref=optimum();print('trained denoising map',w.round(9).tolist(),'closed-form discrepancy',float(np.max(np.abs(w-ref))))
    print('identity / denoising expected half-MSE',objective(np.eye(2))[0],round(objective(w)[0],9))
    eigen=np.linalg.eigvalsh(COV);print('signal eigenvalues',eigen.round(9).tolist(),'shrinkage',(eigen/(eigen+.25)).round(9).tolist())
    print('corrupted input (1,0) reconstruction',(w@np.array([1.,0])).round(9).tolist(),'zero-noise optimum',optimum(0).round(9).tolist())

Actual output:

trained denoising map [[0.661246614, 0.216802166], [0.216802166, 0.661246614]] closed-form discrepancy 1.786388703628461e-09
identity / denoising expected half-MSE 0.25 0.165311653
signal eigenvalues [0.2, 1.8] shrinkage [0.444444444, 0.87804878]
corrupted input (1,0) reconstruction [0.661246614, 0.216802166] zero-noise optimum [[1.0, 0.0], [0.0, 1.0]]

Two hundred steps give a map within 1.79×10⁻⁹ of the closed form. Expected half-MSE falls from the identity map’s 0.25 to 0.165311653. The reconstructed (1,0) is approximately (0.661246614,0.216802166). With zero corruption the optimum returns to identity. These are expected errors under the specified covariance model, not measured image-denoising scores.

In d dimensions, dense evaluation of this expected objective uses matrix products; a direct linear solve costs O(d³), while applying a learned dense map costs O(d²) per example. A learned nonlinear encoder has different costs. Validation on real noisy data must use a corruption model and clean reference appropriate to the intended application.

When the method fails

Denoising learns the regularities favored by its corruption process. A model trained on independent Gaussian noise may not repair missing blocks, systematic bias or unfamiliar sensor artifacts. Excessive corruption can remove information needed for the target, while weak corruption can permit near-copying.

Good denoising does not prove that the latent code supports a particular downstream task, nor does one denoising map automatically define a normalized generative model. Avoid corrupting evaluation targets or fitting preprocessing on held-out clean labels. Compare with the noisy-input identity baseline and a simple model matched to the noise assumptions.

Exercises with answers

  1. Which input is used as the reconstruction target?

Answer 1: The original clean x; the encoder receives its corrupted version.

  1. Does ν=0.25 mean noise standard deviation 0.25?

Answer 2: No. ν is variance; the corresponding standard deviation is 0.5.

  1. Why is the difference direction shrunk more?

Answer 3: Its signal eigenvalue 0.2 is smaller relative to the same noise variance than the common direction’s 1.8.

  1. When is this also the unrestricted MSE-optimal predictor?

Answer 4: When the joint Gaussian assumptions make the conditional mean equal to this linear covariance formula.

Sources and next steps

Vincent et al. physical page 9, Section 3.1, defines corrupted input with clean reconstruction and resampled corruption. Chapter 14 supplies the distinction between architectural and regularization constraints. The covariance calculation and spectral shrinkage are original derivations under explicit assumptions. Continue with sparse autoencoders and contractive autoencoders for two different regularizers.

Make a prediction, then check

What is the target in denoising-autoencoder training?

Choose one answer

Learning objectives

  • Derive the expected denoising objective and its optimum.
  • Separate a linear covariance solution from a general conditional-mean claim.

Prerequisites & connections

Explore related knowledge →

References

  1. Stacked Denoising Autoencoders: Learning Useful Representations in a Deep Network with a Local Denoising Criterion
    Pascal Vincent; Hugo Larochelle; Isabelle Lajoie; Yoshua Bengio; Pierre-Antoine Manzagol · 2010
  2. Deep Learning — Chapter 14: Autoencoders
    Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-07 · Codex single-AI-author technical check: primary-source scope, explicit assumptions, original calculations, independent mathematical references and bilingual tests; not independent human or second-agent review.

  • Single-AI-author technical check: bounded primary-source reading, explicit assumptions, original calculations, runnable examples and matching bilingual equations, code and exercises. Not an independent human or second-agent review.
  • Four focused CPython 3.12.4 checks passed per chapter: independent finite differences, exact covariance/binomial references, queue transitions, stopped versus full gradients, batch-normalization derivatives and collapse/rank counterexamples as applicable. All ten programs use NumPy 1.26.4. This scoped final record supersedes the generic carried-over checklist in the frozen metadata; original drafts are retained.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
  • Bilingual Matplotlib 3.9.1 charts use executed article functions: exact denoising scales, binomial expected InfoNCE bounds and actual trained cross-correlations. Both locale SVGs and samples are hash-bound. Variance, expectation, shared color scales and finite-optimization limits are explicit.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.