You don't have to start from scratch — usually you shouldn't
A model pretrained on a huge dataset (ImageNet for vision, the Common Crawl for text) has learned representations that generalize. Adapting that to your specific task — almost always — beats training a fresh model on your (much smaller) dataset, even when your task seems unrelated.
Two extremes, plus the middle
- Feature extraction — freeze the entire pretrained model, train only a new head. Cheap, fast, needs little data. Works well when your task is "close enough" to the pretraining task.
- Full fine-tuning — unfreeze everything, train the whole model on your data with a small learning rate. Best results, needs more data and care. Standard for serious work.
- Partial fine-tuning — freeze early layers (which learn generic features) and unfreeze later layers (which learn task-specific features). The pragmatic middle.
The big modern addition: parameter-efficient fine-tuning
For huge models (BERT-large, Llama, ViT-Huge), even full fine-tuning is expensive — you need to update billions of parameters. LoRA (Low-Rank Adaptation) and friends inject tiny trainable matrices alongside the frozen weights, training as little as 0.1–1% of the parameters while matching full-fine-tune quality. We'll get to LoRA in a later lesson; for now, just know it exists and changes the economics.
The torchvision weights API — modern
The old models.resnet50(pretrained=True) is deprecated. The modern call is models.resnet50(weights=ResNet50_Weights.IMAGENET1K_V2). The new API gives you versioned weights AND weights.transforms() — the exact preprocessing the model was trained with. Always use it.