{"id":23488,"library":"d2l","title":"Dive into Deep Learning (d2l)","description":"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.","status":"active","version":"1.0.3","language":"python","source_language":"en","source_url":"https://github.com/d2l-ai/d2l-en","tags":["deep learning","education","pytorch","data loader","utility"],"install":[{"cmd":"pip install d2l","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"d2l is built on PyTorch; core dependency for all tensor operations and models","package":"torch","optional":false},{"reason":"Used for plotting utilities (e.g., show_images)","package":"matplotlib","optional":false},{"reason":"Used for downloading datasets from the d2l data server","package":"requests","optional":false}],"imports":[{"note":"Commonly imported as a module; subpackages like d2l.torch, d2l.mxnet, d2l.tensorflow exist but torch is default","wrong":null,"symbol":"d2l","correct":"import d2l"},{"note":"d2l.torch is deprecated; use from d2l import torch and then call d2l.torch.xxx or simply import d2l and use d2l.xxx","wrong":"from d2l.torch import *","symbol":"torch","correct":"from d2l import torch as d2l_torch"},{"note":"d2l.utils was restructured; direct submodules are preferred","wrong":"from d2l.utils import data","symbol":"data","correct":"from d2l import data"},{"note":"Animator is now top-level in d2l","wrong":"from d2l.plot import Animator","symbol":"Animator","correct":"from d2l import Animator"},{"note":"Top-level utility; no common mistake","wrong":null,"symbol":"Accumulator","correct":"from d2l import Accumulator"}],"quickstart":{"code":"import torch\nfrom d2l import torch as d2l\n\n# Load a small dataset (Fashion-MNIST)\ntrain_iter, test_iter = d2l.load_data_fashion_mnist(batch_size=256)\n\n# Check batch\nfor X, y in train_iter:\n    print(X.shape, y.shape)\n    break","lang":"python","description":"Quickstart: Load Fashion-MNIST using d2l's data loader. The d2l package simplifies dataset access and common training loops."},"warnings":[{"fix":"Replace `from d2l.torch import ...` with `from d2l import torch as d2l` or simply `import d2l` and use `d2l.xxx`.","message":"d2l.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.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Update imports: use `from d2l import Animator, Accumulator` instead of `from d2l.utils import Animator`.","message":"In 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set environment variable `D2L_DATA_DIR` to a local directory with pre-downloaded datasets. For offline use, manually copy datasets to ~/.d2l/data/.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the torch backend: `from d2l import torch` or `import d2l` (defaults to torch). Avoid importing d2l.mxnet or d2l.tensorflow.","message":"The `d2l.mxnet` and `d2l.tensorflow` backends are deprecated and no longer maintained. Only PyTorch (torch) backend is actively developed.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace `from d2l.utils import something` with `from d2l import something` (e.g., Animator, Accumulator).","cause":"d2l.utils was removed in v1.0.0; utils are now top-level or in submodules like d2l.data.","error":"ModuleNotFoundError: No module named 'd2l.utils'"},{"fix":"Run `pip install --upgrade d2l` and change import to `from d2l import torch as d2l` or `import d2l`.","cause":"d2l.torch submodule removed; use `from d2l import torch` or upgrade to d2l>=1.0.0 where torch is re-exported at top level.","error":"AttributeError: module 'd2l' has no attribute 'torch'"},{"fix":"Uninstall d2l-zh: `pip uninstall d2l-zh`. Install the correct package: `pip install d2l`. Then use `import d2l` as described.","cause":"The deprecated d2l-zh package (Chinese version) is often confused with d2l. The wrong package downloaded a zip file instead of a proper Python module.","error":"FileNotFoundError: [Errno 2] No such file or directory: '/content/d2l-zh.zip'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}