Robust Fine-Tuning of Deep Neural Networks with Hessian-based Generalization Guarantees

Haotian Ju, Dongyue Li, Hongyang R. Zhang · OpenReview

Abstract

Fine-tuning pretrained deep neural networks is a cornerstone of modern transfer learning, yet it remains susceptible to overfitting, particularly when target datasets are small or contain label noise. While traditional generalization bounds often rely on the distance from initialization, these measures frequently fail to provide non-vacuous guarantees. In this work, we leverage PAC-Bayesian analysis to demonstrate that generalization is fundamentally linked to the Hessian of the loss function, which captures the model's noise stability. We derive Hessian-based generalization bounds and propose a robust fine-tuning algorithm that incorporates consistent losses and layer-wise projections. Our empirical evaluation across various architectures (ResNet, ViT, RoBERTa) and datasets (DomainNet, CIFAR, GLUE) shows that our approach significantly outperforms existing methods, achieving a 3.26% accuracy gain on programmatically labeled tasks while maintaining a Hessian distance measure six times lower than standard baselines.

Introduction

The paradigm of "pretrain and fine-tune" has enabled state-of-the-art performance across computer vision and natural language processing. However, the transition from a broad source domain to a specific target domain often leads to overfitting. This is exacerbated when the target data is "noisy"—containing incorrect or low-quality labels.

Existing theoretical frameworks attempt to quantify generalization using the distance between the initial pretrained weights and the final fine-tuned weights. However, these norm-based bounds are often "vacuous," providing theoretical error limits that exceed 100%, making them practically useless for model selection or optimization. This paper addresses the gap by identifying that the geometry of the loss landscape—specifically its curvature—is a more critical predictor of generalization than simple weight distance.

Theoretical Framework: The Role of the Hessian

Using PAC-Bayesian analysis, we study how a model's output changes in response to weight perturbations, a property known as noise stability. Our analysis reveals that the Hessian matrix (the second-order derivatives of the loss function) is the optimal tool for measuring this stability.

Hessian-based Generalization Bounds

We derive a new bound where the generalization gap is controlled by the product of the weight change and the Hessian. Intuitively, if a model resides in a "flat" region of the loss landscape (characterized by low Hessian values), it is more robust to noise and generalizes better to unseen data. Conversely, moving weights into "sharp" regions leads to poor generalization, even if the total distance from the starting point is small. Our derived bounds are orders of magnitude tighter than previous norm-based measures, often yielding small constant values (e.g., 2.26) where prior methods yielded values in the billions.

Proposed Methodology

Based on our theoretical insights, we propose a robust fine-tuning algorithm designed to minimize the Hessian-based distance while maintaining high accuracy.

  1. Consistent Loss Re-weighting: To handle noisy labels, we utilize statistically-consistent losses. These losses are designed to be "unbiased" estimators of the true loss, even when training labels are flipped according to a class-conditional noise matrix.
  2. Layer-wise Projection: We implement a projection step that constrains each layer's weights within a specific radius of their initial values. The size of these "balls" is informed by our Hessian theory, ensuring the model stays within stable regions of the parameter space.
  3. Noise Resilience: We prove that unbiased weighted losses naturally favor models where the trace of the Hessian is small, providing a principled link between robust statistics and the geometric properties of deep networks.

Empirical Results

We evaluated our algorithm on diverse benchmarks, including DomainNet (six domains), CIFAR-10/100, and GLUE (MRPC, SST-2). We tested architectures ranging from ResNet-18 to Vision Transformers and RoBERTa.

Performance under Label Noise

Our method excels in high-noise environments. On the DomainNet "Sketch" domain with 60% synthetic label noise, our algorithm outperformed standard fine-tuning by approximately 16% and surpassed strong baselines like Mixup and Label Smoothing by over 8%.

Real-World Weak Supervision

In practical scenarios where labels are generated via programmatic labeling (inherently noisy), our approach achieved an average accuracy gain of 3.26% across six domains. Furthermore, the Hessian distance measure of our fine-tuned models was six times lower than those produced by existing approaches, confirming that our algorithm successfully finds flatter, more generalizable minima.

Discussion and Conclusion

Our findings suggest that curvature matters more than distance in the context of transfer learning. By focusing on the Hessian, we can produce generalization guarantees that actually correlate with empirical performance. While computing the full Hessian is computationally intensive, our use of Hessian-vector products makes this approach viable for modern architectures. Future work will explore extending these guarantees to non-smooth activation functions like ReLU through smoothed analysis and applying these techniques to even larger "black-box" foundation models.

Summary updated

BibTeX
@inproceedings{ju2022robust,
  author = {Haotian Ju and Dongyue Li and Hongyang R. Zhang},
  title = {{Robust Fine-Tuning of Deep Neural Networks with Hessian-based Generalization Guarantees}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=71TE-Y7qFO},
}
Figure