I understand that the transforms we put on the dataset only happen when we actually call the data (for example, iterating over a dataloader). However, for creating a randomized dataset of any sort this will give different inputs (for the same initial images). Is there a way to make the dataset fixed? I guess seeding before each time we loop on the dataloader is possible but I’m looking for something more robust.
import torch from torchvision import datasets, transforms from torch.utils.data import DataLoader transform = transforms.Compose([ transforms.RandomRotation(100), transforms.ToTensor() ]) mnist_train = datasets.MNIST("../mnist_train",download=True,train=True, transform=transform ) loader = DataLoader(mnist_train, batch_size=1, shuffle=False)
If you will try to run this (the sum of the first input values), you should get different results each time due to the random transformation happening dynamically:
I will want to pre-compute the transform somehow so the dataloader will be static.