A quick intro to Geometric Deep Learning(WIP)


Coauthored with Zikai Wang.

Most of the time we consider deep learning as an engineering problem – we are told what works, what doesn’t, and what the standard solution is to a specific problem. Yet it is often less clear why these architectures work. Geometric Deep Learning provides us with mathematical tools for understanding why architectures such as CNNs, LSTMs, and Transformers can exploit structure that a plain MLP does not explicitly encode.

To quickly give you a sense of how it works and why it is useful, we will skip most of the math in the front part of Original Geometric Deep Learning book and give you a walk-through derivation of convolution from linearity and shift equivariance.

Shift Equivariance

Let’s start with a 1D image with 4 pixels.

𝒙 = ( 𝑥 0 𝑥 1 𝑥 2 𝑥 3 )

You can imagine each value of 𝑥 as the brightness of one pixel.

Since we want to discuss shift equivariance, we first need to define a shift operation. To make things simple, we assume images with no boundary, which means positions wrap around in a circle. We call this property periodic boundary condition. For example, if we shift the image by 1 pixel to the right, the new image shall be:

( 𝑥 0 𝑥 1 𝑥 2 𝑥 3 ) → ( 𝑥 3 𝑥 0 𝑥 1 𝑥 2 )

Let’s call a shift by 𝑎 pixels 𝑆𝑎. In particular,

𝑆 1 ( 𝑥 0 𝑥 1 𝑥 2 𝑥 3 ) = ( 𝑥 3 𝑥 0 𝑥 1 𝑥 2 ) .

For an 𝑛-pixel signal, the 𝑢-th component of the shifted image is

( 𝑆 𝑎 𝑥 ) 𝑢 = 𝑥 ( 𝑢 − 𝑎 ) mod 𝑛

Now suppose we have an image-processing layer 𝐹 that takes an image as input and outputs a feature map with the same spatial size:

𝐹 ( ( 𝑥 0 𝑥 1 𝑥 2 𝑥 3 ) ) = ( 𝑦 0 𝑦 1 𝑦 2 𝑦 3 )

The layer is shift-equivariant if applying a shift to the input is equivalent to applying the same shift to the output:

𝐹 ( 𝑆 𝑎 𝑥 ) = 𝑆 𝑎 𝐹 ( 𝑥 ) ∀ 𝑎 .

In other words, if the input moves, the feature map moves with it by the same amount.

We call this kind of structural constraint Inductive Bias: an assumption built into a learning algorithm about which functions are likely to be useful for a given task.

For example, shift equivariance means that if a cat moves a few pixels in an image, the intermediate feature map should move by the same amount. Shift invariance, on the other hand, means that the final output, such as a classification score, remains unchanged under the same shift.

These properties can be built into the network architecture or encouraged through regularization. Architectural constraints can enforce exact equivariance under appropriate assumptions, whereas regularization alone does not generally guarantee it.

We will see exactly how that works in the next chapter.

Deriving Convolution with Matrix Representation

On a discrete grid with periodic boundary conditions, the unit shift 𝑆1 corresponds to a simple permutation matrix:

𝑆 1 = [ 0 0 … 0 1 1 0 … 0 0 0 1 … 0 0 ⋮ ⋮ ⋱ ⋮ ⋮ 0 0 … 1 0 ]

Suppose our image-processing layer 𝐹(𝑥)=𝑊𝑥, where 𝑊∈ℝ𝑛×𝑛 is the weight matrix to be determined. (𝑊 is simply the matrix representation of the same linear operator 𝐹)

Using elementary linear algebra, let us examine the restrictions that this commutativity constraint 𝑊𝑆1=𝑆1𝑊 imposes on the entries 𝑊𝑢,𝑣 of matrix 𝑊. Right-multiplication by the shift operator (𝑊𝑆1)𝑢,𝑣 shifts column 𝑣+1 of 𝑊 to column 𝑣, which yields

( 𝑊 𝑆 1 ) 𝑢 , 𝑣 = 𝑊 𝑢 , ( 𝑣 + 1 ) mod 𝑛

.

Whereas the left-multiplication by the shift operator, (𝑆1𝑊)𝑢,𝑣 shifts row 𝑢−1 of 𝑊 to row 𝑢, which yields

