Deep autoencoders — training deep networks to learn compressed representations for dimensionality reduction (Hinton & Salakhutdinov, 2006).
Variational autoencoders (VAE) — a probabilistic framework that combines autoencoders with Bayesian inference to generate new samples (Kingma & Welling, 2014).
This chapter starts the generative-model block of the neural-networks part. The previous chapters focused mostly on architectures for prediction, classification, or representation learning on specific data structures. From here through GANs, diffusion models, and flow matching, the emphasis shifts toward models that learn a data distribution well enough to reconstruct, sample, or generate new realizations.
An autoencoder is a neural network trained to reconstruct its own input. This may sound pointless — why predict something you already have? The key is that the network is forced through a bottleneck: a narrow hidden layer with far fewer neurons than the input dimension. To reconstruct the input from this compressed representation, the network must learn which features are essential and which are noise.
12.1 Architecture
An autoencoder has two parts:
Encoder\(f_\theta\): maps the high-dimensional input \(\mathbf{x}\) to a low-dimensional latent code\(\mathbf{z}\):
After training, the encoder provides a learned compression (useful for dimensionality reduction, denoising, and feature extraction) and the decoder can generate data from latent codes.
12.2 Variational Autoencoder (VAE)
A standard autoencoder maps each input to a single point in latent space. The variational autoencoder(Kingma & Welling, 2014) instead maps each input to a distribution — a mean \(\boldsymbol{\mu}\) and variance \(\boldsymbol{\sigma}^2\) — and samples from that distribution:
# Test on a new signaltest_clean =make_signal(Xoshiro(99), sig_len)test_noisy = test_clean .+0.3f0.*randn(Xoshiro(99), Float32, sig_len)denoised, _ =autoencoder(reshape(test_noisy, sig_len, 1), tstate.parameters, tstate.states)fig =Figure(size = (700, 300))ax =Axis(fig[1, 1], xlabel ="Sample", ylabel ="Amplitude", title ="Denoising autoencoder")lines!(ax, test_noisy, color = (:gray, 0.5), label ="Noisy input")lines!(ax, test_clean, color =:black, linewidth =2, label ="Clean signal")lines!(ax, vec(denoised), color =:steelblue, linewidth =2, linestyle =:dash, label ="Denoised (AE)")axislegend(ax, position =:rt)fig
┌ Warning: Mixed-Precision `matmul_cpu_fallback!` detected and Octavian.jl cannot be used for this set of inputs (C [Matrix{Float64}]: A [Matrix{Float32}] x B [Matrix{Float64}]). Falling back to generic implementation. This may be slow.
└ @ LuxLib.Impl ~/.julia/packages/LuxLib/ZJ3gh/src/impl/matmul.jl:194
12.4 When to use autoencoders
Task
Autoencoder variant
Dimensionality reduction
Standard AE
Denoising
Denoising AE (train on noisy → clean pairs)
Anomaly detection
Train on normal data; high reconstruction error = anomaly
Generative modeling
VAE (sample from latent space to create new data)
Feature learning
Use encoder output as features for downstream tasks
12.5 Geoscience milestones
Subsurface inverse modeling — Lopez-Alvis et al. (2019) used deep autoencoder-based emulation for inverse modeling of subsurface transport, compressing the parameter space before inversion.
Representation learning in Earth science — Bergen et al. (2019) and Reichstein et al. (2019) place autoencoder-based dimensionality reduction inside the wider deep-learning landscape of the geosciences.
Bergen, K. J., Johnson, P. A., Hoop, M. V. de, & Beroza, G. C. (2019). Machine learning for data-driven discovery in solid earth geoscience. Science, 363(6433). https://doi.org/10.1126/science.aau0323
Hinton, G. E., & Salakhutdinov, R. R. (2006). Reducing the dimensionality of data with neural networks. Science, 313(5786), 504–507. https://doi.org/10.1126/science.1127647
Kingma, D. P., & Welling, M. (2014). Auto-encoding variational bayes. Proceedings of the 2nd International Conference on Learning Representations (ICLR). https://arxiv.org/abs/1312.6114
Lopez-Alvis, J., Hermans, T., Nguyen, F., Caterina, D., & Haugerud, A. J. (2019). Deep-learning-based inverse modeling approaches: A subsurface transport example. Water Resources Research, 55(8), 6305–6327. https://doi.org/10.1029/2018WR024638
Reichstein, M., Camps-Valls, G., Stevens, B., Jung, M., Denzler, J., Carvalhais, N., & Prabhat. (2019). Deep learning and process understanding for data-driven earth system science. Nature, 566, 195–204. https://doi.org/10.1038/s41586-019-0912-1