In this example, we want to build a DCGAN (proposed in Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks, Radford A., Metz L., Chintala S., , arXiv:1511.06434 [cs.LG]) with the Fashion-MNIST dataset (obtained through the keras helper function). As the training speed is not very high, we limit the number of samples to 5,000, but I suggest repeating the experiment with larger values. The first step is loading and normalizing (between -1 and 1) the dataset:
import numpy as npfrom keras.datasets import fashion_mnistnb_samples = 5000(X_train, _), (_, _) = fashion_mnist.load_data()X_train = X_train.astype(np.float32)[0:nb_samples] / 255.0X_train = (2.0 * X_train) - 1.0 ...