Preparing our data for image classification
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: which contains images of 10 different classes of clothing (shirts, trousers, shoes, and so on). Let’s prepare this dataset:
The following code can be found in the Preparing_our_data.ipynb file located in the Chapter03 folder on GitHub at https://bit.ly/mcvp-2e.
- Start by downloading the dataset and importing the relevant packages. The 
torchvisionpackage contains various datasets, one of which is theFashionMNISTdataset, which we will work 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)
 ...