liveBook · Manning

Data locality

As explained in Deep Learning with PyTorch, Second Edition

The tendency for nearby memory accesses to hit nearby stored data, which improves performance.

Data locality means focusing each computation on nearby values instead of combining every value with every other value. For images, nearby pixels are usually more useful for recognizing local patterns than distant pixels, so convolutions emphasize neighborhoods and set weights beyond a chosen distance to zero. section 8.1

Convolutions preserve locality while using fewer parameters than fully connected layers. Small kernels such as 3 × 3 or 5 × 5 examine limited neighborhoods; stacking convolutions and downsampling then lets the network combine information across progressively larger portions of an image. section 8.1 section 8.2.3

From local patterns to larger structures

A small kernel can detect part of a shape, while successive convolutions and max pooling combine those local detections into larger structures. In a birds-versus-airplanes classifier, this helps recognize objects whose parts span several pixels without using one large kernel over the entire image. section 8.2.3

Locality in convolutional networks leads to these related effects:

  • Convolution restricts each weighted sum to nearby pixels rather than the whole image. section 8.1
  • Pooling reduces spatial dimensions, commonly by taking maximum or average values over local regions. section 8.2.3
  • Translation invariance complements locality by helping recognize patterns despite their position in the image. section 8.1
Figure 8.10 More convolutions by hand, showing the effect of stacking convolutions and downsampling: a large cross is highlighted using two small, cross-shaped kernels and max pooling
figure

Trace how two small kernels and max pooling combine local evidence to highlight a larger cross. section 8.2.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Explains neighborhood-limited weighted sums, then extends locality through stacked convolutions and pooling.
Examples
Uses birds-versus-airplanes images, small kernels, max pooling, and a large-cross visualization.
What you can do after
Understand why convolutional networks use small kernels and pooling to recognize image structures across larger spatial regions.
How it connects
Connects locality with convolution, translation invariance, pooling, downsampling, and convolutional neural networks.

Also explained in

Compare how 4 books explain data locality →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.