๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #310

Pretrained Models

A pretrained model is one already trained on a large, general dataset, made available for others to reuse โ€” the actual starting point every transfer learning workflow begins from.

Where Pretrained Models Come From

DomainCommon Pretraining DatasetCommon Pretrained Models
Computer visionImageNet (1.2M+ labeled images, 1000 classes)ResNet, EfficientNet, ConvNeXt (see the CNN Architectures category)
NLPMassive text corpora (Wikipedia, books, web text)BERT, RoBERTa, GPT-family models
MultimodalLarge paired image-text datasetsCLIP and related vision-language models

Why Using a Pretrained Model Saves So Much

  • Compute: the original pretraining (potentially thousands of GPU-hours) never needs to be repeated.
  • Data: your target task can use a far smaller labeled dataset than would be needed training from scratch, since general knowledge is already captured.
  • Time: adapting a pretrained model to a new task typically takes hours, not the days/weeks full pretraining requires.

Code โ€” Loading Pretrained Models in Practice

import torchvision.models as models
from transformers import AutoModel

# Vision: many architectures available with pretrained ImageNet weights
resnet = models.resnet50(weights="IMAGENET1K_V2")
efficientnet = models.efficientnet_b0(weights="IMAGENET1K_V1")

# NLP: the Hugging Face Hub hosts thousands of pretrained models
bert_model = AutoModel.from_pretrained("bert-base-uncased")
roberta_model = AutoModel.from_pretrained("roberta-base")

Choosing a Pretrained Model โ€” What Matters

ConsiderationWhy It Matters
What it was originally trained onCloser alignment with your target domain generally transfers better
Model sizeLarger pretrained models often have richer general knowledge, but cost more to run and fine-tune
License and usage termsNot every pretrained model is freely usable for every purpose โ€” worth checking explicitly before deploying

Common Mistakes

  • Defaulting to the largest available pretrained model without considering compute constraints โ€” a smaller model that's easier to fine-tune and deploy is often the more practical choice, especially early in a project.
  • Assuming pretrained model weights are always free to use commercially without checking licensing โ€” usage terms genuinely vary across different pretrained models and providers.

Interview Relevance

Q: "What factors would you weigh when choosing which pretrained model to start from for a new project?" How closely the pretraining data/task aligns with your target domain (closer alignment generally transfers better), the model's size relative to your compute and latency constraints, and licensing/usage terms for your intended application โ€” not just raw benchmark performance in isolation.

Practice Question

For a medical image classification task with a small labeled dataset, would you expect a general ImageNet-pretrained model to transfer well? What might limit how well it transfers?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

Pretrained Models โ€“ FAQs

Quick answers about learning Pretrained Models in Deep Learning.

This free note from CodingNow 2.0 explains Pretrained Models in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including Pretrained Models, is 100% free with no signup required.
With focused practice, most students grasp Pretrained Models in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now