Generalised f-Mean Aggregation for Graph Neural Networks
Graph Neural Network (GNN) architectures are defined by their implementations
of update and aggregation modules. While many works focus on new ways to
parametrise the update modules, the aggregation modules receive comparatively
little attention. Because it is difficult to parametrise aggregation functions,
currently most methods select a ``standard aggregator'' such as
$\mathrm{mean}$, $\mathrm{sum}$, or $\mathrm{max}$. While this selection is
often made without any reasoning, it has been shown that the choice in
aggregator has a significant impact on performance, and the best choice in
aggregator is problem-dependent. Since aggregation is a lossy operation, it is
crucial to select the most appropriate aggregator in order to minimise
information loss. In this paper, we present GenAgg, a generalised aggregation
operator, which parametrises a function space that includes all standard
aggregators. In our experiments, we show that GenAgg is able to represent the
standard aggregators with much higher accuracy than baseline methods. We also
show that using GenAgg as a drop-in replacement for an existing aggregator in a
GNN often leads to a significant boost in performance across various tasks.
Ryan Kortvelesy, Steven Morad, Amanda Prorok
# Generalised \(f\)-Mean Aggregation

###### Abstract

Graph Neural Network (GNN) architectures are defined by their implementations of update and aggregation modules. While many works focus on new ways to parametrise the update modules, the aggregation modules receive comparatively little attention. Because it is difficult to parametrise aggregation functions, currently most methods select a "standard aggregator" such as \(\mathrm{mean}\), \(\mathrm{sum}\), or \(\mathrm{max}\). While this selection is often made without any reasoning, it has been shown that the choice in aggregator has a significant impact on performance, and the best choice in aggregator is problem-dependent. Since aggregation is a lossy operation, it is crucial to select the most appropriate aggregator in order to minimise information loss. In this paper, we present GenAgg, a generalised aggregation operator, which parametrises a function space that includes all standard aggregators. In our experiments, we show that GenAgg is able to represent the standard aggregators with much higher accuracy than baseline methods. We also show that using GenAgg as a drop-in replacement for an existing aggregator in a GNN often leads to a significant boost in performance across various tasks.

## 1 Introduction

Graph Neural Networks (GNNs) provide a powerful framework for operating over structured data. Taking advantage of relational inductive biases, they use local filters to learn functions that generalise over high-dimensional data. Given different graph structures, GNNs can represent many special cases, including CNNs (on grid graphs) [12], RNNs (on line graphs) [4], and Transformers (on fully connected graphs) [19]. All of these architectures can be subsumed under the Graph Networks framework, parametrised by update and aggregation modules [2]. Although the framework itself is general, the representational capacity is often constrained in practice through design choices, which create a human prior [21]. There are two primary reasons for introducing this human prior. First, there are no standard methods to parametrise all of the modules--MLPs can be used as universal approximators in the update modules, but it is nontrivial to parametrise the function space of aggregators. Consequently, most GNNs simply make a design choice for the aggregation functions, selecting mean, sum, or max [21].

Figure 1: A qualitative demonstration of the diversity of functions which can be represented by GenAgg. In these visualisations, GenAgg is plotted as a function of inputs \(x_{0}\) and \(x_{1}\) for different parametrisations \(\theta=\langle f,\alpha,\beta\rangle\) (see Equation (1)).
Second, constraints can boost performance in GNNs, either through invariances or a regularisation effect.

In this paper, we focus on the problem of parametrising the space of aggregation functions. The ultimate goal is to create an aggregation function which can represent the set of all desired aggregators while remaining as constrained as possible. In prior work, one approach introduces learnable parameters into functions that could parametrise min, mean, and max, such as the Powermean and a variant of Softmax [8; 13; 20]. However, these approaches can only parametrise a small set of aggregators, and they can introduce instability in the training process (see Section 4). On the opposite end of the spectrum, methods like Deep Sets [22] and LSTMAgg [9] are capable of universal approximation over set functions, but they are extremely complex, which leads to poor sample efficiency. These methods scale in complexity (_i.e._ number of parameters) with the dimensionality of the input, and lack some of the useful constraints that are shared among standard aggregators (see Section 4). Consequently, the complexity of these methods counteracts the benefits of simple GNN architectures.

Although existing approaches present some limitations, the theoretical advantages of a learnable aggregation module are evident. It has been shown that the choice of aggregation function not only has a significant impact on performance, but also is problem-specific [21]. Since there is no aggregator that can discriminate between all inputs [5], it is important to select an aggregator that preserves the relevant information. In this paper, we present a method that parametrises the function space, allowing GNNs to learn the most appropriate aggregator for each application.

