In the previous recipe, our was able to generate realistic examples after a few epochs. The MNIST dataset has a low translation invariance, so it's easier for our network to generate these examples. In the early days of GANs, the networks were very unstable and small changes could mess up the output. In 2016, DCGANs were introduced. In DCGANs, both the discriminator and the generator are fully convolutional, and the output of DCGANs has proven to be more stable. In our next recipe, we will increase the complexity of our dataset by using the Fashion-MNIST dataset and demonstrate how to implement DCGANs in PyTorch.
- We start by importing the libraries, as follows:
import matplotlib.pyplotasplt importitertoolsimporttorchimporttorch.nnasnnimporttorch.nn.functionalasFimporttorch.optimasoptimfromtorch.autogradimportVariablefromtorch.utils.data.datasetimportDatasetimporttorchvision.datasetsasdsetimporttorchvision.transformsastransforms...