Foundations to Frontier
Tests
E. Deep Learning › E13 Autoencoders

Denoising autoencoder

A denoising autoencoder (Vincent and colleagues, 2008) is trained to recover clean inputs from corrupted copies: Gaussian noise, masked pixels or salt-and-pepper noise. It cannot simply copy its input, so even with a large code it must learn the structure of the data. Its reconstruction points from a noisy input back toward the data, which estimates the score (the gradient of log-density). That link leads directly to score matching and diffusion models, and masked training in BERT and MAE uses the same idea. This page covers corruption types, the denoising objective and the score connection. In the exercises you implement three corruptions, then train an overcomplete autoencoder on a curved 2-D surface in 20 dimensions. Trained plainly, it passed 76% of test noise straight through. Trained to denoise, it cut the error about 8 times, across three seeds.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learn by cleaning up

Instead of asking a network to copy its input, give it a damaged version (noisy, or with pieces blanked out) and ask for the original. To succeed, the network has to know what real data looks like, so it learns useful structure even when its code is large. The demo shows the kinds of damage used in training.

Autoencoder lab
A denoising autoencoder sees this corrupted pattern and is trained to output the clean one, so it must learn the structure of the data rather than copy its input.
Why engineers care

Denoising autoencoders clean sensor signals and images, fill in missing measurements, and learn robust features. The same principle powers diffusion models and masked pre-training.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A denoising autoencoder's input is…
  2. 2. Its target is…
  3. 3. Denoising prevents the network from…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Objective: minimise ‖g(f(x̃)) − x‖², where x̃ ~ q(x̃ | x) is a corrupted copy, drawn afresh each time.
  • Corruptions:
    • Gaussian noise x̃ = x + σε. Its expected energy is σ²D, so 0.3² × 20 = 1.8.
    • Masking: zero each entry with probability p, keeping a fraction 1 − p.
    • Salt-and-pepper: set a fraction p of entries to the minimum or maximum value.
  • Signal-to-noise ratio: 10 log₁₀(P_signal/P_noise) dB. Unit signal with σ = 0.3 gives 10 log₁₀(1/0.09) = 10.46 dB.
  • Clean-input cost: a denoiser slightly blurs clean inputs, a small price for robustness.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Noise energy for σ = 0.3 in 20 dimensions:
  2. 2. Masking with p = 0.25 keeps…
  3. 3. SNR for signal power 100 and noise power 1:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Denoising autoencoders in code

Exercise 1.

  • Gaussian, masking and salt-and-pepper corruption were implemented.
  • The Gaussian noise energy matched σ²D, and the masked fraction matched p.

Practice.

  • Corrupt each mini-batch on the fly with fresh noise: x_noisy = x + sigma * torch.randn_like(x) or a random mask.
  • Choose a corruption that matches the real faults (dropouts, sensor noise, occlusions).
  • Tune σ or p on a validation set. Too little corruption teaches copying; too much destroys the signal.
x_tilde = x * (torch.rand_like(x) > p)          # masking noise (or x + sigma * torch.randn_like(x))
loss = F.mse_loss(model(x_tilde), x)            # target is the CLEAN input
🐍 Exercise 1: corruption processes
Implement Gaussian, masking and salt-and-pepper corruption.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Noise should be drawn…
  2. 2. Too little corruption teaches…
  3. 3. BERT's masked training is a form of…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Learning the manifold.

  • Real data lies near a low-dimensional surface. Corruption pushes points off it, and the denoiser learns to map them back.
  • The denoiser therefore learns where the data is, which is exactly the structure we want, without needing a small code.

The score connection.

  • For small Gaussian noise, the optimal denoiser satisfies r(x) − x ≈ σ² ∇ log p(x) (Alain and Bengio, 2014).
  • So reconstruction minus input estimates the score of the data density. Training a denoiser is score matching (Vincent, 2011).
  • This is the foundation of score-based and diffusion generative models, which chain denoisers across noise levels.

Choosing the noise. The noise level sets the scale of structure learned: small noise captures fine detail near the data; large noise captures coarse structure. Diffusion models use all scales.

📝 Quick check (Level 3)
0/3 answered
  1. 1. r(x) − x for an optimal denoiser estimates…
  2. 2. Denoising training is equivalent to…
  3. 3. Diffusion models chain denoisers across…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Does denoising training stop an overcomplete autoencoder from copying?

History.

  • P. Vincent, H. Larochelle, Y. Bengio and P.-A. Manzagol, “Extracting and composing robust features with denoising autoencoders” (ICML 2008).
  • Stacked denoising autoencoders followed in JMLR 2010.
  • Vincent (2011) linked denoising to score matching, a link later central to diffusion models.

Exercise 2.

  • Data: 300 points on a curved 2-D surface in 20 dimensions, x = tanh(zA).
  • Model: an overcomplete autoencoder with 64 tanh units, larger than the input, trained for 1000 Adam steps with training noise σ = 0, 0.1, 0.3 or 0.6.
  • Test: 500 new surface points with noise σ = 0.3 (energy 1.8), measuring the distance of the output from the clean points.
training noise σ error on clean inputs error on noisy inputs (σ = 0.3)
0 (plain) 0.0003 1.375
0.1 0.0075 0.210
0.3 0.0246 0.173
0.6 0.0898 0.215
  • The plain overcomplete autoencoder copies: it reconstructs clean inputs almost perfectly but passes 76% of the test noise (1.375 of 1.8) straight through, because it has learned something close to the identity.
  • Denoising training removes most of the noise: with σ = 0.3 the error drops to 0.173, 7.9 times lower (10% of the noise energy remains). Seeds 1 and 2 gave 1.54 → 0.18 and 1.28 → 0.20.
  • The price is a slight blur on clean inputs (0.025 instead of 0.0003). Training noise matched to the test noise worked best; too much noise (0.6) over-smooths.
🐍 Exercise 2 (research): does denoising training stop an overcomplete autoencoder from copying?
Train overcomplete autoencoders with different training noise on a curved surface and measure how much test noise they remove.

Denoising in AI, robotics and aerospace

  • Sensor cleaning: denoising IMU, lidar and telemetry streams; filling dropped samples by training with masking noise.
  • Pre-training: masked language and image modelling (BERT, MAE) are denoising autoencoders at scale.
  • Generative models: diffusion models for images, trajectories and robot policies are built from denoisers.
  • Design lesson: choose the corruption to match the faults you expect, and set its strength on validation data.

References

  1. P. Vincent, H. Larochelle, Y. Bengio and P.-A. Manzagol (2008). “Extracting and composing robust features with denoising autoencoders.” Proc. ICML.
  2. P. Vincent (2011). “A connection between score matching and denoising autoencoders.” Neural Computation 23.
  3. G. Alain and Y. Bengio (2014). “What regularized auto-encoders learn from the data-generating distribution.” JMLR 15.