ap.Abhishek Patel

Search

Search notes, essays, projects, the library and the AI course. Use arrow keys to choose and Enter to open.

Module 27

Math and PyTorch Foundations

Open the bonnet of a neural network. You learn the four pieces of maths that matter (linear algebra, probability, statistics and calculus) through one delivery order traced by hand, then build, train, regularise and honestly evaluate real networks in PyTorch, and rebuild one in TensorFlow. Two mini projects close the module: a Keras network trained three ways, and an autoencoder that learns handwriting without labels.

By the end of this module you can

  • explain vectors, dot products, softmax, standardising, derivatives and the chain rule with a worked example
  • implement gradient descent from scratch and diagnose a bad learning rate from the loss curve
  • build PyTorch models from tensors, layers and nn.Module, and read their shapes and parameter counts
  • write a correct training loop and choose between SGD, momentum and Adam
  • spot overfitting, fix it with dropout, weight decay and early stopping, and evaluate with confusion matrices, precision and recall
  • build and train the same network in TensorFlow and Keras, and train an autoencoder for unsupervised representation learning

Lessons

7 in this module
  1. 01The maths you actually needFollow one delivery order through a single neuron by hand, using statistics, linear algebra, probability and calculus, until you can explain what one training step does.30 min
  2. 02Gradient descentFit a forecasting line by gradient descent in NumPy, trace updates by hand, and diagnose learning rates that crawl, bounce or explode.30 min
  3. 03PyTorch tensors, layers and parametersUse tensors, autograd, nn.Linear, activations and nn.Module to build a network, trace one input through it and count its parameters.30 min
  4. 04Training loops, optimisers and learning rateWrite a correct five-step PyTorch training loop, trace one batch through it, and choose and tune SGD, momentum or Adam.30 min
  5. 05Overfitting, dropout and evaluationDetect overfitting with train, validation and test splits, fix it with dropout, weight decay and early stopping, and evaluate with torchmetrics and a cost-based threshold.30 min
  6. 06Mini project: a neural network in TensorFlowBuild the late-delivery classifier three ways in TensorFlow (raw variables with GradientTape, Keras model.fit, and a custom Keras loop), evaluate them honestly and ship a .keras file.Project180 min
  7. 07Mini project: MNIST autoencoderTrain a PyTorch autoencoder on MNIST without labels, visualise its latent space, generate digits from it and use reconstruction error to flag smudged handwriting.Project180 min