( 𝑆 1 𝑊 ) 𝑢 , 𝑣 = 𝑊 ( 𝑢 − 1 ) mod 𝑛 , 𝑣

From 𝑊𝑆1=𝑆1𝑊, we obtain the fundamental constraint equation:

𝑊 𝑢 , ( 𝑣 + 1 ) mod 𝑛 = 𝑊 ( 𝑢 − 1 ) mod 𝑛 , 𝑣 ∀ 𝑢 , 𝑣

letting 𝑢′=𝑢−1,

𝑊 ( 𝑢 ′ + 1 ) mod 𝑛 , ( 𝑣 + 1 ) mod 𝑛 = 𝑊 𝑢 ′ , 𝑣 ∀ 𝑢 ′ , 𝑣

This relations reveals that a shift equivariant operation is represented by a matrix where elements along each diagonal are constant, and any diagonal that runs off one edge wraps around and continues with the same value on the opposite edge. This is also known as a circulant matrix. If we define an 𝑛-dimensional parameter vector 𝜃𝑘≔𝑊𝑘,0, where 𝑘=(𝑢−𝑣)mod𝑛, then

𝑊 𝑢 , 𝑣 = 𝜃 ( 𝑢 − 𝑣 ) mod 𝑛

This demonstrates that the entry 𝑊𝑢,𝑣 depends solely on the index difference (𝑢−𝑣). Substituting this back into 𝑊, its structure is necessarily

𝑊 = 𝐶 ( 𝜃 ) = [ 𝜃 0 𝜃 𝑛 − 1 𝜃 𝑛 − 2 … 𝜃 1 𝜃 1 𝜃 0 𝜃 𝑛 − 1 … 𝜃 2 𝜃 2 𝜃 1 𝜃 0 … 𝜃 3 ⋮ ⋮ ⋮ ⋱ ⋮ 𝜃 𝑛 − 1 𝜃 𝑛 − 2 𝜃 𝑛 − 3 … 𝜃 0 ]

Now consider the 𝑢-th component of the output feature map 𝑦=𝑊𝑥=𝐶(𝜃)𝑥:

𝑦 𝑢 = ∑ 𝑣 = 0 𝑛 − 1 𝑊 𝑢 , 𝑣 𝑥 𝑣 = ∑ 𝑣 = 0 𝑛 − 1 𝜃 ( 𝑢 − 𝑣 ) mod 𝑛 𝑥 𝑣 = ( 𝑥 ∗ 𝜃 ) 𝑢

This is precisely the definition of discrete convolution. In other words, the mathematical framework naturally deduces the convolution formula from linearity and shift equivariance

Another Perspective: Impulse Function Representation

In the example above, representing an image as a vector works perfectly well. However, this is not the most general way to represent a signal. For more complex domains, such as spheres or graphs, a vector representation can obscure the underlying structure of the domain. In GDL, a more general and natural approach is to represent a signal as a function, sometimes also called a mapping.

The standard form is

𝑥 : Ω → ℝ ,

where Ω is the domain. Given a position 𝑢∈Ω, the signal returns its value 𝑥(𝑢). For a 2D image, Ω is a grid. For a signal on a sphere, Ω could be the sphere itself and 𝑥(𝑢) might be a temperature measured at point 𝑢. For a graph, Ω can be the set of nodes and 𝑥(𝑢) a feature attached to node 𝑢.

For example, suppose we have a 2-by-2 image

[ 𝑎 𝑏 𝑐 𝑑 ]

Our previous vector representation flattens it as

𝑥 = ( 𝑎 𝑏 𝑐 𝑑 )

In the function representation, we instead define Ω={(0,0),(0,1),(1,0),(1,1)} and the function as

𝑥 ( ( 0 , 0 ) ) = 𝑎 , 𝑥 ( ( 0 , 1 ) ) = 𝑏 , 𝑥 ( ( 1 , 0 ) ) = 𝑐 , 𝑥 ( ( 1 , 1 ) ) = 𝑑

The values are the same; the advantage is that the geometry lives explicitly in the domain Ω instead of being hidden by an arbitrary flattening order. However, to keep things simple, we are still going to use a 1D example.

