← All Base Form ML projects
BL-13NOT STARTEDBASE FORM · DEEP LEARNINGMLPYTHON

Flower classifier

Classify flower photos and beat overfitting with dropout, weight decay and data augmentation.

EST.6 h
REWARD+100 XP
AFTERoriginal

ML-ARENA BENCHMARKS

YOUR NUMBER VS THE INDUSTRY'S
METRICINDUSTRYMINE
validation accuracy
GOAL · within 2%
PyTorch reference model—
no results yet
YOUR RESULTS

Your recorded results appear here.

Brief

Oxford Flowers 102 has 102 flower species and only 10 training photos for each one. That is a recipe for overfitting: the model memorises the training photos and does badly on new ones. In this project you watch that happen, then fight it with three tools: weight decay, dropout and data augmentation.

You won't train a vision network from scratch yet. That comes in BL-14. Instead, a ResNet-18 pretrained on ImageNet turns each photo into 512 numbers, and you train an MLP on those features. Treat the ResNet as a frozen black box: torchvision.models.resnet18 with ResNet18_Weights.IMAGENET1K_V1, and its fc layer replaced by torch.nn.Identity(). Load the photos with torchvision.datasets.Flowers102, which provides the official train, validation and test splits of 1,020, 1,020 and 6,149 images.

Weight decay adds a penalty λ∥W∥2\lambda \lVert W \rVert^2 to the loss, which pulls weights towards zero. Dropout zeroes each hidden unit with probability pp during training and scales the survivors by 1/(1−p)1/(1-p), so no unit can rely on any other. Augmentation shows the model a different random crop or mirror image of each photo, so it can't memorise exact pixels.

One rule keeps this honest. Tune everything on the validation split. Look at the test split once, at the very end.

VISUALFig. 1
No regularisation 0 4 loss epochs train validation Weight decay + dropout + augmentation 0 4 loss epochs train validation
A sketch of the two curves to watch. Left, no regularisation: training loss heads to zero while validation loss turns back up. Right, regularised: the gap is smaller and validation loss stays low. Why it's here: Objective 2 asks you to spot overfitting in your own plot. This is the pattern to look for.
HINT · OBJECTIVE 4
Stuck? Hints stay hidden until you ask.
HINT · OBJECTIVE 5
Stuck? Hints stay hidden until you ask.

DATA · Oxford Flowers 102

Objectives

0 / 6 CLEARED

Read-only. Log in to update progress.

VICTORY CONDITIONS

  1. Your validation accuracy is within 2 points of the PyTorch reference head, recorded with `python tools/mlarena.py record BL-13 "<yours>% vs <reference>%"`.
  2. Your dropout and weight decay are your own code, not nn.Dropout or an optimiser's weight_decay argument.
  3. The README has the train and validation curves before and after regularisation, an ablation table, and one test accuracy per model, measured once.

Side quests

Unfreeze the last ResNet block and fine-tune it too. Does regularisation matter more or less?
Add label smoothing or mixup and see whether it helps on top of the other three.
Draw a reliability diagram for your best model to see whether its confidence matches its accuracy.

Terms in plain words

Overfitting
When a model learns the training examples so well, quirks included, that it does worse on examples it hasn't seen.
Weight decay
Shrinking every weight a little towards zero at each step, which stops any one weight from growing large to fit noise.
Dropout
Randomly switching off a fraction of hidden units on each training step, so the network can't depend on any single unit.
Data augmentation
Showing the model randomly altered copies of each training image, such as crops and mirror images, so it sees more variety.
Frozen features
The output of a pretrained network whose weights you never update. You use it as a fixed summary of each image.