Set-based Neural Network Encoding
We propose an approach to neural network weight encoding for generalization
performance prediction that utilizes set-to-set and set-to-vector functions to
efficiently encode neural network parameters. Our approach is capable of
encoding neural networks in a modelzoo of mixed architecture and different
parameter sizes as opposed to previous approaches that require custom encoding
models for different architectures. Furthermore, our \textbf{S}et-based
\textbf{N}eural network \textbf{E}ncoder (SNE) takes into consideration the
hierarchical computational structure of neural networks by utilizing a
layer-wise encoding scheme that culminates to encoding all layer-wise encodings
to obtain the neural network encoding vector. Additionally, we introduce a
\textit{pad-chunk-encode} pipeline to efficiently encode neural network layers
that is adjustable to computational and memory constraints. We also introduce
two new tasks for neural network generalization performance prediction:
cross-dataset and cross-architecture. In cross-dataset performance prediction,
we evaluate how well performance predictors generalize across modelzoos trained
on different datasets but of the same architecture. In cross-architecture
performance prediction, we evaluate how well generalization performance
predictors transfer to modelzoos of different architecture. Experimentally, we
show that SNE outperforms the relevant baselines on the cross-dataset task and
provide the first set of results on the cross-architecture task.
Bruno Andreis, Soro Bedionita, Sung Ju Hwang
# Set-based Neural Network Encoding

###### Abstract

We propose an approach to neural network weight encoding for generalization performance prediction that utilizes set-to-set and set-to-vector functions to efficiently encode neural network parameters. Our approach is capable of encoding neural networks in a modelzoo of mixed architecture and different parameter sizes as opposed to previous approaches that require custom encoding models for different architectures. Furthermore, our **Set**-based **Ne**ural network **E**ncoder (SNE) takes into consideration the hierarchical computational structure of neural networks by utilizing a layer-wise encoding scheme that culminates to encoding all layer-wise encodings to obtain the neural network encoding vector. Additionally, we introduce a _pad-chunk-encode_ pipeline to efficiently encode neural network layers that is adjustable to computational and memory constraints. We also introduce two new tasks for neural network generalization performance prediction: cross-dataset and cross-architecture. In cross-dataset performance prediction, we evaluate how well performance predictors generalize across modelzoos trained on different datasets but of the same architecture. In cross-architecture performance prediction, we evaluate how well generalization performance predictors transfer to modelzoos of different architecture. Experimentally, we show that SNE outperforms the relevant baselines on the cross-dataset task and provide the first set of results on the cross-architecture task.

## 1 Introduction

Recently, deep learning methods have been applied to a wide range of fields and problems. With this broad range of applications, large amounts of datasets are continually being made available in the public domain together with neural networks trained on these datasets. Given this abundance of trained neural network models, the following curiosity arises: what can we deduce about these networks with access only to the parameter values? More generally, can we predict properties of these networks such as generalization performance on a testset, the dataset on which the model was trained, the choice of optimizer and learning rate, the number of training epochs, choice of model initialization etc. through an analysis of the model parameters? The ability to infer such fundamental properties of trained neural networks using only the parameter values has the potential to open up new application and research paradigms.

In this work, we tackle a specific version of this problem, namely, that of predicting the generalization performance on a testset of a neural network given access, only to the parameter values at the end of the training process. The first approach to solving this problem, proposed by Unterthiner et al. (2020), involves computing statistics such as the mean, standard deviation and quantiles, of each layer in the network, concatenating them to a single vector that represents the neural network encoding, and using this vector to predict the performance of the network. Another approach, also proposed as a baseline in Unterthiner et al. (2020), involves flattening all the parameter values of the network into a single vector which is then fed as input to layers of multilayer perceptrons(MLPs) to predict the network's performance. An immediate consequence of this approach is that it is practical only for moderately sized neural network architectures. Additionally, this approach ignores the hierarchical
computational structure of neural networks through the weight vectorization process. The second, and most recent approach to this problem, proposed by Zhou et al. (2023), takes a geometric approach to the problem by building neural network weight encoding functions, termed neural functionals, that respect symmetric properties of permutation invariance and equivariance of the hidden layers of multilayer perceptrons under the action of an appropriately applied permutation group. While this approach respect these fundamental properties in the parameter space, it's application is restricted, strictly, to multilayer perceptrons. Also, even when relaxations are made to extend this method to convolutional networks and combinations of convolutional layers and multilayer perceptrons, these only work under strict conditions of equivalence in the channel size in the last convolutional layer and the first linear layer. Hence it is clear that while the method proposed by Zhou et al. (2023) enjoys nice theoretical properties, its application is limited to only a small subset of carefully chosen architectures.

Moreover, both approaches (Unterthiner et al., 2020; Zhou et al., 2023) have a fundamental limitation: their encoding methods are applicable only to a single fixed, pre chosen neural network architecture. Once the performance predictor is trained, in the case of Unterthiner et al. (2020), and the neural network encoder of Zhou et al. (2023) is defined, they cannot be used to predict the performance of neural networks of different architecture. Consequently, evaluating these models on diverse architectures is infeasible without training an new generalization performance predictor for each architecture.

