Where the data would be save when I use torchvision.datasets

I am using pytorch tutorial for training a classifier (http://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#)

When I download the CIFAR10 via:
trainset = torchvision.datasets.CIFAR10(root=’./data’, train=True,
download=True, transform=transform)

Where exactly my the data would be saved? I cannot find any data folder anywhere…

1 Like


it is right in the directory where you run your program. If you want to have a fixed path, you need to specify it yourself, eg using os.path.expanduser.

Best regards



Thank you for your answer.
I have a follow up question.
So I use the following code to define training and testing sets.

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,  download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=4, shuffle=True, num_workers=2)

testset = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=transform)
testloader = torch.utils.data.DataLoader(testset, batch_size=4, shuffle=False, num_workers=2)

My expectation was that by going to data folder, I see training and testing folders and images inside of them, but what I saw was just 8 files with these names: batches.meta, data_batch_1, data_batch_2, data_batch_3, data_batch_4, data_batch_5, readme.html, and test_batch.

Can you please tell me what are they and how they are gonna be used? which one is for training and which one is for testing?

Thanks a lot in advance

1 Like


data_batch_* for training
test_batch for test

You can look at the details of how they are used here:

Best regards


1 Like

Thanks Thomas. That was very simple.
I thought it will download to torch installation directory.