Deep Learning with PyTorch: Train Your First Neural Network
BeginnerTeach a small network to read handwritten digits, from tensors to a saved model.
You build
A command-line program that trains a small neural network on the MNIST images of handwritten digits, measures it on images it never saw, saves it, and says which digit is in an image file.
You need
- Writing basic Python: variables, lists, loops and functions, and importing a module. A class is written once in the course and explained as it is used.
- Running a Python script from a terminal
- School mathematics: arithmetic, averages and percentages. No calculus or linear algebra is needed.
To build it on your own machine
This is optional and comes with a plan. The course pack brings the starting files, a ready container and a check for every lesson. You need only Docker and git, plus your own AI coding agent if you want a tutor.
What you learn
The model, the loss and the update step, written by you once before PyTorch does them for you.
You build one small program that learns to read handwritten digits. It starts as a grid of numbers and two tensors of weights you write by hand, so nothing is a black box: you measure how wrong the model is, let PyTorch find which way to change every weight, and repeat that in a training loop. Then you build the network the usual PyTorch way, measure it honestly on images it never saw, save it and use it on a new image. It trains in a minute or two on a laptop CPU. You need basic Python and school maths.
- Data as Tensors. An image is a grid of numbers, and a tensor holds thousands of them with one shape and one type. Reading shapes and working on whole tensors at once is the skill every later step uses.
- A Loss and Its Gradients. One number says how wrong the model is, and its gradient says which way to move each weight to make it smaller. PyTorch works the gradients out for you, and you learn what it is doing when it does.
- The Training Loop. Predict, measure, find the gradients, update, and again: the same few lines train this network and the largest ones. Batches, epochs and an optimizer are the parts that make it practical.
- Honest Measurement. A model is judged on data it never trained on. Validation data guides your choices, test data gives the final number once, and the gap between training and validation shows overfitting.
Lessons
Deep Learning from the Outside: Examples In, Predictions Out
Learning from examples, A neural network, The training cycle, What PyTorch provides
Tensors: Shapes and Types
Tensor, Shape, Data type, Indexing and slicing
Maths on Whole Tensors: No Loops Needed
Operations on whole tensors, Broadcasting, Reshaping, Reducing along a dimension
A Model by Hand: Weights, Scores and a First Guess
Parameters, Weights and a bias, Matrix multiplication, Random starting weights
Loss: One Number for How Wrong the Model Is
Loss function, Why accuracy cannot guide training, Logits, Softmax
Gradients: Which Way to Change Every Weight
Gradient, Automatic differentiation, Gradient descent, Learning rate
The Training Loop: Batches, Epochs and an Optimizer
Mini-batches, Epochs, The data loader, The optimizer
Build the Network: Layers, ReLU and nn.Module
Linear layer, Hidden layer, Activation function, Module
Measure It Honestly: Validation, Test and Overfitting
Generalisation, Validation set, Test set, Evaluation mode
Save the Model and Predict a New Image
Saving the state dict, Loading weights safely, Inference, Same preparation as in training
Where it fits
Course 2 of 2 on the Machine Learning Engineer path.