Learn PyTorch for Deep Learning: Zero to Mastery book
Welcome to the second best place on the internet to learn PyTorch (the first being the PyTorch documentation).
This is the online book version of the Learn PyTorch for Deep Learning: Zero to Mastery course.
This course will teach you the foundations of machine learning and deep learning with PyTorch (a machine learning framework written in Python).
The course is video based. However, the videos are based on the contents of this online book.
For full code and resources see the course GitHub.
Otherwise, you can find more about the course below.
Does this course cover PyTorch 2.0?
Yes. PyTorch 2.0 is an additive release to previous versions of PyTorch.
This means it adds new features on top of the existing baseline features of PyTorch.
This course focuses on the baseline features of PyTorch (e.g. you're a beginner wanting to get into deep learning/AI).
Once you know the fundamentals of PyTorch, PyTorch 2.0 is a quick upgrade, there's a tutorial on this website which runs through the new features.
Course launched on ZTM Academy!
- Last update: April 16 2023
- Videos are done for chapters: 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 (all chapters!)
- Currently working on: PyTorch 2.0 Tutorial
- See progress on the course GitHub Project.
- 💻 Code on GitHub: All of course materials are available open-source on GitHub.
- 🎥 First five sections on YouTube: Learn Pytorch in a day by watching the first 25-hours of material.
- 🔬 Course focus: code, code, code, experiment, experiment, experiment.
- 🏃♂️ Teaching style: https://sive.rs/kimo.
- 🤔 Ask a question: See the course GitHub Discussions page for existing questions/ask your own.
|Section||What does it cover?||Exercises & Extra-curriculum||Slides|
|00 - PyTorch Fundamentals||Many fundamental PyTorch operations used for deep learning and neural networks.||Go to exercises & extra-curriculum||Go to slides|
|01 - PyTorch Workflow||Provides an outline for approaching deep learning problems and building neural networks with PyTorch.||Go to exercises & extra-curriculum||Go to slides|
|02 - PyTorch Neural Network Classification||Uses the PyTorch workflow from 01 to go through a neural network classification problem.||Go to exercises & extra-curriculum||Go to slides|
|03 - PyTorch Computer Vision||Let's see how PyTorch can be used for computer vision problems using the same workflow from 01 & 02.||Go to exercises & extra-curriculum||Go to slides|
|04 - PyTorch Custom Datasets||How do you load a custom dataset into PyTorch? Also we'll be laying the foundations in this notebook for our modular code (covered in 05).||Go to exercises & extra-curriculum||Go to slides|
|05 - PyTorch Going Modular||PyTorch is designed to be modular, let's turn what we've created into a series of Python scripts (this is how you'll often find PyTorch code in the wild).||Go to exercises & extra-curriculum||Go to slides|
|06 - PyTorch Transfer Learning||Let's take a well performing pre-trained model and adjust it to one of our own problems.||Go to exercises & extra-curriculum||Go to slides|
|07 - Milestone Project 1: PyTorch Experiment Tracking||We've built a bunch of models... wouldn't it be good to track how they're all going?||Go to exercises & extra-curriculum||Go to slides|
|08 - Milestone Project 2: PyTorch Paper Replicating||PyTorch is the most popular deep learning framework for machine learning research, let's see why by replicating a machine learning paper.||Go to exercises & extra-curriculum||Go to slides|
|09 - Milestone Project 3: Model Deployment||So we've built a working PyTorch model... how do we get it in the hands of others? Hint: deploy it to the internet.||Go to exercises & extra-curriculum||Go to slides|
|PyTorch Extra Resources||This course covers a large amount of PyTorch and deep learning but the field of machine learning is vast, inside here you'll find recommended books and resources for: PyTorch and deep learning, ML engineering, NLP (natural language processing), time series data, where to find datasets and more.||-||-|
|PyTorch Cheatsheet||A very quick overview of some of the main features of PyTorch plus links to various resources where more can be found in the course and in the PyTorch documentation.||-||-|
|Three Most Common Errors in PyTorch||An overview of the three most common errors in PyTorch (shape, device and datatype errors), how they happen and how to fix them.||-||-|
|A Quick PyTorch 2.0 Tutorial||A fasssssst introduction to PyTorch 2.0, what's new and how to get started along with resources to learn more.||-||-|
About this course
Who is this course for?
You: Are a beginner in the field of machine learning or deep learning or AI and would like to learn PyTorch.
This course: Teaches you PyTorch and many machine learning, deep learning and AI concepts in a hands-on, code-first way.
If you already have 1-year+ experience in machine learning, this course may help but it is specifically designed to be beginner-friendly.
What are the prerequisites?
- 3-6 months coding Python.
- At least one beginner machine learning course (however this might be able to be skipped, resources are linked for many different topics).
- Experience using Jupyter Notebooks or Google Colab (though you can pick this up as we go along).
- A willingness to learn (most important).
For 1 & 2, I'd recommend the Zero to Mastery Data Science and Machine Learning Bootcamp, it'll teach you the fundamentals of machine learning and Python (I'm biased though, I also teach that course).
How is the course taught?
All of the course materials are available for free in an online book at learnpytorch.io. If you like to read, I'd recommend going through the resources there.
If you prefer to learn via video, the course is also taught in apprenticeship-style format, meaning I write PyTorch code, you write PyTorch code.
There's a reason the course motto's include if in doubt, run the code and experiment, experiment, experiment!.
My whole goal is to help you to do one thing: learn machine learning by writing PyTorch code.
The code is all written via Google Colab Notebooks (you could also use Jupyter Notebooks), an incredible free resource to experiment with machine learning.
What will I get if I finish the course?
There's certificates and all that jazz if you go through the videos.
But certificates are meh.
You can consider this course a machine learning momentum builder.
By the end, you'll have written hundreds of lines of PyTorch code.
And will have been exposed to many of the most important concepts in machine learning.
So when you go to build your own machine learning projects or inspect a public machine learning project made with PyTorch, it'll feel familiar and if it doesn't, at least you'll know where to look.
What will I build in the course?
We start with the barebone fundamentals of PyTorch and machine learning, so even if you're new to machine learning you'll be caught up to speed.
Then we’ll explore more advanced areas including PyTorch neural network classification, PyTorch workflows, computer vision, custom datasets, experiment tracking, model deployment, and my personal favourite: transfer learning, a powerful technique for taking what one machine learning model has learned on another problem and applying it to your own!
Along the way, you’ll build three milestone projects surrounding an overarching project called FoodVision, a neural network computer vision model to classify images of food.
These milestone projects will help you practice using PyTorch to cover important machine learning concepts and create a portfolio you can show employers and say "here's what I've done".
How do I approach this course?
As mentioned, the video version of the course is taught apprenticeship style.
Meaning I write PyTorch code, you write PyTorch code.
But here's what I recommend:
- Code along (if in doubt, run the code) - Follow along with code and try to write as much of it as you can yourself, keep doing so until you find yourself writing PyTorch code in your subconscious that's when you can stop writing the same code over and over again.
- Explore and experiment (experiment, experiment, experiment!) - Machine learning (and deep learning) is very experimental. So if you find yourself wanting to try something on your own and ignoring the materials, do it.
- Visualize what you don't understand (visualize, visualize, visualize!) - Numbers on a page can get confusing. So make things colourful, see what the inputs and outputs of your code looks like.
- Ask questions - If you're stuck with something, ask a question, trying searching for it or if nothing comes up, the course GitHub Discussions page will be the place to go.
- Do the exercises - Each module of the course comes with a dedicated exercises section. It's important to try these on your own. You will get stuck. But that's the nature of learning something new: everyone gets stuck.
- Share your work - If you've learned something cool or even better, made something cool, share it. It could be with the course Discord group or on the course GitHub page or on your own website. The benefits of sharing your work is you get to practice communicating as well as others can help you out if you're not sure of something.
Do I need to take things in order?
The notebooks/chapters build upon each other sequentially but feel free to jump around.
How do I get started?
You can read the materials on any device but this course is best viewed and coded along within a desktop browser.
The course uses a free tool called Google Colab. If you've got no experience with it, I'd go through the free Introduction to Google Colab tutorial and then come back here.
- Click on one of the notebook or section links like "00. PyTorch Fundamentals".
- Click the "Open in Colab" button up the top.
- Press SHIFT+Enter a few times and see what happens.
Happy machine learning!