Notes

Layer Freezing

Imagine starting with a vision model that has already learned to notice edges, textures, shapes, and object parts from millions of images. Layer freezing lets you preserve that useful visual knowledge while teaching the model a new job, rather than retraining every part from scratch.

What is frozen

A neural network is built from layers with learned numerical settings called weights. During training, an optimizer updates these weights to reduce errors. When a layer is frozen, its weights are excluded from those updates: it still processes images and passes information forward, but it does not change.

In transfer learning, a common setup is to freeze a pretrained backbone—such as ResNet, EfficientNet, or a Vision Transformer—and train only a new classification head, detector head, or segmentation head. In PyTorch, this is commonly done by setting a parameter’s requires_grad value to False.

Why this helps

  • Less data is needed: the model reuses general visual features instead of needing to rediscover them from a small dataset.
  • Training is faster: fewer weights require gradient calculations and updates.
  • Useful knowledge is protected: freezing reduces the risk that limited or noisy new data will overwrite robust pretrained features, a problem called catastrophic forgetting.

How it is used in vision

For example, a factory may have only 800 labeled photos of defective parts. A pretrained image model can keep its early and middle layers frozen while a new head learns “defective” versus “acceptable.” For medical-image segmentation or satellite imagery, practitioners commonly first train with the backbone frozen, then unfreeze later layers and fine-tune them with a small learning rate. Early layers capture broadly reusable patterns such as edges; deeper layers are more task-specific and benefit most from adaptation. Freezing too much can leave the model unable to learn a genuinely different visual domain, while freezing too little can overfit a small dataset.

Layer freezing is a transfer-learning technique that prevents selected layers of a pretrained vision model from updating during training, while remaining layers—typically a new task-specific head—are optimized. It preserves reusable visual features learned from large datasets and reduces trainable parameters, training cost, and overfitting on small target datasets. Freezing too many layers can limit adaptation when the new image domain differs substantially from pretraining data.

Imagine hiring an experienced chef to make one new dish. You would not ask them to forget everything they know about chopping, seasoning, and cooking basics. You would keep those skills intact and teach them the new recipe.

Layer freezing does something similar for an AI model. A model trained on many images has already learned useful visual basics, such as edges, shapes, and textures. When adapting it to a new job—like spotting plant diseases—developers “freeze” some of those learned parts so they stay unchanged. The remaining parts learn the new task. This saves time, needs less new data, and helps preserve valuable prior knowledge.