This book assumes that readers have a certain foundation in machine learning and deep learning, and have used Keras or TensorFlow or Pytorch to build trained simple models.
The nickname is a video version of "Eat That Pytorch in 20 Days" is logged into BiliBili. Foodies are full of their hearts, just for the purest local flavor. New and old friends are welcome to come and taste it ??!
https://www.bilibili.com/video/BV1Ua411P7oe
This book is a Pytorch introductory reference book that is extremely friendly to human users. Don't let me think is the highest pursuit of this book.
This book is mainly compiled and written based on reference to the official Pytorch documentation and the function doc documentation.
Although the official Pytorch documentation is quite concise and clear, this book has made a lot of optimizations in the selection of chapter structure and examples, which is better in terms of user friendliness.
This book designs the content according to the difficulty of the content, reader search habits and Pytorch's own hierarchical structure, step by step and clear levels, making it convenient to find corresponding examples according to the functions.
This book is as simple and structured as possible in the example design, enhancing the readability and versatility of the examples. Most code snippets can be used out of the box in practice.
If it is about 5 to master Pytorch through learning Pytorch official documents, then the difficulty of mastering Pytorch through this book should be about 2.
Only the following figure compares the differences between the official Pytorch document and the book "Eat That Pytorch in 20 Days".
1. Study plan
This book was written by the author using about 3 months of his spare time, and most readers should be able to fully learn it within 20 days.
The study time you spend every day is between 30 minutes and 2 hours.
Of course, this book is also very suitable as a reference for Pytorch tool manual when it is implemented as an example library.
Click the blue title of learning content to enter this chapter.
| date | Learning content | Content difficulty | Estimated study time | Update status |
|---|---|---|---|---|
| 1. Pytorch modeling process | ️ | 0hour | ✅ | |
| day1 | 1-1, Structured Data Modeling Process Example | ️️️ | 1hour | ✅ |
| day2 | 1-2, Image data modeling process example | ️️️ | 2hour | ✅ |
| day3 | 1-3, Text data modeling process example | ️️️️ | 2hour | ✅ |
| day4 | 1-4, Time series data modeling process example | ️️️️ | 2hour | ✅ |
| 2. The core concept of Pytorch | ️ | 0hour | ✅ | |
| day5 | 2-1, Tensor data structure | ️️️ | 1hour | ✅ |
| day6 | 2-2, automatic differential mechanism | ️️️ | 1hour | ✅ |
| day7 | 2-3, Dynamic calculation diagram | ️️️️ | 2hour | ✅ |
| 3. Pytorch hierarchy | ️ | 0hour | ✅ | |
| day8 | 3-1, Low-order API Demonstration | ️️️ | 1hour | ✅ |
| day9 | 3-2, Intermediate API Demonstration | ️️️ | 1hour | ✅ |
| day10 | 3-3, Advanced API Demonstration | ️️️ | 1hour | ✅ |
| 4. Pytorch's low-order API | ️ | 0hour | ✅ | |
| day11 | 4-1, Structural operation of tensors | ️️️️ | 2hour | ✅ |
| day12 | 4-2, Mathematical Operation of Tensors | ️️️ | 1hour | ✅ |
| day13 | 4-3, nn.functional and nn.Module | ️️️ | 1hour | ✅ |
| 5. Pytorch's intermediate API | ️ | 0hour | ✅ | |
| day14 | 5-1, Dataset and DataLoader | ️️️ | 1hour | ✅ |
| day15 | 5-2, Model layer | ️️️️ | 2hour | ✅ |
| day16 | 5-3, Loss function | ️️️ | 1hour | ✅ |
| day17 | 5-4, TensorBoard visualization | ️️️ | 1hour | ✅ |
| 6. Pytorch's advanced API | ️ | 0hour | ✅ | |
| day18 | 6-1, 3 ways to build a model | ️️ | 0.5hour | ✅ |
| day19 | 6-2, 3 ways to train the model | ️️️ | 1hour | ✅ |
| day20 | 6-3, Use GPU to train the model | ️️️ | 1hour | ✅ |
| * | Postscript: My product view | ️ | 0hour | ✅ |
2. Learning environment
All the source codes of this book are written in jupyter and passed the test. It is recommended to clone it locally through git and run the learning interactively in jupyter.
step1: Clone the source code of this book to the local area, use the code cloud mirror warehouse to download faster in China
git clone https://gitee.com/Python_Ai_Road/eat_pytorch_in_20_days
step2: Official account algorithm Food House Reply keywords: pytorch , obtain the data set summary compression package used in this project eat_pytorch_datasets.zip Baidu cloud disk download link, download and decompress and move to the eat_pytorch_in_20_days path, about 160M.
import torch
from torch import nn
print ( "torch version:" , torch . __version__ )
a = torch . tensor ([[ 2 , 1 ]])
b = torch . tensor ([[ - 1 , 2 ]])
c = a @ b . t ()
print ( "[[2,1]]@[[-1],[2]] =" , c . item ()) torch version: 2.0.1
[[2,1]]@[[-1],[2]] = 0
Suitable for students who are interested in advertising recommendation fields and need advanced??
| date | Learning content | Content difficulty | Estimated study time | Update status |
|---|---|---|---|---|
| 7. Pytorch and advertising recommendations | ️ | 0hour | ✅ | |
| day1 | 7-1, Recommended algorithm business | ️️️ | 0.5hour | ✅ |
| day2 | 7-2, Advertising Algorithm Business | ️️️ | 0.5hour | ✅ |
| day3 | 7-3, FM model | ️️️ | 1hour | ✅ |
| day4 | 7-4, DeepFM model | ️️️ | 1hour | ✅ |
| day5 | 7-5, FiBiNET model | ️️️ | 2hour | ✅ |
| day6 | 7-6, DeepCross Model | ️️️️ | 2hour | ✅ |
| day7 | 7-7,DIN network | ️️️️ | 2hour | ✅ |
| day8 | 7-8, DIEN network | ️️️️ | 2hour | ✅ |
Introduction to some peripheral tools related to pytorch
| date | Learning content | Content difficulty | Estimated study time | Update status |
|---|---|---|---|---|
| Easter egg: Pytorch peripheral tools | ️ | 0hour | ✅ | |
| day1 | A-1, Kaggle free GPU usage guide | ️️️ | 1hour | ✅ |
| day2 | A-2, Streamlit builds machine learning applications | ️️️ | 1hour | ✅ |
| day3 | A-3, use Mac M1 chip to accelerate pytorch | ️️️ | 1hour | ✅ |
| day4 | A-4, Optuna Visual Parameter Adjustment Magic Guide | ️️️ | 1hour | ✅ |
| day5 | A-5, gradio makes your machine learning model sexy | ️️️ | 1hour | ✅ |
| day6 | A-6, wandb model visual analysis | ️️️ | 0.5hour | ✅ |
| day7 | A-7, wandb model visualization and automatic parameter adjustment | ️️️ | 1hour | ✅ |
The relevant chapter code has been optimized and adjusted accordingly.
| Function | Stable support for the starting version | Depend on or borrow the library |
|---|---|---|
| ✅ Training progress bar | 3.0.0 | Rely on tqdm, learn from keras |
| ✅ Training evaluation indicators | 3.0.0 | Drawing on pytorch_lightning |
| ✅ Training in notebook comes with visualization | 3.8.0 | Draw from fastai |
| ✅ Early stopping | 3.0.0 | Drawing on keras |
| ✅ gpu training | 3.0.0 | Depend on acceleraterate |
| ✅ multi-gpus training(ddp) | 3.6.0 | Depend on acceleraterate |
| ✅ fp16/bf16 training | 3.6.0 | Depend on acceleraterate |
| ✅ tensorboard callback | 3.7.0 | Depend on tensorboard |
| ✅ wandb callback | 3.7.0 | Depend on wandb |
For details, please refer to the project link:: https://github.com/lyhue1991/torchkeras
If this book is helpful to you, I would like to encourage the author, remember to add a star to this project and share it with your friends?!
If you have some questions or suggestions about the content of this book, you can reply to the keywords in the backend of the official account "Algorithm Food House": Join the group and join the reader exchange group to discuss with everyone.