Hands On "AI Engineering"

Hands On "AI Engineering"

180-Day AI and Machine Learning Course from Scratch

Day 14: The Chain Rule and Partial Derivatives

Your Neural Network’s Secret Weapon

SystemDR's avatar
SystemDR
Nov 07, 2025
∙ Paid

What We’ll Build Today

  • Master the chain rule for composite functions that power neural networks

  • Understand partial derivatives for multivariable functions (the backbone of machine learning)

  • Code a simple neural network forward pass that demonstrates these concepts in action


Why This Matters: The Engine Behind AI Learning

Think of learning to drive a car. When you press the gas pedal too hard and the car lurches forward, your brain automatically adjusts: “less pressure next time.” Your brain just performed backpropagation using the chain rule, connecting the steering wheel outcome back through your motor control system to adjust future actions.

Neural networks work exactly the same way. When an AI model makes a wrong prediction, it needs to trace back through layers of calculations to figure out which parts to adjust. The chain rule is what makes this magical “learning from mistakes” possible in every AI system you’ve ever used.


Core Concepts: Building Your Mathematical Toolkit

The Chain Rule: Following the Trail of Changes

Imagine you’re baking a cake and the recipe depends on oven temperature, which depends on the dial setting, which depends on how much you turn it. If the cake burns, how much should you adjust the dial? The chain rule helps you trace this chain of dependencies backward.

In mathematical terms, if we have a function composed of other functions (like f(g(x))), the chain rule tells us:

d/dx[f(g(x))] = f’(g(x)) × g’(x)

This might look abstract, but in AI, this is everywhere. Consider a neural network that processes an image through multiple layers:

Input → Hidden Layer 1 → Hidden Layer 2 → Output

Each layer transforms the data, creating a chain of functions. When we need to update the network’s weights after seeing the result, we use the chain rule to propagate the error backward through each layer.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 AIE
Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture