Registry / ai-ml / d2l
library1.0.3pypypiunverified

The d2l package (v1.0.3) provides utility functions and dataset loaders for the textbook 'Dive into Deep Learning' (d2l.ai). It includes common deep learning building blocks, data iterators, and plotting helpers to accompany the book. Release cadence is irregular, tied to book updates.

pip install d2l
INSTALL
IMPORT
SIG · D2L
D
d2l
ai-mlpythonv1.0.3
Install
29.5s avg
Import
Disk
591MB
Pass rate
3/ 10
Env Coverage3 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 28.2s
py 3.11
✕ build_error
✓ 27.8s
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 32.5s
591MB installed
● package 591MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

d2l
import d2l
Commonly imported as a module; subpackages like d2l.torch, d2l.mxnet, d2l.tensorflow exist but torch is default
torch
from d2l import torch as d2l_torch
from d2l.torch import *
d2l.torch is deprecated; use from d2l import torch and then call d2l.torch.xxx or simply import d2l and use d2l.xxx
data
from d2l import data
from d2l.utils import data
d2l.utils was restructured; direct submodules are preferred
Animator
from d2l import Animator
from d2l.plot import Animator
Animator is now top-level in d2l
Accumulator
from d2l import Accumulator
Top-level utility; no common mistake

Quickstart: Load Fashion-MNIST using d2l's data loader. The d2l package simplifies dataset access and common training loops.

import torch from d2l import torch as d2l # Load a small dataset (Fashion-MNIST) train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size=256) # Check batch for X, y in train_iter: print(X.shape, y.shape) break
Debug
Known issues
deprecatedd2l.torch (submodule) is deprecated; use `from d2l import torch` or `import d2l` directly. The old import path `d2l.torch.nn` etc. may break in future versions.
fix
Replace `from d2l.torch import ...` with `from d2l import torch as d2l` or simply `import d2l` and use `d2l.xxx`.
affects: >=1.0.0
breakingIn d2l 1.0.0, many utility functions were moved to top-level (e.g., Animator, Accumulator, Timer) and removed from submodules like d2l.utils. Scripts using old paths will raise ImportError.
fix
Update imports: use `from d2l import Animator, Accumulator` instead of `from d2l.utils import Animator`.
affects: >=1.0.0
gotchaThe d2l package downloads datasets on first use from a server that may be slow or unreachable in certain regions. If dataset download hangs or fails, check network connectivity or manually download from the book's website.
fix
Set environment variable `D2L_DATA_DIR` to a local directory with pre-downloaded datasets. For offline use, manually copy datasets to ~/.d2l/data/.
affects: all
deprecatedThe `d2l.mxnet` and `d2l.tensorflow` backends are deprecated and no longer maintained. Only PyTorch (torch) backend is actively developed.
fix
Use the torch backend: `from d2l import torch` or `import d2l` (defaults to torch). Avoid importing d2l.mxnet or d2l.tensorflow.
affects: >=1.0.0
Upgrade
Version history
1.0.3latest on PyPI · released Aug 18, 2023
Audit
Dependencies
torchrequiredd2l is built on PyTorch; core dependency for all tensor operations and models
matplotlibrequiredUsed for plotting utilities (e.g., show_images)
requestsrequiredUsed for downloading datasets from the d2l data server
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources