Skip to content

About

This repository provides a novel lightweight and energy-aware training strategy designed for environments with hardware limitations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Fast-and-Frugal-Transfer-Learning

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).

Key Features

  • 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.


Setup

  1. Clone the repository

    git clone https://github.com/DanielVilaCruz/Fast-and-Frugal-Transfer-Learning.git
    cd Fast-and-Frugal-Transfer-Learning
  2. 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
  3. Install project dependencies

    pip install -r requirements.txt
  4. Download datasets and place them under the /data folder.

Usage

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: 1

Parameters

  • method: training mode
    • "ours": precomputed features + lightweight classifier
    • "fine-tune": standard fine-tuning
  • base_backbone: model architecture
    • Options: "resnet18", "resnet50", "mobilenet_v3_large", "densenet121"
  • dataset: dataset to use
    • Options: "brain_cancer", "breakhis", "pcam"
  • n_real_samples: maximum number of samples to use
    • 0: use all available samples
  • num_runs: number of times to repeat the experiment (averages results)
  • lr: learning rate
  • amplify_factor: weight assigned to ambiguous samples in margin-based training
  • patience: early stopping patience
  • unfreeze_layers (only for fine-tuning method): number of last layers to unfreeze in the backbone
  • simple_head: whether to use a minimal classifier head (true) or the improved one (false)

Then launch experiments with:

python launch_exp.py

By default, results (metrics, timings, CO₂ emissions) are stored in results.json and exps/.


Results

Brain Cancer MRI Results

Architecture Fine-tuning Ours
Acc. (%)Time (s)CO₂ (kg) Acc. (%)Time (s)CO₂ (kg)
ResNet1899.16194.6720.0038 98.4232.4860.0006
ResNet5099.25311.5500.0064 97.7557.4070.0011
MobileNetV393.93770.2100.0151 99.7134.7800.0006
DenseNet12199.58625.1400.0127 96.7658.2040.0011

BreakHis Results

Architecture Fine-tuning Ours
Acc. (%)Time (s)CO₂ (kg) Acc. (%)Time (s)CO₂ (kg)
ResNet1899.33367.2990.0069 98.5042.6210.0008
ResNet5097.66513.3830.0104 98.3359.7430.0012
MobileNetV399.00430.9830.0087 98.6757.1470.0010
DenseNet12193.463970.6220.0794 94.52184.3740.0038

PatchCamelyon (PCam) Results

Architecture Fine-tuning Ours
Acc. (%)Time (s)CO₂ (kg) Acc. (%)Time (s)CO₂ (kg)
ResNet18 79.785953.250.1202 79.03841.320.0163
ResNet50 83.5410191.440.2140 81.171114.450.0229
MobileNetV3 82.968009.090.1665 82.64695.830.0134
DenseNet121 84.2220530.340.4382 80.671287.820.0264

Citation

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}
}

About

This repository provides a novel lightweight and energy-aware training strategy designed for environments with hardware limitations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages