页面简介
正文摘录
Dive into Deep Learning Version 2026.11.26 Master the theory, design, and engineering of deep learning by building it from scratch. Each section weaves together intuition, mathematics, working code, and applications—and doubles as an interactive notebook you can run, modify, and experiment with directly. By Alexander J. Smola. First edition by Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola (Cambridge University Press, 2023). Read freely online, download the PDFs, or run the notebooks directly. Choose your framework: Basics and the math appendix support PyTorch, JAX, TensorFlow, and MXNet; Advanced supports PyTorch and JAX; and Language Models will focus on PyTorch. Start with the Introduction → Download the complete book as a single PDF (PyTorch, 75 MB) Start with the part you need Basics Chapters 1–8 · PyTorch, JAX, TensorFlow, MXNet Begin here if you are new to deep learning. Starting from tensors and automatic differentiation, you will build linear models, multilayer perceptrons, convolutional networks, and sequence models from the ground up. By the end, you will be able to train, debug, and evaluate neural networks on images and text, with a solid grasp of core techniques such as dropout and batch normalization. Read online · Download the PDF Advanced Chapters 9–17 · PyTorch, JAX Continue here once you are comfortable training neural networks. You will cover modern optimization (all the way to Muon), attention and Transformers, state space models (from Mamba to hybrid architectures), GPU performance and distributed training, reinforcement learning, GANs, and diffusion models. By the end, you will be able to build and train a Transformer, diagnose performance bottlenecks on single or multiple GPUs, and train both RL agents and modern generative models. Read online · Download the PDF Language Models In preparation Chapters 18–31 · PyTorch Follow the full lifecycle of building a state-of-the-art large language model—from data curation and pretraining to post-training, systems, and serving. Currently published as chapter outlines—full chapters coming soon. Read the outline · Download the PDF Mathematics for Deep Learning Chapters 33–38 · PyTorch, JAX, TensorFlow, MXNet Use it as a quick reference or work through all six chapters: linear algebra, calculus, optimization, probability and statistical learning, information theory, and dynamics. By the end, you will be able to follow every derivation in the main text and read research papers that take this background for granted. Read online · Download the PDF Two additional sections are still in transition. Image Models (Chapter 32, carried over from the first edition’s computer vision chapter) is slated for a full rewrite and expansion. Meanwhile, the Attic (Chapters 40–44: Gaussian processes, hyperparameter optimization, and recommender systems) preserves first-edition chapters that have not yet been updated for the second edition. Try a section now Below is a short example from the softmax regression chapter: the model definition and the four lines that train it on Fashion-MNIST for ten epochs, alongside the resulting training and validation curves (reaching ~83% validation accuracy). Switch frameworks using the tabs—the site will remember your preference—or open the notebook in Colab to run and modify it yourself. PyTorch TensorFlow JAX MXNet class SoftmaxRegression(d2l.Classifier): """The softmax regression model.""" def __init__(self, num_outputs, lr): super().__init__() self.save_hyperparameters() self.net = nn.Sequential(nn.Flatten(), nn.LazyLinear(num_outputs)) def weight_init(self, module): # The Trainer calls this after the lazy layer has learned its shape if isinstance(module, nn.Linear): nn.init.normal_(module.weight, std=0.01) nn.init.zeros_(module.bias) def forward(self, X): return self.net(X) data = d2l.FashionMNIST(batch_size=256) model = SoftmaxRegression(num_outputs=10, lr=0.1) trainer = d2l.Trainer(max_epochs=10) trainer.fit(model, data) Training loss, validation loss, and validation accuracy over ten epochs (PyTorch). Read this section · Open in Colab class SoftmaxRegression(d2l.Classifier): """The softmax regression model.""" def __init__(self, num_outputs, lr): super().__init__() self.save_hyperparameters() self.net = tf.keras.models.Sequential() self.net.add(tf.keras.layers.Flatten()) self.net.add(tf.keras.layers.Dense( num_outputs, kernel_initializer=tf.initializers.RandomNormal(stddev=0.01))) def forward(self, X): return self.net(X) data = d2l.FashionMNIST(batch_size=256) model = SoftmaxRegression(num_outputs=10, lr=0.1) trainer = d2l.Trainer(max_epochs=10) trainer.fit(model, data) Training loss, validation loss, and validation accuracy over ten epochs (TensorFlow). Read this section · Open in Colab class SoftmaxRegression(d2l.Classifier): """The softmax regression model.""" def __init__(self, num_outputs, lr, num_inputs=784, rngs=None): super().__init__() self.save_hyperparameters(ignore=['rngs']) rngs = nnx.Rngs(d2l.get_key()) if rngs is None else rngs self.net = nnx.Linear(num_inputs, num_outputs, kernel_init=nnx.initializers.normal(0.01), rngs=rngs) def forward(self, X): X = X.reshape((X.shape[0], -1)) # Flatten return self.net(X) data = d2l.FashionMNIST(batch_size=256) model = SoftmaxRegression(num_outputs=10, lr=0.1) trainer = d2l.Trainer(max_epochs=10) trainer.fit(model, data) Training loss, validation loss, and validation accuracy over ten epochs (JAX). Read this section · Open in Colab class SoftmaxRegression(d2l.Classifier): """The softmax regression model.""" def __init__(self, num_outputs, lr): super().__init__() self.save_hyperparameters() self.net = nn.Dense(num_outputs) self.net.initialize(init.Normal(sigma=0.01)) def forward(self, X): return self.net(X) data = d2l.FashionMNIST(batch_size=256) model = SoftmaxRegression(num_outputs=10, lr=0.1) trainer = d2l.Trainer(max_epochs=10) trainer.fit(model, data) Training loss, validation loss, and validation accuracy over ten epochs (MXNet). Read this section · Open in Colab Every figure and result in the book comes from its runnable notebooks (221 in PyTorch, 115 in TensorFlow, 188 in JAX, and 121 in MXNet). What you get with the book Run every notebook Launch any section in Colab or Kaggle—or download it as a Jupyter notebook—using the links at the top of the page. See how to run the notebooks. Or download them all in one zip: PyTorch · JAX · TensorFlow · MXNet Present from the slides Every section of Basics, Advanced, and the math appendix comes with a matching slide deck containing the exact same code and outputs as the book. Browse all slide decks and feel free to adapt them for your own courses. Practice what you learned Every section closes with a range of exercises, from checking mathematical derivations to extending the code with hands-on experiments. Try the exercises from the softmax regression section above. Ask in the forum Stuck on a concept or exercise? Every section links at the bottom to its dedicated Discourse thread, where you can ask questions, compare solutions, or report an error. Check the math Whenever the main text references a proof or deeper derivation, you can find the full treatment across the six chapters of Mathematics for Deep Learning. Choose your framework Basics and the math appendix are available in PyTorch, JAX, TensorFlow, and MXNet. Advanced is implemented in PyTorch and JAX—the two primary frameworks for modern deep learning research—and Language Models will focus on PyTorch, the standard ecosystem for sharing pretrained models (such as on Hugging Face). Pick a framework tab once, and the rest of the book follows automatically. What’s new in the second edition New or rebuilt Modular multi-part structure: Now spanning over 3,000 pages, the book is organized into self-contained parts so you can jump straight to what you need—with Basics designed as a standalone companion for an introductory course. Substantially new Advanced part: Brings you close to the current frontier across optimization, Transformers, state space models, reinforcement learning, GANs, and diffusion models. Expanded math appendix: More than doubled in length, adding deeper coverage of optimization, information theory, and the continuous-time dynamics underlying diffusion and flow models. Up-to-date, verified code: Every notebook runs on current framework releases, and every framework supported in a chapter is verified to reach comparable results on the same benchmark. Community-driven polish: Pending GitHub issues, pull requests, and forum bug reports have been resolved, and code, prose, experiments, and equations have been audited end to end for consistency. Still in progress Language Models: Planned and outlined, with full chapters still to be written. You can read the outline today—feedback is warmly welcome. Image Models: Currently retains the first edition’s computer vision chapter; like Language Models, it awaits a full rewrite expanding into modern vision and graphics. Topics outside our current scope: We do not yet cover other modalities such as audio and speech. A thorough treatment of agents likely warrants a part of its own (though some material will appear in Language Models), and rich areas such as graph and geometric deep learning, semi-supervised learning, and interpretability remain uncovered. Inevitably, the field moves faster than any single book can fully keep pace with. Read the preface to the second edition Teach with the book Build an introductory deep learning course around Basics, or pair it with Mathematics for Deep Learning as a companion math text. All slides, notebooks, exercises, and forum resources are free for classroom use. The text is licensed under CC BY-SA 4.0 (LICENSE), and the sample and reference code under a modified MIT license (LICENSE-SAMPLECODE). 500+ universities in 70+ countries have taught with Dive into Deep Learning. Browse their courses below. Universities that have taught with the book (as of November 2026). Feat