11import React , { useState , useCallback } from 'react' ;
22import SectionLayout from '../../../../components/shared/SectionLayout' ;
33import ThemeCard from '../../../../components/shared/ThemeCard' ;
4- import { ArrowRight , RotateCcw } from 'lucide-react' ;
4+ import { ArrowRight , RotateCcw , Lightbulb } from 'lucide-react' ;
55
66interface GraphNode {
77 id : string ;
@@ -145,16 +145,38 @@ const Backpropagation: React.FC = () => {
145145 const heroContent = (
146146 < div className = "max-w-4xl mx-auto text-center" >
147147 < h1 className = "text-4xl font-bold text-gray-900 mb-4" > Backpropagation</ h1 >
148- < p className = "text-xl text-gray-700 leading-relaxed" >
149- Gradient descent tells the network to step downhill. Backpropagation efficiently computes{ ' ' }
150- < strong > which direction is "downhill"</ strong > for every single parameter — by reversing the
151- chain of computation.
148+ < p className = "text-xl text-gray-700 leading-relaxed mb-3" >
149+ In the previous section, gradient descent told the network to "step downhill." But
150+ how does the network figure out which direction is downhill for < em > every single one</ em > of
151+ its millions of parameters? That's the job of backpropagation — the clever algorithm
152+ that < strong > traces the error backward</ strong > through the computation graph, assigning
153+ blame to each parameter along the way.
154+ </ p >
155+ < p className = "text-lg text-gray-600 leading-relaxed" >
156+ Without backpropagation, training would take exponentially longer. It's the reason
157+ modern deep learning is practical at all.
152158 </ p >
153159 </ div >
154160 ) ;
155161
156162 const mainContent = (
157163 < >
164+ { /* ELI10 box */ }
165+ < div className = "bg-gradient-to-r from-amber-50 to-yellow-50 rounded-xl p-5 border border-amber-200 mb-4" >
166+ < div className = "flex items-start gap-3" >
167+ < Lightbulb className = "w-6 h-6 text-amber-600 shrink-0 mt-0.5" />
168+ < div >
169+ < h3 className = "font-bold text-amber-900 mb-1" > Explain Like I'm 10</ h3 >
170+ < p className = "text-gray-700 leading-relaxed" >
171+ Imagine you're in a relay race team. You drop the baton and your team loses. The
172+ coach doesn't just shout at the last runner — they watch the replay and figure
173+ out < strong > who dropped it and when</ strong > . Backpropagation is that instant replay:
174+ it rewinds through every calculation the model made and tells each part exactly how
175+ much it messed up. Then every part can fix its own mistake for next time.
176+ </ p >
177+ </ div >
178+ </ div >
179+ </ div >
158180 < ThemeCard >
159181 < div className = "flex items-center justify-between mb-4 flex-wrap gap-2" >
160182 < h2 className = "text-2xl font-bold text-gray-900" > Computation Graph</ h2 >
@@ -183,8 +205,10 @@ const Backpropagation: React.FC = () => {
183205 </ div >
184206
185207 < p className = "text-sm text-gray-600 mb-3" >
186- Run the forward pass first, then click "Step Backward" repeatedly to watch gradients flow
187- in reverse through the graph.
208+ < strong > How to use:</ strong > Click "Forward Pass" to push values left → right.
209+ Then click "Step Backward" repeatedly to watch gradients flow right → left
210+ through the graph. Red badges show each node's gradient (how much it contributed to
211+ the error). Try "Auto Backward" to watch the full replay automatically!
188212 </ p >
189213
190214 < div className = "bg-gradient-to-br from-slate-50 to-rose-50/30 rounded-xl p-4 border border-rose-100" >
@@ -329,42 +353,59 @@ const Backpropagation: React.FC = () => {
329353
330354 < ThemeCard >
331355 < h2 className = "text-2xl font-bold text-gray-900 mb-4" > 🏭 The Corporate Chain of Command</ h2 >
332- < div className = "space-y-3" >
356+ < p className = "text-gray-700 leading-relaxed mb-4" >
357+ Think of a neural network as a factory with multiple departments. When a defective product
358+ ships, the QC boss doesn't fire everyone — they trace the assembly line backward to
359+ figure out < em > who</ em > is responsible and < em > how much</ em > .
360+ </ p >
361+ < div className = "space-y-3 mb-4" >
333362 { [
334363 {
335- team : 'Factory Floor (Layer 1)' ,
336- role : 'Molds plastic parts — receives the biggest blame if raw materials were wrong.' ,
364+ team : 'QC Boss (Loss Function)' ,
365+ emoji : '🔍' ,
366+ role : 'Inspects the final product, measures how bad the defect is, and starts the blame investigation.' ,
337367 } ,
338368 {
339- team : 'Assembly Team (Layer 2)' ,
340- role : 'Assembles components — "We used what Floor gave us!"' ,
369+ team : 'Packaging (Output Layer)' ,
370+ emoji : '📦' ,
371+ role : 'Closest to the output — gets feedback first. "The label was crooked? That\'s on me."' ,
341372 } ,
342373 {
343- team : 'Packaging (Output Layer)' ,
344- role : 'Boxes the product — closest to the output error.' ,
374+ team : 'Assembly Team (Hidden Layers)' ,
375+ emoji : '🔧' ,
376+ role : 'Middle of the chain. Receives proportional blame: "I used what the floor gave me, but I also bent it wrong."' ,
345377 } ,
346378 {
347- team : 'QC Boss (Loss Function)' ,
348- role : 'Inspects the final product and traces the blame backward.' ,
379+ team : 'Factory Floor (Input Layer)' ,
380+ emoji : '🏗️' ,
381+ role : 'The first to touch raw materials. Gets the smallest blame — but still adjusts for next time.' ,
349382 } ,
350- ] . map ( ( { team, role } ) => (
383+ ] . map ( ( { team, emoji , role } ) => (
351384 < div
352385 key = { team }
353386 className = "flex gap-3 items-start bg-gradient-to-r from-rose-50 to-white rounded-lg p-3 border border-rose-100"
354387 >
355- < div className = "w-2 h-2 rounded-full bg-rose-400 mt-1.5 shrink-0" / >
388+ < div className = "text-xl shrink-0" > { emoji } </ div >
356389 < div >
357390 < span className = "font-bold text-gray-900 text-sm" > { team } </ span >
358391 < p className = "text-xs text-gray-600" > { role } </ p >
359392 </ div >
360393 </ div >
361394 ) ) }
362395 </ div >
396+ < div className = "bg-rose-50 rounded-lg p-3 border border-rose-200" >
397+ < p className = "text-sm text-gray-700" >
398+ < strong > Key insight:</ strong > Each department only needs to know two things — what it
399+ received and what it sent out. It computes its < em > local gradient</ em > and passes the
400+ blame upstream. This is why backprop is so efficient: no department needs to understand
401+ the entire factory!
402+ </ p >
403+ </ div >
363404 </ ThemeCard >
364405
365406 < ThemeCard >
366407 < h2 className = "text-2xl font-bold text-gray-900 mb-4" > The Chain Rule</ h2 >
367- < div className = "bg-gradient-to-r from-rose-50 to-fuchsia-50 rounded-xl p-6 border border-rose-200 text-center" >
408+ < div className = "bg-gradient-to-r from-rose-50 to-fuchsia-50 rounded-xl p-6 border border-rose-200 text-center mb-4 " >
368409 < p className = "font-mono text-lg text-gray-800 mb-2" >
369410 ∂L/∂w = (∂L/∂ŷ) × (∂ŷ/∂z) × (∂z/∂w)
370411 </ p >
@@ -373,7 +414,61 @@ const Backpropagation: React.FC = () => {
373414 graph. Each node only needs to know its own local derivative.
374415 </ p >
375416 </ div >
417+ < div className = "bg-amber-50 rounded-lg p-4 border border-amber-200" >
418+ < h4 className = "font-bold text-amber-800 mb-2" > 🧒 In plain English:</ h4 >
419+ < p className = "text-sm text-gray-700 leading-relaxed mb-2" >
420+ Suppose you increase < strong > w</ strong > by a tiny amount. That changes{ ' ' }
421+ < strong > z</ strong > a little. That change in z changes < strong > ŷ</ strong > a little. And
422+ that change in ŷ changes the < strong > loss</ strong > a little. The chain rule multiplies
423+ all these "a little" effects together to get the total effect of changing w on
424+ the loss.
425+ </ p >
426+ < p className = "text-sm text-gray-700" >
427+ It's like a row of dominoes — each one tips the next, and the chain rule tells you
428+ how hard the last domino falls based on how hard you pushed the first one.
429+ </ p >
430+ </ div >
376431 </ ThemeCard >
432+
433+ { /* Forward vs Backward summary */ }
434+ < div className = "bg-white rounded-xl border border-gray-200 overflow-hidden mb-4" >
435+ < table className = "w-full text-sm" >
436+ < thead >
437+ < tr className = "bg-gray-50 border-b" >
438+ < th className = "p-3 text-left font-bold text-gray-900" > Aspect</ th >
439+ < th className = "p-3 text-left font-bold text-blue-700" > Forward Pass →</ th >
440+ < th className = "p-3 text-left font-bold text-rose-700" > Backward Pass ←</ th >
441+ </ tr >
442+ </ thead >
443+ < tbody >
444+ { [
445+ [ 'Direction' , 'Input → Output' , 'Output → Input' ] ,
446+ [ 'What flows' , 'Data values' , 'Gradients (blame)' ] ,
447+ [ 'Purpose' , 'Compute prediction' , 'Compute how to improve' ] ,
448+ [ 'When' , 'Every training step' , 'Every training step (after forward)' ] ,
449+ [ 'Result' , 'A prediction + loss value' , 'Updated weights' ] ,
450+ ] . map ( ( [ aspect , forward , backward ] ) => (
451+ < tr key = { aspect } className = "border-b last:border-0" >
452+ < td className = "p-3 font-medium text-gray-900" > { aspect } </ td >
453+ < td className = "p-3 text-gray-700" > { forward } </ td >
454+ < td className = "p-3 text-gray-700" > { backward } </ td >
455+ </ tr >
456+ ) ) }
457+ </ tbody >
458+ </ table >
459+ </ div >
460+
461+ { /* Key takeaway */ }
462+ < div className = "bg-gradient-to-r from-emerald-50 to-teal-50 rounded-xl p-5 border border-emerald-200" >
463+ < h3 className = "font-bold text-emerald-900 mb-2" > 🎯 Key Takeaway</ h3 >
464+ < p className = "text-gray-700 leading-relaxed" >
465+ Backpropagation is not a separate algorithm from gradient descent — it's the{ ' ' }
466+ < strong > efficient way to compute</ strong > the gradients that gradient descent needs. It
467+ works by applying the chain rule backward through the computation graph, so each node only
468+ computes its own local derivative. This makes training networks with millions of
469+ parameters practical on modern hardware.
470+ </ p >
471+ </ div >
377472 </ >
378473 ) ;
379474
0 commit comments