Experiments
Parameter-efficient fine-tuning with LoRA on CNNs and ViTs.
How do low-rank adapters compare to traditional fine-tuning methods – is there a hidden cost?
The full paper
This article summarizes attached paper. Read it for all technical details, extended discussions, and references. Source code can be found here.
or read the PDF inline here.
If the viewer isn’t available, open the PDF in a new tab.
Teaching old models new tricks

This is my cat Theo. For us humans it’s pretty intuitive to tell that he is, in fact, a cat. If I want a neural network to distinguish between cats and dogs, or their breeds, things become trickier though. Starting from scratch (get it? cause he’s a cat? whatever…) with randomly initialized weights requires a lot of labelled training data and compute resources (in this economy?!). Hence, people invented fine-tuning: We take an existing model that was pre-trained on a generic data-distribution (let’s say everyday objects) and adapt it slightly and thus specialize it for our use-case (cats and dogs).
Naturally the question arises how to update the weights – what strategies are out there and what are their respective ups and downs? Together with Manuel Voit and Anton Holderied, I explored this in KTH’s deep learning in data science course. We compared training only the final layer/classifier (linear probing), updating the weights into deeper layers and LoRA, which adds small trainable updates while keeping the original weights frozen. Using CNNs and Vision Transformers (ViTs), we looked at accuracy, memory, training time and what happens when there’s barely any data to learn from.
Small updates, big promises
LoRA stands for Low-Rank Adaptation. The idea is simple: adapting a model to a new task might only need a small, low-dimensionality change to its weights, and not require the entire weight matrix to be updated. We freeze the pretrained weights and learn two smaller matrices, and , whose product supplies the update.
At inference time, the original layer still does its usual work. In parallel, maps the input down to values, and maps those back to the output size (essentially compression and decompression through a bottleneck). This correction is added to the original result via . Here, is the rank, is a tunable scaling factor and controls the strength of the update.
Hover or focus to explore. Select to keep a note.Tap a label to explore. Tap again to clear.
Explore the figure
- W₀: the original layer
- W₀ stays fixed during adaptation. It still contributes to every forward pass and takes up memory; freezing removes its weight gradients and optimizer state, not the layer itself.
- A: down to rank r
- A is trainable. For a linear layer it maps dᵢₙ inputs to r values, using r × dᵢₙ weights.
- r: the bottleneck
- r sets the width of the adapter’s hidden representation and marks the update’s rank. The update is scaled by α/r. Two nodes are drawn for illustration; our highlighted runs mostly use r = 8.
- B: back to the output width
- B is trainable too. It expands the r values to dₒᵤₜ outputs.
- Add the correction
- Each output adds the frozen layer’s result to the scaled adapter correction: h = W₀x + (α/r)B(Ax). The adapter branch works alongside the pretrained layer.
This is where the parameter savings come from. A weight matrix has a million entries. With , the two LoRA matrices need just 16,000 trainable parameters. The original million weights still live in memory, they are just not touched during backprop.
The usual pitch is: accuracy close to backbone fine-tuning, smaller checkpoints and less memory and training time. Sounds like a bargain. But our main findings are that fewer trainable parameters don’t automatically translate to less VRAM or faster training. Here’s what those parameter savings actually bought us on CNNs and ViTs.
Putting the promise to the test
We gave ResNet-50 and ResNet-101 (CNNs) and ViT-B/16 (a Vision Transformer) some homework: Oxford-IIIT Pet and MS COCO. Pets asks models to distinguish 37 cat and dog breeds while COCO allows several of its 80 object categories in one image. We graded prediction quality, performance with scarce data and how much GPU memory and training time they needed.
What learns – and when
We grouped each backbone into four stages. These gave us a common unit across architectures for describing how far back from the classifier we allowed weight-adaptation:
| Architecture | What counts as one stage |
|---|---|
| ResNet-50/101 | Residual blocks sharing feature-map resolution and channel count. |
| ViT-B/16 | Three consecutive transformer blocks. |
The classifier was always trainable. For the backbone, we compared three approaches:
- Linear probing: leave the entire backbone frozen and train only the final classification layer.
- Backbone fine-tuning: update the original weights in the last stages, keeping the stem frozen. Simultaneous unfreezing trains all those stages from the start. Gradual unfreezing starts with the classifier and adds one stage every epochs, working backwards until reaching depth .
- LoRA: keep all original backbone weights frozen. Here, specifies the last stages receiving adapters; sets the adapters’ rank. We tested training all selected adapters from the start as well as gradual LoRA: adapters were installed upfront, then their parameters were unfrozen stage by stage using the same interval .
LoRA across architectures: same idea, different wiring
CNN LoRA-adapters keep the spatial structure intact. reduces channels to using the original kernel size, stride and padding. restores the output channels with a convolution. We also test where to put the adapters: on both and convolutions (general LoRA), or only on the ones (targeted LoRA).
ViT LoRA-adapters are linear projections on attention’s query and value weights. We exclude feed-forward blocks to limit parameter growth.
For input/output widths and , has shape and has shape . Together, that’s trainable weights. Neat!
Fewer cat pictures, more training choices
We test with various fractions of the training data to simulate data scarceness. Separately, we made some breeds rarer, countering imbalance through oversampling and/or weighted loss, where with being the class’s sample count.
To keep the comparison fair, each strategy gets its own hyperparameter search on validation data, with a separate test set for final evaluation. All runs use AdamW with cosine learning-rate decay (and warmup for ViTs). Early stopping ends training when validation loss stops improving.
Counting more than weights
We tracked accuracy on Pets, classification mAP on COCO, and precision, recall and macro-F1. Resource comparisons measured trainable parameters, peak GPU memory, epoch time and total training time on the same machine under the same load conditions. Memory has several hungry residents:
The total VRAM footprint is made up of weights, gradients, optimizer state and activations. Freezing cuts gradient and optimizer storage, but weights and activations still need space. In particular, backprop still needs intermediate activations to train LoRA-adapters, including through frozen layers. Training time is calculated by
, where is the mean epoch time and the number of epochs run until the model converges.
Results
A few weights go a long way
With all the Pets training data, backbone fine-tuning keeps the accuracy lead. The following representative example of ResNet-101 runs makes this clear:
| Strategy | Trainable parameters | Validation accuracy | Test accuracy |
|---|---|---|---|
| Linear probing | 75.8 K | 95.0% | 92.8% |
| Gradual fine-tuning | 15.0 M | 96.6% | 93.8% |
| LoRA, general (all convs) | 1.29 M | 95.8% | 92.2% |
| LoRA, targeted (3x3 convs only) | 711 K | 96.6% | 92.2% |
Targeted LoRA uses 95.3% fewer trainable parameters than gradual fine-tuning, but gives up 1.6 percentage points of test accuracy. It also uses fewer parameters than the general LoRA configuration, while both reach 92.2% test accuracy. Gradual LoRA hurts performance in our CNN runs and enabling all adapters from the start works better.
What if we have fewer examples?
Hover or focus to explore. Select to keep a note.Tap a label to explore. Tap again to clear.
Explore the figure
- γ = 0.02: the smallest training set
- Validation accuracy: linear probing 67.5%, simultaneous backbone fine-tuning 22.5%, gradual backbone fine-tuning 16.6%. LoRA reaches 67.1% with adapters in the last stage (k = 1).
- γ = 0.1: a little more to learn from
- Validation accuracy: linear probing 89.6%, simultaneous backbone fine-tuning 76.2%, gradual backbone fine-tuning 67.1%. LoRA reaches 88.5% with adapters only in the last stage (k = 1), outperforming deeper injections.
- γ = 1: backbone adaptation catches up
- In the baseline sweep, simultaneous and gradual backbone fine-tuning both reach 96.6% validation accuracy. Linear probing reaches 95.2%. The table uses a selected linear-probing run at 95.0%. Targeted LoRA also reaches 96.6% on validation, but has lower test accuracy.
First, we crank down the amount of training data . With only 2% of the Pets training data, gradual and simultaneous backbone fine-tuning drop starkly, while linear probing holds up at 67.5%. This motivates LoRA: can we keep that robustness in low-data regimes, while giving the frozen features some room to adapt?
We test this directly with and (10% and 2% of the training data). LoRA reaches 88.5% and 67.1% validation accuracy, respectively. At 2%, it effectively matches linear probing, while avoiding the collapse seen with backbone fine-tuning. At full data availability it stays competitive with backbone fine-tuning methods.
How well do our findings generalize?
LoRA stays competitive beyond the original CNN/Pets setup. These are held-out classification mAP scores for COCO and test accuracies for Pets:
| Model / data | Linear probing | Best backbone fine-tuning | LoRA |
|---|---|---|---|
| ResNet-101 / COCO | 69.83% | 77.26% | 76.26% |
| ViT-B/16 / Pets, full data | 92.3% | 93.8% | 93.0% |
| ViT-B/16 / Pets, 2% data | 80.5% | 59.0% | 80.8% |
On COCO, linear probing underfits. LoRA finishes just one mAP point behind the best backbone fine-tuning. On the ViT, LoRA’s advantage is clearest with scarce data: 80.8% test accuracy versus 59% for backbone fine-tuning. Linear probing is also strong at 80.5%, so the benefit isn’t unique to LoRA.
So, is it worth it?
Hover or focus to explore. Select to keep a note.Tap a label to explore. Tap again to clear.
Explore the figure
- Linear probing: only the classifier learns
- 75.8 K trainable parameters, with peak VRAM being 1.53 thousand MiB. The backbone has no trainable stages; its stored weights still occupy GPU memory.
- Gradual backbone fine-tuning: k = 1
- 15.04 M trainable parameters. Peak VRAM is 1,764 MiB. Only the last backbone stage is unfrozen, at an interval of τ = 3 epochs.
- Targeted LoRA: r = 8, k = 3
- 711 K trainable parameters, but peak VRAM is 10,425 MiB. Adapters reach three stages back, requiring more activation storage.
Now for the catch. Our strongest targeted CNN LoRA configuration needs 10,425 MiB of peak VRAM, compared with 1,764 MiB for gradual fine-tuning, despite its significantly smaller number of trainable parameters. Why is that?
These are different configurations: LoRA reaches back three stages, fine-tuning one. Remember that the VRAM footprint is made up of weights, gradients, optimizer state and activations. Deeper adapters require more large activations for backprop. This is especially costly in CNNs and clearly outweighed the gradient and optimizer savings in this case. At the same injection/unfreezing depth, LoRA can still reduce memory, however this was often not optimal for accuracy in case of LoRA.
Fewer trainable parameters don’t make each epoch faster: LoRA’s many small operations are limited by GPU memory bandwidth. But its regularizing effect often means fewer epochs to converge. In one comparison at 95.7% validation accuracy, LoRA finishes in 27.0s, versus 36.1s for gradual fine-tuning.
Back to Theo
Recognizing Theo doesn’t require reinventing the neural network. The trick is deciding how much of an existing one to change.
With plenty of data, backbone fine-tuning gives us the best accuracy. With very few examples, frozen backbones hold up much better. LoRA lets us adapt the features while preserving that robustness, though plain linear probing proved to be surprisingly competitive.
The resource savings need a closer look. LoRA learns far fewer weights and tends to converge sooner, but deeper CNN LoRA-adapters can send memory use in the opposite direction. The choice of the optimal adaption strategy must take accuracy, VRAM and total training time together. Choose wisely.
Better adapters for CNNs and gradient checkpointing are promising next steps. For now, Theo’s takeaway is simple: small updates can go a long way.