Background
Sections
IntroductionModule 01 β€” Tensors 🧊01 Β· Creating Tensors 🧊02 Β· Indexing & Reshaping πŸ”ͺ03 Β· Tensor Math βž—04 Β· Device Placement πŸ–₯️⚑Module 02 β€” Autograd βš™οΈ01 Β· The Computational Graph πŸ•ΈοΈ02 Β· Backward Pass & Gradients ⬅️03 Β· Turning Autograd Off πŸ›‘04 Β· Gradient Gotchas πŸͺ€Module 03 β€” Neural Networks01 Β· The `nn.Module` Basics 🧱02 Β· Common Layers 🧩03 Β· Building a Network πŸ—οΈ04 Β· Inspecting Models πŸ”Module 04 β€” Data Handling πŸ—‚οΈ01 Β· Dataset Basics πŸ“‡02 Β· The DataLoader 🚚03 Β· Transforms 🎨04 Β· Splits & Built-in Datasets βœ‚οΈModule 05 β€” The Training Loop πŸ”01 Β· Loss Functions 🎯02 Β· Optimizers βš™οΈ03 Β· The Training Loop πŸ”04 Β· Evaluation & Metrics πŸ“ŠModule 06 β€” Saving & Loading πŸ’Ύ01 Β· `state_dict` Basics πŸ’Ύ02 Β· Checkpoints & Resuming ⏸️03 Β· Loading for Inference πŸš€04 Β· Best Model & Early Stopping πŸ…Module 07 β€” Computer Vision πŸ‘οΈ01 Β· Convolutions πŸ”²02 Β· CNN Architecture πŸ›οΈ03 Β· Transfer Learning πŸ”04 Β· Image Classification Project πŸ§ͺModule 08 β€” NLP & Transformers πŸ’¬01 Β· Text Data & Tokenization πŸ”€02 Β· Embeddings 🧭03 Β· Recurrent Layers & LSTMs πŸ”„04 Β· Intro to Transformers ⚑Module 09 β€” Ecosystem: PyTorch Lightning ⚑01 Β· Why Lightning? πŸ€”02 Β· The LightningModule 🧩03 Β· The Trainer πŸŽ›οΈ04 Β· DataModules & Callbacks 🧰Module 10 β€” Deployment & Optimization πŸš€01 Β· Exporting Models πŸ“¦02 Β· `torch.compile` ⚑03 Β· Inference Optimization πŸͺΆ04 Β· Serving & Next Steps πŸŽ“

PyTorch 101: Zero to Hero

July 11, 20264 min read
PyTorchDeep LearningNeural NetworksMachine LearningComputer VisionNLP

A beginner-to-advanced learning path for PyTorch β€” built as reference material, a technical portfolio, and a foundation for future articles.

Welcome! This article is designed to take you from "What even is a tensor?" to confidently building, training, and deploying deep learning models in PyTorch. Think of it less like documentation and more like a mentor sitting next to you β€” we'll always explain why a concept exists before showing you how to code it.

Each module is a self-contained, article-quality deep dive. Read them in order if you're new, or jump around if you're brushing up on a specific topic.


πŸš€ Quickstart

1. Install PyTorch

The safest way to install PyTorch is to grab the exact command from the official install selector, which tailors it to your OS and hardware. For a quick CPU-only start:

# Create an isolated environment (recommended)
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

# Install PyTorch + companions
pip install torch torchvision torchaudio

2. Verify your installation

import torch

print(torch.__version__)                 # e.g. 2.3.0
print("CUDA available:", torch.cuda.is_available())   # NVIDIA GPU?
print("MPS available:", torch.backends.mps.is_available())  # Apple Silicon?

If either prints True, you have hardware acceleration available. If not, no worries β€” every example here runs fine on a CPU.

3. Start learning

Head into docs/01-tensors/ and work your way up. πŸŽ“


πŸ—ΊοΈ The Roadmap / Syllabus

The curriculum is split into three phases, moving from raw building blocks to full deployment.

Phase 1 β€” Fundamentals

The bedrock. Master these and everything else clicks into place.

# Module What you'll learn
01 Tensors Creation, dtypes, slicing, reshaping, matrix math, device placement (CPU/GPU/MPS/CUDA)
02 Autograd The computational graph, requires_grad, forward/backward passes, gradients, torch.no_grad()
03 Neural Networks Custom architectures with nn.Module, the forward() method, Linear/ReLU/Dropout

Phase 2 β€” Data & Training

Turning models into things that actually learn.

# Module What you'll learn
04 Data Handling torch.utils.data, custom Dataset classes, DataLoader, batching, shuffling, transforms
05 The Training Loop Loss functions, optimizers (Adam, SGD), zeroing grads, backprop, train() vs eval()
06 Saving & Loading state_dict best practices, checkpoints, resuming training

Phase 3 β€” Advanced Architectures & Ecosystem

Real-world models and the tools around them.

# Module What you'll learn
07 Computer Vision CNNs, Conv2d, MaxPool2d, transfer learning
08 NLP & Transformers Text data, embeddings, LSTMs, intro to nn.Transformer
09 Ecosystem: Lightning Refactoring boilerplate loops into PyTorch Lightning
10 Deployment & Optimization Exporting models, PyTorch 2.x torch.compile for speed

πŸ“ Article Structure

Each module is a folder containing a short README.md index plus 2–4 sequentially numbered sub-module files that each go deep on one concept.

Every sub-module file follows the same predictable structure: The 'Why' β†’ Core Concepts β†’ Code in Action β†’ Common Pitfalls β†’ Further Reading & Watch List.


πŸ“š Top-Tier Resources (used throughout)

These are the resources I reference again and again. Bookmark them.


🀝 How to Use This Article

  • Total beginner? Start at Module 01 and don't skip ahead β€” each module assumes the previous ones.
  • Need a refresher? Jump straight to the module you need; each is self-contained.
  • Building a portfolio? Each module doubles as a polished write-up you can point to.

Happy learning. Let's build something. πŸ§