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.
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:
Let’s call a shift by pixels . In particular,
For an -pixel signal, the -th component of the shifted image is
Now suppose we have an image-processing layer that takes an image as input and outputs a feature map with the same spatial size:
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 corresponds to a simple permutation matrix:
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 imposes on the entries of matrix . Right-multiplication by the shift operator shifts column of to column , which yields
.
Whereas the left-multiplication by the shift operator, shifts row of to row , which yields
From , we obtain the fundamental constraint equation:
letting ,
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 , where , then
This demonstrates that the entry depends solely on the index difference . Substituting this back into , its structure is necessarily
Now consider the -th component of the output feature map :
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 and the function as
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:
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:
By itself, it means one bright pixel at the origin…
…, 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 . 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:
can be represented as .
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:
Because is shift equivariant, we can replace with .
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. 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 (), then
According to the definition of the shift operation, . We now get:
which is exactly the definition of discrete convolution.