Course contentsShow
← Machine Learning and Deep Learning
Lesson 1492 of 3,53833. Generative Adversarial NetworksFree lesson

CycleGAN: Unpaired Image Translation

Learning bidirectional mappings between domains without paired data using cycle consistency loss.

CycleGAN: Unpaired Image Translation

What you'll learn: How CycleGAN translates images between domains (like horses ↔ zebras) without needing matched pairs of training images.

The Challenge of Unpaired Translation

Pix2Pix requires paired training data: matching images from both domains (e.g., a photo of a building and its architectural sketch). But what if you just have two separate collections—photos of horses and photos of zebras—with no correspondence? CycleGAN solves this.

The Core Idea: Cycle Consistency

CycleGAN uses two generators and two discriminators:

  • Generator G: translates domain A → B (horse → zebra)
  • Generator F: translates domain B → A (zebra → horse)
  • Discriminators: one for each domain to judge realism

The breakthrough is cycle consistency loss: if you translate a horse to a zebra (using G), then translate that zebra back to a horse (using F), you should get the original horse back. This roundtrip constraint enforces that the translation preserves content while changing style.

Think of it like translating English → French → English. If the final result doesn't match your original sentence, something went wrong in translation.

The Loss Function

CycleGAN combines three losses:

  1. Adversarial losses: both generators fool their respective discriminators
  2. Cycle consistency loss: |F(G(x)) - x| and |G(F(y)) - y|
  3. Identity loss (optional): if you "translate" a zebra image using the zebra generator, it should stay unchanged

This elegant approach enables learning meaningful mappings without paired data, opening doors to countless creative applications.

Key Takeaway: CycleGAN learns bidirectional image translation between unpaired datasets by enforcing that translating forward then backward returns the original image, using cycle consistency loss to maintain content while transforming style.