Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 19 — Assignment Project: A Classifier From 500 Photographs

Open in Colab

Overview

A wildlife project wants to sort camera photos into five kinds of animal: bird, cat, deer, dog and frog. It has labelled 100 photos of each. You will measure what a network trained from scratch can do with so little data, compare two pretrained backbones as feature extractors, fine-tune the better one, find how many labelled photos are really needed, and recommend a strategy. We use CIFAR-10’s photos of these five classes (32×32 pixels), and a fixed test set of 500 photos that you use only to report.

PartTaskPoints
AA baseline from scratch15
BTwo backbones as feature extractors20
CFine-tuning25
DHow many photos are needed?20
ERecommendation20

Part A — A Baseline From Scratch (15 points)

Train the small CNN below from scratch for 30 epochs (Adam, 10-3, with fit) on the 500 training photos. Report its parameter count and test accuracy. What would a random guess score?


Part B — Two Backbones as Feature Extractors (20 points)

  1. Extract pooled features from ResNet-18 and MobileNet-V3-Small, both pretrained on ImageNet, at an input size of 96×96 with ImageNet normalisation (for the training photos, their mirror images, and the test photos).

  2. Train a linear head on each for 30 epochs (10-3). Report the feature size, the extraction time and the test accuracy of each.

  3. Which backbone would you keep, and why? Consider accuracy, speed and size.

Your choice and why:


Part C — Fine-Tuning (25 points)

Keep ResNet-18. Cache the output of layer3 (for the training photos, their mirror images and the test photos), then compare, with 10 epochs each:

  1. the head alone on pooled features (Part B);

  2. layer4 and a new head, with one learning rate of 10-4;

  3. layer4 at 10-4 and the head at 10-3, as two parameter groups;

  4. layer4 and the head at 10-2.

Explain the differences.

Your explanation:


Part D — How Many Photos Are Needed? (20 points)

With 10, 25, 50 and 100 training photos per class (the first ones of each class in Xtr), compare the ResNet-18 feature extractor (linear head, 30 epochs) with the small CNN from scratch (30 epochs). Plot both curves. From how many photos per class does the pretrained model reach the accuracy that the CNN from scratch gets with 100?

Your answer:


Part E — Recommendation (20 points)

One page for the wildlife project:

  • which approach you recommend (backbone, frozen or fine-tuned, learning rates), with the evidence;

  • how many photos they should label, from Part D;

  • the risks: the camera photos are larger, at night, often blurred; and ImageNet’s own biases;

  • how they should check the model on their own photos before relying on it.

Grading Rubric

CriterionExcellentAdequateInsufficient
A (15)accuracy against chance, overfitting discussednumber onlymissing
B (20)both backbones, the trade-off arguednumbers onlyone backbone
C (25)four variants, the effect of the rate explainedvariants without explanationmissing
D (20)both curves, the crossing point read offone curvemissing
E (20)concrete, evidence-based, honest about the domain gapgenericmissing