Build a Trainable CNN from Scratch
Follow the data, decisions, feedback, and validation boundaries before writing the full system.

How to read this diagram
Read left to right for the forward path: raw information becomes a representation, passes through the project’s main computational ideas, and produces an output that can be measured. Then follow the feedback path back toward the trainable or decision-making components.
im2col
A convolution shares a local kernel across spatial positions. im2col unfolds receptive fields into matrix columns so the forward pass becomes GEMM; the backward pass must scatter overlapping column gradients back to the image.
Boundary check: document its accepted input, output shape, mutable state, failure modes, and the metric that proves this stage is correct before connecting it downstream.
Pooling
Pooling summarizes a local neighborhood to reduce spatial resolution. Max pooling routes gradient only to the recorded argmax, making index caching and tie behavior important for a correct backward pass.
Boundary check: document its accepted input, output shape, mutable state, failure modes, and the metric that proves this stage is correct before connecting it downstream.
Adam
Adam tracks exponential moving averages of gradients and squared gradients, applies bias correction early in training, and scales each parameter update by its estimated second moment. Epsilon placement and weight-decay semantics matter.
Boundary check: document its accepted input, output shape, mutable state, failure modes, and the metric that proves this stage is correct before connecting it downstream.
Architecture review checklist
- Every arrow has a documented shape, dtype, unit, or schema.
- Training and evaluation paths cannot leak information into each other.
- Randomness is seeded and captured in experiment metadata.
- Expensive stages expose timing, memory, throughput, and error metrics.
- Each feedback loop has a stop condition and a rollback strategy.
- Small reference implementations exist for numerical comparisons.