# d2l-ai/d2l-en architecture

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

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

## Overview

D2L is an open-source, hands-on deep-learning book: readers study explanations, mathematics, figures, and runnable examples, with framework-specific helper code supporting the examples. Its content ranges from foundations and model training through specialized applications, with mathematics and tooling appendices. The four backend modules provide parallel PyTorch, TensorFlow, JAX, and MXNet APIs. The README documents the integrated book-and-code experience; backend imports and framework dependencies are visible in the excerpts. Most chapter implementations and their specific code links were not sampled, so those relationships are not expanded.

Main entry points: [`d2l/__init__.py`](https://github.com/d2l-ai/d2l-en/blob/master/d2l/__init__.py) (Backend selection), [`d2l/torch.py`](https://github.com/d2l-ai/d2l-en/blob/master/d2l/torch.py) (PyTorch helpers), [`d2l/tensorflow.py`](https://github.com/d2l-ai/d2l-en/blob/master/d2l/tensorflow.py) (TensorFlow helpers), [`d2l/jax.py`](https://github.com/d2l-ai/d2l-en/blob/master/d2l/jax.py) (JAX helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_book["Book content"]
  node_foundations["Foundations"]
  node_training["Model training"]
  node_vision["Computer vision"]
  node_language["Language models"]
  node_advanced["Advanced topics"]
end

subgraph group_appendices["Reference material"]
  node_math["Math reference"]
  node_tools["Learning tools"]
end

subgraph group_api["Example support"]
  node_backend_select["Backend selection<br/>[__init__.py]"]
  node_torch_api["PyTorch helpers<br/>[torch.py]"]
  node_tf_api["TensorFlow helpers<br/>[tensorflow.py]"]
  node_jax_api["JAX helpers<br/>[jax.py]"]
  node_mx_api["MXNet helpers<br/>[mxnet.py]"]
end

subgraph group_frameworks["ML frameworks"]
  node_pytorch["PyTorch"]
  node_tensorflow["TensorFlow"]
  node_jax["JAX"]
  node_mxnet["MXNet"]
end

node_reader(("Reader"))

node_reader -->|"studies"| node_foundations
node_reader -->|"studies"| node_training
node_reader -->|"studies"| node_vision
node_reader -->|"studies"| node_language
node_reader -->|"studies"| node_advanced
node_reader -->|"consults"| node_math
node_reader -->|"consults"| node_tools
node_reader -->|"runs examples with"| node_backend_select
node_backend_select -->|"selects"| node_torch_api
node_backend_select -->|"selects"| node_tf_api
node_backend_select -->|"selects"| node_jax_api
node_backend_select -->|"selects"| node_mx_api
node_torch_api -->|"uses"| node_pytorch
node_tf_api -->|"uses"| node_tensorflow
node_jax_api -->|"uses"| node_jax
node_mx_api -->|"uses"| node_mxnet

click node_foundations "https://github.com/d2l-ai/d2l-en/tree/master/chapter_preliminaries"
click node_training "https://github.com/d2l-ai/d2l-en/tree/master/chapter_linear-regression"
click node_vision "https://github.com/d2l-ai/d2l-en/tree/master/chapter_computer-vision"
click node_language "https://github.com/d2l-ai/d2l-en/tree/master/chapter_natural-language-processing-pretraining"
click node_advanced "https://github.com/d2l-ai/d2l-en/tree/master/chapter_attention-mechanisms-and-transformers"
click node_math "https://github.com/d2l-ai/d2l-en/tree/master/chapter_appendix-mathematics-for-deep-learning"
click node_tools "https://github.com/d2l-ai/d2l-en/tree/master/chapter_appendix-tools-for-deep-learning"
click node_backend_select "https://github.com/d2l-ai/d2l-en/blob/master/d2l/__init__.py"
click node_torch_api "https://github.com/d2l-ai/d2l-en/blob/master/d2l/torch.py"
click node_tf_api "https://github.com/d2l-ai/d2l-en/blob/master/d2l/tensorflow.py"
click node_jax_api "https://github.com/d2l-ai/d2l-en/blob/master/d2l/jax.py"
click node_mx_api "https://github.com/d2l-ai/d2l-en/blob/master/d2l/mxnet.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_foundations,node_training,node_vision,node_language,node_advanced toneBlue
class node_math,node_tools toneAmber
class node_backend_select,node_torch_api,node_tf_api,node_jax_api,node_mx_api toneMint
class node_pytorch,node_tensorflow,node_jax,node_mxnet toneRose
class node_reader toneIndigo
```

## Components

### Book content

- [Foundations](https://github.com/d2l-ai/d2l-en/tree/master/chapter_preliminaries): `chapter_preliminaries`
- [Model training](https://github.com/d2l-ai/d2l-en/tree/master/chapter_linear-regression): `chapter_linear-regression`
- [Computer vision](https://github.com/d2l-ai/d2l-en/tree/master/chapter_computer-vision): `chapter_computer-vision`
- [Language models](https://github.com/d2l-ai/d2l-en/tree/master/chapter_natural-language-processing-pretraining): `chapter_natural-language-processing-pretraining`
- [Advanced topics](https://github.com/d2l-ai/d2l-en/tree/master/chapter_attention-mechanisms-and-transformers): `chapter_attention-mechanisms-and-transformers`

### Reference material

- [Math reference](https://github.com/d2l-ai/d2l-en/tree/master/chapter_appendix-mathematics-for-deep-learning): `chapter_appendix-mathematics-for-deep-learning`
- [Learning tools](https://github.com/d2l-ai/d2l-en/tree/master/chapter_appendix-tools-for-deep-learning): `chapter_appendix-tools-for-deep-learning`

### Example support

- [Backend selection](https://github.com/d2l-ai/d2l-en/blob/master/d2l/__init__.py): `d2l/__init__.py`
- [PyTorch helpers](https://github.com/d2l-ai/d2l-en/blob/master/d2l/torch.py): `d2l/torch.py`
- [TensorFlow helpers](https://github.com/d2l-ai/d2l-en/blob/master/d2l/tensorflow.py): `d2l/tensorflow.py`
- [JAX helpers](https://github.com/d2l-ai/d2l-en/blob/master/d2l/jax.py): `d2l/jax.py`
- [MXNet helpers](https://github.com/d2l-ai/d2l-en/blob/master/d2l/mxnet.py): `d2l/mxnet.py`

### ML frameworks

- **PyTorch**
- **TensorFlow**
- **JAX**
- **MXNet**

### Other components

- **Reader**

## Connections

- Reader → Foundations: studies (evidence: `README.md`)
- Reader → Model training: studies (evidence: `README.md`)
- Reader → Computer vision: studies (evidence: `README.md`)
- Reader → Language models: studies (evidence: `README.md`)
- Reader → Advanced topics: studies (evidence: `README.md`)
- Reader → Math reference: consults (evidence: `README.md`)
- Reader → Learning tools: consults (evidence: `README.md`)
- Reader → Backend selection: runs examples with (evidence: `README.md`)
- Backend selection → PyTorch helpers: selects (evidence: `d2l/__init__.py`)
- Backend selection → TensorFlow helpers: selects (evidence: `d2l/__init__.py`)
- Backend selection → JAX helpers: selects (evidence: `d2l/__init__.py`)
- Backend selection → MXNet helpers: selects (evidence: `d2l/__init__.py`)
- PyTorch helpers → PyTorch: uses (evidence: `d2l/torch.py`)
- TensorFlow helpers → TensorFlow: uses (evidence: `d2l/tensorflow.py`)
- JAX helpers → JAX: uses (evidence: `d2l/jax.py`)
- MXNet helpers → MXNet: uses (evidence: `d2l/mxnet.py`)
