Skip to main content

dl_d2l

Project description

dl_d2l

This repository contains PyTorch implementations of the Deep Learning book "Dive into Deep Learning" (D2L).
It provides code examples, tutorials, and exercises to help you learn deep learning concepts using PyTorch.

Installation

pip install -U dl_d2l

Code Examples

You can find the code examples in the dl_d2l package. Here is a simple example of how to use it:

from dl_d2l import d2l_torch as d2l

x = d2l.arange(4)
print(x)
# enable_matplotlib_chinese
from dl_d2l.util import matplotlib_util

matplotlib_util.enable_chinese()

# example plot with Chinese characters
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-10, 10, 100)
y = x

plt.plot(x, y)
plt.title("中文标题:y = x")
plt.xlabel("横轴(x)")
plt.ylabel("纵轴(y)")
plt.show()
# get_available_device
from dl_d2l.util import device_util

device = device_util.get_available_device()

print(f"Available device: {device}")
# Check if running in Google Colab
from dl_d2l.util import colab_util

if colab_util.is_colab():
    print("Running in Google Colab")
else:
    print("Not running in Google Colab")
# Get base data directory in Google Colab or local environment
import os
from dl_d2l.util import colab_util

base_data_dir = colab_util.get_base_data_dir()
print(f'base data dir: {base_data_dir}')

datasets_dir = os.path.join(base_data_dir, 'ML', 'Datasets')
os.makedirs(datasets_dir, exist_ok=True)
print(f'datasets dir: {datasets_dir}')
# flush_drive in Google Colab
from dl_d2l.util import colab_util

colab_util.flush_drive()
print("Google Drive flushed.")

Build & upload to pypi (For Developers)

prerequirement: twine is installed. If not, run the following command to install it:

pip install -U twine

build and upload:

## package
python setup.py sdist

## upload
twine upload dist/*

D2L

For more information about the "Dive into Deep Learning" book, visit the official website.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dl_d2l-1.0.21.tar.gz (5.3 MB view details)

Uploaded Source

File details

Details for the file dl_d2l-1.0.21.tar.gz.

File metadata

  • Download URL: dl_d2l-1.0.21.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dl_d2l-1.0.21.tar.gz
Algorithm Hash digest
SHA256 2c75489ba0a13eb6ecf16816a1a96a73b2d6af0fa3c20fab1f33ffd47cd389e7
MD5 ff2cff8d0f54ca71246ff195716462e2
BLAKE2b-256 71e4dce360ef0dfca2e6b465c4c88ee51571156db8b5b7df028475f9569dd754

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page