NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Data Augmentation Techniques to Reverse-Engineer Neural Network Weights from Input-Output Queries

Alexander Beiser, Flavio Martinelli, Wulfram Gerstner, Johanni Brea

TL;DR

Reverse-engineering a neural network's weights from input–output queries breaks down when the network has more parameters than training examples, as student models overfit rather than aligning their internal weights. This paper shows that standard data augmentations fail to fix this in high dimensions, and introduces biased-noise and grid-composition augmentations designed to perturb neuron pre-activations effectively. These techniques allow researchers to reconstruct networks possessing up to 100 times more parameters than original training samples.

What Problem Does This Paper Address?

Model extraction and reverse-engineering aim to infer the internal weights of a "black box" neural network by querying its inputs and observing its outputs. A prominent approach—the Expand-and-Cluster (EC) framework—trains an over-parameterized "student" model to imitate a "teacher" network, then clusters redundant neurons to extract the exact teacher weights.

However, EC encounters a fundamental barrier when the teacher is over-parameterized relative to its training set (i.e., parameters > training points). In this regime, querying the teacher only on its training set allows student networks to achieve near-zero training loss via spurious solutions without actually recovering the teacher’s true weights. Simply put: the student overfits to the queries instead of discovering the underlying network parameters.

Methods

The authors build upon the four-stage Expand-and-Cluster (EC) pipeline:

  1. Teacher Training: Train a target single-hidden-layer network on image classification (MNIST).
  2. Teacher Querying: Generate input queries, feed them to the teacher black box, and record output logits.
  3. Student Training: Train an over-parameterized student (with $4\times$ the hidden width) using MSE loss on the query set.
  4. Student Reconstruction: Cluster the student's redundant hidden weight vectors, collapse duplicates, and fine-tune to extract the teacher's weights.

Novel Augmentation Strategies

To eliminate student overfitting, the authors design queries that explicitly drive variance across the teacher’s hidden neuron hyperplanes:

  • Biased-Noise Augmentation ($\pm\eta_{[0,1]}$): Unlike zero-mean noise, biased noise creates two shifted versions of each image—one perturbed with pixel values sampled from $\mathcal{U}[0, 1]$ and another from $\mathcal{U}[-1, 0]$. This pushes inputs across the teacher neurons' decision boundaries without drifting too far into non-informative, saturated asymptotic regimes.
  • Grid Composition (Grid-Comp.): To synthesize realistic, in-distribution-like inputs when base data is scarce, new $28 \times 28$ inputs are formed by stitching together nine smaller image patches arranged in a $3 \times 3$ grid. This yields combinatorial variations (up to $D^9$ combinations from $D$ base images).
  • Grid-Comp. $\pm\eta_{[0,1]}$: Blends grid composition with positive and negative biased noise.

Datasets

  • MNIST ($28 \times 28$ grayscale digits): Used to train the teacher networks, both on the complete 60k dataset and on an aggressively constrained subset of 5k examples.
  • FashionMNIST: Utilized purely as an out-of-distribution (OOD) test set to evaluate student generalization and detect whether an imitation model is genuinely copying teacher functionality.

Key Insights and Ideas

  • Training Loss is Deceptive: When attempting weight recovery on a 512-neuron teacher using standard queries, student training loss reaches an impressive $\approx 10^{-4}$ MSE, yet parameter reconstruction fails entirely. Out-of-distribution loss on FashionMNIST exposes the truth: failure to generalize correlates directly with failed weight recovery.
  • The High-Dimensional Trap of Standard Augmentations: Common augmentations (random rotations, horizontal/vertical flips, and standard zero-mean Gaussian/uniform noise) fail. In 784 dimensions, zero-mean perturbations average out along the weight vectors ($w^* \cdot x_{\text{aug}} \approx 0$), producing virtually zero variance in teacher pre-activations.
  • The "Goldilocks" Pre-activation Window: Informative queries must induce pre-activation shifts across the teacher's decision hyperplanes, but perturbations cannot be too large. Excessive noise shoves activations into the flat, asymptotic regimes of activation functions, destroying gradient signals.

Key Results

  • Reconstructing Over-parameterized 512-Neuron Networks: On an MNIST-trained teacher with 512 hidden units (over 407,000 parameters):

  • Original MNIST Queries (60k): Fails to reconstruct; average weight cosine distance is high ($7.15 \times 10^{-1}$, max $9.03 \times 10^{-1}$).

  • Standard Augmentations (180k queries): Fails; max cosine distance remains between $0.87$ and $0.89$.
  • Biased Noise ($\text{MNIST}\pm\eta_{[0,1]}$, 180k queries): Achieves near-perfect reconstruction, driving average cosine distance down to $2.53 \times 10^{-8}$ (max $3.34 \times 10^{-7}$).
  • Grid-Comp. $\pm\eta_{[0,1]}$ (180k queries): Successfully reconstructs with an average cosine distance of $9.74 \times 10^{-6}$.
  • 100× Parameter-to-Data Ratio: When the teacher is trained on only 5,000 MNIST samples, unaugmented EC fails for teachers larger than 32 neurons. Using Grid-Comp. $\pm\eta_{[0,1]}$, the authors successfully recover teachers with 512 neurons (over 100 times more parameters than the 5k original training instances).

Limitations and Future Work

  • Network Depth and Architecture: The study is currently restricted to shallow (one-hidden-layer) feedforward architectures. Extending the approach to deep networks and convolutional layers remains an open challenge.
  • Hardware Bottlenecks: Memory scaling in the clustering phase halted experiments at 512 neurons; scaling to 1,024 neurons exhausted available server RAM (up to 512 GB).
  • Theoretical Framework: The heuristics regarding pre-activation variance and directional noise are demonstrated empirically; the authors note that a comprehensive theoretical framework guaranteeing generalization-to-weight recovery is still needed.

Summary updated

BibTeX
@inproceedings{beiser2025data,
  author = {Alexander Beiser and Flavio Martinelli and Wulfram Gerstner and Johanni Brea},
  title = {{Data Augmentation Techniques to Reverse-Engineer Neural Network Weights from Input-Output Queries}},
  booktitle = {UniReps @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=0HO6md3VvK},
}

Loading related content...

Figure