1.1 PyTorch Tensors & Autograd
Tensors: creation (torch.tensor, zeros, ones, randn), operations, device management (CPU ↔ GPU with .to('cuda')). Autograd: automatic differentiation — requires_grad=True, .backward(), .grad. Computational graph: how PyTorch tracks operations for backpropagation. The foundation of every PyTorch model: tensors + autograd + GPU = fast training.
1.2 Dataset, DataLoader & Transforms
torch.utils.data.Dataset: custom dataset class (__len__, __getitem__). DataLoader: batching, shuffling, num_workers for parallel loading. torchvision.transforms: Compose, Resize, ToTensor, Normalize, RandomHorizontalFlip. Data augmentation pipeline for training vs validation (augment train only). The data pipeline every PyTorch project needs — custom datasets for ANY data format (images, text, tabular).
1.3 Building Neural Networks: nn.Module
nn.Module: the base class for all models. __init__ (define layers), forward (define computation). Common layers: nn.Linear, nn.ReLU, nn.Dropout, nn.BatchNorm1d. nn.Sequential for simple architectures. Model parameters: model.parameters(), count with sum(p.numel()). Saving/loading: torch.save(model.state_dict()), model.load_state_dict(). Building an MLP classifier from scratch on tabular data.
1.4 Training Loop: Forward → Loss → Backward → Step
The training loop: optimizer.zero_grad() → output = model(x) → loss = criterion(output, y) → loss.backward() → optimizer.step(). Validation loop: with torch.no_grad(). Loss functions: CrossEntropyLoss (classification), MSELoss (regression), BCEWithLogitsLoss (binary). Optimizers: SGD (+ momentum), Adam, AdamW. Learning rate scheduling: StepLR, CosineAnnealingLR, OneCycleLR. Writing the training loop from scratch teaches what frameworks abstract away.
1.5 GPU Training & Google Colab Setup
Google Colab: free GPU (T4) access. Runtime → Change runtime type → GPU. Moving tensors and model to GPU: .to('cuda'). Mixed precision training: torch.cuda.amp for 2x speed with half-precision. Gradient accumulation for training with larger effective batch sizes on limited GPU memory. torch.cuda.memory_summary() for debugging OOM. The practical GPU training skills every DL practitioner needs.
1.6 Experiment Tracking: Weights & Biases
W&B (wandb): log metrics, hyperparameters, model architecture, sample predictions. wandb.init(), wandb.log(). Visualise training curves (loss, accuracy) across runs. Hyperparameter sweeps with wandb.sweep. Model checkpointing. Compare experiments. Why W&B is the DL experiment tracking standard — used at OpenAI, Google DeepMind, and most AI research labs. Free tier is sufficient for learning.
Placement relevance: "Write a PyTorch training loop from scratch" is the standard DL interview coding question. Understanding tensors, autograd, and the training loop is what separates "I used Keras" from "I understand deep learning." W&B knowledge signals research-level practice. Google Colab + GPU training is the practical starting point for all DL work.