Theoretical Motivations
local graph
Chapter 7 — Theoretical Motivations
Section titled “Chapter 7 — Theoretical Motivations”In this chapter, we will visit some of the theoretical underpinnings of GNNs. One of the most intriguing aspects of GNNs is that they were independently developed from distinct theoretical motivations. From one perspective, GNNs were developed based on the theory of graph signal processing, as a generalization of Euclidean convolutions to the non-Euclidean graph domain [Bruna et al., 2014]. At the same time, however, neural message passing approaches—which form the basis of most modern GNNs—were proposed by analogy to message passing algorithms for probabilistic inference in graphical models [Dai et al., 2016]. And lastly, GNNs have been motivated in several works based on their connection to the Weisfeiler–Lehman graph isomorphism test [Hamilton et al., 2017b].
This convergence of three disparate areas into a single algorithm framework is remarkable. That said, each of these three theoretical motivations comes with its own intuitions and history, and the perspective one adopts can have a substantial impact on model development. Indeed, it is no accident that we deferred the description of these theoretical motivations until after the introduction of the GNN model itself. In this chapter, our goal is to introduce the key ideas underlying these different theoretical motivations, so that an interested reader is free to explore and combine these intuitions and motivations as they see fit.
7.1 GNNs and Graph Convolutions
Section titled “7.1 GNNs and Graph Convolutions”In terms of research interest and attention, the derivation of GNNs based on connections to graph convolutions is the dominant theoretical paradigm. In this perspective, GNNs arise from the question: How can we generalize the notion of convolutions to general graph-structured data?
7.1.1 Convolutions and the Fourier Transform
Section titled “7.1.1 Convolutions and the Fourier Transform”In order to generalize the notion of a convolution to graphs, we first must define what we wish to generalize and provide some brief background details. Let and be two functions. We can define the general continuous convolution operation as
One critical aspect of the convolution operation is that it can be computed by an element-wise product of the Fourier transforms of the two functions:
where
is the Fourier transform of and its inverse Fourier transform is defined as
In the simple case of univariate discrete data over a finite domain (i.e., restricting to finite impulse response filters) we can simplify these operations to a discrete circular convolution1
and a discrete Fourier transform (DFT)
where is the Fourier coefficient corresponding to the sequence . In Equation (7.5) we use the notation to emphasize that this is a circular convolution defined over the finite domain , but we will often omit this subscript for notational simplicity.
Interpreting the (discrete) Fourier transform The Fourier transform essentially tells us how to represent our input signal as a weighted sum of (complex) sinusoidal waves. If we assume that both the input data and its Fourier transform are real-valued, we can interpret the sequence as the coefficients of a Fourier series. In this view, tells us the amplitude of the complex sinusoidal component , which has frequency (in radians). Often we will discuss high-frequency components that have a large and vary quickly as well as low-frequency components that have and vary more slowly. This notion of low- and high-frequency components will also have an analog in the graph domain, where we will consider signals propagating between nodes in the graph.
In terms of signal processing, we can view the discrete convolution as a filtering operation of the series by a filter . Generally, we view the series as corresponding to the values of the signal throughout time, and the convolution operator applies some filter (e.g., a band-pass filter) to modulate this time-varying signal.
One critical property of convolutions, which we will rely on below, is the fact that they are translation (or shift) equivariant:
This property means that translating a signal and then convolving it by a filter is equivalent to convolving the signal and then translating the result. Note that as a corollary convolutions are also equivariant to the difference operation:
where
is the Laplace (i.e., difference) operator on discrete univariate signals.
These notions of filtering and translation equivariance are central to digital signal processing (DSP) and also underly the intuition of CNNs, which utilize a discrete convolution on two-dimensional data. We will not attempt to cover even a small fraction of the fields of digital signal processing, Fourier analysis, and harmonic analysis here, and we point the reader to various textbooks on these subjects [Grafakos, 2004, Katznelson, 2004, Oppenheim et al., 1999, Rabiner and Gold, 1975].
7.1.2 From Time Signals to Graph Signals
Section titled “7.1.2 From Time Signals to Graph Signals”In the previous section, we (briefly) introduced the notions of filtering and convolutions with respect to discrete time-varying signals. We now discuss how we can connect discrete time-varying signals with signals on a graph. Suppose we have a discrete time-varying signal . One way of viewing this signal is as corresponding to a chain (or cycle) graph (Figure 7.1), where each point in time is represented as a node and each function value represents the signal value at that time/node. Taking this view, it is convenient to represent the signal as a vector , with each dimension corresponding to a different node in the chain graph. In other words, we have that (as a slight abuse of notation). The edges in the graph thus represent how the signal propagates; i.e., the signal propagates forward in time.2
graph LR n0((0)) --> n1((1)) --> dots["…"] --> nN2((N-2)) --> nN1((N-1)) nN1 --> n0
Figure 7.1: Representation of a (cyclic) time-series as a chain graph.
One interesting aspect of viewing a time-varying signal as a chain graph is that we can represent operations, such as time-shifts, using the adjacency and Laplacian matrices of the graph. In particular, the adjacency matrix for this chain graph corresponds to the circulant matrix with
and the (unnormalized) Laplacian for this graph can be defined as
We can then represent time shifts as multiplications by the adjacency matrix,
and the difference operation by multiplication by the Laplacian,
In this way, we can see that there is a close connection between the adjacency and Laplacian matrices of a graph, and the notions of shifts and differences for a signal. Multiplying a signal by the adjacency matrix propagates signals from node to node, and multiplication by the Laplacian computes the difference between a signal at each node and its immediate neighbors.
Given this graph-based view of transforming signals through matrix multiplication, we can similarly represent convolution by a filter as matrix multiplication on the vector :
where is a matrix representation of the convolution operation by filter function and is a vector representation of the function . Thus, in this view, we consider convolutions that can be represented as a matrix transformation of the signal at each node in the graph.3 Of course, to have the equality between Equation (7.15) and Equation (7.16), the matrix must have some specific properties. In particular, we require that multiplication by this matrix satisfies translation equivariance, which corresponds to commutativity with the circulant adjacency matrix , i.e., we require that
The equivariance to the difference operator is similarly defined as
It can be shown that these requirements are satisfied for a real matrix if
i.e., if is a polynomial function of the adjacency matrix . In digital signal processing terms, this is equivalent to the idea of representing general filters as polynomial functions of the shift operator [Ortega et al., 2018].4
Generalizing to General Graphs
We have now seen how shifts and convolutions on time-varying discrete signals can be represented based on the adjacency matrix and Laplacian matrix of a chain graph. Given this view, we can easily generalize these notions to more general graphs.
In particular, we saw that a time-varying discrete signal corresponds to a chain graph and that the notion of translation/difference equivariance corresponds to a commutativity property with adjacency/Laplacian of this chain graph. Thus, we can generalize these notions beyond the chain graph by considering arbitrary adjacency matrices and Laplacians. While the signal simply propagates forward in time in a chain graph, in an arbitrary graph we might have multiple nodes propagating signals to each other, depending on the structure of the adjacency matrix. Based on this idea, we can define convolutional filters on general graphs as matrices that commute with the adjacency matrix or the Laplacian.
More precisely, for an arbitrary graph with adjacency matrix , we can represent convolutional filters as matrices of the following form:
Intuitively, this gives us a spatial construction of a convolutional filter on graphs. In particular, if we multiply a node feature vector by such a convolution matrix , then we get
which means that the convolved signal at each node will correspond to some mixture of the information in the node’s -hop neighborhood, with the terms controlling the strength of the information coming from different hops.
We can easily generalize this notion of a graph convolution to higher-dimensional node features. If we have a matrix of node features then we can similarly apply the convolutional filter as
From a signal processing perspective, we can view the different dimensions of the node features as different “channels.”
Graph Convolutions and Message Passing GNNs
Equation (7.22) also reveals the connection between the message passing GNN model we introduced in Chapter 5 and graph convolutions. For example, in the basic GNN approach (see Equation (6.5)) each layer of message passing essentially corresponds to an application of the simple convolutional filter
combined with some learnable weight matrices and a nonlinearity. In general, each layer of message passing GNN architecture aggregates information from a node’s local neighborhood and combines this information with the node’s current representation (see Equation (5.4)). We can view these message passing layers as a generalization of the simple linear filter in Equation (7.23), where we use more complex nonlinear functions. Moreover, by stacking multiple message passing layers, GNNs are able to implicitly operate on higher-order polynomials of the adjacency matrix.
The adjacency matrix, Laplacian, or a normalized variant? In Equation (7.22) we defined a convolution matrix for arbitrary graphs as a polynomial of the adjacency matrix. Defining in this way guarantees that our filter commutes with the adjacency matrix, satisfying a generalized notion of translation equivariance. However, in general commutativity with the adjacency matrix (i.e., translation equivariance) does not necessarily imply commutativity with the Laplacian (or any of its normalized variants). In this special case of the chain graph, we were able to define filter matrices that simultaneously commute with both and , but for more general graphs we have a choice to make in terms of whether we define convolutions based on the adjacency matrix or some version of the Laplacian. Generally, there is no “right” decision in this case, and there can be empirical trade-offs depending on the choice that is made. Understanding the theoretical underpinnings of these trade-offs is an open area of research [Ortega et al., 2018].
In practice, researchers often use the symmetric normalized Laplacian or the symmetric normalized adjacency matrix to define convolutional filters. There are two reasons why these symmetric normalized matrices are desirable. First, both these matrices have bounded spectrums, which gives them desirable numerical stability properties. In addition—and perhaps more importantly—these two matrices are simultaneously diagonalizable, which means that they share the same eigenvectors. In fact, one can easily verify that there is a simple relationship between their eigendecompositions, since
where is the shared set of eigenvectors and is the diagonal matrix containing the Laplacian eigenvalues. This means that defining filters based on one of these matrices implies commutativity with the other, which is a very convenient and desirable property.
7.1.3 Spectral Graph Convolutions
Section titled “7.1.3 Spectral Graph Convolutions”We have seen how to generalize the notion of a signal and a convolution to the graph domain. We did so by analogy to some important properties of discrete convolutions (e.g., translation equivariance), and this discussion led us to the idea of representing graph convolutions as polynomials of the adjacency matrix (or the Laplacian). However, one key property of convolutions that we ignored in the previous subsection is the relationship between convolutions and the Fourier transform. In this section, we will thus consider the notion of a spectral convolution on graphs, where we construct graph convolutions via an extension of the Fourier transform to graphs. We will see that this spectral perspective recovers many of the same results we previously discussed, while also revealing some more general notions of a graph convolution.
The Fourier Transform and the Laplace Operator
To motivate the generalization of the Fourier transform to graphs, we rely on the connection between the Fourier transform and the Laplace (i.e., difference) operator. We previously saw a definition of the Laplace operator in the case of a simple discrete time-varying signal (Equation (7.10)) but this operator can be generalized to apply to arbitrary smooth functions as
This operator computes the divergence of the gradient . Intuitively, the Laplace operator tells us the average difference between the function value at a point and function values in the neighboring regions surrounding this point.
In the discrete time setting, the Laplace operator simply corresponds to the difference operator (i.e., the difference between consecutive time points). In the setting of general discrete graphs, this notion corresponds to the Laplacian, since by definition
which measures the difference between the value of some signal at a node and the signal values of all of its neighbors. In this way, we can view the Laplacian matrix as a discrete analog of the Laplace operator, since it allows us to quantify the difference between the value at a node and the values at that node’s neighbors.
Now, an extremely important property of the Laplace operator is that its eigenfunctions correspond to the complex exponentials. That is,
so the eigenfucntions of are the same complex exponentials that make up the modes of the frequency domain in the Fourier transform (i.e., the sinusoidal plane waves), with the corresponding eigenvalue indicating the frequency. In fact, one can even verify that the eigenvectors of the circulant Laplacian for the chain graph are where .
The graph Fourier transform
The connection between the eigenfunctions of the Laplace operator and the Fourier transform allows us to generalize the Fourier transform to arbitrary graphs. In particular, we can generalize the notion of a Fourier transform by considering the eigendecomposition of the general graph Laplacian:
where we define the eigenvectors to be the graph Fourier modes, as a graph-based notion of Fourier modes. The matrix is assumed to have the corresponding eigenvalues along the diagonal, and these eigenvalues provide a graph-based notion of different frequency values. In other words, since the eigenfunctions of the general Laplace operator correspond to the Fourier modes—i.e., the complex exponentials in the Fourier series—we define the Fourier modes for a general graph based on the eigenvectors of the graph Laplacian.
Thus, the Fourier transform of signal (or function) on a graph can be computed as
and its inverse Fourier transform computed as
Graph convolutions in the spectral domain are defined via point-wise products in the transformed Fourier space. In other words, given the graph Fourier coefficients of a signal as well as the graph Fourier coefficients of some filter , we can compute a graph convolution via element-wise products as
where is the matrix of eigenvectors of the Laplacian and where we have used to denote that this convolution is specific to a graph .
Based on Equation (7.32), we can represent convolutions in the spectral domain based on the graph Fourier coefficients of the function . For example, we could learn a nonparametric filter by directly optimizing and defining the convolution as
where is matrix with the values of on the diagonal. However, a filter defined in this non-parametric way has no real dependency on the structure of the graph and may not satisfy many of the properties that we want from a convolution. For example, such filters can be arbitrarily non-local.
To ensure that the spectral filter corresponds to a meaningful convolution on the graph, a natural solution is to parameterize based on the eigenvalues of the Laplacian. In particular, we can define the spectral filter as , so that it is a degree polynomial of the eigenvalues of the Laplacian. Defining the spectral convolution in this way ensures our convolution commutes with the Laplacian, since
Moreover, this definition ensures a notion of locality. If we use a degree polynomial, then we ensure that the filtered signal at each node depends on information in its -hop neighborhood.
Thus, in the end, deriving graph convolutions from the spectral perspective, we can recover the key idea that graph convolutions can be represented as polynomials of the Laplacian (or one of its normalized variants). However, the spectral perspective also reveals more general strategies for defining convolutions on graphs.
Interpreting the Laplacian eigenvectors as frequencies In the standard Fourier transform we can interpret the Fourier coefficients as corresponding to different frequencies. In the general graph case, we can no longer interpret the graph Fourier transform in this way.
However, we can still make analogies to high-frequency and low-frequency components. In particular, we can recall that the eigenvectors of the Laplacian solve the minimization problem:
by the Rayleigh–Ritz Theorem. And we have that
by the properties of the Laplacian discussed in Chapter 1. Together these facts imply that the smallest eigenvector of the Laplacian corresponds to a signal that varies from node to node by the least amount on the graph, the second-smallest eigenvector corresponds to a signal that varies the second smallest amount, and so on. Indeed, we leveraged these properties of the Laplacian eigenvectors in Chapter 1 when we performed spectral clustering. In that case, we showed that the Laplacian eigenvectors can be used to assign nodes to communities so that we minimize the number of edges that go between communities. We can now interpret this result from a signal processing perspective: the Laplacian eigenvectors define signals that vary in a smooth way across the graph, with the smoothest signals indicating the coarse-grained community structure of the graph.
7.1.4 Convolution-Inspired GNNs
Section titled “7.1.4 Convolution-Inspired GNNs”The previous subsections generalized the notion of convolutions to graphs. We saw that basic convolutional filters on graphs can be represented as polynomials of the (normalized) adjacency matrix or Laplacian. We saw both spatial and spectral motivations of this fact, and we saw how the spectral perspective can be used to define more general forms of graph convolutions based on the graph Fourier transform. In this section, we will briefly review how different GNN models have been developed and inspired based on these connections.
Purely Convolutional Approaches
Some of the earliest work on GNNs can be directly mapped to the graph convolution definitions of the previous subsections. The key idea in these approaches is that they use either Equation (7.34) or Equation (7.35) to define a convolutional layer, and a full model is defined by stacking and combining multiple convolutional layers with nonlinearities. For example, in early work Bruna et al. [2014] experimented with the nonparametric spectral filter (Equation (7.34)) as well as a parametric spectral filter (Equation (7.35)), where they defined the polynomial via a cubic spline approach. Following on this work, Defferrard et al. [2016] defined convolutions based on Equation (7.35) and defined using Chebyshev polynomials. This approach benefits from the fact that Chebyshev polynomials have an efficient recursive formulation and have various properties that make them suitable for polynomial approximation [Mason and Handscomb, 2002]. In a related approach, Liao et al. [2019b] learn polynomials of the Laplacian based on the Lanczos algorithm.
There are also approaches that go beyond real-valued polynomials of the Laplacian (or the adjacency matrix). For example, Levie et al. [2018] consider Cayley polynomials of the Laplacian and Bianchi et al. [2019] consider ARMA filters. Both of these approaches employ more general parametric rational complex functions of the Laplacian (or the adjacency matrix).
Graph Convolutional Networks and Connections to Message Passing
In their seminal work, Kipf and Welling [2016a] built off the notion of graph convolutions to define one of the most popular GNN architectures, commonly known as the graph convolutional network (GCN). The key insight of the GCN approach is that we can build powerful models by stacking very simple graph convolutional layers. A basic GCN layer is defined in Kipf and Welling [2016a] as
where is a normalized variant of the adjacency matrix (with self-loops) and is a learnable parameter matrix. This model was initially motivated as a combination of a simple graph convolution (based on the polynomial ), with a learnable weight matrix and a nonlinearity.
As discussed in Chapter 5, we can also interpret the GCN model as a variation of the basic GNN message passing approach. In general, if we consider combining a simple graph convolution defined via the polynomial with nonlinearities and trainable weight matrices we recover the basic GNN:
In other words, a simple graph convolution based on is equivalent to aggregating information from neighbors and combining that with information from the node itself. Thus, we can view the notion of message passing as corresponding to a simple form of graph convolutions combined with additional trainable weights and nonlinearities.
Over-smoothing as a low-pass convolutional filter In Chapter 5, we introduced the problem of over-smoothing in GNNs. The intuitive idea in over-smoothing is that after too many rounds of message passing, the embeddings for all nodes begin to look identical and are relatively uninformative. Based on the connection between message-passing GNNs and graph convolutions, we can now understand over-smoothing from the perspective of graph signal processing.
The key intuition is that stacking multiple rounds of message passing in a basic GNN is analogous to applying a low-pass convolutional filter, which produces a smoothed version of the input signal on the graph. In particular, suppose we simplify a basic GNN (Equation (7.40)) to the following update equation:
Compared to the basic GNN in Equation (7.40), we have simplified the model by removing the nonlinearity and removing addition of the “self” embeddings at each message-passing step. For mathematical simplicity and numerical stability, we will also assume that we are using the symmetric normalized adjacency matrix rather than the unnormalized adjacency matrix. This model is similar to the simple GCN approach proposed in Kipf and Welling [2016a] and essentially amounts to taking the average over the neighbor embeddings at each round of message passing.
Now, it is easy to see that after rounds of message passing based on Equation (7.41), we will end up with a representation that depends on the th power of the adjacency matrix:
where is some linear operator and is the matrix of input node features. To understand the connection between over-smoothing and convolutional filters, we just need to recognize that the multiplication of the input node features by a high power of the adjacency matrix can be interpreted as convolutional filter based on the lowest-frequency signals of the graph Laplacian.
For example, suppose we use a large enough value of such that we have reached the a fixed point of the following recurrence:
One can verify that this fixed point is attainable when using the normalized adjacency matrix, since the dominant eigenvalue of is equal to one. We can see that at this fixed point, all the node features will have converged to be completely defined by the dominant eigenvector of , and more generally, higher powers of will emphasize the largest eigenvalues of this matrix. Moreover, we know that the largest eigenvalues of correspond to the smallest eigenvalues of its counterpart, the symmetric normalized Laplacian (e.g., see Equation (7.24)). Together, these facts imply that multiplying a signal by high powers of corresponds to a convolutional filter based on the lowest eigenvalues (or frequencies) of , i.e., it produces a low-pass filter!
Thus, we can see from this simplified model that stacking many rounds of message passing leads to convolutional filters that are low-pass, and—in the worst case—these filters simply converge all the node representations to constant values within connected components on the graph (i.e., the “zero-frequency” of the Laplacian).
Of course, in practice we use more complicated forms of message passing, and this issue is partially alleviated by including each node’s previous embedding in the message-passing update step. Nonetheless, it is instructive to understand how stacking “deeper” convolutions on graphs in a naive way can actually lead to simpler, rather than more complex, convolutional filters.
GNNs Without Message Passing
Inspired by connections to graph convolutions, several recent works have also proposed to simplify GNNs by removing the iterative message passing process. In these approaches, the models are generally defined as
where is some deterministic function of the adjacency matrix , denotes a dense neural network, is the matrix of input node features, and is the matrix of learned node representations. For example, in Wu et al. [2019], they define
where is the symmetric normalized adjacency matrix (with self-loops added). In a closely related work, Klicpera et al. [2019] defines by analogy to the personalized PageRank algorithm as5
The intuition behind these approaches is that we often do not need to interleave trainable neural networks with graph convolution layers. Instead, we can simply use neural networks to learn feature transformations at the beginning and end of the model and apply a deterministic convolution layer to leverage the graph structure. These simple models are able to outperform more heavily parameterized message passing models (e.g., GATs or GraphSAGE) on many classification benchmarks.
There is also increasing evidence that using the symmetric normalized adjacency matrix with self-loops leads to effective graph convolutions, especially in this simplified setting without message passing. Both Wu et al. [2019] and Klicpera et al. [2019] found that convolutions based on achieved the best empirical performance. Wu et al. [2019] also provide theoretical support for these results. They prove that adding self-loops shrinks the spectrum of corresponding graph Laplacian by reducing the magnitude of the dominant eigenvalue. Intuitively, adding self-loops decreases the influence of far-away nodes and makes the filtered signal more dependent on local neighborhoods on the graph.
7.2 GNNs and Probabilistic Graphical Models
Section titled “7.2 GNNs and Probabilistic Graphical Models”GNNs are well understood and well motivated as extensions of convolutions to graph-structured data. However, there are alternative theoretical motivations for the GNN framework that can provide interesting and novel perspectives. One prominent example is the motivation of GNNs based on connections to variational inference in probabilistic graphical models (PGMs).
In this probabilistic perspective, we view the embeddings for each node as latent variables that we are attempting to infer. We assume that we observe the graph structure (i.e., the adjacency matrix, ) and the input node features, , and our goal is to infer the underlying latent variables (i.e., the embeddings ) that can explain this observed data. The message passing operation that underlies GNNs can then be viewed as a neural network analog of certain message passing algorithms that are commonly used for variational inference to infer distributions over latent variables. This connection was first noted by Dai et al. [2016], and much of the proceeding discussions is based closely on their work.
Note that the presentation in this section assumes a substantial background in PGMs, and we recommend Wainwright and Jordan [2008] as a good resource for the interested reader. However, we hope and expect that even a reader without any knowledge of PGMS can glean useful insights from the following discussions.
7.2.1 Hilbert Space Embeddings of Distributions
Section titled “7.2.1 Hilbert Space Embeddings of Distributions”To understand the connection between GNNs and probabilistic inference, we first (briefly) introduce the notion of embedding distributions in Hilbert spaces [Smola et al., 2007]. Let denote a probability density function defined over the random variable . Given an arbitrary (and possibly infinite dimensional) feature map , we can represent the density based on its expected value under this feature map:
The key idea with Hilbert space embeddings of distributions is that Equation (7.48) will be injective, as long as a suitable feature map is used. This means that can serve as a sufficient statistic for , and any computations we want to perform on can be equivalently represented as functions of the embedding . A well-known example of a feature map that would guarantee this injective property is the feature map induced by the Gaussian radial basis function (RBF) kernel [Smola et al., 2007].
The study of Hilbert space embeddings of distributions is a rich area of statistics. In the context of the connection to GNNs, however, the key takeaway is simply that we can represent distributions as embeddings in some feature space. We will use this notion to motivate the GNN message passing algorithm as a way of learning embeddings that represent the distribution over node latents .
7.2.2 Graphs as Graphical Models
Section titled “7.2.2 Graphs as Graphical Models”Taking a probabilistic view of graph data, we can assume that the graph structure we are given defines the dependencies between the different nodes. Of course, we usually interpret graph data in this way. Nodes that are connected in a graph are generally assumed to be related in some way. However, in the probabilistic setting, we view this notion of dependence between nodes in a formal, probabilistic way.
To be precise, we say that a graph defines a Markov random field:
where and are non-negative potential functions, and where we use as a shorthand for the set . Equation (7.49) says that the distribution over node features and node embeddings factorizes according to the graph structure. Intuitively, indicates the likelihood of a node feature vector given its latent node embedding , while controls the dependency between connected nodes. We thus assume that node features are determined by their latent embeddings, and we assume that the latent embeddings for connected nodes are dependent on each other (e.g., connected nodes might have similar embeddings).
In the standard probabilistic modeling setting, and are usually defined as parametric functions based on domain knowledge, and, most often, these functions are assumed to come from the exponential family to ensure tractability [Wainwright and Jordan, 2008]. In our presentation, however, we are agnostic to the exact form of and , and we will seek to implicitly learn these functions by leveraging the Hilbert space embedding idea discussed in the previous section.
7.2.3 Embedding Mean-Field Inference
Section titled “7.2.3 Embedding Mean-Field Inference”Given the Markov random field defined by Equation (7.49), our goal is to infer the distribution of latent embeddings for all the nodes , while also implicitly learning the potential functions and . In more intuitive terms, our goal is to infer latent representations for all the nodes in the graph that can explain the dependencies between the observed node features.
In order to do so, a key step is computing the posterior , i.e., computing the likelihood of a particular set of latent embeddings given the observed features. In general, computing this posterior is computationally intractable—even if and are known and well-defined—so we must resort to approximate methods.
One popular approach—which we will leverage here—is to employ mean-field variational inference, where we approximate the posterior using some functions based on the assumption:
where each is a valid density. The key intuition in mean-field inference is that we assume that the posterior distribution over the latent variables factorizes into independent distributions, one per node.
To obtain approximating functions that are optimal in the mean-field approximation, the standard approach is to minimize the Kullback–Leibler (KL) divergence between the approximate posterior and the true posterior:
The KL divergence is one canonical way of measuring the distance between probability distributions, so finding functions that minimize Equation (7.51) gives an approximate posterior that is as close as possible to the true posterior under the mean-field assumption. Of course, directly minimizing Equation (7.51) is impossible, since evaluating the KL divergence requires knowledge of the true posterior.
Luckily, however, techniques from variational inference can be used to show that that minimize the KL must satisfy the following fixed point equations:
where is a constant that does not depend on or . In practice, we can approximate this fixed point solution by initializing some initial guesses to valid probability distributions and iteratively computing
The justification behind Equation (7.52) is beyond the scope of this book. For the purposes of this book, however, the essential ideas are the following.
-
We can approximate the true posterior over the latent embeddings using the mean-field assumption, where we assume that the posterior factorizes into independent distributions .
-
The optimal approximation under the mean-field assumption is given by the fixed point in Equation (7.52), where the approximate posterior for each latent node embedding is a function of (i) the node’s feature and (ii) the marginal distributions of the node’s neighbors’ embeddings.
At this point the connection to GNNs begins to emerge. In particular, if we examine the fixed point iteration in Equation (7.53), we see that the updated marginal distribution is a function of the node features (through the potential function ) as well as function of the set of neighbor marginals from the previous iteration (through the potential function ). This form of message passing is highly analogous to the message passing in GNNs! At each step, we are updating the values at each node based on the set of values in the node’s neighborhood. The key distinction is that the mean-field message passing equations operate over distributions rather than embeddings, which are used in the standard GNN message passing.
We can make the connection between GNNs and mean-field inference even tighter by leveraging the Hilbert space embeddings that we introduced in Section 7.2.1. Suppose we have some injective feature map and can represent all the marginals as embeddings
With these representations, we can re-write the fixed point iteration in Equation (7.52) as
where is a vector-valued function. Notice that aggregates information from the set of neighbor embeddings (i.e., and updates the node’s current representation (i.e., ) using this aggregated data. In this way, we can see that embedded mean-field inference exactly corresponds to a form of neural message passing over a graph!
Now, in the usual probabilistic modeling scenario, we would define the potential functions and , as well as the feature map , using some domain knowledge. And given some , and , we could then try to analytically derive the function in Equation (7.55) that would allow us to work with an embedded version of mean field inference. However, as an alternative, we can simply try to learn embeddings in and end-to-end fashion using some supervised signals, and we can define to be an arbitrary neural network. In other words, rather than specifying a concrete probabilistic model, we can simply learn embeddings that could correspond to some probabilistic model. Based on this idea, Dai et al. [2016] define in an analogous manner to a basic GNN as
Thus, at each iteration, the updated Hilbert space embedding for node is a function of its neighbors’ embeddings as well as its feature inputs. And, as with a basic GNN, the parameters and of the update process can be trained via gradient descent on any arbitrary task loss.
7.2.4 GNNs and PGMs More Generally
Section titled “7.2.4 GNNs and PGMs More Generally”In the previous subsection, we gave a brief introduction to how a basic GNN model can be derived as an embedded form of mean field inference—a connection first outlined by Dai et al. [2016]. There are, however, further ways to connect PGMs and GNNs. For example, different variants of message passing can be derived based on different approximate inference algorithms (e.g., Bethe approximations as discussed in Dai et al. [2016]), and there are also several works which explore how GNNs can be integrated more generally into PGM models [Qu et al., 2019, Zhang et al., 2020]. In general, the connections between GNNs and more traditional statistical relational learning is a rich area with vast potential for new developments.
7.3 GNNs and Graph Isomorphism
Section titled “7.3 GNNs and Graph Isomorphism”We have now seen how GNNs can be motivated based on connections to graph signal processing and probabilistic graphical models. In this section, we will turn our attention to our third and final theoretical perspective on GNNs: the motivation of GNNs based on connections to graph isomorphism testing.
As with the previous sections, here we will again see how the basic GNN can be derived as a neural network variation of an existing algorithm—in this case the Weisfieler-Lehman (WL) isomorphism algorithm. However, in addition to motivating the GNN approach, connections to isomorphism testing will also provide us with tools to analyze the power of GNNs in a formal way.
7.3.1 Graph Isomorphism
Section titled “7.3.1 Graph Isomorphism”Testing for graph isomorphism is one of the most fundamental and well-studied tasks in graph theory. Given a pair of graphs and , the goal of graph isomorphism testing is to declare whether or not these two graphs are isomorphic. In an intuitive sense, two graphs being isomorphic means that they are essentially identical. Isomorphic graphs represent the exact same graph structure, but they might differ only in the ordering of the nodes in their corresponding adjacency matrices. Formally, if we have two graphs with adjacency matrices and , as well as node features and , we say that two graphs are isomorphic if and only if there exists a permutation matrix such that
It is important to note that isomorphic graphs are really are identical in terms of their underlying structure. The ordering of the nodes in the adjacency matrix is an arbitrary decision we must make when we represent a graph using algebraic objects (e.g., matrices), but this ordering has no bearing on the structure of the underlying graph itself.
Despite its simple definition, testing for graph isomorphism is a fundamentally hard problem. For instance, a naive approach to test for isomorphism would involve the following optimization problem:
This optimization requires searching over the full set of permutation matrices to evaluate whether or not there exists a single permutation matrix that leads to an equivalence between the two graphs. The computational complexity of this naive approach is immense at , and in fact, no polynomial time algorithm is known to correctly test isomorphism for general graphs.
Graph isomorphism testing is formally referred to as NP-indeterminate (NPI). It is known to not be NP-complete, but no general polynomial time algorithms are known for the problem. (Integer factorization is another well-known problem that is suspected to belong to the NPI class.) There are, however, many practical algorithms for graph isomorphism testing that work on broad classes of graphs, including the WL algorithm that we introduced briefly in Chapter 1.
7.3.2 Graph Isomorphism and Representational Capacity
Section titled “7.3.2 Graph Isomorphism and Representational Capacity”The theory of graph isomorphism testing is particularly useful for graph representation learning. It gives us a way to quantify the representational power of different learning approaches. If we have an algorithm—for example, a GNN—that can generate representations for graphs, then we can quantify the power of this learning algorithm by asking how useful these representations would be for testing graph isomorphism. In particular, given learned representations and for two graphs, a “perfect” learning algorithm would have that
A perfect learning algorithm would generate identical embeddings for two graphs if and only if those two graphs were actually isomorphic.
Of course, in practice, no representation learning algorithm is going to be “perfect” (unless P=NP). Nonetheless, quantifying the power of a representation learning algorithm by connecting it to graph isomorphism testing is very useful. Despite the fact that graph isomorphism testing is not solvable in general, we do know several powerful and well-understood approaches for approximate isomorphism testing, and we can gain insight into the power of GNNs by comparing them to these approaches.
7.3.3 The Weisfieler–Lehman Algorithm
Section titled “7.3.3 The Weisfieler–Lehman Algorithm”The most natural way to connect GNNs to graph isomorphism testing is based on connections to the family of Weisfieler–Lehman (WL) algorithms. In Chapter 1, we discussed the WL algorithm in the context of graph kernels. However, the WL approach is more broadly known as one of the most successful and well-understood frameworks for approximate isomorphism testing. The simplest version of the WL algorithm—commonly known as the 1-WL—consists of the following steps.
The graph (one graph, five nodes a–e, shown left to right in the print): edges a–b, b–c, b–d, c–e.
| Node | Iteration 0 label | Iteration 1: (label, {neighbor labels}) → new label | Iteration 2: (label, {neighbor labels}) → new label |
|---|---|---|---|
| a | 1 | 1,{3} → A | A,{B} → E |
| b | 3 | 3,{1,1,2} → B | B,{A,A,C} → F |
| c | 2 | 2,{3,1} → C | C,{B,D} → G |
| d | 1 | 1,{3} → A | A,{B} → E |
| e | 1 | 2,{3,1} → D | D,{C} → H |
[!visual-conversion] The three panels (Iteration 0, 1, 2) are transcribed as one table. Node names a–e are added here to index the rows; the print identifies nodes only by position. The OCR had reduced the figure to a placeholder.
Figure 7.2: Example of the WL iterative labeling procedure on one graph.
-
Given two graphs and we assign an initial label to each node in each graph. In most graphs, this label is simply the node degree, i.e., , but if we have discrete features (i.e., one hot features ) associated with the nodes, then we can use these features to define the initial labels.
-
Next, we iteratively assign a new label to each node in each graph by hashing the multi-set of the current labels within the node’s neighborhood, as well as the node’s current label:
where the double-braces are used to denote a multi-set and the HASH function maps each unique multi-set to a unique new label.
-
We repeat Step 2 until the labels for all nodes in both graphs converge, i.e., until we reach an iteration where .
-
Finally, we construct multi-sets
summarizing all the node labels in each graph, and we declare and to be isomorphic if and only if the multi-sets for both graphs are identical, i.e., if and only if .
Figure 7.2 illustrates an example of the WL labeling process on one graph. At each iteration, every node collects the multi-set of labels in its local neighborhood, and updates its own label based on this multi-set. After iterations of this labeling process, every node has a label that summarizes the structure of its -hop neighborhood, and the collection of these labels can be used to characterize the structure of an entire graph or subgraph.
The WL algorithm is known to converge in at most iterations and is known to known to successfully test isomorphism for a broad class of graphs [Babai and Kucera, 1979]. There are, however, well-known cases where the test fails, such as the simple example illustrated in Figure 7.3.
graph LR
subgraph G1["Graph 1: one 6-cycle"]
a1(( )) --- a2(( )) --- a3(( )) --- a4(( )) --- a5(( )) --- a6(( )) --- a1
end
subgraph G2["Graph 2: two disjoint triangles"]
b1(( )) --- b2(( )) --- b3(( )) --- b1
c1(( )) --- c2(( )) --- c3(( )) --- c1
end
[!visual-conversion] Both graphs are transcribed exactly: six unlabelled nodes each, all of degree 2. The print draws the 6-cycle as a rectangle and the triangles side by side; Mermaid’s layout differs.
Figure 7.3: Example of two graphs that cannot be distinguished by the basic WL algorithm.
7.3.4 GNNs and the WL Algorithm
Section titled “7.3.4 GNNs and the WL Algorithm”There are clear analogies between the WL algorithm and the neural message passing GNN approach. In both approaches, we iteratively aggregate information from local node neighborhoods and use this aggregated information to update the representation of each node. The key distinction between the two approaches is that the WL algorithm aggregates and updates discrete labels (using a hash function) while GNN models aggregate and update node embeddings using neural networks. In fact, GNNs have been motivated and derived as a continuous and differentiable analog of the WL algorithm.
The relationship between GNNs and the WL algorithm (described in Section 7.3.3) can be formalized in the following theorem:
Theorem 7.1 [Morris et al., 2019, Xu et al., 2019]. Define a message-passing GNN (MP-GNN) to be any GNN that consists of message-passing layers of the following form:
where is a differentiable permutation invariant function and is a differentiable function. Further, suppose that we have only discrete feature inputs at the initial layer, i.e., . Then we have that only if the nodes and have different labels after iterations of the WL algorithm.
In intuitive terms, Theorem 7.3.4 states that GNNs are no more powerful than the WL algorithm when we have discrete information as node features. If the WL algorithm assigns the same label to two nodes, then any message-passing GNN will also assign the same embedding to these two nodes. This result on node labeling also extends to isomorphism testing. If the WL test cannot distinguish between two graphs, then a MP-GNN is also incapable of distinguishing between these two graphs. We can also show a more positive result in the other direction:
Theorem 7.2 [Morris et al., 2019, Xu et al., 2019]. There exists a MP-GNN such that if and only if the two nodes and have the same label after iterations of the WL algorithm.
This theorem states that there exist message-passing GNNs that are as powerful as the WL test.
Which MP-GNNs are most powerful? The two theorems above state that message-passing GNNs are at most as powerful as the WL algorithm and that there exist message-passing GNNs that are as powerful as the WL algorithm. So which GNNs actually obtain this theoretical upper bound? Interestingly, the basic GNN that we introduced at the beginning of Chapter 5 is sufficient to satisfy this theory. In particular, if we define the message passing updates as follows:
then this GNN is sufficient to match the power of the WL algorithm [Morris et al., 2019].
However, most of the other GNN models discussed in Chapter 5 are not as powerful as the WL algorithm. Formally, to be as powerful as the WL algorithm, the and functions need to be injective [Xu et al., 2019]. This means that the and operators need to be map every unique input to a unique output value, which is not the case for many of the models we discussed. For example, functions that use a (weighted) average of the neighbor embeddings are not injective; if all the neighbors have the same embedding then a (weighted) average will not be able to distinguish between input sets of different sizes.
Xu et al. [2019] provide a detailed discussion of the relative power of various GNN architectures. They also define a “minimal” GNN model, which has few parameters but is still as powerful as the WL algorithm. They term this model the Graph Isomorphism Network (GIN), and it is defined by the following update:
where is a trainable parameter.
7.3.5 Beyond the WL Algorithm
Section titled “7.3.5 Beyond the WL Algorithm”The previous subsection highlighted an important negative result regarding message-passing GNNs (MP-GNNs): these models are no more powerful than the WL algorithm. However, despite this negative result, investigating how we can make GNNs that are provably more powerful than the WL algorithm is an active area of research.
Relational Pooling
One way to motivate provably more powerful GNNs is by considering the failure cases of the WL algorithm. For example, we can see in Figure 7.3 that the WL algorithm—and thus all MP-GNNs—cannot distinguish between a connected six-cycle and a set of two triangles. From the perspective of message passing, this limitation stems from the fact that and operations are unable to detect when two nodes share a neighbor. In the example in Figure 7.3, each node can infer from the message passing operations that they have two degree-2 neighbors, but this information is not sufficient to detect whether a node’s neighbors are connected to one another. This limitation is not simply a corner case illustrated in Figure 7.3. Message passing approaches generally fail to identify closed triangles in a graph, which is a critical limitation.
To address this limitation, Murphy et al. [2019] consider augmenting MP-GNNs with unique node ID features. If we use MP-GNN() to denote an arbitrary MP-GNN on input adjacency matrix and node features , then adding node IDs is equivalent to modifying the MP-GNN to the following:
where is the -dimensional identity matrix and denotes column-wise matrix concatenation. In other words, we simple add a unique, one-hot indicator feature for each node. In the case of Figure 7.3, adding unique node IDs would allow a MP-GNN to identify when two nodes share a neighbor, which would make the two graphs distinguishable.
Unfortunately, however, this idea of adding node IDs does not solve the problem. In fact, by adding unique node IDs we have actually introduced a new and equally problematic issue: the MP-GNN is no longer permutation equivariant. For a standard MP-GNN we have that
where is an arbitrary permutation matrix. This means that standard MP-GNNs are permutation equivariant. If we permute the adjacency matrix and node features, then the resulting node embeddings are simply permuted in an equivalent way. However, MP-GNNs with node IDs are not permutation invariant since, in general,
The key issue is that assigning a unique ID to each node fixes a particular node ordering for the graph, which breaks the permutation equivariance.
To alleviate this issue, Murphy et al. [2019] propose the Relational Pooling (RP) approach, which involves marginalizing over all possible node permutations. Given any MP-GNN the RP extension of this GNN is given by
Summing over all possible permutation matrices recovers the permutation invariance, and we retain the extra representational power of adding unique node IDs. In fact, Murphy et al. [2019] prove that the RP extension of a MP-GNN can distinguish graphs that are indistinguishable by the WL algorithm.
The limitation of the RP approach is in its computational complexity. Naively evaluating Equation (7.67) has a time complexity of , which is infeasible in practice. Despite this limitation, however, Murphy et al. [2019] show that the RP approach can achieve strong results using various approximations to decrease the computation cost (e.g., sampling a subset of permutations).
The -WL Test and -GNNs
The RP approach discussed above can produce GNN models that are provably more powerful than the WL algorithm. However, the RP approach has two key limitations:
-
The full algorithm is computationally intractable.
-
We know that RP-GNNs are more powerful than the WL test, but we have no way to characterize how much more powerful they are.
To address these limitations, several approaches have considered improving GNNs by adapting generalizations of the WL algorithm.
The WL algorithm we introduced in Section 7.3.3 is in fact just the simplest of what is known as the family of -WL algorithms. In fact, the WL algorithm we introduced previously is often referred to as the 1-WL algorithm, and it can be generalized to the -WL algorithm for . The key idea behind the -WL algorithms is that we label subgraphs of size rather than individual nodes. The -WL algorithm generates representation of a graph through the following steps:
-
Let be a tuple defining a subgraph of size , where . Define the initial label for each subgraph by the isomorphism class of this subgraph (i.e., two subgraphs get the same label if and only if they are isomorphic).
-
Next, we iteratively assign a new label to each subgraph by hashing the multi-set of the current labels within this subgraph’s neighborhood:
where the th subgraph neighborhood is defined as
-
We repeat Step 2 until the labels for all subgraphs converge, i.e., until we reach an iteration where for every -tuple of nodes .
-
Finally, we construct a multi-set
summarizing all the subgraph labels in the graph.
As with the 1-WL algorithm, the summary multi-set generated by the -WL algorithm can be used to test graph isomorphism by comparing the multi-sets for two graphs. There are also graph kernel methods based on the -WL test [Morris et al., 2019], which are analogous to the WL-kernel introduced that was in Chapter 1.
An important fact about the -WL algorithm is that it introduces a hierarchy of representational capacity. For any we have that the -WL test is strictly more powerful than the -WL test.6 Thus, a natural question to ask is whether we can design GNNs that are as powerful as the -WL test for , and, of course, a natural design principle would be to design GNNs by analogy to the -WL algorithm.
Morris et al. [2019] attempt exactly this: they develop a -GNN approach that is a differentiable and continuous analog of the -WL algorithm. -GNNs learn embeddings associated with subgraphs—rather than nodes—and the message passing occurs according to subgraph neighborhoods (e.g., as defined in Equation (7.68)). Morris et al. [2019] prove that -GNNs can be as expressive as the -WL algorithm. However, there are also serious computational concerns for both the -WL test and -GNNs, as the time complexity of the message passing explodes combinatorially as increases. These computational concerns necessitate various approximations to make -GNNs tractable in practice [Morris et al., 2019].
Invariant and Equivariant -Order GNNs
Another line of work that is motivated by the idea of building GNNs that are as powerful as the -WL test are the invariant and equivariant GNNs proposed by Maron et al. [2019]. A crucial aspect of message-passing GNNs (MP-GNNs; as defined in Theorem 7.3.4) is that they are equivariant to node permutations, meaning that
for any permutation matrix . This equality says that that permuting the input to an MP-GNN simply results in the matrix of output node embeddings being permuted in an analogous way.
In addition to this notion of equivariance, we can also define a similar notion of permutation invariance for MP-GNNs at the graph level. In particular, MP-GNNs can be extended with a : function (see Chapter 5), which maps the matrix of learned node embeddings to an embedding of the entire graph. In this graph-level setting we have that MP-GNNs are permutation invariant, i.e.,
meaning that the pooled graph-level embedding does not change when different node orderings are used.
Based on this idea of invariance and equivariance, Maron et al. [2019] propose a general form of GNN-like models based on permutation equivariant/invariant tensor operations. Suppose we have an order- tensor , where we assume that the first channels/modes of this tensor are indexed by the nodes of the graph. We use the notation to denote the operation where we permute the first channels of this tensor according the node permutation matrix . We can then define an linear equivariant layer as a linear operator (i.e., a tensor) :
where we use to denote a generalized tensor product. Invariant linear operators can be similarly defined as tensors that satisfy the following equality:
Note that both equivariant and invariant linear operators can be represented as tensors, but they have different structure. In particular, an equivariant operator corresponds to a tensor , which has channels indexed by nodes (i.e., twice as many node channels as the input). On the other hand, an invariant operator corresponds to a tensor , which has channels indexed by nodes (i.e., the same number as the input). Interestingly, taking this tensor view of the linear operators, the equivariant (Equation (7.71)) and invariant (Equation (7.72)) properties for can be combined into a single requirement that the tensor is a fixed point under node permutations:
In other words, for a given input , both equivariant and invariant linear operators on this input will correspond to tensors that satisfy the fixed point in Equation (7.73), but the number of channels in the tensor will differ depending on whether it is an equivariant or invariant operator.
Maron et al. [2019] show that tensors satisfying the fixed point in Equation (7.73) can be constructed as a linear combination of a set of fixed basis elements. In particular, any order- tensor that satisfies Equation (7.73) can be written as
where are a set of fixed basis tensors, are real-valued weights, and is the th Bell number. The construction and derivation of these basis tensors is mathematically involved and is closely related to the theory of Bell numbers from combinatorics. However, a key fact and challenge is that the number of basis tensors needed grows with th Bell number, which is an exponentially increasing series.
Using these linear equivariant and invariant layers, Maron et al. [2019] define their invariant -order GNN model based on the following composition of functions:
In this composition, we apply equivariant linear layers , where with and . Between each of these linear equivariant layers an element-wise nonlinearity, denoted by , is applied. The penultimate function in the composition, is an invariant linear layer, , which is followed by an MLP as the final function in the composition. The input to the -order invariant GNN is the tensor , where the first two channels correspond to the adjacency matrix and the remaining channels encode the initial node features/labels.
This approach is called -order because the equivariant linear layers involve tensors that have up to different channels. Most importantly, however, Maron et al. [2019] prove that -order models following Equation (7.75) are equally powerful as the -WL algorithm. As with the -GNNs discussed in the previous section, however, constructing -order invariant models for is generally computationally intractable.
Footnotes
Section titled “Footnotes”-
For simplicity, we limit ourselves to finite support for both and and define the boundary condition using a modulus operator and circular convolution. ↩
-
Note that we add a connection between the last and first nodes in the chain as a boundary condition to keep the domain finite. ↩
-
This assumes a real-valued filter . ↩
-
Note, however, that there are certain convolutional filters (e.g., complex-valued filters) that cannot be represented in this way. ↩
-
Note that the equality between Equations (7.46) and (7.47) requires that the dominant eigenvalue of is bounded above by 1. In practice, Klicpera et al. [2019] use power iteration to approximate the inversion in Equation (7.46). ↩
-
However, note that running the -WL requires solving graph isomorphism for graphs of size , since Step 1 in the -WL algorithm requires labeling graphs according to their isomorphism type. Thus, running the -WL for is generally computationally intractable. ↩