Neural Metamorphosis

Xingyi Yang, Xinchao Wang

Introduction

Standard neural networks are inherently rigid. Once trained, their architecture—defined by specific widths, depths, and parameter counts—is fixed. Adapting these models to diverse hardware constraints typically requires expensive retraining, network pruning, or the creation of multiple "slimmable" versions. Neural Metamorphosis (NeuMeta) proposes a paradigm shift: treating neural networks as continuous "weight manifolds" rather than static, discrete entities. By leveraging Implicit Neural Representations (INRs) as hypernetworks, NeuMeta can generate high-performing weights for any-sized network on the fly, even for configurations never encountered during training.

Overview of the Neural Metamorphosis framework, illustrating the transition from a discrete model space to a continuous weight manifold for flexible deployment.

Methodology

The core innovation of NeuMeta lies in representing the weights of a neural network as a continuous function. This is achieved through several key technical components:

  1. Implicit Neural Representations (INR) as Hypernetworks: Instead of storing massive weight matrices, NeuMeta trains a small Multi-Layer Perceptron (MLP) to act as a weight generator. This MLP takes a coordinate (layer and channel index) and a model configuration (desired width/depth) as input to output the corresponding weight value.
  2. Intra-Model Smoothness via Weight Permutation: Raw weight matrices are often non-smooth, making them difficult for an INR to learn. NeuMeta addresses this by reordering channels through solving a Shortest Hamiltonian Path (SHP) problem. This ensures adjacent weights are similar, creating a smooth surface for the INR to fit.
  3. Cross-Network Smoothness: To ensure generalization to unseen sizes, random noise is added to input coordinates during training. This forces the INR to learn smooth transitions between different model scales rather than memorizing discrete points.
  4. Block-based Architecture: To scale to modern networks, a grid-based approach is used where separate, small MLP "blocks" control different segments of the weights.
The NeuMeta pipeline: transforming a trained network into a smoothed version to train an INR, which then enables sampling weights for target models of arbitrary configurations.

Experimental Evaluation

The authors evaluated NeuMeta across image classification (MNIST, CIFAR, ImageNet), semantic segmentation (PASCAL VOC 2012), and image generation (MNIST, CelebA).

Key Results

  • Superior Compression: On CIFAR-100, NeuMeta achieved 62.62% accuracy at a 75% compression rate, significantly outperforming standard pruning (61.37%) and slimmable networks, which often collapse at such extreme compression levels.
  • Zero-Shot Resizing: NeuMeta successfully generates weights for "unseen" configurations. It can produce a model with a width never explicitly sampled during training while maintaining high accuracy.
  • Storage Efficiency: By storing only the parameters of small INR blocks instead of full target model matrices, NeuMeta maintains a minimal storage footprint compared to maintaining multiple discrete models.
  • Segmentation Gains: In semantic segmentation tasks, NeuMeta showed a massive 20 mIOU improvement over slimmable networks at high compression levels.

Insights and Future Directions

NeuMeta demonstrates that the success of coordinate-based networks depends heavily on the smoothness of the underlying data. By mathematically reordering weights, simple MLPs can represent complex architectures. Furthermore, the framework naturally encourages "implicit distillation," where different-sized versions of the same model produce consistent internal representations.

While highly effective, the approach currently focuses on morphing width and depth. Future work may explore more complex architectural traits, such as the number of heads in a Transformer or layer connectivity patterns. Additionally, while the weight permutation step is efficient, it remains an additional requirement in the training pipeline compared to traditional methods.

Summary updated

BibTeX
@inproceedings{yang2024neural,
  author = {Xingyi Yang and Xinchao Wang},
  title = {{Neural Metamorphosis}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72754-2\_1},
}
Figure