Test the PyTorch example and try to download the data using the following code. It is too slow.
trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
testset = torchvision.datasets.CIFAR10(root='./data', train=False,
download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=4,
shuffle=True, num_workers=2)
testloader = torch.utils.data.DataLoader(testset, batch_size=4,
shuffle=False, num_workers=2)
Copy the code
So I manually downloaded the data. After a bit of research, it became clear that Pytorch was required to load data
- Specify a directory
$root
- in
$root
Unzip the data package - The folder decompressed cannot be renamed.
Using the CIFAR10 data set as an example, the decompressed directory must be $root/ CIFAR-10-BATCHES -py, and $root (in this example,.data) is sent as an additional parameter