Advanced level · Module 1: Advanced CNN Architectures · Lesson 3 of 3
Benchmarking and Choosing an Architecture
Learners benchmark several pretrained models on their own laptops for accuracy, file size and CPU latency, and choose one for a defined hardware budget.
In this lesson you will
- Benchmark models consistently on CPU
- Choose an architecture for constraints
Key concepts
latency measurementwarm-up runsbatch size 1accuracy-latency trade-offhardware budget
The lesson
Latency must be measured on the target hardware: run a few warm-up inferences, then time 50 single-image inferences with torch.inference_mode() and report the median.
Fine-tune two or three candidate models (for example MobileNetV3-Small, EfficientNet-B0, ResNet18) on the same task and plot accuracy against latency. Models on the upper-left of the plot (accurate and fast) are the best candidates.
Write the budget first (for example 'under 100 ms per image on a lab laptop, under 20 MB') and choose the most accurate model that fits.
Step by step
- Write a benchmarking function that reports median latency.
- Fine-tune three small models on the produce dataset.
- Plot accuracy against latency and size.
- Choose a model for a stated budget.
Practice activity
Produce an architecture benchmark and recommendation for the capstone hardware.
Expected result: Measured trade-offs and a justified choice.
Check your understanding
-
Why run warm-up inferences before timing?
Show answer
The first runs include one-off setup costs that distort timing.
-
Which models are the best candidates on an accuracy-latency plot?
Show answer
Those that are both accurate and fast (upper-left).
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.