2. Implementing DCGAN in Keras
Figure 4.2.1 shows DCGAN that is used to generate fake MNIST images:
Figure 4.2.1: A DCGAN model
DCGAN implements the following design principles:
- Use strides > 1, and a convolution instead of
MaxPooling2D
orUpSampling2D
. With strides > 1, the CNN learns how to resize the feature maps. - Avoid using
Dense
layers. Use CNN in all layers. TheDense
layer is utilized only as the first layer of the generator to accept the z-vector. The output of theDense
layer is resized and becomes the input of the succeeding CNN layers. - Use Batch Normalization (BN) to stabilize learning by normalizing the input to each layer to have zero mean and unit variance. There is no BN in the generator output layer and discriminator input layer. In the implementation example to be presented here, no batch normalization is used in the discriminator.
- Rectified Linear Unit (ReLU) is used in all layers of the generator except...