Deep Learning Academy · درس

Softmax للاحتمالات

حوّل الدرجات الخام إلى توزيع للفئات

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

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

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

From Scores to Choices

A classifier's last layer spits out raw scores, one per class. These unbounded numbers are called logits, and they are hard to read directly. 🔢

Enter Softmax

Softmax turns a vector of logits into a clean probability distribution over all your classes. Now each score becomes a chance.

import torch.nn.functional as F
probs = F.softmax(logits, dim=-1)

Two Guarantees

Softmax promises two things: every output is between 0 and 1, and all of them sum to one. That is exactly what a distribution needs.

How It Works

Softmax exponentiates each logit, then divides by the total. The exponential makes bigger logits dominate, sharpening the winner.

exp = logits.exp()
probs = exp / exp.sum()

Relative, Not Absolute

Softmax cares about the gaps between logits, not their raw size. Adding the same constant to every logit leaves the probabilities unchanged.

Sigmoid vs Softmax

Use sigmoid for one yes-or-no output. Use softmax when classes compete and exactly one of several should win.

Picking the Winner

To get the predicted class, take the argmax of the softmax output. That index is the class with the highest probability.

pred = probs.argmax(dim=-1)

Mind the Dimension

Always set the right dim so softmax normalizes across classes, not across the batch. A wrong axis quietly ruins your probabilities.

Skip It While Training

During training you usually do not apply softmax yourself. The cross-entropy loss expects raw logits and applies it internally.

loss = F.cross_entropy(logits, target)  # logits, not probs

Why That Is Safer

Combining softmax and the log inside one function is more numerically stable. Doing both steps by hand can overflow or lose precision.

Temperature Tweaks Sharpness

Dividing logits by a temperature before softmax controls confidence. Low values sharpen the peak; high values flatten it out.

Quick Check

Think about what cross-entropy loss expects as its input.

Recap

Softmax converts logits into probabilities that sum to one, perfect for multiclass output. But let cross-entropy handle it during training. 🏁

البدء مجانًا

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

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

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

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

هل درس «Softmax للاحتمالات» مجاني؟

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

ماذا ستتعلم في «Softmax للاحتمالات»؟

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

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

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

كم من الوقت يستغرق درس «Softmax للاحتمالات»؟

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

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

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

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

  1. لماذا تفتح اللاخطية المجال للقوة الحقيقية
  2. ReLU وشقيقتاها Leaky وGELU
  3. Sigmoid وTanh: حصر القيم ضمن نطاق
  4. Softmax للاحتمالات
← العودة إلى Deep Learning Academy