-
Notifications
You must be signed in to change notification settings - Fork 18
/
data.py
24 lines (20 loc) · 844 Bytes
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
from torchvision import datasets, transforms
train_transforms = transforms.Compose([
transforms.RandomCrop(32, padding=4),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2023, 0.1994, 0.2010])
])
test_transforms = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2023, 0.1994, 0.2010])
])
trainset = datasets.CIFAR10(
root='./data', train=True, download=True, transform=train_transforms)
testset = datasets.CIFAR10(
root='./data', train=False, download=True, transform=test_transforms)
trainloader = torch.utils.data.DataLoader(
trainset, batch_size=128, shuffle=True, num_workers=4)
testloader = torch.utils.data.DataLoader(
testset, batch_size=128, shuffle=False, num_workers=4)