Improving the clothing image classifier with data augmentation
Armed with several common augmentation methods, we will now apply them to train our image classifier on a small dataset in the following steps:
- We start by constructing the transform function by combining all the data augmentation techniques we just discussed:
>>> torch.manual_seed(42) >>> transform_train = transforms.Compose([ transforms.RandomHorizontalFlip(), transforms.RandomRotation(10), transforms.RandomResizedCrop(size=(28, 28), scale=(0.9, 1)), transforms.ToTensor(), ])
Here, we employ horizontal flip, rotation of up to 10 degrees, and cropping, with dimensions ranging from 90% to 100% of the original size.
- We reload the training dataset with this transform function and only use 500 samples for training...