Path: blob/master/examples/generative/ipynb/dcgan_overriding_train_step.ipynb
8214 views
Kernel: Python 3
DCGAN to generate face images
Author: fchollet
Date created: 2019/04/29
Last modified: 2023/12/21
Description: A simple DCGAN trained using fit() by overriding train_step on CelebA images.
Setup
In [0]:
Prepare CelebA data
We'll use face images from the CelebA dataset, resized to 64x64.
In [0]:
Create a dataset from our folder, and rescale the images to the [0-1] range:
In [0]:
Let's display a sample image:
In [0]:
Create the discriminator
It maps a 64x64 image to a binary classification score.
In [0]:
Create the generator
It mirrors the discriminator, replacing Conv2D layers with Conv2DTranspose layers.
In [0]:
Override train_step
In [0]:
Create a callback that periodically saves generated images
In [0]:
Train the end-to-end model
In [0]:
Some of the last generated images around epoch 30 (results keep improving after that):
