Appending augmented data to original training set


I am new to PyTorch and currently looking to perform data augmentation on the FashionMNIST data, through flip and crop transformations. After that, would like to add these transformed data tensors to the training set to get an expanded dataset. The transforms I am using are as follows:

aug_transform = transforms.Compose([transforms.RandomVerticalFlip(p = 0.5),
transforms.RandomResizedCrop((28, 28),(0.9, 1.0)),
transforms.Normalize((0.5,), (0.5,)),

Are there any ways that you would suggest adding the augmented tensors to the training set? Also, is it possible to add the transformation on the existing training data on the fly (dynamically) while training the model?

You could create two separate datasets, the standard one and the other one with transformations, and combine them into a ConcatDataset.

The transformations will be applied on-the-fly by default on each sample in the __getitem__ method of the dataset.

1 Like

Thank you, @ptrblck. It works like a charm.