🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Backpropagation Algorithm — Forward Pass, Backward Pass and Computational Graphs

FoundationsOptimization🟢 Free Lesson

Advertisement

DL Foundations

Backpropagation — How Neural Networks Actually Learn

Backpropagation is the algorithm that trains all neural networks. It efficiently computes the gradient of the loss with respect to every parameter using the chain rule, enabling gradient descent optimization.

  • Forward Pass — Compute outputs layer by layer while storing intermediate values
  • Backward Pass — Propagate error signals backward to compute parameter gradients
  • Efficient Gradient Computation — Same complexity as forward pass, reusing intermediate computations

Backpropagation Algorithm — Forward Pass, Backward Pass and Computational Graphs

Backpropagation is the algorithm that enables neural networks to learn from data. It efficiently computes the gradient of the loss with respect to every parameter using the chain rule.


What Is Backpropagation?


Computational Graphs

Computational Graph: f(x,y) = (x+y)·(x·y)xy+×a = x+yb = x·y×fBackward Pass:∂f/∂f = 1∂f/∂a = b∂f/∂b = a∂f/∂x = b + a∂f/∂y = b + a

Forward Pass

Forward Pass Through a 3-Layer NetworkInputh⁰ = xLayer 1z¹ = W¹h⁰ + b¹h¹ = σ(z¹)Layer 2z² = W²h¹ + b²h² = σ(z²)Layer 3z³ = W³h² + b³h³ = σ(z³)OutputŷForward: Input → Output (compute predictions)

Backward Pass

Backward Pass: Gradient Flow∂L/∂h³= 1∂L/∂z³= ∂L/∂h³ · σ'(z³)∂L/∂W³ = ∂L/∂z³ · (h²)ᵀ∂L/∂z²= ∂L/∂h² · σ'(z²)∂L/∂W² = ∂L/∂z² · (h¹)ᵀ∂L/∂z¹= ∂L/∂h¹ · σ'(z¹)∂L/∂W¹ = ∂L/∂z¹ · (h⁰)ᵀ∂L/∂h³(W³)ᵀ(W²)ᵀBackward: Output → Input (compute gradients)∂L/∂W⁽ˡ⁾ = ∂L/∂z⁽ˡ⁾ · (h⁽ˡ⁻¹⁾)ᵀ

Gradient Flow Through Layers

Gradient Magnitude Through LayersLayer 1||∂L/∂W¹|| = 1.0Layer 2||∂L/∂W²|| = 0.75Layer 3||∂L/∂W³|| = 0.40Layer 4||∂L/∂W⁴|| = 0.15Layer 5||∂L/∂W⁵|| = 0.05Vanishing Gradient• Gradients shrink exponentially• Early layers learn slowly• Caused by: sigmoid, tanh, small init• Solution: ReLU, skip connections

PyTorch Autograd


Practical Considerations


Summary

  • Backpropagation efficiently computes gradients using the chain rule
  • The forward pass computes outputs and stores intermediates; the backward pass computes gradients
  • Computational graphs represent the sequence of operations for automatic differentiation
  • Vanishing/exploding gradients are fundamental challenges solved by architectural innovations
  • PyTorch autograd implements reverse-mode automatic differentiation

Next: Activation Functions

Need Expert Deep Learning Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement