Capstone 1: gradient checker + PCA compressor
Part 1 ends by turning two of its ideas into tools you will keep using.
1. A gradient checker for real models. From Part 2 on, a model’s parameters are a dictionary of arrays ({"W1": ..., "b1": ..., ...}). check_gradients(loss, grads, params) returns the relative error for each named parameter, so you can see exactly which gradient is wrong. Every backward pass you write in Parts 2–3 is verified with it, starting with Capstone 2.
2. An SVD image compressor. Compress each colour channel to rank k, rebuild the image, and report the compression ratio and PSNR (peak signal-to-noise ratio, in dB). Find the smallest k that keeps 99% of the energy. The tests check your reconstruction against the Eckart–Young bound from 1.2.
stubs/cap1_compressor.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/cap1_compressor.py and run mlc check cap1. The tests are identical; import the results on the progress page.
Then compress your own photo (locally, needs pip install pillow):
cd exercises && python projects/compress_image.py path/to/photo.jpg --energy 0.99It prints k, the compression ratio and the PSNR, and writes photo_rank{k}.png next to the original.
- not yet: All tests pass (0/?)
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.