Pretraining initializes a model with weights learned on a source dataset before adapting it to a downstream task. For image classification, a ResNet pretrained on ImageNet starts with convolutional filters already shaped by a large set of images; replacing its final layer supplies a new, randomly initialized classifier for the target labels. section 13.2.1
The intuition is that early convolutional layers learn broadly useful visual features, such as edges, colors, and changes in color. Those features can provide a better starting point than random weights when learning a new image task. section 13.2.1
Pretrained weights can be used in different ways during adaptation:
- A warm start allows the pretrained weights to change during training; frozen weights remain constant. These choices offer different benefits depending on how much data is available. section 13.6
- A warm start is a general optimization strategy, not a synonym for transfer learning: initial weights need only be expected to be closer to the desired solution than random weights. section 13.2.3
model_pretrained = torchvision.models.resnet18(pretrained=True) #1 model_pretrained.fc = nn.Linear(model_pretrained.fc.in_features, 2) #2
This PyTorch example loads pretrained ResNet-18 weights, then replaces the final layer with a two-output classifier. section 13.2.1













