Reconstructing Training Data From Trained Neural Networks

Niv Haim, Gal Vardi, Gilad Yehudai, Ohad Shamir, michal Irani

Introduction

In deep learning, there is a long-standing tension between generalization (the ability to perform well on new data) and memorization (storing specific details of the training data). While it is widely acknowledged that neural networks often memorize their training sets, the prevailing wisdom has been that this information is "scrambled" within the weights in a way that makes recovering the original raw data nearly impossible.

Previous attempts to "peek" inside networks, such as model inversion, typically produced only generic class representatives (e.g., a blurry average of a class) or adversarial noise. This paper addresses a much more alarming question: Are specific, individual training samples encoded in the parameters, and can they be recovered without any prior knowledge of the data? The authors demonstrate that a significant portion of a training dataset can indeed be reconstructed directly from the parameters of a trained neural network classifier, posing a major potential privacy risk.

Methodology

The authors' approach is rooted in recent theoretical breakthroughs regarding the implicit bias of gradient descent.

For a specific class of models (homogeneous ReLU networks), training with a logistic loss (binary cross-entropy) causes the parameters to converge toward a "maximum-margin" solution. Mathematically, the final weights satisfy a stationarity condition: they are essentially a linear combination of the gradients of the network evaluated at the training points.

The authors turn this theoretical observation into a novel reconstruction scheme. Given a trained network with weights $\theta$, they formulate an optimization problem to find a set of "candidate" images and coefficients such that the weighted sum of their gradients matches the actual weights of the trained model. They define a reconstruction loss function that penalizes the difference between the actual weights and the weights predicted by their candidate images. Using standard optimization (Stochastic Gradient Descent), they "evolve" random noise into images that satisfy the network's internal equations. Unlike previous methods, this approach does not require a prior (like a pre-trained GAN) to make the images look realistic; the structural information comes entirely from the trained classifier's weights.

Experimental Setup

The authors evaluated their method on several datasets:

  • Toy 2D Data: Points on a unit circle with alternating labels to visualize the reconstruction process.
  • MNIST: A binary version (odd vs. even digits).
  • CIFAR-10: A binary version (animals vs. vehicles).

The primary architectures tested were 3-layer Multi-Layer Perceptrons (MLPs) with 1000 neurons per hidden layer.

Key Insights and Results

The core insight of this work is that a trained network's weights are not just abstract features; they act as a compressed, noisy record of the gradients of the training samples.

Interestingly, the reconstruction is most successful for samples that lie on the margin (the decision boundary). Similar to how Support Vector Machines (SVMs) are defined by their support vectors, neural networks are heavily biased by the samples they find hardest to classify. Furthermore, the paper notes that overparameterization—having more parameters than data points, a standard state in modern deep learning—actually makes reconstruction easier by providing more "equations" to solve for the unknown training pixels.

Reconstructed images compared to their nearest neighbors in the training set.

The authors successfully reconstructed recognizable images from both MNIST and CIFAR-10. While the reconstructions contain some noise, they are clearly identifiable as the specific original training samples, a fact verified using the SSIM metric. In a model trained on 500 images, the authors could recover dozens of samples with high accuracy. Their method significantly outperformed traditional Model Inversion and Weights Visualization techniques, which failed to produce recognizable individual samples in these high-dimensional settings.

Limitations and Future Work

While groundbreaking, the current approach has limitations:

  • Scale: The experiments were conducted on relatively small-scale models (MLPs) and small training sets ($n=500$). Reconstructing data from massive models like ResNets or Transformers trained on millions of images remains a significant computational challenge.
  • Optimization Complexity: Solving the reconstruction equations for Convolutional Neural Networks (CNNs) is much harder due to the complexity of the gradient landscape.
  • Classification Scope: The current work focuses on binary classification. Extending this to multi-class problems is theoretically possible but adds another layer of optimization complexity.

This paper serves as a powerful "proof-of-concept" attack. A natural next step for the field is investigating how techniques like Differential Privacy might mitigate this specific, highly targeted type of reconstruction attack.

Summary updated

BibTeX
@inproceedings{haim2022reconstructing,
  author = {Niv Haim and Gal Vardi and Gilad Yehudai and Ohad Shamir and michal Irani},
  title = {{Reconstructing Training Data From Trained Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=Sxk8Bse3RKO},
}
Figure