Batch Norm وLayer Norm
ثبّت التنشيطات للتدريب بعمق أكبر
Batch Norm وLayer Norm درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why Normalize Activations
As signals flow through layers, their scale drifts and training slows. Normalization keeps activations in a stable, well-behaved range. ⚖️
Batch Norm in One Line
Batch normalization rescales each feature using the mean and variance computed across the current mini-batch.
Add Batch Norm
You drop in a batch norm layer after a linear or conv layer. Use nn.BatchNorm1d for dense features and BatchNorm2d for images.
self.bn = nn.BatchNorm1d(128)
x = torch.relu(self.bn(self.fc(x)))Learnable Scale and Shift
Batch norm adds two trainable parameters, gamma and beta, so the network can rescale and shift the normalized output as it needs.
It Lets You Train Deeper
By steadying activations, batch norm allows higher learning rates and deeper networks that would otherwise be hard to train.
Train vs Eval Stats
During training, batch norm uses batch statistics; at eval it switches to running averages, so call model.eval() before testing.
Batch Size Matters
Batch norm depends on the batch. With very small batches the statistics get noisy and the benefit can disappear.
Enter Layer Norm
Layer normalization normalizes across the features of a single sample, so it does not depend on the batch at all.
Add Layer Norm
Layer norm shines in transformers and RNNs. You add it with nn.LayerNorm, passing the size of the features to normalize.
self.ln = nn.LayerNorm(256)
x = self.ln(x)Same Behavior Both Modes
Because layer norm uses per-sample statistics, it behaves the same in training and eval, which suits variable batch sizes.
Which One to Pick
Reach for batch norm in conv vision models and layer norm in sequence and transformer models, where batches and lengths vary.
Quick Check
Recall the key difference between the two normalization styles.
Recap
You compared normalization: batch norm uses batch statistics and helps CNNs, while layer norm works per-sample and powers transformers. 🚀
الأسئلة الشائعة
هل درس «Batch Norm وLayer Norm» مجاني؟
نعم — نص درس «Batch Norm وLayer Norm» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
ماذا ستتعلم في «Batch Norm وLayer Norm»؟
ثبّت التنشيطات للتدريب بعمق أكبر تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟
لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «Batch Norm وLayer Norm»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟
نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- قراءة الفجوة بين التدريب والتحقق
- Dropout: إسقاط الخلايا العصبية عشوائيًا
- Batch Norm وLayer Norm
- زيادة البيانات كبيانات مجانية