Transfer Learning and Pre-trained CNNs

Related: 8. Convolutional Neural Networks | 9. CNNs Part II — Improving Generalisability | 4. Deep Learning and FCNs | Artificial Intelligence


What is a Pre-trained Model?

A saved network previously trained on a large dataset (e.g., ImageNet with 1.4M images, 1000 classes). Useful when you have a small dataset — improves accuracy and saves training time.

Examples: VGG-16, GoogLeNet/Inception, ResNet, MobileNet, BERT, GPT.

Using a Pre-trained Model

Feature Extraction (Shallow Mode)

  1. Load pre-trained convolutional base without the top classifier
  2. Freeze all convolutional layers (trainable = False)
  3. Add new custom dense layers on top for your specific task
  4. Train only the new dense layers

Why not reuse the classifier? The original classifier was trained for 1000 ImageNet classes — not your task.

Fine-Tuning (Deep Mode)

Two approaches:

  1. Full fine-tuning: Set entire model as trainable (conv_base.trainable = True), train end-to-end with a low learning rate
  2. Partial fine-tuning: Freeze early layers, only unfreeze later layers (e.g., from block5_conv1 onwards)

Rationale: Early layers learn generic features (edges, textures) transferable across tasks. Later layers learn task-specific features. This connects to how 8. Convolutional Neural Networks extract hierarchical features — shallow layers capture edges and textures, while deeper layers capture complex patterns specific to the training task.