Given that we are covering multiple scenarios in this chapter, in order for us to see the advantage of one scenario over the other, we will work on a single dataset throughout this chapter – the Fashion MNIST dataset. Let's prepare this dataset:
The following code is available as Preparing_our_data.ipynb in the Chapter03 folder of this book's GitHub repository - https://tinyurl.com/mcvp-packt
- Start by downloading the dataset and importing the relevant packages. The torchvision package contains various datasets – one of which is the FashionMNIST dataset, which we will be working on in this chapter:
from torchvision import datasets
import torch
data_folder = '~/data/FMNIST' # This can be any directory
# you want to download FMNIST to
fmnist = datasets.FashionMNIST(data_folder, download=True, \
train=True)
In the preceding code, we are specifying the folder (data_folder) where we...