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 CIFAR-10 dataset.8 The images in this dataset are part of a larger 80 million “small image” dataset9, most of which do not have class labels like CIFAR-10. For CIFAR-10, the labels were initially created by student volunteers10, and the larger small image dataset allows researchers to submit labels for parts of the data.
CIFAR-10 can be downloaded using PyTorch:
import torch
from torch.utils.data import Dataset
from torchvision import datasets
from torchvision.transforms import ToTensor
import matplotlib.pyplot as plt
cifar10_train = datasets.CIFAR10(
root="data",
train=True,
download=True,
transform=ToTensor()
)
cifar10_test = datasets.CIFAR10(
root="data"...