Basics

In the Introduction, we saw how machine learning replaces hand-written rules with parameterized programs that learn directly from examples. Suppose you are handed tens of thousands of small grayscale photographs of clothing and asked to build a system that identifies whether each image shows a T-shirt, a sneaker, a coat, or a handbag. No programmer knows how to write explicit if–else rules that map raw pixel intensities to clothing categories reliably. Yet by the end of the first three chapters of this part, you will have built and trained a working classifier that does exactly that—and by the end of the part, you will have progressed to deep convolutional networks that recognize complex visual scenes and recurrent networks that learn to generate English prose from scratch.

Our approach throughout Basics is guided by a simple principle: to truly understand deep learning, you should build its core mechanisms with your own hands before relying on black-box library calls. Across these eight chapters, we implement nearly every foundational model, layer, loss function, and optimizer twice: first from scratch, relying only on basic tensor arithmetic and automatic differentiation so that every mathematical operation is visible in code, and then concisely, using the high-level abstractions of modern deep learning frameworks (PyTorch, JAX, TensorFlow, and MXNet). Once you have seen how a component works from the ground up, we use its concise framework implementation as a building block in later chapters.

The eight chapters of this part unfold in three stages:

The first five chapters (1  Preliminaries through 5  Computation) form a sequential spine and are best read in order. Once you have completed them, the computer vision chapters (6  Convolutional Neural Networks and 7  Modern Convolutional Neural Networks) and the sequence modeling chapter (8  Sequence Models) do not depend on one another and can be studied in either order. Together, they establish the conceptual and engineering habits that the Advanced part builds upon.