CodeRigor

COURSE / REAL PRACTICE

Deep learning 1: training a network

Watch lectures 1 to 8 of CMU’s public 11-785 course, then build what they derive in NumPy: threshold networks, cross-entropy, gradient descent, backpropagation, momentum, Adam, batch normalization and dropout. Every build is graded against PyTorch or an exact check. Unofficial practice material, not affiliated with CMU.

Free to useLessons & exercises8 authored lessons4 units
Start with the first lesson.

Read the explanation and diagrams, then work through the practice. Your browser profile supplies your saved progress.

What you’ll work toward

Train a multilayer classifier with your own NumPy code: backpropagation, mini-batches, Adam and weight decay, with every update checked against PyTorch’s and the best weights chosen on held-out data.

Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.

Before you start

This course builds on these skills:

Individual lessons can add prerequisites. Your lesson progress shows your actual readiness.

A look inside the first lesson

Perceptrons, Boolean logic and depth

Python
import itertools

def unit(w, b, x):
    return int(sum(wi * xi for wi, xi in zip(w, x)) + b >= 0)

inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
print("AND", [unit((1, 1), -2, x) for x in inputs])
print("OR ", [unit((1, 1), -1, x) for x in inputs])
print("NOT", [unit((-1,), 0, (v,)) for v in (0, 1)])

grid = [v / 2 for v in range(-6, 7)]   # -3.0 to 3.0 in steps of 0.5
xor = [0, 1, 1, 0]
hits = sum(
    [unit((w0, w1), b, x) for x in inputs] == xor
    for w0, w1, b in itertools.product(grid, repeat=3)
)
print("settings tried:", len(grid) ** 3, "that give XOR:", hits)

Your lesson sequence

Follow the same units and lessons in either view. Prerequisite links and your practice progress stay with each lesson.

UNIT 012 lessons What a network computes
  1. LESSON 01.01

    Perceptrons, Boolean logic and depth

    Threshold units as logic gates, why XOR needs a hidden layer, and a construction that turns any truth table into a two-layer network.

    Open lesson
  2. LESSON 01.02

    Empirical risk, softmax and cross-entropy

    Why training minimizes an average loss over samples, why that loss cannot be the error count, and a stable softmax cross-entropy with its gradient.

    Open lesson
UNIT 022 lessons Learning by gradient
  1. LESSON 02.01

    Gradient descent on a classifier

    Turn a gradient into a training loop: batch gradient descent on softmax regression, with the loss recorded before every step.

    Open lesson
  2. LESSON 02.02

    Backpropagation through an MLP

    Cache the forward pass, push the loss derivative back through softmax cross-entropy, linear layers and activations, and prove every gradient two independent ways.

    Open lesson
UNIT 033 lessons Making training converge
  1. LESSON 03.01

    Learning rates, momentum and Nesterov

    Why a step size above 2/L diverges on a quadratic bowl, and how momentum and Nesterov lookahead speed up the slow directions of a ravine.

    Open lesson
  2. LESSON 03.02

    Mini-batches, RMSProp and Adam

    What a mini-batch gradient estimates, and Adam: momentum plus a per-parameter step size with bias correction, matched step for step against PyTorch.

    Open lesson
  3. LESSON 03.03

    Batch normalization and dropout

    Two layers that behave differently in training and evaluation: batch statistics versus running averages, and inverted dropout that keeps the expected activation.

    Open lesson
UNIT 041 lesson A classifier trained end to end
  1. LESSON 04.01

    Capstone: train a classifier end to end

    Put backpropagation, mini-batches, Adam and weight decay into one training run, check every update against PyTorch, and keep the weights that do best on held-out data.

    Open lesson

WATCH ALONG

Videos for these lessons

One hand-picked talk, lecture or tutorial per lesson, in course order. They play here when you press play; nothing loads from the video provider before that.

8 videos· 11 h 25 min

  1. 01Perceptrons, Boolean logic and depth

  2. 02Empirical risk, softmax and cross-entropy

    The lecture this lesson is built around: learning a network by minimizing a loss averaged over training samples, and the choice of a differentiable divergence between output and target. Watch it first, then build the loss and its gradient here.

  3. 03Gradient descent on a classifier

  4. 04Backpropagation through an MLP

    The lecture this lesson is built around: the forward pass, the backward pass and the calculus of backpropagation for vector activations. Watch it first, then implement the same recursion here and check it against finite differences and autograd.

  5. 05Learning rates, momentum and Nesterov

    The lecture this lesson is built around: how the choice of step size and the shape of the loss surface govern gradient descent, and the momentum and Nesterov fixes. Watch it first, then build the three update rules here and measure them.

  6. 06Mini-batches, RMSProp and Adam

  7. 07Batch normalization and dropout

  8. 08Capstone: train a classifier end to end