tezvyn:

Transfer learning from ResNet50 on small data

AI-drafted, machine-checkedSource: interviewbeginner
WHAT IT TESTS

applying transfer learning.

OUTLINE

replace the final classification head with one sized to your classes, freeze the pretrained convolutional backbone as a feature extractor, train the new head, then optionally fine-tune top blocks at a low…

WHAT THIS TESTS: Whether you understand transfer learning and which layers to freeze, replace, or fine-tune given little data.

A GOOD ANSWER COVERS: ResNet50 trained on ImageNet has learned a hierarchy of features, generic edges and textures in early layers and increasingly task-specific patterns deeper down. With a small labeled dataset, training from scratch would overfit, so reuse those features. First remove the original classification layer, which outputs the thousand ImageNet classes, and attach a new head, typically a global pooling layer followed by a dense softmax sized to your number of classes. Freeze the convolutional backbone so it behaves as a fixed feature extractor and train only the new head; this needs few parameters and resists overfitting. If you have a little more data and want more accuracy, optionally unfreeze just the top residual blocks and fine-tune them together with the head at a much lower learning rate, leaving the early generic layers frozen so you do not wash out broadly useful features. Use strong data augmentation, regularization, and early stopping to further combat overfitting, and consider keeping batch-norm layers in inference mode while frozen.

COMMON WRONG ANSWERS: Unfreezing the entire network and training on a tiny dataset, which overfits and can erase pretrained knowledge; fine-tuning the earliest layers rather than the top ones; using a high learning rate during fine-tuning that destabilizes pretrained weights; forgetting to resize and normalize inputs to match the pretraining preprocessing; not replacing the thousand-class head.

LIKELY FOLLOW-UPS: Why fine-tune top layers rather than bottom ones? Why a lower learning rate when fine-tuning? How does dataset size change how many layers you unfreeze? What preprocessing must match the original training? How do frozen batch-norm statistics matter?

ONE CONCRETE EXAMPLE: With a few hundred labeled images across five plant-disease classes, take ResNet50 without its top, add global average pooling and a five-way softmax, and freeze the backbone. Train the head for a few epochs with augmentation; accuracy plateaus, so unfreeze the last residual stage and continue at a learning rate roughly ten to one hundred times smaller, gaining a few points without overfitting, while the early edge-and-texture layers stay fixed.

Read the original → keras.io

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.