Abstract
Learning representations of well-trained neural network models holds the promise to provide an understanding of the inner workings of those models. However, previous work has either faced limitations when processing larger networks or was task-specific to either discriminative or generative tasks. This paper introduces the SANE approach to weight-space learning. SANE overcomes previous limitations by learning task-agnostic representations of neural networks that are scalable to larger models of varying architectures and that show capabilities beyond a single task. Our method extends the idea of hyper-representations towards sequential processing of subsets of neural network weights, thus allowing one to embed larger neural networks as a set of tokens into the learned representation space. SANE reveals global model information from layer-wise embeddings, and it can sequentially generate unseen neural network models, which was unattainable with previous hyper-representation learning methods. Extensive empirical evaluation demonstrates that SANE matches or exceeds state-of-the-art performance on several weight representation learning benchmarks, particularly in initialization for new tasks and larger ResNet architectures.
Introduction
Deep learning models are often characterized as "black boxes," where the relationship between high-dimensional weight configurations and model behavior remains opaque. Weight-space learning—the practice of training models to represent and understand the parameters of other models—offers a potential solution. By learning a "hyper-representation" of weights, researchers can predict a model's performance without exhaustive testing or even generate new, high-performing weight initializations for novel tasks.
Despite this potential, existing weight-space learning methods have historically struggled with two primary challenges. First is scalability: most approaches attempt to embed the entire weight vector of a network simultaneously, which becomes computationally prohibitive for modern architectures like ResNet-18 (containing over 11 million parameters). Second is versatility: previous methods were typically specialized for either discriminative tasks (e.g., predicting accuracy) or generative tasks (e.g., sampling weights), but rarely both.
The SANE Approach
To address these limitations, we introduce SANE (Sequential Autoencoder for Neural Embeddings). SANE shifts the paradigm from global weight embeddings to sequential processing, treating neural network weights as a sequence of tokens.
Tokenization and Positional Encoding
Instead of treating a network as one giant vector, SANE reshapes weights into 2D matrices and slices them into manageable tokens. To preserve the structural hierarchy of the original network, we employ a 3D positional encoding scheme. This tracks a token's global position, its specific layer index, and its relative position within that layer, ensuring the transformer architecture understands the underlying topology.
Transformer-Based Autoencoder
SANE utilizes a transformer-based autoencoder architecture. The encoder compresses weight tokens into a latent space, while the decoder reconstructs them. This sequential nature allows SANE to process networks of varying lengths and sizes, providing a flexible framework for diverse architectures.
Model Alignment and Symmetry
Neural networks exhibit permutation symmetries, where swapping neurons in a layer can result in identical outputs despite different weight values. To simplify the learning task, SANE uses "git re-basin" techniques to align all models within a population to a common reference point, reducing noise in the weight space.
Experimental Framework
We evaluated SANE using extensive "Model Zoos"—large collections of trained neural networks:
- Small CNN Zoos: Models trained on MNIST, SVHN, CIFAR-10, and STL.
- Large ResNet Zoos: ResNet-18 models trained on CIFAR-10, CIFAR-100, and Tiny-ImageNet.
- Out-of-Distribution (OOD) Generalization: To test the limits of the representation, we evaluated SANE on VGG architectures and larger ResNets (ResNet-34, 50, 101, 152) sourced from public repositories.
Key Insights and Results
Scalability and Property Prediction
SANE successfully processed ResNet-18 models, which are three orders of magnitude larger than those handled by previous state-of-the-art hyper-representation methods. In discriminative tasks, such as predicting a model's generalization gap or test accuracy, SANE achieved $R^2$ scores as high as 0.99, demonstrating that the latent space captures fundamental quality metrics of the architectures.
Generative Capabilities and Zero-Shot Initialization
SANE demonstrates remarkable generative performance. By using Kernel Density Estimation (KDE) in the latent space and "prompting" the system with a few high-performing model examples, SANE can sample new weight sequences. Sampled ResNet-18 models achieved 68.1% accuracy on CIFAR-10 zero-shot (without any fine-tuning). When fine-tuned, these SANE-initialized models reached peak performance significantly faster than those using random initialization.
Cross-Architecture Transfer
One of the most striking findings is SANE's ability to generalize across architectures. SANE was able to generate weights for a ResNet-34 despite being pretrained exclusively on ResNet-18 models. This suggests that the sequential processing of layer-wise components allows the model to learn universal features of "good" weights that transcend specific layer counts.
Conclusion and Future Work
SANE represents a significant step toward a "foundation model" for weight spaces. By treating weights as sequences, it achieves the scalability necessary for modern deep learning while maintaining the versatility to perform both analysis and generation.
Future research will focus on training SANE on heterogeneous zoos containing multiple architecture types simultaneously and exploring its application to Large Language Models (LLMs) and Reinforcement Learning agents. While currently dependent on prompt examples for very large models, SANE provides a robust framework for moving beyond the black-box nature of neural parameters.
Summary updated