Importing CIFAR
Now that we've discussed the underlying theory of VAE algorithms, let's start building a practical example using a real-world dataset. As we discussed in the introduction, for the experiments in this chapter, we'll be working with the Canadian Institute for Advanced Research (CIFAR) 10 dataset.10 The images in this dataset are part of a larger 80 million "small image" dataset11, most of which do not have class labels like CIFAR-10. For CIFAR-10, the labels were initially created by student volunteers12, and the larger tiny images dataset allows researchers to submit labels for parts of the data.
Like the MNIST dataset, CIFAR-10 can be downloaded using the TensorFlow dataset's API:
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds
cifar10_builder = tfds.builder("cifar10")
cifar10_builder.download_and_prepare()
This will download the dataset to disk and make it available for our experiments. To split...