Deep Learning: Making It Learnable
What to Learn, What to Build In, and What to Reuse
A first-principles deep learning textbook built around one compounding question: what if we made this learnable? From linear regression to the pretrained era.
Preface
A first-principles course in Python and PyTorch.
Much of modern deep learning can be understood as familiar machinery, made learnable and placed inside the right structure.
What to learn. What to build in. What to reuse.
Take a linear model and let it learn its own nonlinear features: the core of a multilayer perceptron. Take fixed convolutional filters and learn them from data: the core of a convolutional network. Take similarity-weighted averaging and learn how to compare and mix: the core of attention. Learn a representation once and adapt it many times: the pretrained era.
The underlying mathematical move, in its simplest instance:
\[ \underbrace{f_{\vect{w}}(x) = \vect{w}^\top \phi(x)}_{\text{linear model on fixed features}} \qquad\longrightarrow\qquad \underbrace{f_{\vect{w},\theta}(x) = \vect{w}^\top \phi_\theta(x)}_{\text{linear readout on learned nonlinear features}}. \]
What we build in — through architecture, objectives, data, or training — is inductive bias: regularities the model should not have to rediscover from scratch. Three questions organize everything that follows:
\[ \begin{aligned} \textbf{What is learned?} &\quad \text{features, filters, comparisons, representations} \\ \textbf{What is built in?} &\quad \text{locality, sharing, order, invariance, visibility} \\ \textbf{What is reused?} &\quad \text{pretrained representations and models} \end{aligned} \]
MLPs, convolutional networks, attention, and pretraining are examples of this framework, not separate inventions, and each part of the book returns to the same design question in a new regime.
This book develops those moves by construction and experiment. We build the simplest mechanism, test where it fails, and let the failure motivate the next design. By the end, modern AI should feel less like a zoo of architectures and more like a small set of ideas — made learnable, shaped by structure, and reused at scale.
Make the right parts learnable. Build in the structure you trust. Reuse what transfers.
This is the free, open book for DS 6050 Deep Learning at UVA’s School of Data Science. The course arc is published, and the book continues to receive corrections and teaching improvements. The current stable edition is v1.2.1 (August 2, 2026); its archived release and PDF preserve a fixed version. The live site is a rolling post-v1.2.1 build. The HTML edition is canonical; the PDF is a derived print conversion. Executable figures and numerical results are produced by code in the book’s source: experiments carry their executable code, revealed step by step or all at once, and concept diagrams fold theirs. Every printed snippet is the executed artifact — nothing on the page is retyped — and the repository’s checks re-execute the book’s notebooks. Source, provenance, and licenses remain visible in the repository.
For the graduate continuation—from numerical and hardware contracts through high-dimensional probability, random-matrix spectra, and optimization dynamics—see Deep Learning: Making It Trainable.
Suggested citation: Shakeri, Heman. 2026. Deep Learning: Making It Learnable. Version 1.2.1. https://shakeri-lab.github.io/dl-book/.
How to read this book
Every chapter follows the course’s learning loop: read → predict → run → audit. Before running an experiment, write down the direction you expect; after running it, audit the code the way you would audit a colleague’s — or an AI assistant’s. Five questions cover most audits: what function class does this code implement, what objective does it optimize, what estimator does each batch compute, what information is visible to the model (masks, padding, order), and what claim does the output support? The code is written directly in Python and PyTorch and runs on an ordinary laptop CPU — small data, honest experiments. Watch the lecture videos, read the chapter, run the cells, and test yourself against the self-checks on the course site.
Course route and dependencies
The route is cumulative. Modules sometimes revisit a chapter because the course uses the same idea first as a mechanism and later as evidence. The appendices are just-in-time support, not a separate prerequisite block: A is linear algebra, B is tensors, C is precision and performance, D is notation, and E is statistical learning contracts.
| Course module | Primary book route | Supporting appendices |
|---|---|---|
| 1 · foundations and MLPs | 1 → 2 → 3 → 4 | A · B · D · E |
| 2 · backpropagation | 5 | B · D |
| 3 · optimization and ablation | 4 → 6 → experiment interlude | B · D · E |
| 4 · convolutional networks | 6 → 7 → 8 | B · D · E |
| 5 · modern CNNs and transfer | 9 | B · C · D |
| 6 · PCA and autoencoders | PCA → autoencoder interlude | A · B · D |
| 7 · recurrent sequences | 10 → 11 | B · D |
| 8 · attention | 12 → 13 | A · B · D |
| 9 · Transformers | 14 → test-time-regression interlude | B · C · D |
| 10 · pretrained models, ViTs, scaling | 15 → 16 | B · C · D |
| 11 · adaptation and alignment | 17 → 18 | B · C · D · E |
| 12 · generative and multimodal models | 19 → 20 | A · B · C · D · E |
Plan a reading session
Time depends more on whether you stop to derive and run than on page count. As a planning range, allow roughly 45–90 minutes for a careful first read of most chapters, with the experiment-heavy later chapters often taking the longer end or a second sitting. Once the environment and data are ready, reproducing a few key cells commonly adds 20–45 minutes; rerunning every training cell from scratch can take substantially longer and varies by machine. Exercises are best treated as their own work session. These are orientation bands, not completion-time promises.
If you have one short sitting, read the opening problem, study the figures, run one cell that tests the main claim, and answer any closing Check yourself prompts without looking back. Return for the derivations and exercises when you can explain what failed, what changed, and what evidence supports the repair.
Exercises, hints, and solutions
The book supports both enrolled and self-paced readers. For-credit assignment rules on the course site and in the syllabus take precedence. To protect those assignments, the public book does not publish full worked solutions to overlapping graded work. Public Check yourself prompts are retrieval practice, not answer banks; the chapter recap and course-site self-check feedback provide the first layer of hints.
For self-paced work, use these acceptance criteria:
- A conceptual answer names the mechanism, predicts a direction or limiting case, and states one condition under which the claim could fail.
- A shape derivation labels every axis before the operation and checks the resulting shape against the code.
- A code exercise runs from a fresh session, fixes its seed, prints or asserts the important shapes, and reproduces the requested qualitative relationship. Small machine-dependent numerical differences are not failures unless the exercise sets a tolerance.
- An experiment states the question before the run, separates tuning from final evaluation, keeps the comparison recipe fixed, reports seed variation when requested, and ends with a limitation rather than a universal claim.
When stuck, inspect the nearest Trap: or tip callout, write the expected shape or trend before running anything, and reduce the code to one batch or one example. Enrolled students should use the course’s approved help channels for assignment-specific hints; complete graded solutions stay there rather than in the public text.
Acknowledgments
To the students of DS 6050, whose questions shaped every explanation here.
Support this open book
This book is free to read and download at $0, and no contribution unlocks additional content. Reading it, sharing it, or reporting a correction is already meaningful support. If it has been useful and you would like to help sustain ongoing corrections, new figures, and open releases, you may make an optional contribution here:
Text and figures licensed CC BY-NC-SA 4.0; all code MIT. Source on GitHub. The graduate companion is Deep Learning: Making It Trainable.
A release is a fixed place to point a syllabus, assignment, or citation. The live book may continue to receive corrections, but a tagged release keeps its source and attached PDF stable. When page numbers matter, name the version.
Rolling build · August 20, 2026
The canonical HTML now keeps ancillary material quiet until a reader asks for it: About this edition, Revision notes, and the left-sidebar chapter groups begin closed, while the active chapter’s own Part remains available for orientation. The sidebar also opens a cover-led download page directly under the book title. That page keeps both PDF editions free and links its suggested $20 contribution directly to the external support page, without inserting a redundant local amount picker. The support heading gains one small decorative coffee mark. Narrative tips, traps, and retrieval checks remain open so the reading momentum is unchanged.
Rolling build · August 19, 2026
Both derived PDFs now open with the author-supplied cover while retaining their searchable title pages and title verso. The shared Preface also closes with one optional support invitation: the complete book remains free at $0, no contribution unlocks additional content, and readers may help sustain corrections, new figures, and open releases through one stable link.
Rolling build · August 8, 2026
The canonical HTML now carries book-level description, favicon, social-card, and machine-readable citation metadata; MathJax is pinned to the exact renderer used by this build. Interlude tables complete the EX. namespace, Plan → Code panels add an explicit Show all code path, the link palette clears WCAG AA, selected prose-like outputs wrap on narrow screens, and the two softest executed figures are regenerated at high density. A book-specific 404 page keeps stale links inside the reading path.
Rolling build · August 6, 2026
The live post-v1.2.1 book adds Appendix E as an optional statistical-contract reference, replaces Chapter 1’s bias–variance cartoon with a seeded show-then-name experiment, separates representation, optimization, and generalization evidence in Chapter 6, and bounds Chapter 18’s alignment contract within a broader sociotechnical assessment. The stable v1.2.1 release remains unchanged.
v1.2.1 · August 2, 2026
Version 1.2.1 establishes the reciprocal interface with the graduate companion volume. Ten chapter anchors are now protected as public interfaces in source and rendered-HTML audits; five bounded forward pointers separate mechanics owned here from the diagnostic extensions in Deep Learning: Making It Trainable. The two books also point to each other from their colophons.
v1.2 · July 29, 2026
Version 1.2 is the comprehensive audit and convention-parity release. It gives all three interludes independent figure namespaces and retrieval checks, completes the book-wide Plan → Code and exercise-taxonomy contracts, strengthens estimator and evidence discipline, adds the attention-as-test-time-regression interlude, and closes the temperature thread from kernel bandwidth through training-time scale and post-hoc calibration. The epilogue now has its own E. figure namespace and primary-source receipts. Its attached 552-page PDF is the stable page-reference target; the canonical HTML and derived PDF passed the complete manuscript, frozen-output, glyph, and cross-reference audits at release.
v1.1 · July 24, 2026
Version 1.1 is the readable-code and estimator-discipline release. It establishes the equation/kernel/harness visibility rule, transcludes canonical executable listings, adds the learned-feature and forget-gate diagnostics, strengthens batch-estimator discipline, and adds a weekly from-scratch execution audit. Its attached 502-page PDF is the v1.1 page-reference target.
v1.0 · July 16, 2026
Version 1.0 is the first stable, citable edition. It closes the July 2026 structural and research-frontier revision with the complete twenty-chapter course arc, both bridge interludes, the epilogue, and four just-in-time appendices. It also pins the Chapter 1–9 corpus used by the Chapter 10/14 language-model rematch, completes the figure-description audit, and applies one presentation rule consistently: experiments expose their code, while pure concept diagrams keep executable drawing source in the repository without printing pages of coordinates.
Pre-v1.0 builds moved page numbers while the middle of the book was restructured and the final chapters were added. Migrate old page references to the PDF attached to the v1.0 release. Later notes will describe any page-reference changes relative to this baseline. Machine-readable citation metadata lives in CITATION.cff.