0Pricing
Deep Learning Academy · Lekcja

Strata przeciwstawna

Stosować uczenie minimax w praktyce

Strata przeciwstawna to bezpłatna lekcja Deep Learning Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Deep Learning Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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. 🎯

Często zadawane pytania

Czy lekcja „Strata przeciwstawna” jest bezpłatna?

Tak — pełny tekst „Strata przeciwstawna” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Deep Learning Academy, przejdź na CoddyKit PRO. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Strata przeciwstawna”?

Stosować uczenie minimax w praktyce Ćwiczysz Deep Learning Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Deep Learning Academy?

Nie wymagamy żadnego doświadczenia. Deep Learning Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Strata przeciwstawna”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Deep Learning Academy?

Tak. Każda lekcja Deep Learning Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Generator a dyskryminator: gra
  2. Strata przeciwstawna
  3. Zbudować DCGAN
  4. Zapaść trybów i sztuczki stabilizujące
← Powrót do Deep Learning Academy