Deep Learning Academy · درس

جمّد Backbone ودرّب Head

أعد استخدام الميزات المتعلَّمة بتكلفة منخفضة

الدرس 1 من 413 خطوة

جمّد Backbone ودرّب Head درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Borrow a Smart Brain

Why train from zero? A model already trained on millions of images has learned useful features. Transfer learning reuses that knowledge for your task. 🧠

Backbone vs Head

A pretrained model has two parts: the backbone that extracts general features, and the head that makes the final prediction for its original task.

The Plan

The simplest recipe: freeze the backbone so it stays as is, then swap in a fresh head and train only that part on your own labels.

Load a Pretrained Model

Start with a model that already carries good weights. torchvision hands you popular architectures with one call.

from torchvision import models
model = models.resnet18(weights='DEFAULT')

Freezing Means No Gradients

To freeze a layer you set requires_grad to False. PyTorch then skips computing gradients for it, so its weights never change.

for p in model.parameters():
    p.requires_grad = False

Why Freeze at All?

Freezing the backbone keeps its hard-won features intact and means far fewer weights to update. That makes training faster and works with little data.

Swap the Head

The old head predicts the wrong classes. Replace it with a fresh Linear layer sized for your number of classes.

import torch.nn as nn
model.fc = nn.Linear(512, 3)

The New Head Is Trainable

A brand-new layer starts with requires_grad set to True automatically. So only your head will learn while the frozen backbone watches.

Optimize Only the Head

Pass just the head's parameters to your optimizer. Updating only these few weights is what makes this approach so cheap.

opt = torch.optim.Adam(model.fc.parameters(), lr=1e-3)

The Backbone Becomes an Extractor

With its weights frozen, the backbone simply turns each image into a rich feature vector. Your head learns to read those features.

When This Shines

Freeze-and-train-head is ideal with a small dataset or limited compute. You get strong results in minutes instead of days.

Quick Check

You froze the backbone and replaced the head. Which weights actually update during training?

Recap

You learned to borrow a pretrained backbone, freeze it, attach a fresh head, and train just that head. Fast, cheap, and great with small data. 🎯

البدء مجانًا

تعلم Python مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
30
الدروس
120

الأسئلة الشائعة

هل درس «جمّد Backbone ودرّب Head» مجاني؟

نعم — نص درس «جمّد Backbone ودرّب Head» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

ماذا ستتعلم في «جمّد Backbone ودرّب Head»؟

أعد استخدام الميزات المتعلَّمة بتكلفة منخفضة تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟

لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «جمّد Backbone ودرّب Head»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟

نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. جمّد Backbone ودرّب Head
  2. الضبط الدقيق بمعدل تعلّم أقل
  3. معدلات تمييزية حسب الطبقة
  4. ضبط نموذج Hugging Face دقيقًا
← العودة إلى Deep Learning Academy