Gradient Descent & Backpropagation Explained: How AI Learns | LLM Course #13
How does a neural network actually learn? In Lecture 13 of the LLM Masterclass: the loss (how wrong the network is), the derivative as a slope, gradient descent as a ball rolling down a loss valley, the learning rate, the chain rule and backpropagation in plain words, and a single neuron in NumPy that learns a pattern while you watch the loss fall from 1.54 to 0.015. 💻 Code for this lecture (branch lecture-13): https://github.com/programmingline/chotugpt/tree/lecture-13 Lecture 13 of 32 — LLM Masterclass · Module 2: Just enough maths ⚠️ ChotuGPT is a simplified teaching model. The numbers in the examples are toy values, for teaching only. In this lecture: • The loss: one number that says how wrong the network is (squared error: (0.18 − 1)² ≈ 0.67) • The derivative is the slope of the loss: at w = 0.2 it is −1.48 • Gradient descent: new w = w − learning rate × gradient (w: 0.2 → 0.94, loss: 0.67 → 0.02) • The learning rate: too small is slow, too big overshoots • The chain rule and backpropagation: one backward pass gives every gradient • chotugpt/nn.py gets Linear.backward, Linear.step and mse_loss • A single neuron learns chai → 1, tea → 1, car → 0 in NumPy • Forward, loss, backward, step: the loop that trains every LLM Chapters: 00:00 Lecture 12 quiz answer 00:11 How networks learn 00:23 The loss: how wrong? 00:58 Forward, loss, backward, step 01:03 The slope: a derivative 01:31 Gradient descent and the learning rate 02:07 Backpropagation and the chain rule 02:31 Training a neuron in NumPy 03:06 Quiz 03:29 The loop that trains every LLM 03:50 Recap & next lecture ✅ Lecture 12 quiz answer: A, it turns it into zero. Positive numbers pass through unchanged. ❓ Quiz: Gradient descent moves each weight… A) In the direction that increases the loss B) Opposite to the gradient, to reduce the loss C) Randomly. Comment your answer. I reveal it in Lecture 14! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 12 — A neural network from scratch ⏭ Next: Lecture 14 — Softmax, probability and cross-entropy Sources: D. Rumelhart, G. Hinton and R. Williams, "Learning representations by back-propagating errors", Nature 323, 1986. A. Cauchy, "Méthode générale pour la résolution des systèmes d'équations simultanées", 1847 (gradient descent). I. Goodfellow, Y. Bengio and A. Courville, "Deep Learning", MIT Press 2016, chapters 4 and 6. NumPy documentation: numpy.ndarray.T, the @ operator (numpy.matmul). #GradientDescent #Backpropagation #NeuralNetwork…more
How does a neural network actually learn? In Lecture 13 of the LLM Masterclass: the loss (how wrong the network is), the derivative as a slope, gradient descent as a ball rolling down a loss valley, the learning rate, the chain rule and backpropagation in plain words, and a single neuron in NumPy that learns a pattern while you watch the loss fall from 1.54 to 0.015. 💻 Code for this lecture (branch lecture-13): https://github.com/programmingline/chotugpt/tree/lecture-13 Lecture 13 of 32 — LLM Masterclass · Module 2: Just enough maths ⚠️ ChotuGPT is a simplified teaching model. The numbers in the examples are toy values, for teaching only. In this lecture: • The loss: one number that says how wrong the network is (squared error: (0.18 − 1)² ≈ 0.67) • The derivative is the slope of the loss: at w = 0.2 it is −1.48 • Gradient descent: new w = w − learning rate × gradient (w: 0.2 → 0.94, loss: 0.67 → 0.02) • The learning rate: too small is slow, too big overshoots • The chain rule and backpropagation: one backward pass gives every gradient • chotugpt/nn.py gets Linear.backward, Linear.step and mse_loss • A single neuron learns chai → 1, tea → 1, car → 0 in NumPy • Forward, loss, backward, step: the loop that trains every LLM Chapters: 00:00 Lecture 12 quiz answer 00:11 How networks learn 00:23 The loss: how wrong? 00:58 Forward, loss, backward, step 01:03 The slope: a derivative 01:31 Gradient descent and the learning rate 02:07 Backpropagation and the chain rule 02:31 Training a neuron in NumPy 03:06 Quiz 03:29 The loop that trains every LLM 03:50 Recap & next lecture ✅ Lecture 12 quiz answer: A, it turns it into zero. Positive numbers pass through unchanged. ❓ Quiz: Gradient descent moves each weight… A) In the direction that increases the loss B) Opposite to the gradient, to reduce the loss C) Randomly. Comment your answer. I reveal it in Lecture 14! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 12 — A neural network from scratch ⏭ Next: Lecture 14 — Softmax, probability and cross-entropy Sources: D. Rumelhart, G. Hinton and R. Williams, "Learning representations by back-propagating errors", Nature 323, 1986. A. Cauchy, "Méthode générale pour la résolution des systèmes d'équations simultanées", 1847 (gradient descent). I. Goodfellow, Y. Bengio and A. Courville, "Deep Learning", MIT Press 2016, chapters 4 and 6. NumPy documentation: numpy.ndarray.T, the @ operator (numpy.matmul). #GradientDescent #Backpropagation #NeuralNetwork