§5.8.2 k-means clustering (concluded from last page)
k-means k-means clustering Alternate assigning points to nearest centroid and re-averaging centroids; yields one-hot (extreme sparse) codes; clustering is inherently ill-posed. defined in ch. 5 — open in glossary is representation learning by cluster membership: initialize k centroids , then alternate until convergence — assign each example to its nearest centroid; move each centroid to the mean of its assigned examples. The resulting code is a one-hot vector ( for your cluster, zeros elsewhere): an extreme sparse representation — cheap (one integer!), but it forfeits the advantages of distributed codes.
Aside — clustering is ill-posed: the red-trucks problem
There is no single criterion for how well a clustering matches the world. Cluster images of {red, gray} × {cars, trucks} into two groups: one algorithm finds cars-vs-trucks, another red-vs-gray — both valid. Ask for four clusters and similarity information vanishes: red cars are simply “different” from both gray cars and gray trucks, with no notion that they are MORE similar to gray cars. A distributed representation — one attribute for color, one for vehicle type — keeps both facts and measures fine-grained similarity. This argument returns as a pillar of deep representation learning (§15.4).
§5.9 Stochastic gradient descent
Nearly all of deep learning runs on one algorithm — SGD. The setup: costs decompose over examples as an average of a per-example loss (typically the negative log-likelihood negative log-likelihood The standard cost: NLL = −E log p_model. ANY NLL is a cross-entropy — MSE is the cross-entropy of a Gaussian model. defined in ch. 5 — open in glossary ), so the full gradient is an average too — which a minibatch minibatch The small uniformly-sampled example set (size m′) whose average loss gradient estimates the true gradient in SGD. defined in ch. 5 — open in glossary can cheaply estimate. Formally, costs decompose over examples,
Term by term
| the per-example loss, e.g. the negative conditional log-likelihood −log p(y|x; θ) | one example | |
| full-batch gradient descent costs O(m) per step — prohibitive at billions of examples | the problem | |
| THE INSIGHT: the gradient is an expectation — and expectations can be estimated from small samples | the way out |
Term by term
| a MINIBATCH: m′ examples (1 to a few hundred) drawn uniformly from the training set — and m′ stays FIXED as m grows to billions | the estimate | |
| the minibatch gradient: a noisy but unbiased estimate of ∇J | noisy ∇J | |
| the learning rate, as in ch. 4 — SGD is gradient descent following the ESTIMATED gradient downhill | step size |
Why SGD is the scalability story
Cost per update: O(1) as a function of m. Better: as m → ∞, the model converges to its best test error before SGD has even touched every example — asymptotically, training costs O(1) total in m. Contrast kernel machines’ O(m²) Gram matrix. That asymmetry is why deep learning became the scalable way to train nonlinear models — first interesting academically (better generalization on medium data, 2006), then industrially. Gradient descent on non-convex losses was long “regarded as foolhardy”; today it demonstrably works — finding very low, if not minimal, cost fast enough to be useful. Chapter 8 is SGD grown up.
step 0/36 · f = 169.33
Well-conditioned: contours are nearly circular and −∇f points almost straight at the minimum.
§5.10 The recipe
Nearly every deep learning algorithm is one instance of: dataset + cost + model + optimizer — swappable mostly independently.
Supervised AND unsupervised fit the same template. Swap the model to something nonlinear and closed forms die — an iterative optimizer (gradient descent) takes over; costs that can’t even be evaluated can still be minimized if their GRADIENTS can be approximated.
Algorithms that look hand-crafted (decision trees, k-means) fit too — they use special-case optimizers, needed because their costs have flat regions that defeat gradient methods. The recipe turns a zoo of algorithms into a taxonomy of interchangeable parts.
§5.11 → §5.11.1 The curse of dimensionality
Simple ML works widely — yet failed at the central AI problems (speech, objects). The rest of this chapter explains why, starting with the statistical wall: the curse of dimensionality curse of dimensionality Configurations grow exponentially with dimensions: typical grid cells contain NO training example, defeating purely local generalization. defined in ch. 5 — open in glossary — the number of distinct configurations of a variable set grows exponentially with the number of variables.
Fig 5.9 (recreated) — with d dimensions and v distinguishable values per axis, configurations explode as vᵈ.
The statistical consequence: with far more cells than examples, a typical cell contains no training data at all. Local recipes — report the most common class in your cell, average your cell’s targets — have nothing to say there. Most traditional algorithms fall back on assuming the answer at a new point matches its nearest training point: the smoothness prior, whose limits are the next section’s whole story.
Check yourself — k-means, SGD, the curse
1.The red-trucks story: why does the book prefer distributed representations over k-means' one-hot codes?
2.What is SGD's core insight, and what does it do to the cost of one update?
3.Why did SGD-trained models displace kernel machines on large datasets?
4.Name the four interchangeable parts of the ML recipe — and what breaks when the model goes nonlinear.
5.With d = 10 binary-ish dimensions at v = 10 values each, roughly how many cells must local methods cover — and what happens in a typical cell?