Gradient LabSign up free

Cheat sheets › Chapter 9

Computer vision cheat sheet

Teach networks to see with convolutions. Every lesson in one page: the key idea, the pseudocode and the terms.

Images as numbers

To a computer, an image is a grid of tiny squares called pixels. This one is just 6 × 6, a little smiley face.

image = a grid of pixels, 6 × 6
each pixel = brightness from 0 (black) to 1 (white)
a color image = 3 grids stacked: red, green, blue
shape = (height, width, channels) = (6, 6, 3)
a phone photo: (3000, 4000, 3) = 36 million numbers

Terms: pixel, channel, tensor

Convolution

This image is dark on the left and bright on the right. A filter is a small 3 × 3 grid of weights. This one is built to light up wherever dark changes to bright: a vertical edge.

filter = a small 3 × 3 grid of weights
for each position in the image:
    lay the filter on top
    multiply the overlapping numbers and add them up
    write the result into the output map
slide one step to the right (then down) and repeat

Terms: filter, feature map, convolution

Filters and feature maps

The first layer has many filters, each producing its own feature map. They learn to respond to simple things: edges at different angles, patches of color.

layer 1 filters find:  edges and color blobs
layer 2 combines them: corners, textures, simple shapes
layer 3 combines those: eyes, wheels, letters
last layers:            whole objects → “cat”, “car”, “stop sign”

Terms:

Pooling and stride

Split the map into 2 × 2 blocks (one color each).

feature_map = a 4 × 4 grid
for each 2 × 2 block:
    keep only the largest number      # max pooling
result = a 2 × 2 map
# smaller, faster, and it barely cares if the pattern shifts a little

Terms: pooling

CNN architectures

Most vision networks follow one recipe: repeat “convolution, ReLU, pooling” a few times, then finish with ordinary dense layers. Here is that pipeline, left to right.

image
→ [convolution → relu → pooling] × several blocks   # shrink, deepen
→ flatten into one long list
→ fully connected layers
→ softmax over the classes

# ResNet adds shortcuts: output = block(x) + x

Terms: skip connection

Transfer learning

transfer learning starts from a network someone already trained on a huge photo collection. Its early layers already detect edges, textures and parts, and those are useful for almost any picture. Freeze them.

base = a network trained on millions of everyday photos
freeze base                 # keep what it already knows
head = a new small output layer for your classes
train only the head on your few hundred photos

# optional: unfreeze the top layers and fine-tune gently

Terms: transfer learning, fine-tuning

Revise with flashcards and quizzes. Free practice for every lesson in this chapter.

Open in the app