Enhancing Transfer Learning with Flexible Nonparametric Posterior Sampling

Hyungi Lee, Giung Nam, Edwin Fong, Juho Lee

TL;DR

Nonparametric Transfer Learning (NPTL) is a new posterior sampling method that uses nonparametric priors to bridge the gap between upstream pre-training and downstream fine-tuning. By treating the data distribution itself as a random variable rather than just the model weights, NPTL effectively handles distribution shifts and model misspecification, outperforming standard Bayesian methods and ensembles in both accuracy and uncertainty quantification.

What Problem Does This Paper Address?

In the world of deep learning, the standard operating procedure is "pre-train then fine-tune." Bayesian Deep Learning (BDL) aims to improve this by providing uncertainty estimates through Bayesian Model Averaging (BMA)—instead of one "best" model, you average predictions from a distribution of models.

However, BDL in transfer learning faces a major hurdle: the prior. Standard priors (like zero-mean Gaussians) don't capture the "prior knowledge" from the upstream task. Even advanced priors centered on pre-trained weights struggle when there is a distribution shift—a mismatch between what the model learned during pre-training and what it sees during fine-tuning. Most existing methods assume the model is "true" (correctly specified), but in transfer learning, the model is almost always a simplified approximation of the complex downstream data.

Methods

The authors introduce Nonparametric Transfer Learning (NPTL), which adapts the recent framework of Bayesian Nonparametric Learning (NPL) to the transfer learning setting.

The Core Innovation: Nonparametric Priors

Instead of placing a prior directly on the neural network weights $\theta$, NPTL uses a Dirichlet Process (DP) prior on the data distribution itself. This allows the method to account for model misspecification—essentially acknowledging that the model might not be a perfect fit for the data.

Bridging the Gap with Linear Probing

To make this work without needing access to the original (often massive or private) upstream dataset, the authors use linear probing. They freeze the pre-trained feature extractor and train only the final head on the downstream data. This "probed" model serves as the center for their nonparametric prior, effectively distilling upstream knowledge into a usable base measure for the Dirichlet Process.

Scalable Sampling

Sampling from a Dirichlet Process for large datasets is computationally brutal. The authors solve this using:

  1. Block Dirichlet Distribution: They partition the data into blocks to stabilize and parallelize the weight sampling process.
  2. Parallel Optimization: Unlike traditional MCMC methods that are sequential, NPTL samples can be optimized independently using standard SGD, making it highly compatible with modern GPU clusters.

Datasets

The authors validated NPTL across a wide array of tasks:

  • Vision: ResNet-20x4 on CIFAR-10/100, Food-101, and Stanford Dogs. ResNet-50 and ViT-B/16 on Caltech-UCSD Birds 200, Caltech-101, Describable Textures (DTD), Oxford Flowers, and Oxford-IIIT Pet.
  • Robustness: CIFAR-10-C (a benchmark for common image corruptions like blur and noise).
  • Language: RoBERTa-Base on GLUE subtasks (CoLA, MRPC, RTE).
  • Segmentation: PASCAL VOC 2012 using DeepLabv3+.

Key Insights and Ideas

  • Robustness to Misspecification: By using a nonparametric approach, NPTL doesn't "over-trust" the model. This makes it significantly more resilient when the downstream task differs from the pre-training task.
  • Implicit Prior Knowledge: Linear probing is a clever "middle ground." It captures the essence of the upstream data generation process without requiring the actual upstream data, which is often a bottleneck in real-world applications.
  • Parallelism is King: The move from sequential MCMC to parallel SGD-based sampling is a major practical win for researchers working with large-scale models.

Key Results

NPTL consistently outperformed strong baselines like SGHMC (Stochastic Gradient Hamiltonian Monte Carlo) and Deep Ensembles.

  • Better Uncertainty: In vision tasks, NPTL achieved the lowest Negative Log-Likelihood (NLL), indicating higher quality posterior samples. As shown in the ResNet-20x4 results, NPTL often provides a better balance of accuracy and NLL than ensembles.
Table 1: Main results with BMA for ResNet-20x4. Evaluation results of NPTL and baseline methods for BMA on four image classification datasets, including C10, C100, F101, and D120. Results with standard deviations represent the average of three runs.
  • Scalability: The performance gains held up as the models scaled from ResNet-20 to ResNet-50 and Vision Transformers (ViT).
Table 2: Main results with BMA for ResNet-50. Evaluation results of NPTL and baseline meth- ods for BMA on five image classification datasets, including B200, C101, D47, F102, and P37. Results with standard deviations represent the average of three runs.
  • Corruption Robustness: On the CIFAR-10-C benchmark, NPTL showed superior robustness across all intensity levels of data corruption compared to all other methods.
Table 4: Results on CIFAR-10-C benchmark for ResNet-20x4. Evaluation results of NPTL and baseline methods for BMA under five different levels of common corruptions. Results with standard deviations represent the average across 15 different corruption types.

Limitations and Future Work

  • Inference Cost: Like all BMA methods, NPTL requires multiple forward passes (one for each posterior sample) during inference. The authors propose "NPTL-Soup" (weight averaging) as a mitigation, but this remains a challenge for real-time deployment.
  • Linear Probing Step: While efficient, the requirement to perform linear probing before the main sampling stage adds an extra step to the pipeline.
  • Future Directions: The authors suggest exploring ensemble distillation to reduce inference costs and investigating how NPTL behaves in even more extreme distribution shift scenarios.

Summary updated

BibTeX
@inproceedings{lee2024enhancing,
  author = {Hyungi Lee and Giung Nam and Edwin Fong and Juho Lee},
  title = {{Enhancing Transfer Learning with Flexible Nonparametric Posterior Sampling}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=vSwu81S33z},
}
Figure