3.4.11 · D1Convolutional Neural Networks

Foundations — Transfer learning and fine-tuning

2,224 words10 min readBack to topic

Before you can read the parent note Transfer learning and fine-tuning, every squiggle in its equations must mean something concrete to you. This page picks up every symbol and word the parent uses and builds it from nothing. Read top to bottom — each idea leans on the one above it.


1. What is a "model"? The function

We write one use of the machine as , read aloud as " of ": "the answer the machine gives when I feed it ."

  • (chalk-blue in the figure) = the input, here an image (a grid of pixel numbers).
  • = the output, here a guess like "this is a robin."
Figure — Transfer learning and fine-tuning

Look at the figure: goes in the left, travels through the box , and a label pops out the right. That box is the whole reason we build networks. If you have met the pixel-grid idea in 3.4.1-Introduction-to-CNs, this is the same picture.


2. The tuning knobs: parameters

The box has thousands of little dials inside it. Turning the dials changes what guess comes out. We bundle all those dial settings into one symbol: (the Greek letter theta, said "THAY-ta").

Whenever the parent writes or , it just means "the dials belonging to this particular part of the machine." We build those parts in §7.


3. Data, the pair , and the dataset

To learn, the machine needs examples where we already know the right answer.

A whole pile of these flashcards is the dataset, written (a fancy curly ).

The parent uses two piles:

  • — the huge pile the model first learned on (ImageNet, ~14 million pictures).
  • your small pile (the new task, maybe a few thousand).

The entire point of transfer learning is: knowledge squeezed out of helps us when is too small to learn from alone.


4. Being wrong on purpose: the loss

How do we know if a dial setting is good? We measure how wrong the guess is.

The parent's loss is categorical_crossentropy. You do not need its formula here — just hold the picture: a scoreboard that punishes wrong guesses. Lower is better.


5. Averaging over the pile:

One flashcard's score isn't enough — we care about doing well on average across the whole pile.

Put §4 and §5 together and the parent's core objective reads in plain English:


6. Layers, and the "early → late" ladder

A CN is not one box but a stack of boxes called layers. Each layer transforms the picture a little and passes it to the next.

Figure — Transfer learning and fine-tuning

The figure shows the ladder the parent leans on constantly:

  • Early layers (near the input) → generic edges, colours, simple textures. These look the same for cats, X-rays, or satellites — that's why they transfer.
  • Middle layers → object parts (an eye, a wheel).
  • Late layers (near the output) → the actual answer classes, tightly tied to the source task.

This ladder is the whole reason freezing works: the bottom rungs are reusable, only the top rungs are task-specific. If layers and convolutions are new, pause and read 3.4.1-Introduction-to-CNs.


7. Splitting the machine: base and head

Transfer learning cuts the stack into two pieces.

The parent writes the reassembled machine as:

Figure — Transfer learning and fine-tuning

The lock icon on the base means frozen — its dials stay fixed. The green head is what we actually train. This single picture is the heart of the whole parent note.


8. Freezing, and the sample-complexity ratio

Why freeze? The parent gives a ratio:


9. Nudging the dials: the update rule and

Training turns the dials in small steps. One step looks like:

Let's decode every piece.

Figure — Transfer learning and fine-tuning

The parent even uses different step sizes per part: tiny for early layers (keep the general edges), a larger for the head (it needs to learn a lot). Same idea, applied layer by layer.


10. Squeezing the feature map: Global Average Pooling

The base hands back not a flat list but a little stack of grids of shape .

To feed the head, we flatten each map to a single number by averaging it:

You'll also see 3.4.7-Batch-normalization and 3.4.8-Residual-connections named in the head and inside ResNet50; those are covered in their own notes — here just know they're standard layers you can drop in.


Prerequisite map

Model f as a function

Parameters theta the dials

Loss L wrongness score

Dataset D of pairs x y

Average E over the pile

Objective argmin over theta

Layers early to late ladder

Split into base h and head g

Freezing to cut trainable dials

Update rule with rate eta

Transfer learning and fine tuning

GAP squeeze feature maps

Every arrow is a "you need this before that." The bottom node is exactly the parent topic.


Equipment checklist

Cover the right side and answer each. If you can, you're ready for the parent note.

What does mean in plain words?
The guess the model makes for input , using the fixed dial settings .
What is ?
The whole bundle of adjustable numbers (weights and biases) inside the model.
What does say?
Our dataset has far fewer examples than millions.
In one sentence, what is the loss ?
A single number scoring how wrong the model's guess is — 0 is perfect, big is bad.
Read aloud.
Find the dial settings that make the average wrongness as small as possible.
Which layers transfer best and why?
Early layers — they detect generic edges and textures shared by almost every vision task.
Compute and in what order for ?
Base first (pixels to features), then head (features to answer).
What does freezing a layer do?
Fixes its dials so training never changes them, shrinking the count of trainable parameters.
In , what is ?
The learning rate — the size of each step we take when nudging the dials.
Why a tiny when fine-tuning the base?
To take short steps that stay near the good pretrained weights and avoid catastrophic forgetting.
What does GAP turn a block into?
A flat list of 2048 numbers, one average per channel.