अब हम Deep Learning में Pretrained Models की बात करेंगे, जो Transfer Learning की रीढ़ की हड्डी हैं।
ये models पहले से बहुत बड़े datasets पर train हो चुके हैं, और इन्हें विभिन्न tasks में reuse किया जा सकता है।
🔶 1. What are Pretrained Models?
Pretrained Models वे deep learning architectures होते हैं जिन्हें पहले से किसी बड़े dataset (जैसे ImageNet या Wikipedia) पर train किया गया है।
आप इन्हें reuse करके:
- Feature Extraction कर सकते हैं
- Fine-Tuning कर सकते हैं
- Zero-shot tasks भी perform कर सकते हैं (कुछ models)
🎯 क्यों ज़रूरी हैं?
✅ Save time and computation
✅ बेहतर performance, खासकर छोटे datasets पर
✅ Common architectures को standard बनाना
✅ Foundation models का निर्माण
🔷 A. Pretrained Models in Computer Vision
1. VGGNet
- 🧠 Developed by: Visual Geometry Group, Oxford
- 📆 Year: 2014
- 📐 Architecture: Simple CNNs with 3×3 convolutions
- 🧱 Versions: VGG-16, VGG-19
- ⚠️ Downside: Large number of parameters, slow
from torchvision import models
vgg = models.vgg16(pretrained=True)
2. ResNet (Residual Network)
resnet = models.resnet50(pretrained=True)
3. Inception (GoogLeNet)
- 🧠 By: Google
- 📆 Year: 2014
- 🔄 Inception Module: Multiple filter sizes in parallel
- 🧠 Deep but Efficient
- 📊 Version: Inception-v1, v2, v3, v4
inception = models.inception_v3(pretrained=True)
🔷 B. Pretrained Models in Natural Language Processing (NLP)
4. BERT (Bidirectional Encoder Representations from Transformers)
- 🧠 By: Google AI
- 📆 Year: 2018
- 🔍 Key Idea: Bidirectional context + Masked Language Modeling
- 🌍 Trained On: Wikipedia + BookCorpus
- ✅ Used for: Text classification, Q&A, NER, etc.
- 🔁 Fine-tune specific to downstream tasks
from transformers import BertModel, BertTokenizer
model = BertModel.from_pretrained("bert-base-uncased")
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
📊 Comparison Table
Model | Domain | Strengths | Weakness |
---|---|---|---|
VGG | Vision | Simplicity | Too many parameters |
ResNet | Vision | Deep + residual connections | Slightly complex |
Inception | Vision | Multi-scale processing | Harder to modify |
BERT | NLP | Powerful language understanding | Large memory usage |
🧠 Use Cases of Pretrained Models
Task | Model |
---|---|
Image Classification | ResNet, VGG |
Object Detection | Faster R-CNN with ResNet |
Semantic Segmentation | DeepLab, U-Net |
Sentiment Analysis | BERT |
Machine Translation | mBERT, T5 |
Question Answering | BERT, RoBERTa |
📝 Practice Questions
- Pretrained model क्या होता है?
- VGG और ResNet में क्या अंतर है?
- Inception module का उद्देश्य क्या है?
- BERT किस तरीके से context को समझता है?
- Vision और NLP में कौन-कौन से pretrained models आम हैं?
🧠 Summary
Feature | Vision | NLP |
---|---|---|
Basic CNN | VGG | – |
Deep Network | ResNet | BERT |
Advanced Structure | Inception | Transformer variants |
Library | torchvision | transformers (HuggingFace) |