Representing a 1D Signal Using Impulses

Now, we are going to represent a 1D image as the linear combination of impulse functions. But what’s even an impulse function? We all know that every vector can be reconstructed from its coordinates and the standard basis vectors:

( 𝑎 𝑏 𝑐 ) = 𝑎 ( 1 0 0 ) + 𝑏 ( 0 1 0 ) + 𝑐 ( 0 0 1 )

When we are presenting an image as a function, we also want an analogous set of “basis functions”, which picks out each position of the domain. This is exactly what the impulse function does:

𝛿 0 ( 𝑢 ) = { 1 if 𝑢 = 0 0 if 𝑢 ≠ 0 , 𝑢 ∈ ℤ

By itself, it means one bright pixel at the origin…


            
... 0 0 1 0 0...

            
        ^

            
        0

            
... 0 0 1 0 0...

            
        ^

            
        0

            
... 0 0 1 0 0...

            
        ^

            
        0

            
... 0 0 1 0 0...

            
        ^

            
        0

…, which is not very useful. But we can combine it with the shift operation we defined earlier to represent any image. To make things easier to read, we define 𝛿𝑣=𝑆𝑣(𝛿0). Then any signal 𝑥 can be assembled out of these one-pixel signals:

𝑥 = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝛿 𝑣

Pointwise, this says

𝑥 ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝛿 𝑣 ( 𝑢 ) .

For simplicity’s sake 𝑥 is also written as 𝑥=∑𝑣∈ℤ𝑎(𝑣)𝛿𝑣. Keep in mind that 𝛿𝑣 is a function.

For example, an image like this:


            
position:      -1   0   1

            
x:              2   5  -1

            
position:      -1   0   1

            
x:              2   5  -1

            
position:      -1   0   1

            
x:              2   5  -1

            
position:      -1   0   1

            
x:              2   5  -1

can be represented as 𝑥=2𝛿−1+5𝛿0−1𝛿1.

From Shift Equivariance to Convolution

Let’s also start from a linear layer 𝐹, which takes a signal 𝑥:Ω→ℝ and outputs a signal 𝑦:Ω→ℝ.

𝐹 : 𝑋 ( Ω ) → 𝑋 ( Ω )

(So when you see [𝐹(𝑥)](𝑢) below, it means the u-th component of the output signal 𝑦.) This is the same kind of 𝐹 as in the matrix section; once we choose the impulse basis, its coordinate matrix is the 𝑊 used above.

Plug in the representation of 𝑥 above to our layer 𝐹, we have:

[ 𝐹 ( 𝑥 ) ] ( 𝑢 ) = 𝐹 ( ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝛿 𝑣 ) ( 𝑢 )

By linearity, we can move it inside the summation:

[ 𝐹 ( 𝑥 ) ] ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) [ 𝐹 ( 𝛿 𝑣 ) ] ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝐹 ( 𝑆 𝑣 𝛿 0 ) ( 𝑢 )

Because 𝐹 is shift equivariant, we can replace 𝐹(𝑆𝑣𝛿0) with 𝑆𝑣𝐹(𝛿0).

[ 𝐹 ( 𝑥 ) ] ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) [ 𝑆 𝑣 𝐹 ( 𝛿 0 ) ] ( 𝑢 )

The key insight is that shift equivariance allows us to determine the response to an impulse at any position from the response to a single impulse at the origin. 𝐹(𝛿0) is a constant “vector” to all the input signals. When we process different positions, we simply shift this “constant vector”. We call it a kernel in convolution term. Let’s denote 𝜃=𝐹(𝛿0) (𝜃:ℤ→ℝ), then

[ 𝐹 ( 𝑥 ) ] ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝑆 𝑣 𝜃 ( 𝑢 )

According to the definition of the shift operation, (𝑆𝑣𝑔)(𝑢)=𝑔(𝑢−𝑣). We now get:

[ 𝐹 ( 𝑥 ) ] ( 𝑢 ) = ∑ 𝑣 ∈ ℤ 𝑎 ( 𝑣 ) 𝜃 ( 𝑢 − 𝑣 )

which is exactly the definition of discrete convolution.

Comments