when i use
train_transforms = torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.1307,), (0.3081,))
])
for loading MNIST dataset, it slows down learning even with mean = 0
and std = 1
.
The transformations are performed on CPU, and it doesn't matter if the mean/std are all zeros (BTW, don't set std to 0). To speed up the transform you have two options:
torch.utils.data.DataLoader
with some arguments: for examplenum_workers
specifies how many CPU processes to use to transform the data. THere is alsopin_memory
which will speed up the whole thing if you are using CUDA.