StyleGAN
Most generators stir z into every layer at the same time. StyleGAN split it apart: first map z to an intermediate w, then inject w at every resolution level through AdaIN. That single change untangled the latent space and made photorealistic faces a solved problem for seven years running. A DCGAN maps z to an image through a stack of transposed convolutions. The problem: z controls everything — pose, lighting, identity, background — entangled together. Move along one axis of z, all four change. You cannot ask the model "same person, different pose" because the representation does not factor that way. Karras et al. (2019, NVIDIA) proposed: stop feeding z directly into conv layers. Feed a constant 4×4×512 tensor as the network input. Learn an 8-layer MLP that maps z ∈ Z → w ∈ W. Inject w at every resolution via adaptive instance normalization (AdaIN): normalize each conv feature map, then scale and shift by affine projections of w. Add per-layer noise for stochastic detail (skin pores, hair strands). The result: W has roughly orthogonal axes for "high-level style" (pose, identity) vs "fine style" (lighting, color). You can swap styles between two images by using image A's w for the low-resolution levels and image B's w for the high. This unlocked editing, cross-domain stylization, and the entire "StyleGAN-inversion" line…
StyleGAN: Most generators stir z into every layer at the same time. StyleGAN split it apart: first map z to an intermediate w, then inject w at every…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.