Study time: about 2 hours. Coding: know the main calls, extract the latent layer, interpret reconstruction — no simulation loops.
8.1 Pass
8.1.1 Situation
You want a low-dimensional code that can rebuild the input. An autoencoder is a neural net trained to predict its own inputs.
Encoder: maps input \mathbf{x} to the code \mathbf{z} (bottleneck).
Decoder: maps \mathbf{z} back toward \mathbf{x}.
Bottleneck: narrowest layer; the latent representation.
If the bottleneck is as wide as the input, there is no compression — the net can learn to copy.
8.1.2 Loss and activations
The target is the input (or a clean input, for denoising). Squared error suits continuous features; binary cross-entropy suits binary features.
Non-linear activations matter: with only linear layers and squared error, the model spans the same subspace as PCA (up to rotation) and does not even order components by variance. Non-linearity is what buys curved manifolds.
8.1.3 Overfitting and held-out data
The architecture is flexible. Held-out validation/test data are required to see whether reconstruction generalises. Early stopping uses validation loss.
Reconstruction error on training data can rise with a wider bottleneck if a larger net was not trained long enough. On test data, rising error with width often signals overfitting.
8.1.4 Denoising
Input: corrupted \mathbf{x} (noise, or variables zeroed). Target: clean \mathbf{x}. Forces robustness and discourages trivial copying.
8.1.5 MNIST lesson (prose only)
A linear output layer is natural for unbounded reconstructions; clip only for display. A ReLU bottleneck forces non-negative codes. Reconstruction MSE can look excellent because most pixels are background white — still check whether digits are confused.
8.1.6 Runnable: keras3 on iris (this year’s verbs)
H2O is not running yet, starting it now...
Note: In case of errors look at the following log files:
/var/folders/b4/q35h60c10_53lf20j68vwbd00000gn/T//RtmpKt2m6Z/filee685d7054d5/h2o_maesela_started_from_r.out
/var/folders/b4/q35h60c10_53lf20j68vwbd00000gn/T//RtmpKt2m6Z/filee6879d19bdf/h2o_maesela_started_from_r.err
Starting H2O JVM and connecting: .. Connection successful!
R is connected to the H2O cluster:
H2O cluster uptime: 2 seconds 64 milliseconds
H2O cluster timezone: Africa/Johannesburg
H2O data parsing timezone: UTC
H2O cluster version: 3.44.0.3
H2O cluster version age: 2 years, 10 months and 19 days
H2O cluster name: H2O_started_from_R_maesela_lxv521
H2O cluster total nodes: 1
H2O cluster total memory: 1.98 GB
H2O cluster total cores: 10
H2O cluster allowed cores: 2
H2O cluster healthy: TRUE
H2O Connection ip: localhost
H2O Connection port: 54321
H2O Connection proxy: NA
H2O Internal Security: FALSE
R Version: R version 4.5.3 (2026-03-11)