Representation learning and deep architectures
Representation learning studies how deep networks automatically learn useful features (representations) of data; this note covers principles (manifold hypothesis, distributed representations), key theorems (linear autoencoder = PCA, universal approximation), architectures and practical consequences.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Representation learning is how a neural network converts raw input (images, signals, text) into internal features that make tasks (classification, regression, generation) easier. Engineers use these ideas when designing deep architectures (how many layers, what type of layer, whether to pre-train, whether to use autoencoders) to get better accuracy, faster training and more compact models.
Key ideas
Manifold hypothesis — high-dimensional data (for example, images in R^D) concentrate near a low-dimensional manifold M embedded in R^D. Formal statement used in practice: data probability mass lies on or near a smooth manifold of dimension d << D. Assumption needed: local smoothness; consequence: representations should learn coordinates on M.
Hierarchy / deep architectures — stacking layers transforms representation repeatedly: h^{(l)} = f^{(l)}(h^{(l-1)}), with h^{(0)} = x. Each layer extracts features of increasing abstraction (edges → parts → objects in vision). Assumption: composing simple non-linear maps can represent complex functions more compactly than shallow maps.
Universal Approximation Theorem (UAT) — exact statement (as commonly required in exams): Let K be a compact subset of R^n and let φ: R -> R be a nonpolynomial continuous activation function (for example logistic sigmoid or hyperbolic tangent). Then finite linear combinations of functions of the form x -> φ(w·x + b) are dense in C(K) (the continuous functions on K) with respect to the uniform norm. Assumptions: φ continuous and not a polynomial; network has one hidden layer with sufficiently many hidden units; result is existential (gives approximation but not how many units). Diagram to draw: a single-hidden-layer network box showing input x, many hidden units each computing φ(w_i·x + b_i) and a linear output combiner.
Depth vs width (informal theorem) — there exist families of functions that a deep network (with L layers) can represent with O(poly(n)) units, while any shallow (fixed 1 hidden layer) network requires exponentially many units to approximate them. Assumption: construct specific functions (often based on oscillatory patterns) to prove separation. Exact constants depend on the construction; state as "exponential separation" and describe proof idea: deep composition creates many linear regions or oscillations with few units.
Autoencoder (AE) — an unsupervised model with encoder z = f_enc(x) and decoder x̂ = f_dec(z). Training minimizes reconstruction loss (often mean squared error). Two important cases:
- Undercomplete autoencoder: code dimension dim(z) < dim(x). Learns a compressed representation (like PCA for linear AE).
- Overcomplete autoencoder: dim(z) >= dim(x). Needs regularisation (sparsity, denoising, contractive penalty) to avoid learning the identity. Diagram to draw: left column input x, arrow to hidden bottleneck z, arrow back to reconstruction x̂; label encoder and decoder weights. Also know the Variational Autoencoder (VAE): a probabilistic encoder q(z|x) and decoder p(x|z) trained by maximising the ELBO L_VAE = E_{q(z|x)}[log p(x|z)] - KL(q(z|x) || p(z)); it learns a latent representation useful for generation and downstream tasks.
Linear autoencoder = PCA (exact theorem and derivation) — For a single hidden layer linear autoencoder with encoder z = W_e x and decoder x̂ = W_d z, and using mean-square error loss with data centered (mean 0), the subspace spanned by columns of W_d (or rows of W_e) is the same as the subspace spanned by the top-k principal components (top k eigenvectors of the data covariance). Assumptions: linear activations, squared error loss, data centered, hidden dimension k. The common exam derivation: write loss as trace of covariance minus projection term, show minimising reconstruction error chooses projector onto top-k eigenvectors (showing equivalently maximising captured variance).
Pre-training / greedy layer-wise training — train first an autoencoder on raw x to get first-layer weights, freeze or initialise, then train next autoencoder to encode outputs of first layer, repeat. Used historically to help optimisation and to initialise deep nets (worth mentioning in "Weight initialisation and greedy layer-wise pre-training" topic). Assumption: unsupervised pretraining helps when labelled data small or weights poorly initialised.
Residual connections and depth enabling optimisation — adding identity skip connections (x + F(x) blocks) eases training of very deep nets by providing gradient paths and preserving low-level features. Draw a block: input, branch through F (two layers), add input, output. Also know convolutional layers and pooling: convolution implements weight sharing and translation equivariance (y = σ(K * x + b)); pooling/striding build local invariance and reduce spatial resolution. Batch Normalization and proper weight initialization (Glorot/Xavier: Var = 2/(fan_in+fan_out); He: Var = 2/fan_in) further stabilise training of deep architectures.
Where proofs or derivations are commonly asked: UAT statement and proof sketch, linear autoencoder → PCA full derivation (in Key ideas), sketch depth advantage proof idea.
Formulas
h = f(x) — h: representation vector in R^m, f: function (no units), applies to any layer output.
z = W_e x — encoder (linear), W_e in R^{k×n}. x in R^n. Applies for linear autoencoder.
x̂ = W_d z — decoder (linear), W_d in R^{n×k}. x̂ in R^n.
L = (1/N) Σ_{i=1..N} ||x_i - x̂_i||^2 — mean squared reconstruction loss. Units: x in SI units of data (e.g., volts); L has square of those units.
C = (1/N) Σ_{i=1..N} x_i x_i^T — data covariance matrix (assumes mean 0). Units: (data unit)^2.
max_{U: U^T U = I_k} trace(U^T C U) — objective for k-dimensional PCA subspace U (columns are orthonormal). Units: (data unit)^2. Applies when finding subspace capturing maximal variance.
Projection matrix P = U U^T (for orthonormal U) — projects vectors in R^n onto subspace spanned by U. Dimensionless.
UAT (informal formula): for any continuous f on compact K and any ε>0, ∃ finite sum g(x)=Σ_{i=1..M} α_i φ(w_i·x+b_i) s.t. sup_{x∈K} |f(x)-g(x)| < ε. Applies under assumptions in Key ideas.
Worked examples
Linear autoencoder on a tiny dataset (numerical, exam-style) Dataset: two points x1=(1,0), x2=(0,1). Step 1: compute mean μ = (0.5, 0.5). Centered points: x1'=(0.5,-0.5), x2'=(-0.5,0.5). Covariance C = (1/2)[x1' x1'^T + x2' x2'^T] = (1/2)[[0.25,-0.25],[-0.25,0.25] + [0.25,-0.25],[-0.25,0.25]] = [[0.25,-0.25],[-0.25,0.25]]. Find eigenvectors: matrix = 0.25[[1,-1],[-1,1]]. Eigenvector v1 = (1,-1)/√2 with eigenvalue λ1 = 0.5; v2 = (1,1)/√2 with λ2 = 0. For k=1, PCA chooses U = v1. Projection matrix P = U U^T = (1/2)[[1,-1],[-1,1]]. For x1' = (0.5,-0.5) the projection x̂' = P x1' = (1/2)[1,-1],[-1,1]^T = (1/2)(1.0,-1.0)^T = (0.5,-0.5). So x̂'=(0.5,-0.5) which equals x1' (so x1' lies in principal direction). Reconstruct original x̂ = x̂'+μ = (1,0) which matches x1 exactly. Final answer: reconstruction equals original for x1; autoencoder captures principal direction. (Units follow original data units.) Note: This example checks that the linear AE with k=1 captures the principal direction and projects points accordingly.
Model-answer style: Explain manifold hypothesis and how deep architectures exploit it (exam question) Start with definition: the manifold hypothesis states that data lie near a low-dimensional manifold M ⊂ R^D. Explain implications: local neighbourhoods are low-dimensional, good features parametrize coordinates on M. Explain representation learning goal: learn mapping f such that coordinates of M become linearly separable or simpler for the task. Sketch proof idea: compositions of local non-linear maps can flatten curved manifolds into locally linear coordinates; deep networks implement successive local flattenings and disentangling of factors. Diagram to draw: high-dimensional ambient space R^D with a curved 2D sheet (label M), arrows showing a sequence of mappings f^{(1)}, f^{(2)} transforming sheet to near-flat plane in feature space; label axes: x (input), h^{(1)}, h^{(2)}. Conclude: deep networks are effective when data satisfy manifold hypothesis because each layer can learn local coordinate charts.
Common mistakes
- Confusing undercomplete and overcomplete autoencoders: undercomplete compresses, overcomplete needs regularisation to not learn identity.
- Thinking depth always reduces parameters: deeper architectures can require fewer units to represent some functions, but not always; depth vs width trade-offs depend on function class.
- Forgetting assumptions (activation must be nonpolynomial) when quoting UAT.
For your exam
Types of questions: definitions (define representation learning, distributed representation, manifold hypothesis), derivations (derive linear autoencoder → PCA), short notes (depth vs width, residual connections), diagram questions (draw an autoencoder and label encoder/decoder, draw manifold and mapping), and proofs/sketches (state UAT and sketch proof, argue depth advantage). What a full-marks answer includes:
- Precise definitions with bold terms and assumptions stated.
- For derivations: start from loss, show algebraic steps (for PCA derivation: write loss = trace(C) - trace(U^T C U), then argue choose top-k eigenvectors), include centring of data.
- For theorems: state exact assumptions (e.g., activation is continuous nonpolynomial), and give a proof sketch or main lemmas.
- Diagrams: draw boxes and arrows for networks and label variables, or draw ambient space and manifold and label mappings.
Quick check
- What is the manifold hypothesis in one sentence?
- Under what conditions does a linear autoencoder recover PCA subspace?
- State the Universal Approximation Theorem in one short sentence. Answers: The manifold hypothesis: real-world high-dimensional data lie near a low-dimensional manifold embedded in the ambient space. Linear AE = PCA conditions: single linear hidden layer, squared-error loss, centred data (mean zero), hidden dim k; the learned subspace equals top-k PCA subspace. UAT: A feedforward net with one hidden layer and a nonpolynomial continuous activation can approximate any continuous function on a compact domain arbitrarily well (existentially, with enough hidden units).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?