From a8f672028db71dffde648568ca4e97c1aa249b8d Mon Sep 17 00:00:00 2001 From: Vijay Janapa Reddi Date: Tue, 30 Sep 2025 17:17:46 -0400 Subject: [PATCH] style: Make Milestone 04 architecture consistent with others MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed from Panel to plain console.print with ASCII diagram. All 4 milestones now follow identical format: - console.print('[bold]πŸ—οΈ The Architecture:[/bold]') - ASCII box diagram with arrows - console.print('[bold]πŸ”§ Components:[/bold]') - Bullet list of components This ensures visual consistency across all milestone demonstrations! --- .../04_cnn_revolution_1998/cnn_digits.py | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/milestones/04_cnn_revolution_1998/cnn_digits.py b/milestones/04_cnn_revolution_1998/cnn_digits.py index 2edbe53f..53b9ff1d 100644 --- a/milestones/04_cnn_revolution_1998/cnn_digits.py +++ b/milestones/04_cnn_revolution_1998/cnn_digits.py @@ -232,26 +232,23 @@ def train_cnn(): # ACT 2: THE SETUP πŸ—οΈ # ═══════════════════════════════════════════════════════════════════════ - console.print("[bold]πŸ—οΈ The CNN Architecture:[/bold]\n") + console.print("[bold]πŸ—οΈ The Architecture:[/bold]") + console.print(""" + β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” + β”‚ Input β”‚ β”‚ Conv2d β”‚ β”‚ ReLU β”‚ β”‚MaxPool2dβ”‚ β”‚ Flatten β”‚ β”‚ Linear β”‚ + β”‚ 1Γ—8Γ—8 │───▢│ 1β†’8 │───▢│ │───▢│ 2Γ—2 │───▢│ 8Γ—3Γ—3 │───▢│ 72β†’10 β”‚ + β”‚ β”‚ β”‚ 3Γ—3 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ =72 β”‚ β”‚ β”‚ + β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ + ↑ Detects ↑ Spatial + local patterns downsampling + """) - architecture_text = """[cyan]Layer Flow:[/cyan] - Input (1Γ—8Γ—8) - ↓ - Conv2d(1β†’8, 3Γ—3) ← Detect edges, curves - ↓ - ReLU ← Nonlinearity - ↓ - MaxPool(2Γ—2) ← Downsample, translation invariance - ↓ - Flatten(8Γ—3Γ—3=72) - ↓ - Linear(72β†’10) ← Classification - - [yellow]Key Insight:[/yellow] - Conv layers share weights across space - β†’ 100Γ— fewer params than MLP!""" - - console.print(Panel(architecture_text, title="Architecture", border_style="blue", box=box.ROUNDED)) + console.print("[bold]πŸ”§ Components:[/bold]") + console.print(" β€’ Conv layer: Detects local patterns (edges, curves)") + console.print(" β€’ ReLU: Non-linear activation") + console.print(" β€’ MaxPool: Spatial downsampling + translation invariance") + console.print(" β€’ Linear: Final classification (72 β†’ 10 classes)") + console.print(" β€’ [bold cyan]Key insight: Shared weights β†’ 100Γ— fewer params![/bold cyan]") # Create model console.print("\n🧠 Building Convolutional Neural Network...")