PyTorch
Learn PyTorch from tensors and autograd to nn.Module models, training loops, data pipelines, GPUs, mixed precision, saving and deployment.
Learn PyTorch free, in English or Hindi, with lessons, shorts and interview questions.
Start course → · Interview questions
33 lessons · 10 modules · Free
What you'll learn
- Create, index, reshape and broadcast tensors while keeping track of shape, dtype and device.
- Explain how autograd records operations and computes gradients, and control it with no_grad, inference_mode and detach.
- Build models with nn.Module, choose the right layers and loss functions, and write a correct training and evaluation loop.
- Feed models with Dataset, DataLoader and torchvision transforms, and apply transfer learning to real tasks.
- Speed up training with GPUs, mixed precision and torch.compile, and make runs reproducible.
- Save, load, debug, export and serve models safely, and answer common PyTorch interview questions.
Syllabus
Mental model and setup
- What PyTorch is and why people use it
- Installing PyTorch and choosing a device
- The training loop idea, without PyTorch
Tensor foundations
- Creating tensors: shape, dtype and device
- Tensor operations and reductions
- Indexing, views and reshaping
- Broadcasting rules and the silent shape bug
Autograd: automatic gradients
- requires_grad, backward and .grad
- The dynamic computation graph
- no_grad, inference_mode, detach and zeroing gradients
Building models with torch.nn
- nn.Module: the shape of every model
- Common layers: Linear, Conv2d, activations and Sequential
- Loss functions and the logits rule
Training: optimizers, the loop and evaluation
- Optimizers and learning-rate schedules
- The canonical training loop
- Evaluation: train vs eval mode and metrics
Data pipelines: Dataset, DataLoader and transforms
- Writing a custom Dataset
- DataLoader: batching, shuffling and workers
- Image transforms and augmentation
Real-world models
- A convolutional image classifier
- Transfer learning with pretrained models
- Embeddings and sequence models
GPUs and performance
- Devices: moving models and data to the GPU
- Mixed precision with autocast and GradScaler
- torch.compile and a faster input pipeline
Saving, debugging, security and deployment
- Saving and loading with state_dict
- Debugging training: shapes, NaNs and silent failures
- Reproducibility and randomness
- Exporting and serving models
Revision and interview prep
- PyTorch cheat sheet
- Common interview and exam questions
- Self-check: spot the bugs
- Mixed self-check