Why is the accuracy difference so much when I use the image data set and pytorch's own data set directly?
For example, for the cifar10 data set, directly using the data set that comes with pytorch, the accuracy rate can reach 96% under the same network structure, but after I converted cifar10 into a picture, I tested it and the accuracy rate was only 92%. why?
This is the previous code：
train_dataset = dset.CIFAR10(args.data_path, train=True, transform=train_transform, download=True)
test_dataset = dset.CIFAR10(args.data_path, train=False, transform=test_transform, download=True)

This is the modified code：
train_dataset = datasets.ImageFolder(root='/home/ubuntu/bigdisk/DataSets/cifar10/static/orig/train/',
                                         transform=train_transform
                                         )
test_dataset = datasets.ImageFolder(root='/home/ubuntu/bigdisk/DataSets/cifar10/static/orig/test/',
                                        transform=test_transform
                                        )

train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=args.batch_size, shuffle=True,
                                               num_workers=args.prefetch, pin_memory=True)
test_loader = torch.utils.data.DataLoader(test_dataset, batch_size=args.test_bs, shuffle=False,
                                              num_workers=args.prefetch, pin_memory=True)


If the downloaded dataset, hyperparameters(such as batch size or learning rate), dataset transformation, etc were equal, I think it is because the randomness.
Your dataloader shuffles the dataset randomly. The shuffled dataset will always be different every time you shuffle it, which might have led to the accuracy difference.
Also, the model will be initialized with different values each time. (Unless you have used some initialization method that always initializes the model with the same values.)
You could check https://pytorch.org/docs/stable/notes/randomness.html for more information.
