TL;DR
This paper argues that flat posteriors are crucial for effective Bayesian Model Averaging (BMA) in neural networks, a fact previously overlooked. They introduce FP-BMA, a novel optimization method that explicitly encourages flat posteriors, leading to improved generalization and robustness, especially in transfer learning scenarios.
What Problem Does This Paper Address?
Bayesian Neural Networks (BNNs) offer a principled way to model uncertainty by approximating the posterior distribution of model parameters. This posterior is then used for Bayesian Model Averaging (BMA) to make predictions, which generally improves generalization over deterministic models. However, the authors observe that while flatness in the loss landscape is known to improve generalization in standard neural networks, its impact on BNNs and BMA has not been thoroughly investigated. They find that existing approximate Bayesian inference methods often fail to produce flat posteriors, and BMA without considering flatness is less effective. This gap limits the full potential of BNNs for robust and generalizable predictions.
Methods
The core contribution is the Flat Posterior-aware Bayesian Model Averaging (FP-BMA) method. FP-BMA is a novel training objective that explicitly encourages flat posteriors. It achieves this by:
- Adversarial Posterior Computation: Computing an adversarial posterior in the vicinity of the current posterior that maximizes the BNN loss.
- Gradient-based Update: Updating the posterior using the gradient derived from this adversarial posterior.
FP-BMA is presented as a generalized version of existing flatness-aware optimizers like SAM and FSAM, but adapted for the probabilistic nature of BNNs. They also introduce a Flat Posterior-aware Bayesian Transfer Learning scheme that leverages pre-trained models as priors, further enhancing robustness against model misspecification.
Datasets
The paper uses standard image classification datasets for training and evaluation:
- CIFAR10
- CIFAR100
- ImageNet (IN) and its variants (IN-V2, IN-R, IN-A, IN-S) for transfer learning.
- EuroSAT, Flowers102, Pets, UCF101 for fine-grained image classification.
- CIFAR10C and CIFAR100C for evaluating robustness under distribution shift.
Key Insights and Ideas
- Flatness is Key for BMA: The paper provides both empirical and theoretical evidence that posterior flatness is not just correlated with generalization but is a necessary component for effective BMA.
- Existing BNN Methods Struggle with Flatness: Most common approximate Bayesian inference methods (VI, MCMC, SWAG) fail to produce flat posteriors, limiting the benefits of BMA.
- FP-BMA Generalizes Existing Optimizers: FP-BMA is shown to be a unified framework that can degenerate into SAM, FSAM, and approximate Natural Gradient under specific conditions, demonstrating its theoretical grounding.
- Transfer Learning Benefits from Flatness: The proposed Flat Posterior-aware Bayesian Transfer Learning scheme significantly improves robustness and generalization on downstream tasks, especially when dealing with model misspecification.
- Fewer Samples Needed for Good BMA: FP-BMA allows for effective BMA with fewer sampled models, indicating a higher quality posterior approximation.
Key Results
- FP-BMA consistently outperforms baseline methods (SGD, SAM, FSAM, VI, MCMC, SWAG) in terms of accuracy, ECE, and NLL across various datasets and tasks, including learning from scratch and transfer learning.
- For example, in Table 1, FP-BMA (SWAG) achieves the best accuracy on CIFAR100 with ResNet18 (63.63%), outperforming other methods.
- In transfer learning (Table 2), FP-BMA (VI) achieves the best accuracy on CIFAR10 10-shot with ResNet18 (64.98%).
- The method demonstrates strong robustness on corrupted datasets (Figure 3 and Table 11), maintaining performance even under distribution shifts.
- The theoretical analysis provides a generalization error bound for BMA that explicitly depends on posterior flatness.
Limitations and Future Work
- Theoretical Assumptions: The authors acknowledge that their theoretical insights rely on strong assumptions.
- MCMC Algorithms: The empirical evaluation does not cover the full spectrum of MCMC algorithms.
- Future Directions:
- Extending FP-BMA to a wider variety of Bayesian inference methods.
- Investigating its effectiveness on more complex datasets.
- Exploring automated ways to quantify and enforce flatness during model training.
- Further extending FP-BMA for multi-modal posteriors.
Summary updated