← All projects

Fake Faces with DCGAN

Synthetic faces are now cheap enough to be a privacy and misinformation risk. To understand what they get right and wrong, I trained a deep convolutional GAN on CelebA from scratch, and compared it with two likelihood-based generators.

  • Generative adversarial networks
  • EECS 6327 · Probabilistic Models in ML
  • York University
  • PyTorch · CelebA
100epochs, about 30 s each
50 mintotal training, the fastest of the three models
z ∈ ℝ100latent noise, 64 feature maps in G and D
2e-4learning rate, Adam with β1 = 0.5, batch 128

Real or fake?

Spot the generated face

Game

Each tile is cut from either a grid of real CelebA photos or a grid of my DCGAN's samples, both at the same low resolution. Make a call, then see the answer.

How DCGAN works

Two networks play a minimax game. The generator G turns random noise into an image; the discriminator D sees real and generated images and outputs the probability that its input is real. G improves only by fooling D. At the game's equilibrium G reproduces the data distribution and D can do no better than a coin flip.

  1. All-convolutionalStrided convolutions replace pooling, so the networks learn their own up- and down-sampling.
  2. Batch normNormalisation in both networks (except G's output and D's input) keeps gradients healthy.
  3. ActivationsReLU in the generator with tanh at the output; LeakyReLU throughout the discriminator.
  4. LossBinary cross-entropy on D's real/fake call, optimised with Adam for both players.

Results

An 8 by 8 grid of faces generated by the DCGAN
Samples from my DCGAN after 100 epochs.
An 8 by 8 grid of real CelebA photos
Real CelebA images at the same resolution.

The samples are convincing at thumbnail size, especially for hair and skin tone. Up close, the classic GAN failures show: asymmetric eyes, warped jawlines and a few near-duplicate faces, a sign of partial mode collapse. Adversarial training also never settles; the generator and discriminator losses keep oscillating rather than converging.

How it compares

The same study trained a normalizing flow and a variational autoencoder on the same data. Each family trades speed, sharpness and structure differently.