Ow, I am sorry, I misread one of your posts.



 patrick126:

dataset_valid.dataset.targets


Is not giving you the subsets you created by random_split. .dataset gives you original dataset and for using transforms you had to use it.
In this part of code, you just need to get the subset instead of whole dataset:



 patrick126:

accuracy_valid = 100. * predictions.eq(dataset_valid.dataset.targets).sum().float() / len(dataset_valid)


Fix:
accuracy_valid = 100. * predictions.eq(dataset_valid.dataset.targets[dataset_valid.indices]).sum().float() / len(dataset_valid)

More explanation would be when you use random_split, it does not create two objects that have data, it just creates a list of indices that are randomly generated from original dataset.
So for instance, you can obtain original dataset by calling dataset_valid.dataset which is equal to first line of your code in first post. and it also have another attribute dataset_valid.indices which contains 5000 indices (as you provided) of randomly selected items in dataset.