# d2l-ai/d2l-zh architecture

> Architecture diagram of the GitHub repository d2l-ai/d2l-zh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d2l-ai/d2l-zh
- Repository: https://github.com/d2l-ai/d2l-zh

## Overview

D2L is an open, practice-oriented deep-learning textbook accompanied by runnable examples and framework-specific helper libraries. The main reader workflow is to study mathematical and computational foundations, learn model and training methods, apply them to vision and language tasks, and explore performance and deployment topics; examples use the `d2l` adapters with frameworks and datasets. The graph groups the book’s major documented subject areas and its internal code layer. README and the sampled adapter sources support the overall workflow, but do not establish detailed calls among unsampled chapter subsystems.

Main entry points: [`d2l/__init__.py`](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/__init__.py) (Framework Helpers), [`d2l/torch.py`](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/torch.py) (PyTorch Adapter), [`d2l/tensorflow.py`](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/tensorflow.py) (TensorFlow Adapter), [`d2l/mxnet.py`](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/mxnet.py) (MXNet Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundations["Foundations"]
  node_intro["Introduction<br/>[index.md]"]
  node_preliminaries["Math And Data<br/>[index.md]"]
end

subgraph group_models["Models And Methods"]
  node_linear["Linear Networks<br/>[index.md]"]
  node_mlp["Multilayer Networks<br/>[index.md]"]
  node_optimization["Optimization<br/>[index.md]"]
  node_computation["Model Computation<br/>[index.md]"]
  node_cnn["Convolutional Models<br/>[index.md]"]
  node_modern_cnn["Modern Vision Models<br/>[index.md]"]
  node_rnn["Recurrent Models<br/>[index.md]"]
  node_attention["Attention And Transformers<br/>[index.md]"]
end

subgraph group_applications["Applications"]
  node_vision["Computer Vision<br/>[index.md]"]
  node_nlp_pretraining["Language Pretraining<br/>[index.md]"]
  node_nlp_applications["Language Applications<br/>[index.md]"]
end

subgraph group_systems["Systems And Tools"]
  node_performance["Performance And Scaling<br/>[index.md]"]
  node_tools["Tools And Deployment<br/>[index.md]"]
end

subgraph group_runtime["Example Runtime"]
  node_d2l_api["Framework Helpers<br/>[__init__.py]"]
  node_torch_backend["PyTorch Adapter<br/>[torch.py]"]
  node_tf_backend["TensorFlow Adapter<br/>[tensorflow.py]"]
  node_mx_backend["MXNet Adapter<br/>[mxnet.py]"]
  node_paddle_backend["Paddle Adapter<br/>[paddle.py]"]
end

node_learner(("Reader / Learner"))
node_frameworks["ML Frameworks"]
node_data_service[("Dataset Hosting")]
node_discussion(("Reader Discussion"))

node_learner -->|"starts with"| node_intro
node_learner -->|"studies"| node_preliminaries
node_learner -->|"studies"| node_linear
node_learner -->|"studies"| node_mlp
node_learner -->|"studies"| node_optimization
node_learner -->|"studies"| node_computation
node_learner -->|"studies"| node_cnn
node_learner -->|"studies"| node_modern_cnn
node_learner -->|"studies"| node_rnn
node_learner -->|"studies"| node_attention
node_learner -->|"applies methods"| node_vision
node_learner -->|"studies"| node_nlp_pretraining
node_learner -->|"applies methods"| node_nlp_applications
node_learner -->|"explores scaling"| node_performance
node_learner -->|"consults"| node_tools
node_linear -->|"examples use"| node_d2l_api
node_mlp -->|"examples use"| node_d2l_api
node_cnn -->|"examples use"| node_d2l_api
node_rnn -->|"examples use"| node_d2l_api
node_attention -->|"examples use"| node_d2l_api
node_vision -->|"examples use"| node_d2l_api
node_nlp_pretraining -->|"examples use"| node_d2l_api
node_nlp_applications -->|"examples use"| node_d2l_api
node_d2l_api -->|"selects backend"| node_torch_backend
node_d2l_api -->|"selects backend"| node_tf_backend
node_d2l_api -->|"selects backend"| node_mx_backend
node_d2l_api -->|"selects backend"| node_paddle_backend
node_torch_backend -->|"uses"| node_frameworks
node_tf_backend -->|"uses"| node_frameworks
node_mx_backend -->|"uses"| node_frameworks
node_paddle_backend -->|"uses"| node_frameworks
node_torch_backend -->|"downloads datasets"| node_data_service
node_tf_backend -->|"downloads datasets"| node_data_service
node_mx_backend -->|"downloads datasets"| node_data_service
node_paddle_backend -->|"downloads datasets"| node_data_service
node_learner -.->|"asks questions"| node_discussion

click node_intro "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_introduction/index.md"
click node_preliminaries "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_preliminaries/index.md"
click node_linear "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_linear-networks/index.md"
click node_mlp "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_multilayer-perceptrons/index.md"
click node_optimization "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_optimization/index.md"
click node_computation "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_deep-learning-computation/index.md"
click node_cnn "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_convolutional-neural-networks/index.md"
click node_modern_cnn "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_convolutional-modern/index.md"
click node_rnn "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_recurrent-neural-networks/index.md"
click node_attention "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_attention-mechanisms/index.md"
click node_vision "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_computer-vision/index.md"
click node_nlp_pretraining "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_natural-language-processing-pretraining/index.md"
click node_nlp_applications "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_natural-language-processing-applications/index.md"
click node_performance "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_computational-performance/index.md"
click node_tools "https://github.com/d2l-ai/d2l-zh/blob/master/chapter_appendix-tools-for-deep-learning/index.md"
click node_d2l_api "https://github.com/d2l-ai/d2l-zh/blob/master/d2l/__init__.py"
click node_torch_backend "https://github.com/d2l-ai/d2l-zh/blob/master/d2l/torch.py"
click node_tf_backend "https://github.com/d2l-ai/d2l-zh/blob/master/d2l/tensorflow.py"
click node_mx_backend "https://github.com/d2l-ai/d2l-zh/blob/master/d2l/mxnet.py"
click node_paddle_backend "https://github.com/d2l-ai/d2l-zh/blob/master/d2l/paddle.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_intro,node_preliminaries toneBlue
class node_linear,node_mlp,node_optimization,node_computation,node_cnn,node_modern_cnn,node_rnn,node_attention,node_data_service toneAmber
class node_vision,node_nlp_pretraining,node_nlp_applications toneMint
class node_performance,node_tools toneRose
class node_d2l_api,node_torch_backend,node_tf_backend,node_mx_backend,node_paddle_backend,node_learner,node_frameworks,node_discussion toneIndigo
```

## Components

### Foundations

- [Introduction](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_introduction/index.md): `chapter_introduction/index.md`
- [Math And Data](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_preliminaries/index.md): `chapter_preliminaries/index.md`

### Models And Methods

- [Linear Networks](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_linear-networks/index.md): `chapter_linear-networks/index.md`
- [Multilayer Networks](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_multilayer-perceptrons/index.md): `chapter_multilayer-perceptrons/index.md`
- [Optimization](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_optimization/index.md): `chapter_optimization/index.md`
- [Model Computation](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_deep-learning-computation/index.md): `chapter_deep-learning-computation/index.md`
- [Convolutional Models](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_convolutional-neural-networks/index.md): `chapter_convolutional-neural-networks/index.md`
- [Modern Vision Models](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_convolutional-modern/index.md): `chapter_convolutional-modern/index.md`
- [Recurrent Models](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_recurrent-neural-networks/index.md): `chapter_recurrent-neural-networks/index.md`
- [Attention And Transformers](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_attention-mechanisms/index.md): `chapter_attention-mechanisms/index.md`

### Applications

- [Computer Vision](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_computer-vision/index.md): `chapter_computer-vision/index.md`
- [Language Pretraining](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_natural-language-processing-pretraining/index.md): `chapter_natural-language-processing-pretraining/index.md`
- [Language Applications](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_natural-language-processing-applications/index.md): `chapter_natural-language-processing-applications/index.md`

### Systems And Tools

- [Performance And Scaling](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_computational-performance/index.md): `chapter_computational-performance/index.md`
- [Tools And Deployment](https://github.com/d2l-ai/d2l-zh/blob/master/chapter_appendix-tools-for-deep-learning/index.md): `chapter_appendix-tools-for-deep-learning/index.md`

### Example Runtime

- [Framework Helpers](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/__init__.py): `d2l/__init__.py`
- [PyTorch Adapter](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/torch.py): `d2l/torch.py`
- [TensorFlow Adapter](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/tensorflow.py): `d2l/tensorflow.py`
- [MXNet Adapter](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/mxnet.py): `d2l/mxnet.py`
- [Paddle Adapter](https://github.com/d2l-ai/d2l-zh/blob/master/d2l/paddle.py): `d2l/paddle.py`

### Other components

- **Reader / Learner**
- **ML Frameworks**
- **Dataset Hosting**
- **Reader Discussion**

## Connections

- Reader / Learner → Introduction: starts with
- Reader / Learner → Math And Data: studies
- Reader / Learner → Linear Networks: studies
- Reader / Learner → Multilayer Networks: studies
- Reader / Learner → Optimization: studies
- Reader / Learner → Model Computation: studies
- Reader / Learner → Convolutional Models: studies
- Reader / Learner → Modern Vision Models: studies
- Reader / Learner → Recurrent Models: studies
- Reader / Learner → Attention And Transformers: studies
- Reader / Learner → Computer Vision: applies methods
- Reader / Learner → Language Pretraining: studies
- Reader / Learner → Language Applications: applies methods
- Reader / Learner → Performance And Scaling: explores scaling
- Reader / Learner → Tools And Deployment: consults
- Linear Networks → Framework Helpers: examples use
- Multilayer Networks → Framework Helpers: examples use
- Convolutional Models → Framework Helpers: examples use
- Recurrent Models → Framework Helpers: examples use
- Attention And Transformers → Framework Helpers: examples use
- Computer Vision → Framework Helpers: examples use
- Language Pretraining → Framework Helpers: examples use
- Language Applications → Framework Helpers: examples use
- Framework Helpers → PyTorch Adapter: selects backend
- Framework Helpers → TensorFlow Adapter: selects backend
- Framework Helpers → MXNet Adapter: selects backend
- Framework Helpers → Paddle Adapter: selects backend
- PyTorch Adapter → ML Frameworks: uses
- TensorFlow Adapter → ML Frameworks: uses
- MXNet Adapter → ML Frameworks: uses
- Paddle Adapter → ML Frameworks: uses
- PyTorch Adapter → Dataset Hosting: downloads datasets
- TensorFlow Adapter → Dataset Hosting: downloads datasets
- MXNet Adapter → Dataset Hosting: downloads datasets
- Paddle Adapter → Dataset Hosting: downloads datasets
- Reader / Learner → Reader Discussion: asks questions