Contributions
* We introduce Generalised Aggregation (GenAgg), the first aggregation method based on the _generalised f-mean_. GenAgg is a learnable permutation-invariant aggregator which is provably capable (both theoretically and experimentally) of representing all "standard aggregators" (see Appendix C for proofs). The representations learned by GenAgg are _explainable_--each learnable parameter has an interpretable meaning (Section 6).
* Our experiments provide several insights about the role of aggregation functions in the performance of GNNs. In our regression experiments, we demonstrate that GNNs struggle to "make up for" the lack of representational complexity in their constituent aggregators, even when using state-of-the-art parametrised aggregators. This finding is validated in our GNN benchmark experiments, where we show that a GenAgg-based GNN outperforms all of the baselines, including standard aggregators and other state-of-the-art parametrised aggregators.
* Finally, we show that GenAgg satisfies a generalisation of the distributive property. We derive the a solution for a binary operator that satisfies this property for given parametrisations of GenAgg. The generalised distributive property can be leveraged in algorithms using GenAgg to improve space and memory-efficiency.

## 2 Problem Statement

Consider a multiset \(\mathcal{X}=\{x_{1},x_{2},\ldots,x_{n}\}\) of cardinality \(|\mathcal{X}|=n\), where \(x_{i}\in\mathbb{R}^{d}\). We define an aggregation function as a symmetric function \(\bigcirc:\mathbb{R}^{n\times d}\mapsto\mathbb{R}^{1\times d}\). The aggregator must be independent over the feature dimension, so without loss of generality it can be represented over a single dimension \(\bigcirc:\mathbb{R}^{n}\mapsto\mathbb{R}^{1}\). A set of standard aggregators is defined \(\mathcal{A}=\{\mathrm{mean},\mathrm{sum},\mathrm{product},\mathrm{min}, \mathrm{max},\ldots\}\) (for the full list see Table 1). Our task is to create an aggregator \(\bigoplus_{\theta}:\mathbb{R}^{n}\mapsto\mathbb{R}^{1}\) parametrised by \(\theta\) which can represent all standard aggregators: \(\forall\bigcirc_{i}\in\mathcal{A}\;\exists\theta:\;\bigoplus_{\theta}=\bigcirc_ {i}\).

## 3 Method

In this section we introduce GenAgg, a parametrised aggregation function which is based on the _generalised f-mean_[11]. In our formulation, we introduce additional parameters to increase the representational capacity of the \(f\)-mean, producing the _augmented f-mean_ (AFM). Then, as the implementation is non-trivial, we propose a method to implement it. The novel aspect of GenAgg is not
only the augmented \(f\)-mean formula, but also the implementation, which allows the mathematical concept of a generalised mean to be utilised in a machine learning context.

### Generalised \(f\)-Mean

The _generalised f-mean_[11] is given by: \(f^{-1}(\frac{1}{n}\sum_{i}f(x_{i}))\). While it is difficult to define aggregation functions, the generalised \(f\)-mean provides a powerful intuition: most aggregators can be represented by a single invertible scalar-valued function \(f:\mathbb{R}^{1}\mapsto\mathbb{R}^{1}\). This is a useful insight, because it allows comparisons to be drawn between aggregators by analysing their underlying functions \(f\). Furthermore, it provides a framework for discovering new aggregation functions. While classic functions like \(e^{x},\log(x),x^{p}\) all map to aggregators in \(\mathcal{A}\), new aggregators can be created by defining new functions \(f\).

### Augmented \(f\)-Mean

The standard generalised \(f\)-mean imposes strict constraints, such as symmetry (permutation-invariance), idempotency (\(\bigoplus(\{x,\ldots,x\})=x\)), and monotonicity (\(\forall i\in[1..n],\frac{\partial\bigoplus(\{x_{1},\ldots,x_{n}\})}{\partial x _{i}}\geq 0\)). However, this definition is too restrictive to parametrise many special cases of aggregation functions. For example, sum violates idempotency (\(\sum_{i\in[1..n]}x_{i}=nx\)), and standard deviation violates monotonicity (\(\frac{\partial\sigma(\{x_{1},1\})}{\partial x_{1}}|_{x_{1}=0}<0\)). Consequently, we deem these constraints to be counterproductive. In our method, we introduce learnable parameters \(\alpha\) and \(\beta\) to impose a relaxation on the idempotency and monotonicity constraints, while maintaining symmetry. We call this relaxed formulation the _augmented \(f\)-mean_ (AFM), given by:

\[\bigoplus_{i\in[1..n]}x_{i}=f^{-1}\left(n^{\alpha-1}\sum_{i\in[1..n]}f(x_{i}- \beta\mu)\right). \tag{1}\]

