Autoencoder Model Reduction
Overview
An autoencoder is a neural network that compresses data through a narrow bottleneck and reconstructs it. As a model-reduction tool it learns a nonlinear low-dimensional manifold — unlike POD’s linear subspace — by training an encoder n → r and a decoder r → n jointly. autoencoder_rom fits one to snapshot data; the reconstruction error measures how much of the dynamics the latent space captures.
using RasmahLearn a low-dimensional manifold
Embed a one-dimensional oscillation into 8 dimensions (harmonics) and compress it back to a 2-D latent code:
t = range(0, 2π; length = 200)
X = vcat(sin.(t)', cos.(t)', sin.(2 .* t)', cos.(2 .* t)',
0.5 .* sin.(t)', 0.5 .* cos.(t)', 0.3 .* sin.(3 .* t)', 0.3 .* cos.(3 .* t)')
rom = autoencoder_rom(X, 2; hidden = [5], epochs = 1500, lr = 1e-2)
println("latent dim = 2, reconstruction error = ", round(ae_reconstruction_error(rom, X); digits = 4))latent dim = 2, reconstruction error = 0.2841
Verification — the compression trade-off
A wider latent space reconstructs better; the error must fall as r grows:
e1 = ae_reconstruction_error(autoencoder_rom(X, 1; hidden = [5], epochs = 1500, lr = 1e-2), X)
e4 = ae_reconstruction_error(autoencoder_rom(X, 4; hidden = [5], epochs = 1500, lr = 1e-2), X)
println("r=1 error = ", round(e1; digits = 4), ", r=4 error = ", round(e4; digits = 4), " (decreases: ", e4 < e1, ")")r=1 error = 0.4544, r=4 error = 0.1417 (decreases: true)
Next steps
- Model reduction: POD and DMD — the linear baseline.
- Quadratic manifolds — a nonlinear manifold without training.
