SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Filippo Maria Bianchi*
Dept. of Mathematics and Statistics UiT the Arctic University of Norway NORCE, Norwegian Research Centre AS filippo.m.bianchi@uit.no
Veronica Lachi*
Dept. of Information Engineering and Mathematics  
University of Siena  
veronica.lachi@student.unisi.it
In Graph Neural Networks (GNNs), hierarchical pooling operators generate local summaries of the data by coarsening the graph structure and the vertex features. While considerable attention has been devoted to analyzing the expressive power of message-passing (MP) layers in GNNs, a study on how graph pooling affects the expressiveness of a GNN is still lacking. Additionally, despite the recent advances in the design of pooling operators, there is not a principled criterion to compare them. In this work, we derive sufficient conditions for a pooling operator to fully preserve the expressive power of the MP layers before it. These conditions serve as a universal and theoretically grounded criterion for choosing among existing pooling operators or designing new ones. Based on our theoretical findings, we analyze several existing pooling operators and identify those that fail to satisfy the expressiveness conditions. Finally, we introduce an experimental setup to verify empirically the expressive power of a GNN equipped with pooling layers, in terms of its capability to perform a graph isomorphism test.
Significant effort has been devoted to characterizing the expressive power of Graph Neural Networks (GNNs) in terms of their capabilities for testing graph isomorphism [34]. This has led to a better understanding of the strengths and weaknesses of GNNs and opened up new avenues for developing advanced GNN models that go beyond the limitations of such algorithms [32]. The more powerful a GNN, the larger the set of non-isomorphic graphs that it can distinguish by generating distinct representations for them. GNNs with appropriately formulated message-passing (MP) layers are as effective as the Weisfeiler-Lehman isomorphism test (WL test) in distinguish graphs [38], while higher-order GNN architectures can match the expressiveness of the  $k$ -WL test [29]. Several approaches have been developed to enhance the expressive power of GNNs by incorporating random features into the nodes [33, 1], by using randomized weights in the network architecture [42], or by using compositions of invariant and equivariant functions [27]. Despite the progress made in understanding the expressive power of GNNs, the results are still limited to flat GNNs consisting of a stack of MP layers followed by a final readout [38, 5].
Inspired by pooling in convolutional neural networks, recent works introduced hierarchical pooling operators that enable GNNs to learn increasingly abstract and coarser representations of the input graphs [39, 9]. By interleaving MP with pooling layers that gradually distill global graph properties through the computation of local summaries, it is possible to build deep GNNs that improve the accuracy in graph classification [8, 4] and node classification tasks [18, 26].
It is not straightforward to evaluate the power of a graph pooling operator and the quality of the coarsened graphs it produces. The most common approach is to simply measure the performance of a GNN with pooling layers on a downstream task, such as graph classification. However, such an approach is highly empirical and provides an indirect evaluation affected by external factors. One factor is the overall GNN architecture: pooling is combined with different MP layers, activation functions, normalization or dropout layers, and optimization algorithms, which makes it difficult to disentangle the contribution of the individual components. Another factor is the dataset at hand: some classification tasks only require isolating a specific motif in the graph [23, 7], while others require considering global properties that depend on the whole graph structure [15]. Recently, two criteria were proposed to evaluate a graph pooling operator in terms of i) the spectral similarity between the original and the coarsened graph topology and ii) its capability of reconstructing the features of the original graph from the coarsened one [20]. While providing valuable insights, these criteria give results that are, to some extent, contrasting and in disagreement with the traditional evaluation based on the performance of the downstream task.
To address this issue, we introduce a universal and principled criterion that quantifies the power of a pooling operator as its capability to retain the information in the graph from an expressiveness perspective. In particular, we investigate how graph pooling affects the expressive power of GNNs and derive sufficient conditions under which the pooling operator preserves the highest degree of expressiveness. Our contributions are summarized as follows.
- We show that when certain conditions are met in the MP layers and in the pooling operator, their combination produces an injective function between graphs. This implies that the GNN can effectively coarsen the graph to learn high-level data descriptors, without compromising its expressive power.
- Based on our theoretical analysis, we identify commonly used pooling operators that do not satisfy these conditions and may lead to failures in certain scenarios.
- We introduce a simple yet effective experimental setup for measuring, empirically, the expressive power of any GNN in terms of its capability to perform a graph isomorphism test.
Besides providing a criterion for choosing among existing pooling operators and for designing new ones, our findings allow us to debunk criticism and misconceptions about graph pooling.
2.1 Graph neural networks
Let  $\mathcal{G} = (\mathcal{V},\mathcal{E})$  be a graph with node features  $\mathbf{X}^0\in \mathbb{R}^{N\times F}$ , where  $|\mathcal{V}| = N$ . Each row  $\mathbf{x}_i^0\in \mathbb{R}^F$  of the matrix  $\mathbf{X}^0$  represents the initial node feature of the node  $i,\forall i = 1,\dots ,N$ . Through the MP layers a GNN implements a local computational mechanism to process graphs [19]. Specifically, each feature vector  $\mathbf{x}_v$  is updated by combining the features of the neighboring nodes. After  $l$  iterations,  $\mathbf{x}_v^l$  embeds both the structural information and the content of the nodes in the  $l$ -hop neighborhood of  $v$ . With enough iterations, the feature vectors can be used to classify the nodes or the entire graph. More rigorously, the output of the  $l$ -th layer of a MP-GNN is:
$$
\mathbf {x} _ {v} ^ {l} = \operatorname {C o m b i n e} ^ {(l)} \left(\mathbf {x} _ {v} ^ {l - 1}, \operatorname {A G G R E G A T E} ^ {(l)} \left(\left\{\mathbf {x} _ {u} ^ {l - 1}, u \in \mathcal {N} [ v ] \right\}\right)\right) \tag {1}
$$
where  $\mathsf{AGGREGATE}^{(l)}$  is a function that aggregates the node features from the neighborhood  $\mathcal{N}[v]$  at the  $(l - 1)$ -th iteration, and  $\mathsf{COMBINE}^{(l)}$  is a function that combines the own features with those of the neighbors. This type of MP-GNN implements permutation-invariant feature aggregation functions and the information propagation is isotropic [35]. In graph classification/regression tasks, a READOUT function typically transforms the feature vectors from the last layer  $L$  to produce the final output:
$$
\mathbf {o} = \operatorname {R E A D O U T} \left(\left\{\mathbf {x} _ {v} ^ {L}, v \in \mathcal {V} \right\}\right). \tag {2}
$$
The READOUT is implemented as the sum, mean, or the maximum of all node features, or by more elaborated functions [11, 40, 22].
2.2 Expressive power of graph neural networks
When analyzing the expressive power of GNNs, the primary objective is to evaluate their capacity to produce different outputs for non-isomorphic graphs. While an exact test for graph isomorphism has a combinatorial complexity [2], the WL test for graph isomorphism [37] is a computationally efficient yet effective test that can distinguish a broad range of graphs. The algorithm assigns to each graph vertex a color that depends on the multiset of labels of its neighbors and on its own color. At each iteration, the colors of the vertices are updated until convergence is reached.
There is a strong analogy between an iteration of the WL-test and the aggregation scheme implemented by MP in GNNs. In fact, it has been proven that MP-GNNs are at most as powerful as the WL test in distinguishing different graph-structured features [38, 29]. Moreover, if the MP operation is injective, the resulting MP-GNN is as powerful as the WL test [38]. The Graph Isomorphism Network (GIN) implements such an injective multiset function as:
$$
\mathbf {x} _ {v} ^ {l} = \mathrm {M L P} ^ {(l)} \left((1 + \epsilon^ {l}) \mathbf {x} _ {v} ^ {l - 1} + \sum_ {u \in \mathcal {N} [ v ]} \mathbf {x} _ {u} ^ {l - 1}\right). \tag {3}
$$
Under the condition that the nodes' features are from a countable multiset, the representational power of GIN equals that of the WL test. Some GNNs can surpass the discriminative power of the WL test by using higher-order generalizations of MP operation [29], or by using a composition of invariant and equivariant functions [27], at the price of higher computational complexity. In this work, we focus on the standard MP-GNN, which remains the most widely adopted due to its computational efficiency.
2.3 Graph pooling operators
A graph pooling operator implements a function  $\mathsf{P00L}:\mathcal{G}\mapsto \mathcal{G}_P = (\mathcal{V}_P,\mathcal{E}_P)$  such that  $|\mathcal{V}_P| = K$  with  $K\leq N$ . We let  $\mathbf{X}_P\in \mathbb{R}^{K\times F}$  be the pooled nodes features, i.e., the features of the nodes  $\nu_{P}$  in the pooled graph. To formally describe the P00L function, we adopt the Select-Reduce-Connect (SRC) framework [20], that expresses a graph pooling operator through the combination of three functions: selection, reduction, and connection. The selection function (SEL) clusters the nodes of the input graph into subsets called supernodes, namely  $\mathsf{SEL}:\mathcal{G}\mapsto \mathcal{S} = \{\mathcal{S}_1,\dots ,\mathcal{S}_K\}$  with  $\mathcal{S}_j = \left\{s_i^j\right\}_{i = 1}^N$  where  $s_i^j$  is the membership score of node  $i$  to supernode  $j$ . The memberships are conveniently represented by a cluster assignment matrix  $\mathbf{S}$ , with entries  $[\mathbf{S}]_{ij} = s_i^j$ . Typically, a node can be assigned to zero, one, or several supernodes, each with different scores. The reduction function (RED) creates the pooled vertex features by aggregating the features of the vertices assigned to the same supernode, that is, RED:  $(\mathcal{G},\mathbf{S})\mapsto \mathbf{X}_P$ . Finally, the connect function (CON) generates the edges, and potentially the edge features, by connecting the supernodes.
3 Expressive power of graph pooling operators
We define the expressive power of a graph pooling operator as its capability of preserving the expressive power of the MP layers that came before it. We first present our main result, which is a formal criterion to determine the expressive power of a pooling operator. In particular, we provide three sufficient (though not necessary) conditions ensuring that if the MP and the pooling layers meet certain criteria, then the latter retains the same level of expressive power as the former. Then, we analyze several existing pooling operators and analyze their expressive power based on those criteria.
3.1 Conditions for expressiveness
Theorem 1. Let  $\mathcal{G}_1 = (\mathcal{V}_1, \mathcal{E}_1)$  with  $|\mathcal{V}_1| = N$  and  $\mathcal{G}_2 = (\mathcal{V}_2, \mathcal{E}_2)$  with  $|\mathcal{V}_2| = M$  with node features  $\mathbf{X}$  and  $\mathbf{Y}$  respectively, such that  $\mathcal{G}_1 \neq_{WL} \mathcal{G}_2$ . Let  $\mathcal{G}_1^L$  and  $\mathcal{G}_2^L$  be the graph obtained after applying a block of  $L$  MP layers such that  $\mathbf{X}^L \in \mathbb{R}^{N \times F}$  and  $\mathbf{Y}^L \in \mathbb{R}^{M \times F}$  are the new nodes features. Let POOL be a pooling operator expressed by the functions SEL, RED, CON, which is placed after the MP layers. Let  $\mathcal{G}_{1_P} = \mathrm{POOL}(\mathcal{G}_1^L)$  and  $\mathcal{G}_{2_P} = \mathrm{POOL}(\mathcal{G}_2^L)$  with  $|\mathcal{V}_{1_P}| = |\mathcal{V}_{2_P}| = K$ . Let  $\mathbf{X}_P \in \mathbb{R}^{K \times F}$  and  $\mathbf{Y}_P \in \mathbb{R}^{K \times F}$  be the nodes features of the pooled graphs so that the rows  $\mathbf{x}_{P_j}$  and  $\mathbf{y}_{P_j}$  represent the features of supernode  $j$  in graphs  $\mathcal{G}_{1_P}$  and  $\mathcal{G}_{2_P}$ , respectively. If the following conditions hold:
1.  $\sum_{i}^{N}\mathbf{x}_{i}^{L}\neq \sum_{i}^{M}\mathbf{y}_{i}^{L}$
2. The memberships generated by SEL satisfy  $\sum_{j=1}^{K} s_{ij} = \lambda$ , with  $\lambda > 0$  for each node  $i$ , i.e., the cluster assignment matrix  $\mathbf{S}$  is a right stochastic matrix up to the global constant  $\lambda$ ;
3. The function RED is of type RED:  $(\mathbf{X}^L, \mathbf{S}) \mapsto \mathbf{X}_P = \mathbf{S}^T \mathbf{X}^L$ ;
then  $\mathcal{G}_{1_P}$  and  $\mathcal{G}_{2_P}$  will have different nodes features, i.e., for all rows' indices permutations  $\pi : \{1, \ldots, K\} \to \{1, \ldots, K\}$ ,  $\mathbf{X}_P \neq \Pi(\mathbf{Y}_P)$ , where  $[\Pi(\mathbf{Y}_P)]_{ij} = \mathbf{y}_{P_{\pi(i)j}}$ .
The proof can be found in Appendix A and a schematic summary is in Fig. 1.
Figure 1: A GNN with expressive MP layers (condition 1) computes different features  $\mathcal{X}_1^L$  and  $\mathcal{X}_2^L$  for two graphs  $\mathcal{G}_1$ ,  $\mathcal{G}_2$  that are WL-distinguishable. A pooling layer satisfying the conditions 2 and 3 generates coarsened graphs  $\mathcal{G}_{1_P}$  and  $\mathcal{G}_{2_P}$  that are still WL-distinguishable.
Condition 1 is strictly related to the theory of multisets. Indeed, a major breakthrough in designing highly expressive MP layers was achieved by building upon the findings of Deep Sets [41]. Under the assumption that the node features originate from a countable universe, it has been formally proven that there exists a function that, when applied to the node features, makes the sum over a multiset of node features injective [38]. The universal approximation theorem guarantees that such a function can be implemented by an MLP. Moreover, if the pooling operator satisfies conditions 2 and 3, it will produce different sets of node features. Due to the injectiveness of the coloring function of the WL algorithm, two graphs with different multisets of node features will be classified as non-isomorphic by the WL test and, therefore,  $\mathcal{G}_{1_P} \neq_{\mathrm{WL}} \mathcal{G}_{2_P}$ . This implies that the pooling operator effectively coarsens the graphs while retaining all the information necessary to distinguish them. Therefore, our Theorem ensures that there exists a specific choice of parameters for the MP layer that, when combined with a pooling operator satisfying the Theorem's conditions, the resulting GNN architecture is injective.
Condition 2 implies that all nodes in the original graph must contribute to the supernodes. Moreover, letting the sum of the memberships  $s_{ij}$  to be a constant  $\lambda$  (usually,  $\lambda = 1$ ), places a restriction on the formation of the super-nodes. Condition 3 requires that the features of the supernodes  $\mathbf{X}_P$  are a convex combination of the node features  $\mathbf{X}^L$ . It is important to note that the conditions for the expressiveness only involve SEL and RED, but not the CON function. Indeed, both the graph's topology and the nodes' features are embedded in the features of the supernodes by MP and pooling layers satisfying the conditions of Th. 1. Nevertheless, even if a badly-behaved CON function does not affect the expressiveness of the pooling operator, it can still compromise the effectiveness of the MP layers that come afterward. This will be discussed further in Sections 3.3 and 4.
3.2 Expressiveness of existing pooling operators
The SRC framework allows building a comprehensive taxonomy of the existing pooling operators, based on the density of supernodes, the trainability of the SEL, RED, and CON functions, and the adaptability of the number of supernodes  $K$  [20]. The density of a pooling operator is defined as the expected value of the ratio between the cardinality of a supernode and the number of nodes in the graph. A method is referred to as dense if the supernodes have cardinality  $O(N)$ , whereas a pooling operator is considered sparse if the supernodes generated have constant cardinality  $O(1)$  [20].
Pooling methods can also be distinguished according to the number of nodes  $K$  of the pooled graph. If  $K$  is constant and independent of the input graph size, the pooling method is fixed. On the other hand, if the number of supernodes is a function of the input graph, the method is adaptive. Finally, in some pooling operators the SEL, RED, and CON functions can be learned end-to-end along with the other components of the GNN architecture. In this case, the method is said to be trainable, meaning that the operator has parameters that are learned by optimizing a task-driven loss function. Otherwise, the methods are non-trainable.
Dense pooling operators Prominent methods in this class of pooling operators are DiffPool [39], MinCutPool [8], and DDoN [36]. Besides being dense, all these operators are also trainable and fixed. DiffPool, MinCutPool, and DDoN compute a cluster assignment matrix  $\mathbf{S} \in \mathbb{R}^{N \times K}$  either with an MLP or an MP-layer, which is fed with the node features  $\mathbf{X}^L$  and ends with a softmax. The main difference among these methods is in how they define unsupervised auxiliary loss functions, which are used to inject a bias in how the clusters are formed. Thanks to the softmax normalization, the cluster assignments sum up to one, ensuring condition 2 of Th. 1 to be satisfied. Moreover, the pooled node features are computed as  $\mathbf{X}_p = \mathbf{S}^\mathrm{T}\mathbf{X}^L$ , making also condition 3 satisfied.
There are dense pooling operators that use algorithms such as non-negative matrix factorization [3] to obtain a cluster assignment matrix  $\mathbf{S}$ , which may not satisfy condition 2. Nonetheless, it is always possible to apply a suitable normalization to ensure that the rows in  $\mathbf{S}$  sum up to a constant. Therefore, we claim that all dense methods preserve the expressive power of the preceding MP layers.
Non-expressive sparse pooling operators Members of this category are Top- $k$  [18, 23] ASAPool [31], SAGPool [24] and PanPool [26], which are also trainable and adaptive. These methods reduce the graph by selecting a subset of its nodes based on a ranking score and they mainly differ in how their SEL function computes such a score. Specifically, the Top- $k$  method ranks nodes based on a score obtained by multiplying the node features with a trainable projection vector. A node  $i$  is kept ( $s_i = 1$ ) if  $i$  is among the top- $K$  in the ranking and is discarded ( $s_i = 0$ ) otherwise. SAGPool simply replaces the projection vector with an MP layer to account for the graph's structure when scoring the nodes. ASAPool, instead, examines all potential local clusters in the input graph given a fixed receptive field and it employs an attention mechanism to compute the cluster membership of the nodes. The clusters are subsequently scored using a particular MP operator. Finally, in PanPool the scores are obtained from the diagonal entries of the maximal entropy transition matrix, which is a generalization of the graph Laplacian.
Regardless of how the score is computed, all these methods generate a cluster assignment matrix  $\mathbf{S}$  where not all the rows sum to a constant. Indeed, if a node is not selected, it is not assigned to any supernode in the coarsened graph. Therefore, these methods fail to meet condition 2 of Theorem 1. Additionally, in the RED function of all these methods the features of each selected node are multiplied by its ranking score, making condition 3 also unsatisfied.
$\neq W L$
Figure 2: Example of failure of Top-  $k$  pooling. Given two WL-distinguishable graphs with node features  $x_{1} \leq x_{2} \leq x_{3} \leq x_{4}$ , two scoring vectors  $\mathbf{s}_1$  and  $\mathbf{s}_2$  are computed using a projector  $p$ . Then, the two nodes associated with the highest scores are selected. If  $p \leq 0$ , nodes 1 and 2 are chosen in both graphs. Conversely, if  $p > 0$ , nodes 3 and 4 are selected. Therefore, regardless of the value learned for the projector  $p$ , the two input graphs will be mapped into the same pooled graph.
$= W L$
Intuitively, these operators produce a pooled graph that is a subgraph of the original graph and discard the content of the remaining parts. This hinders the ability to retain all the necessary information for
preserving the expressiveness of the preceding MP layers. The limitation of Top- $k$  is exemplified in Fig. 2: regardless of the projector  $p$ , Top- $k$  maps two WL-distinguishable graphs into two isomorphic graphs, meaning that it cannot preserve the partition on graphs induced by the WL test.
Expressive sparse pooling operators Not all sparse pooling operators coarsen the graph by selecting a subgraph. In fact, some of them assign each node in the original graph to exactly one supernode and, thus, satisfy condition 2 of Th. 1. In matrix form and letting  $\lambda = 1$ , the cluster assignment would be represented by a sparse matrix  $\mathbf{S}$  that satisfies  $\mathbf{S}\mathbf{1}_K = \mathbf{1}_N$  and where every row has one entry equal to one and the others equal to zero. Within this category of sparse pooling operators, notable examples include Graclus [13], ECPool [14], and  $k$ -MISPool [4].
Graclus is a non-trainable, greedy bottom-up spectral clustering algorithm, which matches each vertex with the neighbor that is closest according to the graph connectivity [13]. When Graclus is used to perform graph pooling, the RED function is usually implemented as a max_pool operation between the vertices assigned to the same cluster [12]. In this work, to ensure condition 3 of Th. 1 to be satisfied, we use a sum_pool operation instead. Contrarily from Graclus, ECPool, and  $k$ -MISPool are trainable. ECPool first assigns to each edge  $e_{i \rightarrow j}$  a score  $r_{ij} = f(\pmb{x}_i, \pmb{x}_j; \Theta)$ . Then, iterates over each edge  $e_{i \rightarrow j}$ , starting from those with higher scores, and contracts it if neither nodes  $i$  and  $j$  are attached to an already contracted edge. The endpoints of a contracted edge are merged into a new supernode  $S_k = r_{ij}(\pmb{x}_i + \pmb{x}_j)$ , while the remaining nodes become supernodes themselves. Since each supernode either contains the nodes of a contracted edge or is a node from the original graph, all columns of S have either one or two entries equal to one, while each row sums up to one. The RED function can be expressed as  $\mathbf{r} \odot \mathbf{S}^T \mathbf{X}^L$ , where  $\mathbf{r}[k] = r_{ij}$  if  $k$  is the contraction of two nodes  $i, j$ , otherwise  $\mathbf{r}[k] = 1$ . As a result, ECPool met the expressiveness conditions of Th. 1. Finally,  $k$ -MISPool identifies the supernodes with the centroids of the maximal  $k$ -independent sets of a graph [6]. To speed up computation, the centroids are selected with a greedy approach based on a ranking vector  $\pi$ . Since  $\pi$  can be obtained from a trainable projector  $\mathbf{p}$  applied to the vertex features,  $\pi = \mathbf{X}^L \mathbf{p}^T$ ,  $k$ -MISPool is a trainable pooling operator.  $k$ -MISPool assigns each vertex to one of the centroids and aggregates the features of the vertex assigned to the same centroid with a sum_pool operation to create the features of the supernodes. Therefore,  $k$ -MISPool satisfies the expressiveness conditions of Th. 1.