Effective training-time stacking for ensembling of deep neural networks

Polina Proscura, Alexey Zaytsev

TL;DR

Training ensembles of deep neural networks is notoriously expensive, often requiring multiple independent training runs. This paper introduces an improved "snapshot ensembling" technique that collects multiple models from a single training path and combines them using a weighted stacking approach based on training-time likelihoods, achieving near-state-of-the-art accuracy at a fraction of the computational cost.

What Problem Does This Paper Address?

Ensembling—combining the predictions of multiple models—is a gold standard for boosting accuracy and estimating uncertainty. However, training $N$ deep learning models typically costs $N$ times as much as training one.

"Snapshot ensembling" was proposed to solve this by using a cyclical learning rate to visit multiple local minima in a single training run, saving a "snapshot" of the model at each minimum. While efficient, the standard approach simply averages these snapshots. The authors argue this is suboptimal because snapshots vary in quality and diversity; treating a mediocre early-stage model the same as a refined late-stage model leaves performance on the table.

Methods

The authors propose a more sophisticated way to select and combine these snapshots, which they call training-time stacking:

  1. Cyclical Learning Rate: They use a scheduler that oscillates between high and low learning rates, allowing the model to "jump" out of one local minimum and find another.
  2. Windowed Selection: Instead of just grabbing the model at the exact point of the lowest learning rate, they look at a small "window" of iterations around that point and pick the one with the best validation loss. Figure 1: Choosing the best model from a window near the learning rate minimum
  3. Likelihood-Based Weighting: Rather than simple averaging, they assign a weight ($w_k$) to each model based on its likelihood (how well it fits the data).
  4. Temperature Scaling: They introduce a temperature parameter ($\tau$) to calibrate these weights. A high temperature makes weights more uniform (like simple averaging), while a low temperature puts more weight on the best-performing models.
Fig. 1: Choice of the model from the window near the minimum of learning rate

Crucially, they demonstrate that weights calculated using training data likelihood perform nearly as well as those using a separate validation set, making the process highly efficient.

Datasets

The researchers evaluated their approach using three standard image classification benchmarks:

  • CIFAR-10
  • CIFAR-100
  • Fashion MNIST

All experiments were conducted using the ResNet18 architecture.

Key Insights and Ideas

  • Not All Snapshots are Equal: The "aha moment" is that simple averaging is a blunt instrument. By weighting models based on their likelihood, you can filter out "noisy" snapshots that haven't fully converged.
  • Training Data is a Sufficient Signal: Traditional stacking requires a hold-out validation set to determine weights. This paper shows that the internal training likelihood is a strong enough signal to rank model quality within a single training path.
  • Diversity vs. Quality: The authors found that including models from the "middle" of a learning cycle (where the learning rate is higher) can actually improve the ensemble by providing more diversity, provided they are weighted correctly to account for their lower individual quality.

Key Results

The proposed stacking method consistently outperformed both single models and standard snapshot ensembles on the CIFAR-10 dataset:

  • Single Model: 89.49% accuracy.
  • Vanilla Snapshot Ensemble (Averaged): 89.9% accuracy.
  • Proposed Stacked Snapshot Ensemble: Achieved up to 90.8% accuracy.

As shown in the table below, their method narrows the gap significantly between cheap snapshot ensembles and the "gold standard" of training five completely independent models (which reached 91.9% but cost 5x more to train).

TABLE I: Accuracy in percents for different combinations of the models with the best results for each ensembling type for CIFAR-10

The researchers also found that a temperature ($\tau$) around 1.0 was generally optimal for balancing the contributions of different snapshots. Figure 2: Heatmap showing how accuracy varies with the number of models and temperature

Fig. 2: Results for CIFAR-10 for the averaging based on the likelihood on the training set.

Limitations and Future Work

  • Architecture Scope: The study focused primarily on ResNet18 and image classification. It remains to be seen how well this stacking approach generalizes to other architectures like Transformers or different domains like Natural Language Processing.
  • Hyperparameter Tuning: The "window size" for selecting models and the temperature parameter $\tau$ add new hyperparameters that may require tuning for different datasets.
  • Inference Overhead: While training is efficient, the final ensemble still consists of many models (up to 24 in some tests), which increases the memory footprint and computational cost during inference compared to a single model. Future work could explore "distilling" these stacked ensembles back into a single efficient model.

Summary updated

Abstract

Ensembling is a popular and effective method for improving machine learning (ML) models. It proves its value not only in classical ML but also for deep learning. Ensembles enhance the quality and trustworthiness of ML solutions, and allow uncertainty estimation. However, they come at a price: training ensembles of deep learning models eat a huge amount of computational resources. A snapshot ensembling collects models in the ensemble along a single training path. As it runs training only one time, the computational time is similar to the training of one model. However, the quality of models along the training path is different: typically, later models are better if no overfitting occurs. So, the models are of varying utility. Our method improves snapshot ensembling by selecting and weighting ensemble members along the training path. It relies on training-time likelihoods without looking at validation sample errors that standard stacking methods do. Experimental evidence for Fashion MNIST, CIFAR-10, and CIFAR-100 datasets demonstrates the superior quality of the proposed weighted ensembles c.t. vanilla ensembling of deep learning models.
BibTeX
@inproceedings{proscura2022effective,
  author = {Polina Proscura and Alexey Zaytsev},
  title = {{Effective training-time stacking for ensembling of deep neural networks}},
  booktitle = {Aipr},
  year = {2022},
}
Figure