The \(\alpha\) parameter allows AFM to control its level of dependence on the cardinality of the input \(\mathcal{X}\). For example, given \(f(x)=\log(|x|)\), if \(\alpha=0\), then AFM represents the geometric mean: \(\bigoplus_{(f,\alpha,\beta)}=\bigoplus_{(\log(|x|),0,0)}=\sqrt[3]{\prod|x_{i}|}\). However, if \(\alpha=1\), then the \(n\)-th root disappears, and AFM represents a product: \(\bigoplus_{(\log(|x|),1,0)}=\prod|x_{i}|\).

\begin{table}
\begin{tabular}{|l|c|c|c|c|c|c|} \hline Aggregation Function & \(\alpha\) & \(\beta\) & \(f\) & GenAgg & SoftmaxAgg & PowerAgg \\ \hline \hline mean: \(\frac{1}{n}\sum x_{i}\) & 0 & 0 & \(f(x)=x\) & ✓ & ✓ & ✓ \\ \hline sum: \(\sum x_{i}\) & 1 & 0 & \(f(x)=x\) & ✓ & ✗ & ✗ \\ \hline product: \(\prod|x_{i}|\) & 1 & 0 & \(f(x)=\log(|x|)\) & ✓ & ✗ & ✗ \\ \hline min (magnitude): \(\min|x_{i}|\) & 0 & 0 & \(f(x)=\lim_{p\rightarrow\infty}|x|^{-p}\) & ✓ & ✗ & ✓ \\ \hline max (magnitude): \(\max|x_{i}|\) & 0 & 0 & \(f(x)=\lim_{p\rightarrow\infty}|x^{p}|^{p}\) & ✓ & ✗ & ✓ \\ \hline min: min \(x_{i}\) & 0 & 0 & \(f(x)=\lim_{p\rightarrow\infty}e^{-p\alpha}\) & ✓ & ✓ & ✗ \\ \hline max: \(\max x_{i}\) & 0 & 0 & \(f(x)=\lim_{p\rightarrow\infty}e^{\alpha}\) & ✓ & ✓ & ✗ \\ \hline harmonic mean: \(\frac{n}{\sum x}\) & 0 & 0 & \(f(x)=\frac{1}{2}\) & ✓ & ✗ & ✓ \\ \hline geometric mean: \(\sqrt[3]{\prod|x_{i}|}\) & 0 & 0 & \(f(x)=\log(|x|)\) & ✓ & ✗ & ✓ \\ \hline root mean square: \(\sqrt[3]{\sum x_{i}^{2}}\) & 0 & 0 & \(f(x)-x^{2}\) & ✓ & ✗ & ✓ \\ \hline collection norm: \(\sqrt[3]{\sum x_{i}^{2}}\) & 1 & 0 & \(f(x)-x^{2}\) & ✓ & ✗ & ✗ \\ \hline standard deviation: \(\sqrt[3]{\sum x_{i}^{2}(x_{i}-x_{i}^{2})^{2}}\) & 0 & 1 & \(f(x)-x^{2}\) & ✓ & ✗ & ✗ \\ \hline log-sum-exp: \(\log\left(\sum e^{\alpha}\right)\) & 1 & 0 & \(f(x)-e^{\alpha}\) & ✓ & ✗ & ✗ \\ \hline \end{tabular}
\end{table}
Table 1: A table of all of the most common aggregators. For each special case, we specify the values of \(\alpha\), \(\beta\), and \(f\) for which the augmented \(f\)-mean is equivalent (see Appendix C). We also report whether or not SoftmaxAgg and PowermeanAgg can represent each aggregator.
The \(\beta\) parameter enables AFM to calculate _centralised moments_, which are a quantitative measures of the distribution of the input \(\mathcal{X}\)[17]. The first raw moment of \(\mathcal{X}\) is the mean \(\mu=\frac{1}{n}\sum x_{i}\), and the \(k\)-th central moment is given by \(\mu_{k}=\sum\left(x_{i}-\mu\right)^{n}\). With the addition of \(\beta\), it becomes possible for AFM to represent \(\sqrt[k]{\mu_{k}}\), the \(k\)-th root of the \(k\)-th central moment. For \(k=2\), this quantity is the standard deviation, which is in our set of standard aggregators \(\mathcal{A}\). If the output is scaled to the \(k\)-th power, then it can also represent metrics such as variance, unnormalised skewness, and unnormalised kurtosis. It is clear that these metrics about the distribution of data are useful--they can have real-world meaning (_e.g._, moments of inertia), and they have been used as aggregators in GNNs in prior work [5]. Consequently, \(\beta\) provides AFM with an important extra dimension of representational complexity. In addition to representing the centralised moments when \(\beta=1\) and \(f(x)=x^{p}\), \(\beta\) allows _any_ aggregator to be calculated in a centralised fashion. While the centralised moments are the only well-known aggregators that arise from nonzero \(\beta\), there are several aggregators with qualitatively unique behaviour that can only be represented with nonzero \(\beta\) (see Fig. 1).

