liveBook · Manning

Spatial prior

As explained in Inside Deep Learning: Math, Algorithms, Models

An inductive bias that nearby positions in an input, such as image pixels, are more related than distant ones.

A spatial prior encodes the belief that nearby positions are more related than distant positions. Convolutions impose this bias by applying a filter across local regions, producing outputs that highlight learned patterns. section 3.2

For images, neighboring pixels often share similar values, and the same local relationship can occur anywhere. The idea also applies to sequences: a 1D convolution treats nearby words as related, preserving some order information without requiring the exact full order modeled by an RNN. section 3.2 section 12.3

From pixels to words

A filter can identify the horizontal line at the top of a handwritten 7. For text, an embedding shaped (B, T, D) can be permuted to (B, D, T), allowing nn.Conv1d to detect local patterns such as negation before a word. section 3.2 section 12.3

Figure 3.4 Example of a convolution. An input image and a filter are combined by the convolution. The output is a new image that has been altered. The purpose of the filter is to identify or recognize certain patterns in the input. In this example, the filter identifies the horizontal line at the top of a numeral 7.

Shows how an input image and filter combine to produce an output that emphasizes a local visual pattern. section 3.2

How Inside Deep Learning: Math, Algorithms, Models covers it

How deep it goes
Explains local correlations, filters, tensor layouts, and permutation, while deferring convolution arithmetic and detailed padding mechanics.
Examples
Uses neighboring digit pixels, a filter detecting a 7’s top line, negation-word proximity, and permuted embedding tensors.
What you can do after
Apply it via 1D convolutions by permuting embeddings into PyTorch’s (B, C, W) layout.
How it connects
Ties spatial priors to convolutions, CNNs, RNNs, pooling, padding, embeddings, and weight sharing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.