Deep Learning · TEE · section

R24 Q6b

Re examination February 2024 fully solved

Question

Question (10 marks). A supermarket vegetable classifier has 10 classes but few examples per class and limited training resources. Explain different ways to use a pretrained model.

Answer — step by step

Transfer learning reuses features learned on a source task to solve a related target task. For a small vegetable-image dataset, a pretrained CNN provides a stronger starting point than estimating a very large model entirely from that small dataset.

1. Collect labeled examples with varied lighting, pose and background. Split data so duplicate or near-duplicate photos do not leak across sets. Use independently captured vegetable examples in each split; keep near-duplicates or repeated images of the same item together.

2. Resize images and apply the preprocessing expected by the pretrained model. Use label-preserving augmentation such as small crops, shifts or illumination changes.

3. Load a suitable pretrained CNN, remove its source classification head and attach a new head with one output per required class. For mutually exclusive classes use softmax and categorical cross-entropy.

4. Freeze the convolutional base and train the new head. Frozen parameters still participate in prediction but are not updated in this stage.

5. If validation results justify it, unfreeze selected later layers and fine-tune with a smaller learning rate. Use early stopping and appropriate regularization.

6. Evaluate on a held-out vegetable test set and inspect the confusion matrix and per-class errors. Check which vegetables are confused under different lighting or backgrounds.

Feature extraction keeps the base frozen; fine-tuning updates some pretrained weights. Benefits include reduced target-data requirements and faster useful training. Risks include source-target mismatch and overfitting the small target set. Transfer learning improves the starting point, not a guarantee of perfect recognition.

For vegetables, replace the source head with 10 softmax outputs. Strategy 1: freeze the base and train only this head. Strategy 2: initialize from the same pretrained model and fine-tune selected later blocks at a small rate after head training. The first is cheaper and less prone to fitting all parameters from limited examples; the second can adapt features more closely to vegetables when validation supports it.