This repository provides a lightweight and energy-aware transfer learning strategy designed for environments with limited hardware resources. Unlike traditional fine-tuning, the method decouples feature extraction from classifier training, avoiding unnecessary iterations through the backbone.
This work was published at the International Conference on Intelligent Data Engineering and Automated Learning (IDEAL 2025) and received the Best Paper Award🏆 (Springer Link).
- Precomputed Features: Extract features once from the backbone to drastically reduce training time.
- Thresholded Batch Normalization Adaptation: Efficiently adapts batch normalization statistics to new domains.
- Redesigned Classifier Head: Improves generalization with negligible overhead.
- Margin-based Weighted Training: Focuses on ambiguous samples to improve accuracy.
Results on Brain Cancer MRI, BreakHis and PatchCamelyon datasets show up to 22× faster training and 25× lower CO₂ emissions, while maintaining or improving accuracy compared to full fine-tuning.
-
Clone the repository
git clone https://github.com/DanielVilaCruz/Fast-and-Frugal-Transfer-Learning.git cd Fast-and-Frugal-Transfer-Learning -
Install PyTorch
This project requires PyTorch (with CUDA or CPU support).
Example (CUDA 12.1):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Example (CPU):
pip install torch torchvision torchaudio
-
Install project dependencies
pip install -r requirements.txt
-
Download datasets and place them under the /data folder.
- Brain Cancer MRI: https://data.mendeley.com/datasets/mk56jw9rns/1
- BreakHis: https://web.inf.ufpr.br/vri/databases/breast-cancer-histopathological-database-breakhis/
- PatchCamyleon:https://github.com/basveeling/pcam
Experiments are configured in experiments.yaml. Each entry corresponds to a single experiment, and multiple ones can be added to execute them sequentially.
experiments:
- method: "ours"
base_backbone: "resnet18"
dataset: "brain_cancer"
n_real_samples: 0
num_runs: 3
lr: 0.001
amplify_factor: 10.0
patience: 5
unfreeze_layers: 2
simple_head: false
- method: "fine-tune"
base_backbone: "densenet121"
dataset: "breakhis"
n_real_samples: 1000
num_runs: 1method: training mode"ours": precomputed features + lightweight classifier"fine-tune": standard fine-tuning
base_backbone: model architecture- Options:
"resnet18","resnet50","mobilenet_v3_large","densenet121"
- Options:
dataset: dataset to use- Options:
"brain_cancer","breakhis","pcam"
- Options:
n_real_samples: maximum number of samples to use0: use all available samples
num_runs: number of times to repeat the experiment (averages results)lr: learning rateamplify_factor: weight assigned to ambiguous samples in margin-based trainingpatience: early stopping patienceunfreeze_layers(only for fine-tuning method): number of last layers to unfreeze in the backbonesimple_head: whether to use a minimal classifier head (true) or the improved one (false)
Then launch experiments with:
python launch_exp.pyBy default, results (metrics, timings, CO₂ emissions) are stored in results.json and exps/.
| Architecture | Fine-tuning | Ours | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Time (s) | CO₂ (kg) | Acc. (%) | Time (s) | CO₂ (kg) | |
| ResNet18 | 99.16 | 194.672 | 0.0038 | 98.42 | 32.486 | 0.0006 |
| ResNet50 | 99.25 | 311.550 | 0.0064 | 97.75 | 57.407 | 0.0011 |
| MobileNetV3 | 93.93 | 770.210 | 0.0151 | 99.71 | 34.780 | 0.0006 |
| DenseNet121 | 99.58 | 625.140 | 0.0127 | 96.76 | 58.204 | 0.0011 |
| Architecture | Fine-tuning | Ours | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Time (s) | CO₂ (kg) | Acc. (%) | Time (s) | CO₂ (kg) | |
| ResNet18 | 99.33 | 367.299 | 0.0069 | 98.50 | 42.621 | 0.0008 |
| ResNet50 | 97.66 | 513.383 | 0.0104 | 98.33 | 59.743 | 0.0012 |
| MobileNetV3 | 99.00 | 430.983 | 0.0087 | 98.67 | 57.147 | 0.0010 |
| DenseNet121 | 93.46 | 3970.622 | 0.0794 | 94.52 | 184.374 | 0.0038 |
| Architecture | Fine-tuning | Ours | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Time (s) | CO₂ (kg) | Acc. (%) | Time (s) | CO₂ (kg) | |
| ResNet18 | 79.78 | 5953.25 | 0.1202 | 79.03 | 841.32 | 0.0163 |
| ResNet50 | 83.54 | 10191.44 | 0.2140 | 81.17 | 1114.45 | 0.0229 |
| MobileNetV3 | 82.96 | 8009.09 | 0.1665 | 82.64 | 695.83 | 0.0134 |
| DenseNet121 | 84.22 | 20530.34 | 0.4382 | 80.67 | 1287.82 | 0.0264 |
If you use this work, please cite:
@inproceedings{vila2025fast,
title={Fast and Frugal Transfer Learning via Precomputed Features and Adaptive Normalization},
author={Vila-Cruz, Daniel and Bol{\'o}n-Canedo, Ver{\'o}nica and Mor{\'a}n-Fern{\'a}ndez, Laura},
booktitle={International Conference on Intelligent Data Engineering and Automated Learning},
pages={143--149},
year={2025},
organization={Springer}
}