To this end, we propose a Set-based Neural Network Encoder (SNE) for predicting the performance of neural networks given only the model parameters that is agnostic to the network architecture. Specifically, we treat the neural network encoding problem from a set encoding perspective by utilising compositions of _set-to-set_ and _set-to-vector_ functions. However, the parameters of neural networks are ordered. To retain this order information, we utilize positional encoding (Vaswani et al. (2017) at various stages in our model. Also, our model incorporates the hierarchical computational structure of neural networks in the encoder design by encoding independently, layer-wise, culminating in a final encoding stage that compresses all the layer-wise information into a single encoding vector used to predict the network performance. To handle the issue of large and variable parameter sizes efficiently, we incorporate a _pad-chunk-encode_ pipeline that is parallelizable and can be used to iteratively encode layer parameters. In terms of evaluation, we introduce two new tasks: cross-dataset neural network performance prediction and cross-architecture neural network performance prediction. In cross-dataset neural network performance prediction, we fix the neural network architecture used to generate the training data and evaluate how well the performance predictors transfer to the same architecture trained on different datasets. For cross-architecture neural network performance prediction, we fix only the architecture for generating the training data and evaluate the performance of the predictors on architectures unseen during training.

Our contributions are as follows:

Figure 1: **Legend:**: Padding, **: Set-to-Set Function, **: Set-to-Vector Function, **: Layer-Level Encoder, **: Layer-Type Encoder. **Concept:** _(left)_ Given the weights of a layer, SNE begins by padding and chunking the weights into _chunksizes_. Each chunk of the layer weight goes through a series of set-to-set and set-to-vector functions to obtain the chunk representation vector. Layer _level_ and layer _type_ positional encodings are used to inject structural information of the network at each stage of the chunk encoding process. All chunk encoding vectors are encoded together to obtain the layer encoding. _(right)_ All layer encodings in the neural network are encoded to obtain the neural network encoding vector again using as series of set-to-set and set-to-vector functions. This vector is then used to predict the generalization performance of the neural network.
* We develop a Set-based Neural Network Encoder (SNE) for predicting the performance of neural networks given access only to parameter values that is capable of encoding neural networks of arbitrary architecture and takes into account the hierarchical computational structure of neural networks.
* We introduce the cross-dataset neural network performance prediction task where we evaluate how well neural network performance predictors transfer across neural networks trained on different datasets.
* We introduce the cross-architecture neural network performance prediction task where we evaluate how well neural network performance predictors trained on a specific architecture transfer to unseen architectures during training.
* We benchmark our method, SNE, against the relevant baselines on the cross-dataset task and show significant improvement over the baselines.
* Finally, we provide the first set of results on the cross-architecture task using our set-based neural network encoder, SNE.

## 2 Related Work

**Set Functions:** Neural networks that operate on set structured data have recently been used in many applications ranging from point cloud classification to set generation (Kim et al., 2021). Set functions are required to respect symmetric properties such as permutation invariance and equivariance. In DeepSets (Zaheer et al., 2017), a set of sum-decomposable functions are introduced that are equivariant in the Set-to-Set applications and invariant in the Set-to-Vector applications. In Set Transformers (Lee et al., 2019), a class of attention based Set-to-Set and Set-to-Vector functions are introduced that are more expressive and capable of modeling pairwise and higher order interactions between set elements. Recent works such as Bruno et al. (2021) and Willette et al. (2023) deal with the problem of processing sets of large cardinality in the the limited memory/computational budget regime. In this work, we utilize the class of set functions developed in Lee et al. (2019) to develop a neural network encoder for performance prediction that is agnostic to specific architectural choices. Our set-based formulation allows us to build such an encoder, capable of handling neural networks weights of arbitrary parameter sizes. This is different from recent approaches to neural network encoding for performance prediction that can encode only parameters of a single architecture.

**Neural Network Performance Prediction From Weights:** Predicting the performance of neural networks given access only to the trained parameters is a relatively new topic of research introduced by Unterthiner et al. (2020). In Unterthiner et al. (2020), two methods are proposed for predicting the generalization performance of neural networks: the first involves flattening the weights of the network into a single vector, processing it using multiple layers of MLPs to obtain an encoding vector which is then used to predict the performance. The second involves computing the statistics of each layer in the network, such as mean, variance, quantiles etc., concatenating them into a single vector that is then used for predicting the performance of the network. The most recent approach that we are aware of, Zhou et al. (2023), proposes a neural network weight encoder that is invariant or equivariant, depending on the application, to an appropriately applied permutation group to the hidden layers of MLPs. Two variants of their model is provided: one which operates only on the hidden layers, and conforms strictly to the theory of permuting MLP hidden neurons (Hecht-Nielsen, 1990), and a relaxation that assumes that the neurons of both the input and output layers of MLPs are permutable. Additionally, extensions are provided for convolutional layers. Our approach, SNE, is directly comparable to these methods for the neural network performance prediction task. However, unlike the methods of Unterthiner et al. (2020) and Zhou et al. (2023) which operate only on neural networks of fixed architecture, and consequently fixed number of parameters, SNE is capable of encoding networks of arbitrary architecture. Moreover, SNE utilizes the hierarchical computation structure of neural networks by encoding, iteratively or in parallel, from the input to the output layers. Furthermore, we go further than the experimental evaluation in Unterthiner et al. (2020) and Zhou et al. (2023) by introducing two new tasks: cross-dataset and cross-architecture neural network performance prediction. Unterthiner et al. (2020) and Zhou et al. (2023) can only be benchmarked on the cross-dataset task where all networks in the modelzoos are of the same architecture. Their restriction to a single fixed architecture makes cross-architecture evaluation impossible. Our method, SNE, on the other hand can be used for both tasks.
## 3 Set-based Neural Network Encoding

### Preliminaries

We have access to a dataset \(D=\{(x_{1},y_{2}),\ldots,(x_{n},y_{n})\}\) where for each \((x_{i},y_{i})\) pair, \(x_{i}\) represents the weights of a neural network architecture \(a\), sampled from a set of architectures \(\mathcal{A}\) and \(y_{i}\) corresponds to some property of \(x_{i}\) after it has been trained on a specific dataset \(d\). \(y_{i}\) can be properties such as generalization gap, training loss, the learning rate used to train \(x_{i}\), or even the number of epochs, choice of weight initialization, and optimizer used to train \(x_{i}\). Henceforth, we refer to \(D\) as a _modelzoo_. For each \(x_{i}\in D\), \(x_{i}=[w_{i}^{0},\ldots,w_{i}^{|x_{i}|}]\) where \(w_{i}^{j}\) represents the weights (parameters) of the \(jth\) layer of the neural network \(x_{i}\), and \(|x_{i}|\) is the total number of layers in \(x_{i}\). Consequently, \(w_{i}^{0}\) and \(w_{i}^{|x_{i}|}\) are the input and output layers of \(x_{i}\) respectively. Additionally, we introduce the \(\texttt{Flatten}:x_{i}\rightarrow\mathbf{R}^{d_{i}}\) operation, that takes as input the weights of a neural network and returns the flattened weights and \(d_{i}\) is the total number of parameter is \(x_{i}\).

The neural network encoding problem is defined such that, we seek to compress \(x_{i}\in\mathbf{R}^{d_{i}}\) to a compact representation \(z_{x_{i}}\in\mathbf{R}^{h}\) such that \(z_{x_{i}}\) can be used to predict the properties \(y_{i}\) of \(x_{i}\) with \(h\ll d_{i}\). In what follows, we present the details of our Set-Based Neural Network Encoding (SNE) method capable of encoding the weights of neural networks of arbitrary architecture that takes into account the hierarchical computational structure of the given architecture and with efficient methods for processing weights of high dimension.

### Handling High Dimensional Layer Weights via Chunking

For a given layer \(w_{i}^{j}\in x_{i}\), the dimension of \(w_{i}^{j}\), \(|w_{i}^{j}|\) can be very large. For instance, when considering linear layers, flattening the weights can results in a tensor that can require large compute memory to be processable by another neural network. To resolve this issue, we resort to _chunking_. Specifically, for all layers \(w_{i}^{j}\in x_{i}\), we perform the following operations:

\[\hat{w}_{i}^{j}=\texttt{Chunk}(\texttt{Pad}(\texttt{Flatten}(w_{i}^{j}),c),c) =\{w_{i}^{j_{0}},\ldots,w_{i}^{j_{q}}\}, \tag{1}\]

where for any \(w_{i}^{j_{t}}\in\hat{w}_{i}^{j}\), \(|w_{i}^{j_{t}}|\in\mathbf{R}^{c}\). Here, \(c\) is the _chunkinge_, fixed for all layer types in the neural network and \(t\in[0,\ldots,q]\). The padding operation \(\texttt{Pad}(w_{i}^{j},c)\) appends zeros, if required, to extend \(w_{i}^{j}\) and make its dimension a multiple of the chunksize \(c\). To distinguish padded values from actual weight values, each element of \(\hat{w}_{i}^{j}\) has a corresponding set of masks \(\hat{m}_{i}^{j}=\{m_{i}^{j_{0}},\ldots,m_{i}^{j_{q}}\}\). Note that with this padding and subsequent chunking operation, each element in \(\hat{w}_{i}^{j}\) is now small enough, for an appropriately chosen chunksize \(c\), to be processed. Moreover, all the elements in \(\hat{w}_{i}^{j}\) can be processed in parallel.

The modelzoos we consider in the experimental section are populated by neural networks with stacks of convolutional and linear layers. For each such layer, we apply the padding and chunking operation differently. For a linear layer \(w_{i}^{j}\in\mathbf{R}^{\texttt{out}\times\texttt{in}}\), where out and in are the input and output dimensions respectively, we apply the flattening operation on both dimensions followed by padding and chunking. However for a convolutional layer \(w_{i}^{j}\in\mathbf{R}^{\texttt{out}\times\texttt{in}\times\texttt{k}}\), we apply the flattening, padding, and chunking operations only to the kernel dimensions k.

Finally we note that for layers with bias values, we apply the procedure detailed above independently to both the weights and biases.

### Independent Chunk Encoding

The next stage in our Set-based Neural Network encoding pipeline involves encoding, independently, each chunk of weight in \(\hat{w}_{i}^{j}=\{w_{i}^{j_{0}},\ldots,w_{i}^{j_{k}}\}\). For each \(w_{i}^{j_{t}}\in\hat{w}_{i}^{j}\), we treat the \(c\) elements as members of a set. However, it is clear that \(w_{i}^{j_{t}}\) has order in its sequence, _i.e._, an ordered set. We remedy this by providing this order information via positional encoding. Concretely, for a given \(w_{i}^{j_{t}}\in\mathbf{R}^{c\times 1}\), we first model the pairwise relations between all \(c\) elements using a _set-to-set_ function \(\Phi_{\theta_{1}}\) to obtain:

\[\hat{w}_{i}^{j_{t}}=\Phi_{\theta_{1}}(w_{i}^{j_{t}})\in\mathbf{R}^{c\times h}. \tag{2}\]

That is, \(\Phi_{\theta_{1}}\) captures pair-wise correlations in \(w_{i}^{j_{t}}\) and projects all elements (weight values) to a new dimension \(h\).
Given \(\hat{w}_{i}^{j_{t}}\in\mathcal{R}^{c\times h}\), we inject two kinds of positionally encoded information. The first encodes the _layer type_ in a list of layers, _i.e_., linear or convolution for the modelzoos we experiment with, to obtain:

\[\hat{w}_{i}^{j_{t}}=\text{PosEnc}_{Layer}^{Type}(\hat{w}_{i}^{j_{t}})\in\mathbf{ R}^{c\times h}. \tag{3}\]

Here we abuse notation and assign the output of \(\text{PosEnc}(\cdot)\) to \(\hat{w}_{i}^{i_{t}}\) to convey the fact that \(\hat{w}_{i}^{j_{t}}\)'s are modified in place and to simplify the notation. Also, all \(\text{PosEnc}(\cdot)\)s are variants of the positional encoding method introduced in Vaswani et al. (2017). Next we inject the layer level information. Since neural networks are computationally hierarchical, starting from the input to the output layer, we include this information to distinguish chunks, \(w_{i}^{j_{t}}\)'s from different layers. Specifically, we compute:

\[\hat{w}_{i}^{j_{t}}=\text{PosEnc}_{Layer}^{Level}(\hat{w}_{i}^{j_{t}})\in \mathbf{R}^{c\times h}, \tag{4}\]

where the input to \(\text{PosEnc}_{Layer}^{Level}(\cdot)\) is the output of Equation 3. We note that this approach is different from previous neural network encoding methods Unterthiner et al. (2020) that loose the layer/type information by directly encoding the entire flattened weights hence disregarding the hierarchical computational structure of neural networks. Experimentally, we find that injecting such positionally encoded information improves the models performance.

We further model pairwise correlations in \(\hat{w}_{i}^{j_{t}}\), now infused with layer/type information, using another set-to-set function \(\Phi_{\theta_{2}}\):

\[\hat{w}_{i}^{j_{t}}=\Phi_{\theta_{2}}(w_{i}^{j_{t}})\in\mathbf{R}^{c\times h}. \tag{5}\]

The final step in the chunk encoding pipeline involves compressing all \(c\) elements in \(\hat{w}_{i}^{j_{t}}\) to a compact representation. For this, we use a _set-to-vector_ function \(\Gamma_{\theta_{a}}:\mathbf{R}^{c\times h}\rightarrow\mathbf{R}^{h}\). In summary, the chunk encoding layer computes the following function:

\[\hat{w}_{i}^{j_{t}}=\Gamma_{\theta_{a}}[\Phi_{\theta_{2}}(\text{PosEnc}_{Layer }^{Level}(\text{PosEnc}_{Layer}^{Type}(\Phi_{\theta_{1}}(w_{i}^{j_{t}}))))] \in\mathbf{R}^{1\times H}. \tag{6}\]

Note now that for each chunked layer \(\hat{w}_{i}^{j}=\{w_{i}^{j_{0}},\dots,w_{i}^{j_{t}}\}\), the chunk encoder, Equation 6, produces a new set \(\hat{w}_{i}^{j}=\texttt{Concatenate}[\{\hat{w}_{i}^{j_{0}},\dots,\hat{w}_{i} ^{j_{t}}\}]\in\mathbf{R}^{q\times h}\), which represents all the encodings of all chunks in a layer.

**Remark** Our usage of set functions \(\Phi_{\theta_{1}},\Phi_{\theta_{2}}\) and \(\Gamma_{\theta_{a}}\) allows us to process layers of arbitrary sizes. This in turn allows us to process neural networks of arbitrary architecture using a single model, a property lacking in previous approaches to neural network encoding for generalization performance prediction Zhou et al. (2023); Unterthiner et al. (2020).

### Layer Encoding

At this point, we have encoded all the chunked parameters of a given layer to obtain \(\tilde{w}_{i}^{j}\). Encoding a layer, \(w_{i}^{j}\), then involves defining a function \(\Gamma_{\theta_{j}}:\mathbf{R}^{q\times h}\rightarrow\mathbf{R}^{1\times h}\) for arbitrary \(q\). In practice, this is done by computing:

\[\mathbf{w}_{i}^{j}=\Gamma_{\theta_{\beta}}[\text{PosEnc}_{Layer}^{Level}( \Phi_{\theta_{3}}(\tilde{w}_{i}^{j}))]\in\mathbf{R}^{1\times h}. \tag{7}\]

Again we have injected the layer level information, via positional encoding, into the encoding processed by the set-to-set function \(\Phi_{\theta_{3}}\). We then collect all the layer level encoding of the neural network \(x_{i}\):

\[\tilde{w}_{i}=\texttt{Concatenate}[\mathbf{w}_{i}^{0},\dots,\mathbf{w}_{i}^{ |x_{i}|}]\in\mathbf{R}^{|x_{i}|\times h}. \tag{8}\]

### Neural Network Encoding

With all layers in \(x_{i}\) encoded, we compute the neural network encoding vector \(z_{x_{i}}\) as follows:

\[z_{x_{i}}=\Gamma_{\theta_{\beta}}[\Phi_{\theta_{4}}(\text{PosEnc}_{Layer}^{Level }(\tilde{w}_{i}))]\in\mathbf{R}^{h}. \tag{9}\]

\(z_{x_{i}}\) compresses all the layer-wise information into a compact representation for the downstream task. Since \(\Gamma_{\theta_{\gamma}}\) is agnostic to the number of layers \(|x_{i}|\) of network \(x_{i}\), the encoding mechanism can handle networks of arbitrary layers and by extension architecture. Similar to the layer encoding pipeline, we again re-inject the layer-level information through positional encoding before compressing with \(\Gamma_{\theta_{\gamma}}\).

Henceforth, we refer to the entire neural network encoding pipeline detailed so far as \(\text{SNE}_{\Theta}(x_{i})\) for a network \(x_{i}\), where \(\Theta\) encapsulates all the model parameters, \(\Phi_{\theta_{1-4}},\Gamma_{\alpha},\Gamma_{\beta}\) and \(\Gamma_{\gamma}\).
### Choice of Set-to-Set and Set-to-Vector Functions

Now, we specify the choice of Set-to-Set and Set-to-Vector functions encapsulated by \(\Phi_{\theta_{1-4}},\Gamma_{\alpha},\Gamma_{\beta}\) and \(\Gamma_{\gamma}\) that are used to implement SNE. Let \(X\in\mathbf{R}^{n_{X}\times d}\) and \(Y\in\mathbf{R}^{n_{Y}\times d}\) be arbitrary sets where \(n_{X}=|X|\), \(n_{Y}=|Y|\) and \(d\) (note the abuse of notation from Section 3.1 where \(d\) is a dataset) is the dimension of an element in both \(X\) and \(Y\).

The MultiHead Attention Block (MAB) with parameter \(\omega\) is given by:

\[\text{MAB}(X,Y;\omega)=\text{LayerNorm}(H+\text{rFF}(H)),\quad\text{where} \tag{10}\]

\[H=\text{LayerNorm}(X+\text{MultiHead}(X,Y,Y;\omega). \tag{11}\]

Here, LayerNorm and rFF are Layer Normalization (Ba et al., 2016) and row-wise feedforward layers respectively. MultiHead\((X,Y,Y;\omega)\) is the multihead attention layer of Vaswani et al. (2017).

The Set Attention Block (Lee et al., 2019), SAB, is given by:

\[\text{SAB}(X):=\text{MAB}(X,X). \tag{12}\]

That is, SAB computes attention between set elements and models pairwise interactions and hence is a Set-to-Set function. Finally, the Pooling MultiHead Attention Block (Lee et al., 2019), PMA\({}_{k}\), is given by:

\[\text{PMA}_{k}(X)=\text{MAB}(S,\text{rFF}(X)),\quad\text{where} \tag{13}\]

\(S\in\mathbf{R}^{k\times d}\) and \(X\in\mathbf{R}^{n_{X}\times d}\). The \(k\) elements of \(S\) are termed _seed vectors_ and when \(k=1\), as is in all our experiments, PMA\({}_{k}\) pools a set of size \(n_{X}\) to a single vector making it a Set-to-Vector function.

All parameters encapsulated by \(\Phi_{\theta_{1-4}}\) are implemented as a stack of two SAB modules: SAB\((\text{SAB}(X))\). Stacking SAB modules enables us not only to model pairwise interactions but also higher order interactions between set elements. Finally, all of \(\Gamma_{\alpha},\Gamma_{\beta}\) and \(\Gamma_{\gamma}\) are implemented as a single PMA module with \(k=1\).

### Downstream Task

Given \((z_{x_{i}},y_{i})\), we train a predictor \(f_{\theta}(z_{x_{i}})\) to estimate properties of the network \(x_{i}\). In this work, we focus solely on the task of predicting the generalization performance of \(x_{i}\), where \(y_{i}\) is the performance on the test set of the dataset used to train \(x_{i}\). The parameters of the predictor \(f_{\theta}\) and all the parameters in the neural network encoding pipeline, \(\Theta\), are jointly optimized. In particular, we minimize the error between \(f_{\theta}(z_{x_{i}})\) and \(y_{i}\). For the entire modelzo, the objective is given as:

\[\operatorname*{minimize}_{\Theta,\theta}\sum_{i=1}^{d}\ell[f_{\theta}(\text{ SNE}_{\Theta}(x_{i})),y_{i}], \tag{14}\]

for an appropriately chosen loss function \(\ell(\cdot)\). In our experiments, \(\ell(\cdot)\) is the binary cross entropy loss. The entire SNE pipeline is shown in Figure 1.

## 4 Experiments

We now present experimental results on the cross-dataest and cross-architecture neural network performance prediction tasks. Details of experimental settings, hyperparameters, model specification etc. can be found in the Appendix.

### Cross-Dataset Neural Network Performance Prediction

For this task, we train neural network performance predictors on 4 homogeneous modelzoos, of the same architecture, with each modelzoo specialized to a single dataset.

**Datasets and Neural Network Architecture:** Each modelzoo is trained on one of the following datasets: MNIST (Deng, 2012), FashionMNIST (Xiao et al., 2017), CIFAR10 (Krizhevsky, 2009) and SVHN (Netzer et al., 2018). We use the modelzoos provided by Unterthiner et al. (2020). To create each modelzoo, 30K different hyperparameter configurations were sampled. The hyperparameters include the learning rate, regularization coefficient, dropout rate, the variance and choice of initialization, activation functions etc. A thorough description of the modelzoo generation process
can be found in Appendix A.2 of Unterthiner et al. (2020). The single architecture used to general the modelzoos consists of 3 convolutional layers each with 16 filters, a global average pooling layer and linear classification layer. Each modelzoo is split into a training, testing and validation splits.

**Task:** In this task, we consider cross-dataset neural network performance prediction where we evaluate the prediction performance on the testset of the modelzo on which the predictors were trained on. Additionally, we evaluate how well each predictor transfers to the other modelzoos. To the best of our knowledge, this is the first such empirical analysis of how well neural network performance

\begin{table}
\begin{tabular}{l c c c c c} \hline \hline  & MLP & STATNN & NFNNP & NFNNP & SNE(ours) \\ \hline MNIST\(\rightarrow\) MNIST & 0.878\(\pm 0.001\) & 0.926\(\pm 0.000\) & 0.937\(\pm 0.000\) & **0.942\(\pm 0.001\)** & 0.941\(\pm 0.000\) \\ MNIST \(\rightarrow\) FashionMNIST & 0.486\(\pm 0.019\) & 0.756\(\pm 0.006\) & 0.726\(\pm 0.005\) & 0.690\(\pm 0.008\) & **0.773\(\pm 0.009\)** \\ MNIST\(\rightarrow\) CIFAR10 & 0.562\(\pm 0.024\) & 0.773\(\pm 0.005\) & 0.756\(\pm 0.010\) & 0.758\(\pm 0.000\) & **0.792\(\pm 0.008\)** \\ MNIST\(\rightarrow\) SVHN & 0.544\(\pm 0.005\) & 0.698\(\pm 0.005\) & 0.702\(\pm 0.005\) & 0.710\(\pm 0.010\) & **0.721\(\pm 0.001\)** \\ \hline FashionMNIST\(\rightarrow\) FashionMNIST & 0.874\(\pm 0.001\) & 0.915\(\pm 0.000\) & 0.922\(\pm 0.001\) & **0.935\(\pm 0.000\)** & 0.928\(\pm 0.001\) \\ FashionMNIST\(\rightarrow\) MNIST & 0.507\(\pm 0.007\) & 0.667\(\pm 0.010\) & **0.755\(\pm 0.018\)** & 0.617\(\pm 0.012\) & 0.722\(\pm 0.005\) \\ FashionMNIST\(\rightarrow\) CIFAR10 & 0.515\(\pm 0.007\) & 0.698\(\pm 0.029\) & 0.733\(\pm 0.007\) & 0.695\(\pm 0.032\) & **0.745\(\pm 0.008\)** \\ FashionMNIST\(\rightarrow\) SVHN & 0.554\(\pm 0.006\) & 0.502\(\pm 0.043\) & 0.663\(\pm 0.014\) & 0.662\(\pm 0.003\) & **0.664\(\pm 0.003\)** \\ \hline CIFAR10\(\rightarrow\) CIFAR10 & 0.880\(\pm 0.000\) & 0.912\(\pm 0.001\) & 0.924\(\pm 0.002\) & **0.931\(\pm 0.000\)** & 0.927\(\pm 0.000\) \\ CIFAR10\(\rightarrow\) MNIST & 0.552\(\pm 0.003\) & 0.656\(\pm 0.005\) & **0.674\(\pm 0.018\)** & 0.600\(\pm 0.025\) & 0.648\(\pm 0.006\) \\ CIFAR10\(\rightarrow\) FashionMNIST & 0.514\(\pm 0.005\) & **0.677\(\pm 0.004\)** & 0.629\(\pm 0.031\) & 0.526\(\pm 0.038\) & 0.643\(\pm 0.006\) \\ CIFAR10\(\rightarrow\) SVHN & 0.578\(\pm 0.005\) & 0.728\(\pm 0.004\) & 0.697\(\pm 0.006\) & 0.662\(\pm 0.004\) & **0.753\(\pm 0.007\)** \\ \hline SVHN\(\rightarrow\) SVHN & 0.809\(\pm 0.003\) & 0.844\(\pm 0.000\) & 0.855\(\pm 0.001\) & **0.862\(\pm 0.002\)** & 0.858\(\pm 0.003\) \\ SVHN\(\rightarrow\) MNIST & 0.545\(\pm 0.025\) & 0.630\(\pm 0.009\) & **0.674\(\pm 0.008\)** & 0.647\(\pm 0.016\) & 0.647\(\pm 0.001\) \\ SVHN\(\rightarrow\) FashionMNIST & 0.523\(\pm 0.026\) & 0.616\(\pm 0.007\) & 0.567\(\pm 0.014\) & 0.494\(\pm 0.023\) & **0.655\(\pm 0.003\)** \\ SVHN\(\rightarrow\) CIFAR10 & 0.540\(\pm 0.027\) & 0.746\(\pm 0.002\) & 0.725\(\pm 0.007\) & 0.547\(\pm 0.039\) & **0.760\(\pm 0.006\)** \\ \hline Average & 0.616\(\pm 0.143\) & 0.734\(\pm 0.115\) & 0.746\(\pm 0.106\) & 0.705\(\pm 0.140\) & **0.761\(\pm 0.101\)** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Cross-Dataset Neural Network Performance Prediction. We benchmark how well each method transfers across multiple datasets. In the first column, \(A\to B\) implies that a model trained on a homogeneous modelzo of dataset \(A\) is evaluated on a homogeneous modelzo of dataset \(B\). In the last row, we report the averaged performance of all methods across the cross-dataset task. For each row, the best model is shown in red and the second best in blue. Models are evaluated in terms of _Kendall’s_\(\tau\) coefficient.

Figure 2: TSNE Visualization of Neural Network Encoding. We train neural network performance prediction methods on a combination of the MNIST, FashionMNIST, CIFAR10 and SVHN modelzoos of Unterthiner et al. (2020). We present 3 views of the resulting 3-D plots showing how neural networks from each modelzoo are embedded/encoded by the corresponding models. Zoom in for better viewing.
predictors transfer to different datasets. We evaluate all models using _Kendall's_\(\tau\)[13], a rank correlation measure.

**Baselines:** We compare SNE with the following baselines:

* **MLP:** This model flattens all the weights and biases of each neural network into a single vector which is then fed to a stack of MLPs with ReLU activation and finally a Sigmoid activation function for predicting the performance of the neural network.
* **STATNN**[14]**:** Given neural network weights, this model computes statistics of each layer, including their means, variance and quantiles, concatenates them into a single vector which is then used as input to a stack of MLPs with ReLU activation and a final layer with Sigmoid activation that outputs the performance of the neural network.
* **NFN\({}_{\text{HNP}}\) and NFN\({}_{\text{NP}}\)[22]:** These two models termed Neural Functionals(NF), developed mainly for MLPs, are designed to be permutation invariant or equivariant to an appropriately applied permutation group to the hidden layers of the neural networks. HNP, hidden neural permutation, is applied only to the hidden layers of each network since the output and input layers of MLPs are not invariant/equivariant to the action of a permutation group on the neurons. NP, neural permutation, makes a strong assumption that both the input and output layers are also invariant/equivariant under the action of a permutation group.

**Results:** We present the results of the cross-dataset neural network performance prediction task in Table 1. For each row in Table 1, the first column shows the cross-dataset evaluation direction. For instance, MNIST\(\rightarrow\)CIFAR10 implies that a model trained on a modelzoo of neural networks trained on MNIST is cross evaluated on a modelzo populated by neural networks trained on CIFAR10. We note that the A\(\rightarrow\)A setting, _e.g._ MNIST\(\rightarrow\)MNIST, corresponds to the evaluation settings of Unterthiner et al. (2020) and Zhou et al. (2023). Also in Table 1 we show the best model in red and the second best model in blue.

As show in Table 1, SNE is always either the best model or the second best model in the cross-dataset task. Especially, SNE is particularly good in the A\(\rightarrow\)B performance prediction task compared to the next competitive baselines, NFN\({}_{\text{NP}}\) and NFN\({}_{\text{HNP}}\). The MLP baseline, as expected, performs the worse since concatenating all weight values in a single vector looses information such as the network structure. STATNN [14] performs relatively better than the MLP baseline suggesting that the statistics of each layer indeed captures enough information to do moderately well on the neural network performance prediction task. NFN\({}_{\text{NP}}\) and NFN\({}_{\text{HNP}}\) perform much better than STATNN and MLP and NFN\({}_{\text{HNP}}\) in particular shows good results in the A\(\rightarrow\)A setting. Interestingly, NFN\({}_{\text{NP}}\) is a much better cross-dataset performance prediction model than NFN\({}_{\text{HNP}}\). However, across the entire cross-dataset neural network performance prediction task, SNE significantly outperforms all the baselines as shown in the last row of Table 1.

Also, as stated in Section 3.3, positional encoding of layer and level information provides performance boost. For instance, removing all such encoding from SNE reduces the performance on CIFAR10\(\rightarrow\)CIFAR10 from \(0.928\) to \(0.918\).

**Qualitative Analysis:** To further understand how SNE transfers well across modelzoos, we generate TSNE [23] plots for the neural network encoding of all the compared models for all four homogeneous modelzoos in Figure 2. We provide 3 different views of each models embeddings to better illustrate the encoding pattern. In Figures 1(c) and 1(d), we observe that NFN\({}_{\text{NP}}\) and NFN\({}_{\text{HNP}}\) have very clear separation boundaries between the networks from each modelzoo. This may explain NFN\({}_{\text{HNP}}\)'s good performance in the A\(\rightarrow\)A cross-dataset neural network encoding task in Table 1. In Figures 1(a) and 1(b), MLP and STATNN, respectively show similar patterns with small continuous string of modelzoo specific groupings. However, these separations are not as defined as those of NFN\({}_{\text{NP}}\) and NFN\({}_{\text{HNP}}\). The embedding patter of SNE on the other hand is completely different. In Figure 1(e), all networks from all the modelzoos are embedded almost uniformly close to each other. This may suggest why SNE performs much better on the cross-dataset performance prediction task since it is much easier to interpolate between the neural network encodings generated by SNE across modelzoos.
For this tasks, we train SNE on 3 homogeneous modelzoos of the same architecture and test it on 3 other homogeneous modelzoos of a different architecture than the modelzoo used for training. The cross-architecture task demonstrates SNE's agnosticism to particular architectural choices since training and testing are done on modelzoos of different architectures.

**Datasets and Neural Network Architectures:** For cross architecture evaluation, we utilize 3 datasets: MNIST, CIFAR10 and SVHN. Since the modelzoos of Unterthiner et al. (2020) consist of a single architecture, we refer to them as \(\text{Arch}_{1}\). We use all modelzoos of \(\text{Arch}_{1}\) only for training the neural network performance predictors. We create another set of MNIST, CIFAR10 and SVHN modelzoos using a different architecture \(\text{Arch}_{2}\). \(\text{Arch}_{2}\) consists of 3 convolutional layers followed by two linear layers. Exact architectural specifications are detailed in the Appendix. We generate the modelzoos of \(\text{Arch}_{2}\) following the routine described in Appendix A.2 of Unterthiner et al. (2020). All modelzoos of \(\text{Arch}_{2}\) are used only for testing the cross-architecture neural network performance prediction of predictors trained on modelzoos of \(\text{Arch}_{1}\) and are _not_ used during training.

**Task:** For this task, we seek to explore the following question: Does neural network performance predictors trained on modelzoos of \(\text{Arch}_{1}\) transfer or generalize on modelzoos of \(\text{Arch}_{2}\)? Also, we perform cross dataset evaluation on this task. However, this is different from the cross dataset evaluation in Section 4.1 since the cross evaluation is with respect to modelzoos of \(\text{Arch}_{2}\).

**Baselines:** As we already remarked, none of the baselines used in the cross dataset task of Section 4.1 are applicable to this task. The MLP, STATNN, \(\text{NFN}_{\text{NP}}\) and \(\text{NFN}_{\text{HNP}}\) baselines all depend on the architecture of the modelzoo used for training and require modelzoos to be homogeneous architecturally. SNE on the other hand is agnostic to architectural choices and hence can be evaluated cross-architecture. Consequently, we provide the first set of results, to the best of our knowledge, on the cross-architecture neural network performance prediction task.

**Results:** We report the quantitative evaluation on the cross-architecture task in Table 2. The first column, \(\text{Arch}_{1}\rightarrow\text{Arch}_{2}\) shows the direction of transfer, where we train using modelzoos of \(\text{Arch}_{1}\) and test on modelzoos of \(\text{Arch}_{2}\). Additionally, A\(\rightarrow\)B, _e.g._ MNIST\(\rightarrow\)CIFAR10 shows the cross-dataset transfer as in Section 4.1. However, the transfer is now across architectures. We evaluate SNE in terms of Kendall's \(\tau\).

From Table 2, it can be seen that SNE transfers well across architectures. Interestingly, the SVHN modelzoo, the most challenging modelzoo in the cross-dataset task, shows very good transfer across architectures. Alluding to the qualitative analysis in Section 4.1, we infer that SNE transfers well across architectures due to it's spread out neural network encoding pattern that allows for much easier interpolation even across unseen architectures as shown in Table 2.

## 5 Conclusion

In this work, we tackled the problem of predicting neural network generalization performance given access only to the trained parameter values. We presented a Set-based Neural Network Encoder (SNE) that reformulates the neural network encoding problem as a set encoding problem. Using a sequence of set-to-set and set-to-vector functions, SNE utilizes a pad-chunk-encode pipeline to encode each network layer independently; a sequence of operations that is parallelizable across chunked layer parameter values. SNE also utilizes the computational structure of neural networks by injecting positionally encoder layer type/level information in the encoding pipeline. As a result, SNE is capable of encoding neural networks of different architectures as opposed to previous methods that only work on a fixed architecture. Experimentally, we introduced the cross-dataset and cross-architecture neural network generalization performance prediction tasks. We demonstrated SNE's ability to transfer well across modelzoos of the same architecture but with networks trained on different datasets on the cross-dataset task. On the cross-architecture task, we demonstrated SNE's agnosticism to architectural choices and provided the first set of experimental results for this task.

\begin{table}
\begin{tabular}{l c} \hline \hline Arch\({}_{1}\rightarrow\text{Arch}_{2}\) & SNE \\ \hline MNIST\(\rightarrow\) MNIST & 0.452\(\pm 0.021\) \\ MNIST\(\rightarrow\) CIFAR10 & 0.478\(\pm 0.010\) \\ MNIST\(\rightarrow\) SVHN & 0.582\(\pm 0.016\) \\ \hline CIFAR10\(\rightarrow\) CIFAR10 & 0.511\(\pm 0.020\) \\ CIFAR10\(\rightarrow\) MNIST & 0.467\(\pm 0.020\) \\ CIFAR10\(\rightarrow\) SVHN & 0.594\(\pm 0.029\) \\ \hline SVHN\(\rightarrow\) SVHN & 0.621\(\pm 0.013\) \\ SVHN\(\rightarrow\) MNIST & 0.418\(\pm 0.096\) \\ SVHN\(\rightarrow\) CIFAR10 & 0.481\(\pm 0.055\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Cross-Architecture Neural Network Performance Prediction. We compare how SNE transfers across architectures.