With this parametrisation, AFM can represent any standard aggregator in \(\mathcal{A}\) (Table 1). Furthermore, by selecting new parametrisations \(\theta=\langle f,\alpha,\beta\rangle\), it is possible to compose new aggregators (Fig. 1).

### Implementation

In Equation (1), the manner in which \(f^{-1}\) is implemented is an important design choice. One option is to learn the coefficients for an analytical function (_e.g._ a truncated Taylor Series) and analytically invert it. However, it can be difficult to compute the analytical inverse of a function, and without carefully selected constraints, there is no guarantee that \(f\) will be invertible.

Another possible option is an invertible neural network (_e.g._ a parametrised invertible mapping from _normalising flows_[10]). We have tested the invertible networks from normalising flows literature as implementations for \(f\). While they work well on smaller tasks, these methods present speed and memory issues in larger datasets.

In practice, we find that the most effective approach is to use two separate MLPs for \(f\) and \(f^{-1}\). We enforce the constraint \(x=f^{-1}(f(x))\) by minimizing the following optimisation objective:

\[\mathcal{L}_{\mathrm{inv}}(\theta_{1},\theta_{2})=\mathbb{E}\left[\left(\left| f_{\theta_{2}}^{-1}(f_{\theta_{1}}(x))\right|-|x|\right)^{2}\right]. \tag{2}\]

The absolute value operations apply a relaxation to the constraint, allowing \(f^{-1}(f(x))\) to reconstruct either \(x\) or \(|x|\). This is useful because several of the ground truth functions from Table 1 include an absolute value, making them non-invertible. With this relaxation, it becomes possible to represent those cases. This optimisation objective ensures that \(f\) is both monotonic and invertible over the domains \(\mathbb{R}^{+}\) and \(\mathbb{R}^{-}\), independently. In our implementation, this extra optimisation objective is hidden behind the GenAgg interface and gets applied automatically with a forward hook, so it is not necessary for the user to apply an extra loss term.

While using a scalar-valued \(f:\mathbb{R}^{1}\mapsto\mathbb{R}^{1}\) is the most human-interpretable formulation, it is not necessary. A valid implementation of GenAgg can also be achieved with \(f:\mathbb{R}^{1}\mapsto\mathbb{R}^{d}\) and \(f^{-1}:\mathbb{R}^{d}\mapsto\mathbb{R}^{1}\). In our experiments, we found that mapping to a higher intermediate dimension can sometimes improve performance over a scalar-valued \(f\) (see training details in Appendix E).

### Generalised Distributive Property

Given that GenAgg presents a method of parameterising the function space of aggregators, it can also be used as a tool for mathematical analysis. To demonstrate this, we use the augmented \(f\)-mean to analyse a generalised form of the distributive property, which is satisfied if \(\psi\left(c,\sum_{x_{i}\in\mathcal{X}}x_{i}\right)=\bigcirc_{x_{i}\in \mathcal{X}}\psi(c,x_{i})\) for binary operator \(\psi\) and aggregator \(\bigcirc\). For a given aggregation function parametrised by \(f\) (assuming \(\alpha\) is either \(0\) or \(1\) and \(\beta\) is \(0\)), we derive a closed-form solution for a corresponding binary operator which will satisfy the generalised distributive property (for further explanation and proofs, see Appendix A).

**Theorem 3.1**.: _For GenAgg parametrised by \(\theta=\langle f,\alpha,\beta\rangle=\langle f,1,0\rangle\), the binary operator \(\psi\) which will satisfy the Generalised Distributive Property for \(\bigoplus_{\theta}\) is given by \(\psi(a,b)=f^{-1}(f(a)+f(b))\), and for \(\theta=\langle f,\alpha,\beta\rangle=\langle f,0,0\rangle\), the operator \(\psi\) is given by \(\psi(a,b)=f^{-1}(f(a)\cdot f(b))\)._
For example, for the geometric mean where \(f(x)=x^{2}\) and \(\alpha=0\), the binary operator is \(\psi(a,b)=(a^{2}\cdot b^{2})^{-2}=a\cdot b\), which implies that a constant multiplicative term can be moved outside of the geometric mean. This is a useful finding, as the distributive property can used to improve algorithmic time and space complexity (_e.g._ the FFT) [1]. With our derivation of \(\psi\) as a function of \(f\), it is possible to implement similar efficient algorithms with GenAgg.

## 4 Related Work

