Applications
We survey large-scale training (the hardware, the two axes of parallelism, mixed precision, and the compression tricks that shrink a model after it is trained), then specialize the same gradient loop to vision, language, speech, and recommendation. Each domain is a different prior bolted onto one optimizer: convolutional invariance for pixels, distributed word vectors for tokens, sequence transduction for audio, low-rank factorization for the user–item matrix.
╌╌╌╌
A trained network is a function ; an application is the engineering that makes fast enough to run, large enough to be accurate, and shaped to the structure of a particular kind of data. Goodfellow's twelfth chapter applies the abstractions: the same five-line training loop, specialized four ways. The specialization is never in the optimizer; it is in the prior each domain builds into the architecture and the preprocessing.1
Every application in this chapter runs the same recipe, and it pays to name the steps once so the four case studies below read as instances of one procedure.
The steps that vary across domains are the first four. The optimizer, the backpropagation, and the training loop are shared. Each section below walks the recipe once, carrying explicit tensor shapes so the arithmetic of a forward pass is never left implicit.
| Domain | Native input | Prior baked in | Output structure |
|---|---|---|---|
| Vision | pixel grid | translation equivariance (convolution) | label / box / mask |
| Language | token sequence | distributional semantics (embeddings) | next token / sequence |
| Speech | spectrogram frames | temporal locality + monotonic alignment | transcript |
| Recommendation | sparse user–item matrix | low-rank structure | predicted ratings |
Large-scale deep learning
The dominant empirical fact of the field is that scale works: test loss falls as a smooth power law in model size, dataset size, and compute, provided all three grow together. The cost is that a modern model neither fits nor trains on one device, so the practical question becomes how to spread one gradient step across many processors.2
The averaged gradient is exact. Averaging the shard-gradients reproduces the full-batch gradient, so data parallelism is mathematically transparent. Writing for the gradient on shard ,
the synchronized update is , with the sum realized by an all-reduce across devices.
The two axes compose: a large model is sharded by model parallelism across a small group of devices, and that group is replicated by data parallelism across many groups. Orthogonal to both is reducing the cost of each arithmetic operation.
Because half-precision gradients can underflow to zero, the loss is multiplied by a loss-scaling factor before backpropagation and the resulting gradients divided by afterward, a units-preserving trick that shifts small gradients into the representable range:
Training cost is one lever; inference cost is another, and it is paid every time the model runs. Three families of techniques shrink a trained model.
The student objective blends the soft-target term with the ordinary hard-label loss,
where the factor restores the gradient magnitude scaled down by softening. The full set of scaling techniques, training-side and inference-side:
| Technique | Axis | Mechanism | Cost / caveat |
|---|---|---|---|
| Data parallelism | training throughput | split batch, average gradients | all-reduce bandwidth |
| Model parallelism | training memory | split parameters across devices | activation-transfer latency |
| Pipeline parallelism | training memory | split by layer, micro-batch the pipeline | bubbleidle time at fill/drain |
| Mixed precision | compute + memory | 16-bit math, 32-bit master copy | needs loss scaling |
| Quantization | inference memory + speed | store/compute weights in int8/int4 | accuracy loss without calibration |
| Pruning | inference memory | zero out low-magnitude weights | needs sparse kernels to pay off |
| Distillation | inference compute | small student mimics large teacher | student caps below teacher accuracy |
Computer vision
Vision is the domain where deep learning first overturned a hand-engineered pipeline.3 The architectural prior is the convolutional network; the data prior is preprocessing and augmentation.
Fix the input tensor first. A batch of RGB images is a rank-4 tensor. PyTorch stores it channels-first as ; the NHWC convention used by some frameworks stores it as . A batch of 64 color images at is therefore under PyTorch, holding million floats.4 Pixels arrive in and must be normalized before they reach the network. Channel-wise standardization keeps each input coordinate at unit scale so the first layer's gradients are well-conditioned:
with the statistics computed once over the training set per channel and frozen for inference. Data augmentation then manufactures extra training examples by applying label-preserving transformations such as random crops, horizontal flips, color jitter, and small rotations. These encode the invariances the task demands and act as a regularizer; we treat augmentation formally under dropout and data augmentation.5
The vision tasks form a spectrum of increasing output structure: from a single label, to a label plus a box, to many boxes, to a label for every pixel.
| Task | Output | Loss | Representative architecture |
|---|---|---|---|
| Classification | one label | cross-entropy | ResNet, ViT |
| Localization | one label + one box | cross-entropy box regression | overfeat-style heads |
| Detection | classification localization, per object | Faster R-CNN, YOLO | |
| Segmentation | per-pixel label map | pixel-wise cross-entropy | U-Net, Mask R-CNN |
Box regression typically minimizes a smooth loss on the coordinates, quadratic near zero and linear in the tail so large errors do not dominate the gradient, while overlap is scored by intersection over union, , the fraction of the union two boxes share.
The classification path is the one to trace end to end, because every other vision task grows a different head onto the same convolutional trunk. A ResNet-style network takes the normalized tensor and passes it through successive stages that halve the spatial resolution and double the channel count, so the representation trades pixels for features. The figure carries the shapes.
Read the shapes as a budget. The input holds numbers with no abstraction. By stage 3 the map is numbers, each a learned feature summarizing a wide receptive field. Global average pooling then collapses every channel map to its mean, turning into a length-256 vector that no longer depends on where in the frame an object sat. A single linear layer maps that vector to 1000 class logits, and a softmax normalizes them to a distribution. The output head is thus a matrix of shape , the loss is cross-entropy against the one-hot label, and the metric reported at test time is top-1 or top-5 accuracy, which the smooth loss only approximates.
The other three tasks reattach a different head to the same trunk. Localization adds a four-number regression head for one box. Detection runs a classification-plus-box head at many spatial locations. Segmentation replaces global pooling with an upsampling decoder that returns to full resolution, emitting a map of per-pixel class logits scored by pixel-wise cross-entropy and evaluated by mean IoU. The trunk is shared; the head is task-specific.
The characteristic failure modes are worth naming. A classifier trained on clean, centered images degrades on the domain shift of real photographs (odd lighting, occlusion, unusual crops); the fix is heavier augmentation matched to the deployment distribution. A detector floods the frame with near-duplicate boxes unless non-maximum suppression prunes overlapping predictions. A segmenter smears object boundaries because pooling discarded the fine spatial detail the decoder must reconstruct, which is why skip connections from encoder to decoder (as in U-Net) carry the lost resolution forward.
Natural language processing
Language presents a fundamentally discrete, high-cardinality input: a vocabulary of tokens, often . The classical approach, the -gram language model, estimates the probability of the next word from the previous by counting:
This is exact arithmetic on a lookup table, and it collapses under the curse of dimensionality. The table has one entry per possible context, so its size grows exponentially in :
almost all of which are never observed, leaving the count zero and the probability
estimate undefined without smoothing. The deeper problem is that the table treats
every word as an isolated symbol: cat
and dog
are as unrelated as cat
and
thermodynamics,
because one-hot codes are mutually orthogonal and share no
statistics.6
To address this, replace the one-hot symbol with a dense, learned vector, a word embedding, so that statistically similar words occupy nearby points and the model can generalize across them.
Before the embedding, the raw text must become integers. Tokenization splits a string into units drawn from the vocabulary and maps each to its index, so a sentence of tokens becomes an integer vector of shape with entries in . A batch of sentences padded to length is the integer tensor . The embedding layer is a lookup into the matrix : row is the vector for token , so indexing into produces the float tensor .7 For , , a 12-token sentence therefore expands from 12 integers to a -number matrix that a sequence model can consume.
Embeddings are learned from the distributional hypothesis, that a word is known by the company it keeps. word2vec trains by predicting context words from a center word (skip-gram); GloVe factorizes the global co-occurrence matrix. Both yield the same emergent property: semantic relations become vector arithmetic.
The parallelogram is the geometry of analogy: a single offset vector encodes
royalty,
another encodes gender,
and they add independently, so
lands near .
With dense vectors in hand, the neural language model replaces the count table
with a network: look up each context word's embedding, concatenate, and feed a
multilayer perceptron that outputs a softmax over the vocabulary.
The neural model's parameter budget is , additive rather than exponential in context length, and it generalizes to unseen -grams because nearby embeddings produce nearby predictions. Fixed-width context still limits it. Lifting that limit, so that every token can attend to every other, leads to the Transformer architecture, which dropped the Markov window entirely and now underpins every large language model.
| Model | Context | Parameters | Generalizes across words? |
|---|---|---|---|
| -gram count table | fixed | no (one-hot, orthogonal) | |
| Neural LM (MLP) | fixed | MLP | yes (shared embeddings) |
| Recurrent LM | unbounded (decaying) | yes | |
| Transformer LM | full sequence (attention) | per layer | yes |
The full sequence pipeline is the same recipe carried through with different heads depending on whether the target is one label for the whole sequence or one label per position. The figure traces the shapes.
The output head is the only branch point. Sentiment classification pools the state sequence to one vector (mean-pool or the final state) and applies a linear layer to class logits, scored by cross-entropy and evaluated by accuracy. Sequence tagging (part-of-speech, named entities) keeps the time axis and applies the same linear layer at every position, producing logits scored by per-position cross-entropy and evaluated by token-level F1. Language modeling sets and predicts the next token at each step.
The failure modes of a text model trace back to the vocabulary. A token unseen at training time hits the out-of-vocabulary slot and loses all its content, which is why subword tokenization (splitting rare words into known pieces) is standard. Padding a short sequence to length injects meaningless positions that a naive mean-pool averages into the answer, so the pooling must mask them out. A model trained on one genre transfers poorly to another because the embedding geometry it learned reflects the training corpus, not the target domain.
Speech recognition
Speech recognition maps a waveform to text. The raw signal is first reduced to a sequence of acoustic feature frames, typically log-mel spectrograms or MFCCs computed on overlapping short windows, turning audio into a matrix that a sequence model can consume. A 3-second utterance windowed every 10 ms with 80 mel bands is the tensor : 300 time frames, each an 80-dimensional spectral summary.
The central difficulty is alignment: the input has frames but the output has characters, and the frame-to-character correspondence is unknown. Connectionist temporal classification (CTC) solves this without per-frame labels by introducing a blank symbol and summing over all alignments that collapse to the target.8
Collapsing removes blanks and merges adjacent repeats, so many frame paths map to
the same string. The figure shows two of them landing on the target cat
.
The sum over exponentially many alignments is tractable by a forward-backward recursion identical in spirit to the one for hidden Markov models, making the whole acoustic-model-to-transcript path differentiable end to end. The metric at test time is word error rate, the edit distance between prediction and reference over the reference length. The failure modes are homophones the acoustic signal cannot disambiguate (fixed by a language-model rescoring pass) and rare words absent from the training transcripts.
Recommender systems
A recommender predicts how much user will like item from a sparse matrix of observed ratings, most of whose entries are missing. The standard method is matrix factorization: approximate by the product of a thin user-factor matrix and a thin item-factor matrix.9
The factors are fit by minimizing squared error over the observed entries only. The missing entries contribute nothing to the loss, so the model is never asked to predict a rating that was never given. An penalty controls the low-rank capacity:
solvable by stochastic gradient descent or alternating least squares (fix , solve a least-squares for , alternate). The model has a structural limitation.
The metric a recommender optimizes at test time is rarely raw squared error. What matters is the ranking of the top few items shown to the user, so systems report ranking scores such as precision-at- or normalized discounted cumulative gain, and the squared-error training loss is only a differentiable stand-in for them.
Deep recommenders extend the bilinear score by passing the learned embeddings through a neural network and concatenating side features, which both lifts the linear ceiling and softens cold-start by sharing structure through the content features. This is the same embedding-plus-MLP construction used in neural language models, transplanted to the user-item domain.
One architecture eats the four domains
Goodfellow's chapter presents four domains with four distinct priors — convolution for pixels, recurrence for language, spectral front-ends for audio, factorization for the user-item matrix. The decade since collapsed much of that diversity onto a single architecture: the Transformer (Vaswani et al., 2017, NeurIPS).
The consolidation ran domain by domain. Language went first, as attention replaced the gated RNNs of the NLP section outright. Vision followed with the Vision Transformer (Dosovitskiy et al., 2021, ICLR), which cuts an image into patches, treats them as a token sequence, and matches or beats convolutional networks once the training set is large enough — the convolutional prior turns out to be replaceable by data. Speech followed with wav2vec 2.0 and Whisper (Radford et al., 2022, arXiv), which run Transformer encoders on the spectral frames from the speech section. Even recommenders adopted self-attention over a user's interaction history. The prior that each domain once hard-coded into its architecture is increasingly learned instead, given enough data and compute — the same lesson the Vision Transformer taught first.
The hardware story kept pace. The attention cost that would have made long sequences impractical was addressed by FlashAttention (Dao et al., 2022, NeurIPS), an IO-aware kernel that tiles the attention computation to keep it in fast on-chip memory, turning a memory-bound operation into a compute-bound one without changing the math. The two axes of parallelism from the large-scale section became production frameworks — Megatron-LM for tensor parallelism, ZeRO / FSDP for sharding optimizer state across devices — that make trillion-parameter training routine. The recipe is unchanged from the opening of this lesson: one gradient loop, one increasingly universal architecture, specialized now by the data it is fed rather than the prior baked into it.
Takeaways
- One recipe, four domains. Fix the input tensor and its shape, choose the architecture whose bias matches that shape, attach the output head for the target, pick the loss, then read the residual for domain-specific failure modes. Only the first four steps vary; the optimizer and training loop are shared.
- One loop, four priors. Vision, language, speech, and recommendation reuse the same optimizer; they differ only in the architectural and preprocessing prior fitted to the data's structure.
- Scaling has two axes. Data parallelism splits the batch and averages exact gradients; model parallelism splits the parameters when one model exceeds one device. Mixed precision, quantization, pruning, and distillation cut compute and memory on top.
- Vision is a task spectrum. Classification localization detection segmentation adds output structure at each step; normalization and augmentation supply the data prior.
- Embeddings beat the curse of dimensionality. -gram tables grow as and treat words as orthogonal symbols; a shared embedding matrix is parameters, generalizes across words, and makes analogy literal vector arithmetic, the road to the Transformer.
- CTC sums over alignments so speech models train without frame-level labels; matrix factorization of the user-item matrix is a low-rank inner product that fails on the cold-start problem until content features fill the gap.
Footnotes
- Goodfellow, Deep Learning, Ch. 12 — Applications: one optimizer specialized four ways, the domain-specific prior being the only thing that changes across vision, language, speech, and recommendation. ↩
- Goodfellow, Deep Learning, §12.1 — Large-Scale Deep Learning: spreading a gradient step across devices via data and model parallelism, plus precision and inference-time compression. ↩
- Goodfellow, Deep Learning, §12.2 — Computer Vision: contrast normalization and dataset augmentation as the data-side prior, convolution as the architectural one. ↩
- Stevens et al., Deep Learning with PyTorch, Ch. 4 — Real-world data representation: images load as a tensor of channels-first floats, normalized channel-wise before training. ↩
- Chollet, Deep Learning with Python, Ch. 5 — Deep Learning for Computer Vision: data augmentation as label-preserving transformation and a primary regularizer on small image datasets. ↩
- Goodfellow, Deep Learning, §12.4 — Natural Language Processing: -gram tables and the curse of dimensionality, cured by dense word embeddings that make distributional similarity geometric. ↩
- Stevens et al., Deep Learning with PyTorch, Ch. 4 — Representing text: tokenization to integer indices, then an embedding lookup that turns a index tensor into a float tensor. ↩
- Goodfellow, Deep Learning, §12.3 — Speech Recognition: acoustic features and the alignment problem that CTC dissolves by summing over collapsing paths. ↩
- Goodfellow, Deep Learning, §12.5 — Other Applications (Recommender Systems): low-rank matrix factorization of the user–item matrix and the cold-start limitation. ↩
╌╌ END ╌╌