What Is Transfer Learning? Pretrained Models, Freezing vs Fine-Tuning, for Images and Text
Transfer learning reuses a model already trained on a large dataset, such as ImageNet for images or a large text corpus for language, as the starting point for your own task. You keep the pretrained backbone, replace the final layer with one for your classes, and either freeze the backbone and train only the new head, or fine-tune some or all layers at a low learning rate. It lets you build accurate image and text models from hundreds of examples instead of hundreds of thousands. On TensorTurn you can ask for a transfer learning setup in plain English and it generates and runs the PyTorch or Keras notebook on a GPU.
What is transfer learning?
Training a deep network from scratch means learning everything from raw pixels or tokens: edges, textures, shapes, grammar, word meaning. That takes enormous data and compute. Transfer learning skips most of it. A model pretrained on a broad dataset has already learned general-purpose features, and those features are useful for many related tasks. You transfer that knowledge and only teach the model what is specific to your problem.
It works because early layers of a network learn generic patterns, such as edges and colour blobs in vision or common word relationships in language, while later layers become more task-specific. The more similar your data is to the pretraining data, the more of the network you can reuse unchanged.
Popular pretrained backbones for images and text
| Domain | Backbones | Pretrained on | Common sources |
|---|---|---|---|
| Image classification | ResNet, EfficientNet, ConvNeXt, MobileNet | ImageNet | torchvision, timm, Keras Applications |
| Image features | Vision Transformer (ViT), DINOv2 | Large image collections, often self-supervised | Hugging Face, timm |
| Object detection and segmentation | YOLO models | COCO | Ultralytics |
| Text classification and NER | BERT, DistilBERT, RoBERTa | Large general text corpora | Hugging Face transformers |
| Text similarity and search | Sentence-transformer models | Paired sentence datasets | Hugging Face |
Smaller backbones (MobileNet, DistilBERT) train and serve faster and are often enough; larger ones help when classes are subtle or data is plentiful. Start small and scale up only if validation results justify it.
Feature extraction vs fine-tuning: which layers to freeze
The main decision in transfer learning is how much of the pretrained network to update. Freezing a layer means its weights stay fixed during training.
| Strategy | What gets trained | Best when | Risk |
|---|---|---|---|
| Feature extraction (freeze all) | Only the new classification head | Small dataset, similar to pretraining data | Underfits if your domain is very different |
| Partial fine-tuning | Head plus the top few blocks | Moderate data, or domain somewhat different | Needs a lower learning rate for unfrozen layers |
| Full fine-tuning | Every layer | Large dataset, or very different domain (medical scans, satellite images, legal text) | Overfitting and catastrophic forgetting with small data or high learning rates |
A useful rule of thumb: little data and similar domain, freeze more; lots of data or a different domain, unfreeze more. Transformer models for text are usually fully fine-tuned with a small learning rate, because they adapt well and the head alone often underperforms.
A practical transfer learning recipe
- Match the pretraining preprocessing exactly: the same image size and normalization statistics for vision models, the same tokenizer for text models.
- Replace the final layer with one sized to your number of classes.
- Freeze the backbone and train only the head for a few epochs with a normal learning rate.
- Unfreeze the top blocks (or the whole model) and continue at a learning rate roughly 10 to 100 times smaller, optionally with lower rates for earlier layers.
- Use data augmentation for images (flips, crops, colour jitter) that reflects real variation in your data.
- Use early stopping on a validation set, and keep a separate test set untouched until the end.
Common transfer learning mistakes
- Wrong normalization or tokenizer, which silently feeds the backbone inputs unlike anything it was trained on.
- A learning rate that is too high during fine-tuning, which destroys the pretrained features in the first few steps.
- Near-duplicate images split across train and test, which makes a fine-tuned model look far better than it is.
- Mislabeled examples in a small dataset; with only hundreds of images, a few wrong labels matter a lot.
- Forgetting batch normalization behaviour when freezing layers in some frameworks, which can make frozen layers drift.
How to use transfer learning on TensorTurn
- Upload an image archive (zip, rar or 7z) or a text dataset as CSV, JSON or Parquet, or import it from a URL, Hugging Face or Kaggle.
- For images, run the data checks first: in-browser detection of exact and near-duplicate, blurry, corrupt and badly exposed images, and a DINOv2 GPU pass that finds cross-split leakage and likely mislabeled images with a suggested correct label.
- Describe the setup in chat, for example: fine-tune a pretrained EfficientNet in PyTorch, freeze the backbone for 3 epochs then unfreeze the last two blocks at a lower learning rate. For text, ask for a Hugging Face transformers model such as DistilBERT inside the notebook.
- TensorTurn generates and runs the notebook on cloud GPUs or your own connected GPU, and patches failing cells automatically if something errors.
- Compare the reported metrics, adjust the freezing strategy in plain English, then deploy the best weights to a /predict endpoint or export to ONNX.
See the plant disease detection and text classification use cases for transfer learning applied end to end.
Frequently asked questions
What is the difference between transfer learning and fine-tuning?
Transfer learning is the general idea of reusing a pretrained model for a new task. Fine-tuning is one way to do it, where you continue training some or all pretrained layers on your data, as opposed to feature extraction, where the backbone stays frozen and only a new head is trained.
How much data do I need for transfer learning?
Far less than training from scratch. For image classification, a few hundred labeled images per class is often enough for useful results, and text classifiers fine-tuned from BERT-style models can work with similar amounts.
Which layers should I freeze?
With little data and a domain similar to the pretraining data, freeze the whole backbone and train only the head. With more data or a different domain, unfreeze the top blocks or the entire network and use a much lower learning rate.
Can transfer learning work on medical or satellite images?
Yes, ImageNet-pretrained backbones still give a better starting point than random weights for most image domains. Because these domains differ from everyday photos, you typically fine-tune more layers rather than only training the head.
Does transfer learning work for tabular data?
Much less commonly. Pretrained backbones exist mainly for images, text and audio. For tables, gradient-boosted trees are usually the strongest option, although tabular foundation models are an active research area.