فحص المعاملات وأشكال الطبقات
اطّلع بدقة على ما يحتفظ به نموذجك
فحص المعاملات وأشكال الطبقات درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Look Inside Your Model
Once a model exists, you can peek at every weight it holds. Inspecting the parameters builds trust before you train.
Loop Over parameters()
Call model.parameters() to iterate over every learnable tensor. The optimizer uses this exact same list.
for p in model.parameters():
print(p.shape)Names With named_parameters()
Use named_parameters() to see each tensor paired with its name, so you know which layer it belongs to.
for name, p in model.named_parameters():
print(name, p.shape)Weight and Bias Shapes
A linear layer holds a weight matrix and a bias vector. Their shapes follow directly from the in and out features.
fc = nn.Linear(4, 3)
print(fc.weight.shape) # torch.Size([3, 4])Count the Parameters
Sum the elements of every tensor to get a total parameter count, a quick measure of model size.
total = sum(p.numel() for p in model.parameters())Print the Whole Model
Just printing the model shows its layers and their sizes in order. It is the fastest overview you can get.
print(model)Check Output Shape Live
Pass a sample batch through and print the result's shape to confirm dimensions line up end to end.
out = model(torch.randn(1, 4))
print(out.shape)See What Trains
The requires_grad flag tells you which tensors get updated. Frozen layers show it as False.
for p in model.parameters():
print(p.requires_grad)Group With state_dict
The state_dict maps every parameter name to its tensor. It is what you save and load to checkpoint a model.
model.state_dict().keys()Debug Shape Mismatches
Most beginner errors are shape mismatches between layers. Printing shapes pinpoints exactly where the chain breaks.
Know Your Model Cold
Inspecting parameters and shapes turns a black box into something you fully understand. Confidence comes from looking. 🔍
Quick Check
Recall the call that lists each weight tensor with its layer name.
Recap
Use parameters, named_parameters, and printing the model to inspect weights and shapes. This habit makes debugging fast and painless. 🎯
الأسئلة الشائعة
هل درس «فحص المعاملات وأشكال الطبقات» مجاني؟
نعم — نص درس «فحص المعاملات وأشكال الطبقات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
ماذا ستتعلم في «فحص المعاملات وأشكال الطبقات»؟
اطّلع بدقة على ما يحتفظ به نموذجك تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟
لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «فحص المعاملات وأشكال الطبقات»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟
نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- توريث nn.Module: __init__ وforward
- تكديس الطبقات الخطية
- nn.Sequential للنماذج السريعة
- فحص المعاملات وأشكال الطبقات