Several existing works propose methods to parametrise the space of aggregation functions. These methods can broadly be divided into two categories. _Mathematical_ approaches derive an explicit equation in terms of the inputs and one or more learnable parameters. Usually, these approaches represent a smooth interpolation through function space from min, through mean, to max. Alternatively, _Deep Learning_ approaches seek to use the universal approximation properties of neural networks to maximise representational complexity.

### Mathematical Approaches

**SoftmaxAgg** SoftmaxAgg computes the weighted sum of the set, where the weighting is derived from the softmax over the elements with some learnable temperature term \(s\)[13; 20]. This formulation allows SoftmaxAgg to represent mean, min, and max (see Table 1). Unfortunately, it fails to generalise across the majority of the standard aggregators.

**PowerAgg** Based on the \(p\)-norm, PowerAgg is a special case of GenAgg where \(\alpha=0\), \(\beta=0\), and \(f(x)=x^{p}\). There are some methods which use the powermean directly [13; 20; 8], and others which build on top of it [18]. Theoretically, PowerAgg can represent a significant subset of the standard aggregators: min magnitude, max magnitude, mean, root mean square, harmonic mean, and geometric mean (although the geometric mean requires \(\lim_{p\to 0}\), so it is not practically realisable) (see Table 1). Unfortunately, there is a caveat to this approach: for negative inputs \(x_{i}<0\) and non-integer values \(p\), it is only defined in the complex domain. Furthermore, for negative inputs, the gradient \(\frac{\partial x^{p}}{\partial p}\) with respect to trainable parameter \(p\) is complex and oscillatory (and therefore is prone to getting stuck in local optima). In order to fix this problem, the inputs must be constrained to be positive. In prior work, this has been achieved by clamping \(x^{\prime}_{i}=\max(x_{i},0)\)[13], subtracting the minimum element \(x^{\prime}_{i}=x_{i}-\min(\mathcal{X})\)[20], or taking the absolute value \(x^{\prime}_{i}=|x_{i}|\)[8]. However, this removes important information, making it impossible to reconstruct most standard aggregators.

### Deep Learning Approaches

**PNA** While Principle Neighbourhood Aggregation [5] is introduced as a GNN architecture, its novelty stems from its method of aggregation. In PNA, input signal is processed by a set of aggregation functions, which is produced by the cartesian product of standard aggregators \(\{\text{mean},\text{min},\text{max},\text{std}\}\) and scaling factors \(\{\frac{1}{n},1,n\}\). The output of every aggregator is concatenated, and passed through a dense network. While this increases the representational complexity of the aggregator, it also scales the dimensionality of the input by the number of aggregators multiplied by the number of scaling factors, which can decrease sample efficiency. Furthermore, the representational complexity of the method is limited by the choice of standard aggregators--it cannot be used to represent many of the special cases of parametrised general aggregators.

**LSTMAgg** In LSTMAgg, the input set is treated as a sequence (applying some random permutation), and is encoded with a recurrent neural network [9]. While this method is a universal approximator, it is not permutation-invariant. Due to the factorial complexity of possible orderings, this leads to sample inefficiency. SortAgg addresses this issue by sorting the inputs with computed features, and passing the first \(k\) sorted inputs through convolutional and dense networks [23]. While this method solves the issue of non-permutation-invariance, it loses the capability of universal approximation by truncating to \(k\) inputs. While universal approximation is not a requirement for an effective aggregation function, we note that it cannot represent many of the standard aggregators.

**Deep Sets** Deep Sets is a universal set function approximator [22]. Due to its complexity, it is not usually viewed as an aggregator--it usually serves as a full GNN layer or graph pooling architecture [14; 15]. One may note that the formulation for Deep Sets \(\phi(\sum_{i\in[1..n]}f(x_{i}))\) bears some resemblance to our method. However, there are two important differences. First, our method adds the
constraint \(\phi=f^{-1}\), limiting possible parametrisations to the subspace where all of the standard aggregators lie. Second, while the learnable functions \(\phi\) and \(f\) in Deep Sets are fully connected over the feature dimension, the \(f\) and \(f^{-1}\) modules in our architecture are scalar-valued functions which are applied element-wise. To summarise, Deep Sets is useful as a set function approximator, but it lacks constraints that would make it viable as an aggregation function.

## 5 Experiments

In this paper, we run three experiments. First, we show that GenAgg can perform regression to recover any standard aggregation function. Then, we evaluate GenAgg and several baselines inside of a GNN. The resulting GNN architectures are given the same task of regressing upon graph-structured data generated with a standard aggregator. This tests if it is possible for a GNN with a given aggregator to represent data which was generated by different underlying aggregators. Finally, we provide practical results by running experiments on public GNN benchmark datasets: CLUSTER, PATTERN, CIFAR10, and MNIST [6].

