Back to Course
Neural Networks: From Scratch
Module 7 of 12
7. The Training Loop
1. The Cycle of Life
- Forward: Pass data through network -> Get Prediction.
- Loss: Compare Prediction vs Truth. [Current Error: 0.5]
- Backward: Calculate Gradients. [Blame w1: +0.2]
- Step: Update Weights. [w1 = w1 - 0.01 * 0.2]
- Zero Grad: Clear gradients for next step.
pythonfor epoch in range(100): pred = model.forward(x) loss = mse(pred, y) loss.backward() # Magic happens here optimizer.step() optimizer.zero_grad()