Top-tuning: A study on transfer learning for an efficient alternative to fine tuning for image classification with fast kernel methods

Paolo Didier Alfano, Vito Paolo Pastore, Lorenzo Rosasco, Francesca Odone

TL;DR

This paper introduces "top-tuning," a faster and more efficient alternative to traditional fine-tuning for image classification. By leveraging pre-trained convolutional features and training only a fast kernel classifier, top-tuning achieves comparable accuracy to fine-tuning but with a training time reduction of one to two orders of magnitude, making it ideal for resource-constrained scenarios.

What Problem Does This Paper Address?

Deep learning models, particularly for image classification, have achieved remarkable performance but at the cost of massive complexity. This leads to significant computational demands for training and inference, as well as substantial energy consumption. While fine-tuning pre-trained models is a common strategy to mitigate the need for large datasets and reduce training time compared to training from scratch, it can still be computationally expensive. The authors address the question of whether it's possible to achieve comparable performance with even greater efficiency, especially for smaller or medium-sized datasets where transfer learning is most beneficial. They aim to find a method that significantly reduces training time without a substantial drop in accuracy, making deep learning more accessible and sustainable.

Methods

The core of the paper is the "top-tuning" methodology. This approach utilizes a pre-trained convolutional neural network (CNN) as a fixed feature extractor. Instead of fine-tuning the entire network, the convolutional layers are frozen, and their output features for the target dataset are used as input to a separate, fast-to-train kernel method. Specifically, the authors employ a Nyström approximation-based kernel ridge classifier. This method is chosen for its scalability and efficiency. The process can be summarized as:

  1. Feature Extraction: Use a pre-trained CNN (e.g., DenseNet201) to extract features from the target dataset. These convolutional layers are not updated.
  2. Kernel Classifier Training: Train a fast kernel classifier (e.g., Gaussian kernel ridge regression with Nyström approximation) using these extracted features and the corresponding labels. Only the parameters of this kernel classifier are trained.

This contrasts with fine-tuning, where the pre-trained model's weights (at least partially, often the fully connected layers or even convolutional layers) are updated through backpropagation on the target dataset.

Datasets

The authors conducted extensive experiments on 32 small to medium-sized datasets, covering a wide range of image classification tasks. These datasets include:

  • Popular Benchmarks: CIFAR10, CIFAR100, Caltech101, EuroSAT, FGVC Aircraft, Oxford Flowers, Stanford Cars, Stanford Dogs.
  • Diverse Scenarios: Datasets representing various domains like food, medical images, natural scenes, and more.

For pre-training, they primarily used models pre-trained on ImageNet. They also explored alternative pre-training datasets like CIFAR100, a subset of ImageNet (ImageNet100), and a further curated subset (ImageNet 50k) to investigate the impact of pre-training data characteristics.

Key Insights and Ideas

  • The Power of Pre-trained Features: The study strongly suggests that the rich representations learned by deep CNNs on large datasets like ImageNet are highly transferable. These features, when extracted without further tuning, are often sufficient for a separate, simpler classifier to achieve competitive performance.
  • Kernel Methods as Efficient Heads: Fast kernel methods, particularly those leveraging approximations like Nyström, are highly effective "head" classifiers when paired with deep features. Their computational efficiency is a key enabler of the top-tuning speedup.
  • Trade-off is Minimal: The most striking insight is that the significant speedup in training time achieved by top-tuning comes with a minimal, often negligible, drop in accuracy compared to fine-tuning. This suggests that for many tasks, the extensive fine-tuning process might be overkill.
  • Pre-training Quality Matters, but Diversity is Key: While ImageNet pre-training is generally superior, the study shows that the number of classes in the pre-training dataset (as seen with ImageNet 50k) can be a crucial factor for top-tuning performance, sometimes even more so than the sheer number of images. Semantic diversity in the pre-training data also plays a role.

Key Results

  • Massive Speedup: Top-tuning consistently outperformed fine-tuning in training time, achieving speedups ranging from 10x to 165x on average, with a mean speedup of 84.64±38.97x across datasets when using a fast kernel classifier.
  • Comparable Accuracy: In 60% of experiments, the accuracy difference between top-tuning and fine-tuning was within ±2.5%. In many cases, top-tuning even slightly outperformed fine-tuning.
  • Robustness: The findings held across different pre-trained models (DenseNet201, EfficientNetB0, ResNet152, etc.) and were also observed when using simpler head classifiers like shallow neural networks or ridge regressors, though with smaller speedups compared to the fast kernel method.
  • Impact of Pre-training Data: Using ImageNet 50k as a pre-training dataset showed promising results, indicating that a diverse set of classes, even with fewer samples per class, can be highly effective.

Limitations and Future Work

  • Focus on Image Classification: The current study is limited to image classification tasks. The authors suggest extending the methodology to other computer vision tasks like object detection and segmentation, as well as to video-related problems (e.g., action recognition).
  • Hyperparameter Optimization: While the paper uses a grid search for hyperparameter tuning, they note that automatic hyperparameter optimization procedures could be explored for further efficiency, though they found current automatic methods yielded slightly lower accuracy.
  • Fine-grained Datasets: Top-tuning showed a more noticeable accuracy drop on datasets that are underrepresented, small, and fine-grained. However, the speed advantage often remains the most critical factor. The authors acknowledge that fine-grained tasks might require specialized strategies even for fine-tuning.
  • Pre-training Data Impact: While ImageNet is generally best, further research into optimal pre-training datasets for specific downstream tasks could be beneficial.

The paper concludes that top-tuning is a highly efficient and effective alternative to fine-tuning for image classification, especially when computational resources and training time are critical constraints.

Summary updated

BibTeX
@article{alfano2022top,
  author = {Paolo Didier Alfano and Vito Paolo Pastore and Lorenzo Rosasco and Francesca Odone},
  title = {{Top-tuning: A study on transfer learning for an efficient alternative to fine tuning for image classification with fast kernel methods}},
  journal = {Image and Vision Computing},
  year = {2022},
}
Figure