For all baselines, we use the implementations provided in PyTorch Geometric [7]. The only exception is PNA, which is a GNN architecture by nature, not an aggregation method. For our experiments, we adapt PNA into an aggregation method, staying as true to the original formulation as possible: \(\mathrm{PNA}(\mathcal{X})=f([1,n,\frac{1}{n}]\otimes[\mathrm{mean}(\mathcal{ X}),\mathrm{std}(\mathcal{X}),\min(\mathcal{X}),\max(\mathcal{X})])\), where \(f\) is a linear layer mapping from \(\mathbb{R}^{12d}\) back to \(\mathbb{R}^{d}\).

For more training details, see Appendix E. Our code (including a python package with the GenAgg torch module, as well as our experiments) can be found at: [https://anonymous.4open.science/r/generalised-aggregation-42C3](https://anonymous.4open.science/r/generalised-aggregation-42C3).

### Aggregator Regression

In this experiment, we generate a random graph \(\mathcal{G}=\langle\mathcal{V},\mathcal{E}\rangle\) with \(|\mathcal{V}|=8\) nodes and an edge density of \(\frac{|\mathcal{E}|}{|\mathcal{V}|}2=0.3\). For each node \(i\in\mathcal{V}\), we draw an internal state \(x_{i}\in\mathbb{R}^{d}\) from a normal distribution \(x_{i}\sim\mathcal{N}(\mathbf{0}_{d},I_{d})\) with \(d=6\). Then, we generate training data with a set of ground truth aggregators (\(\bigcirc\)\({}_{k}\in\mathcal{A}\) (where \(k\) is an index). For each aggregator \(\bigcirc_{k}\), the dataset \(X_{k},Y_{k}\) is produced with a Graph Network [2], using \(\bigcirc\)\({}_{k}\) as the node aggregation module. The inputs are defined by the set of neighbourhoods in the graph \(X_{k}=\{\mathcal{X}_{i}\mid i\in[1..|\mathcal{V}|]\}\) where the neighbourhood \(\mathcal{X}_{i}\) is defined as \(\mathcal{X}_{i}=\{x_{j}\mid j\in\mathcal{N}_{i}\}\) with \(\mathcal{N}_{i}=\{j\mid(i,j)\in\mathcal{E}\}\). The corresponding ground truth outputs are defined as \(Y_{k}=\{y_{i}\mid i\in[1..|\mathcal{V}|]\}\), where \(y_{i}=\bigcirc_{k}(\mathcal{X}_{i})\).

Figure 2: Results for the Aggregator Regression and GNN Regression experiments, indicating the ability of GenAgg, PowerAgg (P-Agg), SoftmaxAgg (S-Agg), and mean to parametrise each standard aggregator in \(\mathcal{A}\). We report the correlation coefficient between the ground truth and predicted outputs. The highest-performing methods (and those within \(0.01\) correlation) are shown in bold.
The model that we use for regression takes the same form as the model used to generate the data, except that the standard aggregator used to generate the training data \(\bigodot_{k}\) is replaced with a parametrised aggregator \(\bigoplus_{\theta}\):

\[\hat{y}_{i}=\bigoplus_{x_{j}\in\mathcal{X}_{i}}x_{j} \tag{3}\]

In our experiments, each type of parametrised aggregator (GenAgg, SoftmaxAgg, PowerAgg, and mean as a baseline) is trained separately on each dataset \(X_{k},Y_{k}\).

**Results.** We report the MSE loss and correlation coefficient with respect to the ground truth in Table 2a. GenAgg is able to represent all of the standard aggregators with a correlation of at least \(0.96\), and most aggregators with a correlation of greater than \(0.99\). The only cases where the performance of GenAgg is surpassed by a baseline are \(\min\) and \(\max\), where SoftmaxAgg exhibits marginally higher accuracy (Table 1).

One interesting observation is that even if the baselines can represent an aggregator in _theory_, they cannot necessarily do so in practice. For example, PowerAgg can theoretically represent the geometric mean with \(\lim_{p\to 0}(\frac{1}{n}\sum_{i}x_{i}^{p})^{\frac{1}{p}}\), but in practice there are instabilities as \(p\) approaches \(0\) because \(\frac{1}{p}\) approaches \(\frac{1}{0}\). Similarly, while in theory PowerAgg can represent min magnitude, max magnitude, harmonic mean, and root mean square, it falls short in practice (see Table 2a), likely because of the reasons stated in Section 4. In other cases, the baselines can perform well even if they should not be able to represent the target in theory. One such example is PowerAgg, which achieves a correlation of \(0.92\) on max, but only \(0.59\) on max magnitude, which is the opposite of what theory might suggest. This is likely due to the the clamp operation that Pytorch Geometric's implementation uses to restricts inputs to the positive domain. The performance of max magnitude suffers, as it misses cases where the highest magnitude element is negative. Similarly, the performance of

Figure 3: Test accuracy for GNNs with various aggregators on GNN benchmark datasets. In this experiment, each trial uses the same base GNN architecture (4-layer GraphConv), and the default aggregator is replaced with either GenAgg, PowermeanAgg (P-Agg), SoftmaxAgg (S-Agg), PNA, mean, sum, or max. The plots depict the mean and standard deviation of the test accuracy over \(10\) trials (note that the y-axis is scaled to increase readability). The table reports the maximum of the mean test accuracy over all timesteps.
max increases, because it simply selects the maximum among the positive elements. Another baseline which performs unexpectedly well is SoftmaxAgg, which achieves a high correlation with the log-sum-exp aggregator. While it cannot compute a log, the SoftmaxAgg formulation does include a sum of exponentials, so it is able to produce a close approximation.

### GNN Regression

In GNN Regression, the experimental setup is the same as that of Aggregator Regression (Section 5.1), with the exception that the observation size is reduced to \(d=1\). However, instead of using GenAgg \(\bigoplus_{\theta}\) as a model, we use a multi-layer GNN. The GNN is implemented with \(4\) layers of GraphConv [16] with Mish activation (after every layer except the last), where the default aggregation function is replaced by a parametrised aggregator \(\bigoplus_{\theta}\):

\[z_{i}^{(k+1)} =\operatorname{Mish}\left(W_{1}^{(k)}z_{i}^{(k)}+W_{2}^{(k)} \bigoplus_{j\in\mathcal{N}_{i}}z_{i}^{(k)}\right),\text{ s.t. }z_{i}^{(0)}=x_{i} \tag{4}\] \[\hat{y}_{i} =W_{1}^{(3)}z_{i}^{(3)}+W_{2}^{(3)}\bigoplus_{j\in\mathcal{N}_{i }}z_{i}^{(3)} \tag{5}\]

While this experiment uses the same dataset as Aggregator Regression (Section 5.1), it provides several new insights. First, while the aggregator regression experiment shows that GenAgg _can_ represent various aggregators, this experiment demonstrates that training remains stable even when used within a larger architecture. Second, this experiment underlines the importance of using the correct aggregation function. While it is clear that it is advantageous to match a model's aggregation function with that of the underlying mechanism which generated a particular dataset, we often opt to simply use a default aggregator. The conventional wisdom of this choice is that the other learnable parameters in a network layer can rectify an inaccurate choice in aggregator. However, the results from this experiment demonstrate that even with additional parameters, it is not necessarily possible to represent a different aggregator, underlining the importance of aggregators with sufficient representational capacity.

**Results.** The results show that GenAgg maintains its performance, even when used as a component within a GNN (Table 2b). GenAgg achieves a mean correlation of \(0.97\) across all aggregators. While the baselines perform significantly better with the help of a multi-layer GNN architecture, they still cannot represent many of the standard aggregators. The highest-performing baseline is SoftmaxAgg, which only achieves a mean correlation of \(0.86\).

### GNN Benchmark

In this experiment, we examine the performance of GenAgg on GNN benchmark datasets [6]. In order to perform a comparison with benchmarks, we train on an existing GNN architecture (a 4-layer GraphConv [16] GNN with a hidden size of 64) where the default aggregator is replaced with a new aggregator, selected from \(\{\operatorname{GenAgg},\operatorname{PowerAgg},\operatorname{SoftmaxAgg}, \operatorname{PNA},\operatorname{mean},\operatorname{sum},\max\}\).

**Results.** As shown in Fig 3, GenAgg outperforms all baselines in all four GNN benchmark datasets. It provides a significant boost in performance, particularly compared to the relatively small differences in performance between the baseline methods.

The training plots in Fig. 3 provide complementary information. One interesting observation is that GenAgg converges at least as fast as the other methods, and sometimes converges significantly faster (in PATTERN, for example). Furthermore, the training plots lend information about the stability of training. For example, note that in MNIST, most of the baseline methods achieve a maximum and then degrade in performance, while GenAgg maintains a stable performance throughout training.

## 6 Discussion

**Results**. In our experiments, we present two regression tasks and one GNN benchmark task. The regression experiments demonstrate that GenAgg is the only method capable of representing all of the standard aggregators, and a GNN cannot be used to "make up for" the shortcomings of the baseline aggregators. The GNN benchmark experiment complements these findings, demonstrating
that this representational complexity is actually useful in practice. The fact that GenAgg outperforms the standard aggregators (\(\mathrm{mean}\), \(\mathrm{max}\), and \(\mathrm{sum}\)) on the GNN benchmark experiment implies that it is in fact creating a _new_ aggregator. Furthermore, the fact that it outperforms baseline methods like SoftmaxAgg and PowermeanAgg implies that the aggregator learned by GenAgg lies outside the set of functions which can be represented by such methods.

**Limitations**. While GenAgg achieves positive results on these datasets, it is not possible to make generalisations about its performance in all applications. In particular, we observe that on smaller datasets where overfitting is already an issue, GenAgg often fails to deliver the same performance benefits, achieving a similar test accuracy to the baselines. For a full list of datasets that we considered and further discussion of limitations, see Appendix D.

**Parameters**. When comparing the performance of different models, it is important to also consider the number of parameters. By introducing additional parameters, some models can improve overall performance at the cost of sample efficiency. While methods like PowerAgg and SoftmaxAgg only have one trainable parameter, GenAgg has two scalar parameters \(\alpha\) and \(\beta\), and a learnable function \(f\), which has \(30\) parameters in our implementation (independent of the size of the state). However, we observe that using GenAgg within a GNN is always at least as sample-efficient as the baselines, and sometimes converges significantly faster (Fig. 3 and Appendix B). Furthermore, while GenAgg has more parameters than PowerAgg and SoftmaxAgg, the increase is negligible compared to the total number of parameters in the GNN. We also note that GenAgg has significantly fewer parameters than the deep learning methods discussed in Section 4. While the deep learning methods scale linearly or quadratically in the dimension of the state, the number of parameters in GenAgg is constant.

**Stability**. Another observation from our experiments is that GenAgg exhibits more stability during the training process than the baselines (Appendix B). In the GNN Regression experiment, the PowerAgg and SoftmaxAgg training curves tend to plateau at least once before reaching their maximum value. It is possible that these methods lead to local optima because they are optimised in a lower dimensional parameter space [3]. For example, it is straightforward to smoothly transform a learned \(f\) in GenAgg from \(x^{2}\) to \(x^{4}\), but to do so in PowerAgg, it is necessary to pass through \(x^{3}\), which has significantly different behaviour in the negative domain. While PowerAgg restricts inputs to the positive domain to circumvent this particular issue, the problem of local optima can still arise when methods like PowerAgg or SoftmaxAgg are used as components in a larger architecture.

**Explainability**. While in this paper we primarily focus on the _performance_ of GenAgg, we note that it also presents benefits in the realm of explainability. The three parameters in GenAgg are all human-readable (scalars and scalar-valued functions can easily be visualised), and they all provide a unique intuition. The \(\alpha\) parameter controls the dependence on the cardinality of the input set. The \(\beta\) parameter dictates if the aggregator is computed in a raw or centralised fashion (colloquially, it answers if the aggregator operates over the inputs themselves, or the variation between the inputs). Lastly, the function \(f\) can be analysed by interpreting its magnitude \(|f(x_{i})|\) at a given point \(x_{i}\) as the relative impact of that point on the output. For example, the parametrisation of product is \(f(x)=\log(|x|)\), which implies that a value of \(1\) has no impact on the output since \(|\log(|1|)|=0\), and extremely small values \(\epsilon\) have a large impact, because \(\lim_{\epsilon\to 0}|\log(|\epsilon|)|=\infty\). Indeed, \(1\) is the identity element under multiplication, and multiplying by a small value \(\epsilon\) can change the output by many orders of magnitude. The interpretability of GenAgg can also be leveraged as a method to _select_ an aggregator--a model can be pre-trained with GenAgg, and then each instance of GenAgg can be replaced with the most similar standard aggregator in \(\mathcal{A}\).

## 7 Conclusion

In this paper we introduced GenAgg, a generalised, explainable aggregation function which parametrises the function space of aggregators, yet remains as constrained as possible to improve sample efficiency and prevent overfitting. In our experiments, we showed that GenAgg can represent all \(13\) of our selected "standard aggregators" with a correlation coefficient of at least \(0.96\). We also evaluated GenAgg alongside baseline methods within a GNN, illustrating how other approaches have difficulties representing standard aggregators, even with the help of additional learnable parameters. Finally, we demonstrated the usefulness of GenAgg on GNN benchmark tasks, comparing the performance of the same GNN with various different aggregators. The results showed that GenAgg provided a significant boost in performance over the baselines in all four datasets. Furthermore,
GenAgg often exhibited more stability and faster convergence than the baselines in the training process. These results show that GenAgg is an application-agnostic aggregation method that can provide a boost in performance as a drop-in replacement for existing aggregators.

## 8 Acknowledgements

This work was supported by ARL DCIST CRA W911NF-17-2-0181 and European Research Council (ERC) Project 949940 (gAIa).