The transformation will be lost, if you pass the train_mnist.data directly to TensorDataset as it is applied in the __getitem__ method for each .data sample. You could try to normalize the data inplace before passing it to the TensorDataset.