Our first step is to provide the data. We will rely on datasets that have already been preprocessed, but our readers could use different kinds of images for their own GAN implementation. The idea is to keep separate a Dataset class that will have the task of providing batches of normalized and reshaped images to the GANs class we will build later.
In the initialization, we will deal with both images and their labels (if available). Images are first reshaped (if their shape differs from the one defined when instantiating the class), then shuffled. Shuffling helps GANs learning better if any order, for instance by class, is initially inscribed into the dataset - and this is actually true for any machine learning algorithm based ...