explaingit

chenyuntc/pytorch-book

12,837Jupyter NotebookAudience · researcherComplexity · 3/5Setup · moderate

TLDR

Companion code for a Chinese-language PyTorch book covering neural network basics through hands-on projects including image classifiers, anime portrait GANs, poem generators, and object detection.

Mindmap

mindmap
  root((pytorch-book))
    PyTorch basics
      Tensors
      Autograd
      Neural layers
      Data loading
    Advanced topics
      Vectorized ops
      Distributed training
      Custom CUDA extensions
    Projects
      Image classifier
      GAN portraits
      Poem generator
      Style transfer
      Object detection
    Format
      Jupyter notebooks
      Chinese explanations
      Interactive examples
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn PyTorch fundamentals by running interactive Jupyter notebooks covering tensors, neural networks, and data loading.

USE CASE 2

Build a ResNet image classifier in under 50 lines of code using the provided tutorial project.

USE CASE 3

Train a generative adversarial network to produce anime-style portrait images using the book's GAN project.

USE CASE 4

Implement a Chinese poem generator or object detection model using the Transformer and CenterNet project code.

Tech stack

PythonPyTorchJupyter NotebookCUDA

Getting it running

Difficulty · moderate Time to first run · 30min

Tested with PyTorch 1.6, 1.8, newer versions may require code modifications before running.

In plain English

This repository contains the companion code for a Chinese-language book titled "Deep Learning Framework PyTorch: Introduction and Practice" (second edition). The code can also be used as a standalone PyTorch tutorial independent of the printed book. The repository includes over 90% of the code from the book and more than 60% of its written explanations, so it is usable without purchasing the physical copy. The material is divided into three sections. The first covers the basics of PyTorch: installation, tensors (the core data structure), automatic differentiation, building neural network layers, and working with data loading and pretrained models. This section uses Jupyter Notebooks so readers can run and modify code interactively. One exercise in this section builds a ResNet image classification network in fewer than 50 lines of code. The second section covers more advanced topics including vectorized operations, distributed and parallel training across multiple machines, and writing custom CUDA extensions for GPU operations. The third section contains a set of hands-on projects: a binary image classifier built around a Kaggle competition dataset, a generative adversarial network that produces anime-style portrait images, a Chinese poem generator using a Transformer architecture, a neural style transfer network that applies the visual style of paintings to photos, and an object detection implementation using the CenterNet algorithm. All code was written for Python 3 and tested with PyTorch versions 1.6 to 1.8. Newer PyTorch versions may or may not work without modification. The README is written in Chinese, though the code itself uses standard Python and PyTorch conventions. Issues and pull requests are welcome for bugs or unclear explanations.

Copy-paste prompts

Prompt 1
Using the pytorch-book ResNet example, help me adapt the image classifier to recognize my own custom dataset of product photos instead of the default Kaggle dataset.
Prompt 2
I am following the pytorch-book GAN chapter. My generated anime portraits look blurry after 50 epochs, what hyperparameters should I adjust and why?
Prompt 3
Using the pytorch-book CenterNet object detection code, how do I run inference on a video file and draw bounding boxes frame by frame?
Prompt 4
Help me convert the pytorch-book neural style transfer example to run on CPU so I can test it on a laptop without a GPU.
Prompt 5
I want to extend the pytorch-book Chinese poem generator to produce English haiku. What changes are needed in the Transformer tokenizer and training data?
Open on GitHub → Explain another repo

← chenyuntc on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.