Deep Learning Academy · درس

الخسارة التنافسية

التدريب بطريقة Min-Max عمليًا

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

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

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

Loss Drives Both Players

Every GAN player learns from a loss that scores how well it did. The two losses pull in opposite directions, which is what makes training adversarial.

The Min-Max Game

GAN training is a min-max game: the discriminator tries to maximize its score while the generator tries to minimize it. Neither fully wins.

Binary Cross-Entropy

Most GANs measure each prediction with binary cross-entropy, the standard loss for a real-versus-fake yes or no decision.

criterion = nn.BCELoss()

Discriminator on Real Data

First the discriminator sees real images and should call them real. Its real loss pushes those outputs toward the label 1.

out_real = D(real)
loss_real = criterion(out_real, ones)

Discriminator on Fakes

Next it judges generated images and should call them fake. The fake loss pushes those outputs toward the label 0.

out_fake = D(fake.detach())
loss_fake = criterion(out_fake, zeros)

Why detach the Fakes

When updating the discriminator you call detach on the fakes so gradients do not flow back into the generator on this step.

fake.detach()

The Generator's Loss

The generator wants its fakes labeled real, so its loss compares the discriminator's verdict on fakes against the label 1.

out = D(fake)
loss_g = criterion(out, ones)

The Non-Saturating Trick

Telling the generator to maximize real-ness, instead of just minimizing fake-ness, gives stronger early gradients. This is the non-saturating loss.

Two Updates, One Round

Each training round does two updates: first the discriminator on its combined loss, then the generator on its own. Order and timing matter.

A Moving Target

Because both networks change every step, each one chases a moving target. This is why GAN losses bounce around instead of falling smoothly.

Losses Are Not Accuracy

In a GAN a falling loss does not mean better images. You judge quality by looking at samples, not by the loss number alone. 👀

Quick Check

One detail trips up many beginners.

Recap: Adversarial Loss

You saw the min-max game: cross-entropy guides both players, fakes are detached for the judge, and samples, not loss, reveal real progress. 🎯

البدء مجانًا

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

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

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

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

هل درس «الخسارة التنافسية» مجاني؟

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

ماذا ستتعلم في «الخسارة التنافسية»؟

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

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

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

كم من الوقت يستغرق درس «الخسارة التنافسية»؟

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

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

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

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

  1. Generator مقابل Discriminator: اللعبة
  2. الخسارة التنافسية
  3. بناء DCGAN
  4. انهيار الأنماط وحيل التثبيت
← العودة إلى Deep Learning Academy