-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatasets.py
29 lines (18 loc) · 949 Bytes
/
datasets.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
25
26
27
import torch
import torchvision
import torchvision.transforms as transforms
import numpy as np
def get_datasets():
transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
batch_size = 1
trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
shuffle=True, num_workers=1)
validset = torchvision.datasets.CIFAR10(root='./data', train=False,
download=True, transform=transform)
validloader = torch.utils.data.DataLoader(validset, batch_size=batch_size,
shuffle=False, num_workers=1)
return trainset, trainloader, validset, validloader